Performance of: asynchronous request handler with blocking tasks handled by worker pool

别来无恙 提交于 2019-12-05 22:17:28

The overall pattern is fine, with the caveat that thanks to the GIL, your thread pool will only be able to use a single CPU, and you'll need to use multiple processes to make full use of the available hardware.

Taking a closer look at the numbers, 10 threads is way too small if your requests are really going to average 6 seconds each. You've got 6000 seconds worth of work coming in every second, so you need a total of at least 6000 threads across all your processes (and that's assuming the 6 seconds is really just blocking on external events and the CPU cost in the python process is negligible). I'm not sure how many threads a modern system can handle, but 6000 Python threads doesn't sound like a great idea. If you've really got 6 seconds of blocking per request (and thousands of requests/sec) it sounds like it would be worthwhile to convert these blocking functions to be asynchronous.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!