问题
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