Is concurrency possible in tornado?

后端 未结 2 1350
春和景丽
春和景丽 2021-01-11 15:29

I understand tornado is a single threaded and non-Blocking server, hence requests are handled sequentially (except when using event driven approach for IO operation).

<
2条回答
  •  粉色の甜心
    2021-01-11 16:17

    If you are truly going to be dealing with multiple simultaneous requests that are compute-bound, and you want to do it in Python, then you need a multi-process server, not multi-threaded. CPython has Global Interpreter Lock (GIL) that prevents more than one thread from executing python bytecode at the same time.

    Most web applications do very little computation, and instead are waiting for I/O, either from the database, or the disk, or from services on other servers. Be sure you need to handle compute-bound requests before discarding Tornado.

提交回复
热议问题