The guess is that gevent is a C module, and tornado packet reassembly and HTTP protocol parsing are all written in Python. For example, regular expressions are used to parse HTTP headers. . .
In tornado-over-gevent, tornado runs in wsgi mode, and HTTP protocol parsing and other work are completed by gevent.
As for the question asked by the questioner, asynchronous is not necessarily faster than synchronous. This depends on the specific application scenario.
In comparison, if it is not concurrent and not for blocking operations. It’s hard to say which one is faster, synchronous or asynchronous.
Python’s concurrency technology is roughly multi-threading, multi-process, and coroutine. You can refer to this article
tornado can be asynchronous or synchronous, it depends on how to use it.
tornaod provides a magic stackcontext manager to provide context management of coroutines, and this is implemented by tornado. And gevent completes the same work in C. But there is not much difference in efficiency between the two.
Another point worth mentioning is that tornado actually provides a @coroutine mechanism, which makes synchronous writing also consume efficiency.
Listen to what my boss said, gevent uses greenlet + epoll. Greenlet customizes the stack. Greenlet is a bit similar to goroutine. It can achieve parallelism. Tornado just implements epoll by itself.
The guess is that gevent is a C module, and tornado packet reassembly and HTTP protocol parsing are all written in Python. For example, regular expressions are used to parse HTTP headers. . .
In tornado-over-gevent, tornado runs in wsgi mode, and HTTP protocol parsing and other work are completed by gevent.
As for the question asked by the questioner, asynchronous is not necessarily faster than synchronous. This depends on the specific application scenario.
In comparison, if it is not concurrent and not for blocking operations. It’s hard to say which one is faster, synchronous or asynchronous.
Python’s concurrency technology is roughly multi-threading, multi-process, and coroutine. You can refer to this article
tornado can be asynchronous or synchronous, it depends on how to use it.
Original text says:
I have seen such test conclusions in other articles. Since it's not much faster, it's better not to use it.
tornaod provides a magic stackcontext manager to provide context management of coroutines, and this is implemented by tornado. And gevent completes the same work in C. But there is not much difference in efficiency between the two.
Another point worth mentioning is that tornado actually provides a @coroutine mechanism, which makes synchronous writing also consume efficiency.
Listen to what my boss said, gevent uses greenlet + epoll. Greenlet customizes the stack. Greenlet is a bit similar to goroutine.
It can achieve parallelism. Tornado just implements epoll by itself.