What's the advantage of running multiple threads per UWSGI process?

馋奶兔 提交于 2019-12-11 08:43:15

问题


If I'm performing blocking operations like querying a database, then what is the advantage? How does this add extra worthwhile capacity?


回答1:


Python's native multithreading is affected by GIL limitations. Simply put, only one Python thread at a time is physically executed. An exception to this are blocking IO calls (e. g. DB query) that let other Python threads take over, which may increase performance of IO-bound operations.

So the real performance gain would only be possible if your application is mostly IO-bound. However, in this case you should consider making the app asynchronous, which uWSGI also supports.

Otherwise you should keep your app single-threaded and use multiprocess uWSGI to scale up.



来源:https://stackoverflow.com/questions/20058464/whats-the-advantage-of-running-multiple-threads-per-uwsgi-process

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