2020年1月22日水曜日

How many data can be processed per second by Python's Sanic framework?

Japanese Version:
https://neovisionconsulting.blogspot.com/2020/01/pythonsanic1data.html

Click here for the reprint source


Yasuhiro Niji, working as a freelancer (2013-present)

You can find it on the TechEmpower Framework Benchmarks page. It is 283,645 per second in JSON serialization.

However, that number has little practical meaning.

First, a typical Web server performs processes such as user authentication, database access, and HTML creation, so the processing time is much longer. It simply means that Sanic's processing time is negligible.

Also, there are not many cases where a web application needs more than 1000 processes per second. First, a web server such as Niginx can process and cache static files. If you do so, it is unlikely that your company's internal system of 10,000 employees will need 1000 processes per second.

Even now, Dgango and Flask are mainly used because they are generally sufficient in many cases. If you have a problem, it's usually better to use the Go language, which is faster and has more parallel processing capabilities than using Sanic in Python. Note that this does not mean that Sanic is not used, but that if the number of processes per second becomes very large, Python itself is often not suitable for that process. .

Masahiro Ishizuka

Thank you for your answer.
> In general, it is better to use the Go language, which is faster and has more parallel processing functions than using Sanic in Python.
I see, together
Python concurrency threading module-molpako.py
Conclusion
Python's GIL prevents multithreading from benefiting from multicore.
If this blog is right, and we consider it together, Python is a programming language that doesn't take advantage of multi-core CPUs. If you don't need AI (artificial intelligence) or machine learning libraries, Go lang is better than Python. We hope that either the framework or the formal support of multi-core CPUs will be resolved in the future. There is also an AI, machine learning and numerical analysis library developed by Google called TensorFlow for Go lang. Although this API can be used with Go lang, it is still only Python that can build and learn models, so I hope that it will be improved in the future.

Yasuhiro Niji
Original AuthorWednesday
In terms of GIL, it is usually not a problem because heavy processing can be removed by writing it in C / C ++ or using a library written in C / C ++. However, if the number of operations per second becomes very large, processing collisions cannot be avoided, and Python becomes inefficient. So I only recommend using Go. If it's not large, developing with Python alone is not a problem. For large scales, it may be necessary to calculate and test whether Python alone can withstand it.

As for machine learning, training uses a lot of data to do a lot of calculations. In this regard, Python is good at Go and not good at Go, so Go will never be able to build and learn machine learning models.

On the other hand, in the process using the learned result, the calculation is light because only the result is used. If you have to deal with a lot of processing here, there is an API for Go because Go is more suitable for the reasons mentioned above.

Both TesorFlow and Go have been developed by Google, but it's a good idea to consider the characteristics of Python and Go, so it won't be unified.

0 コメント:

コメントを投稿