How to tell uWSGI to prefer processes to threads for load balancing

江枫思渺然 提交于 2019-12-03 05:44:28
raacer

So, the solution is:

  1. Upgrade uWSGI to recent stable version (as roberto suggested).
  2. Use --thunder-lock option.

Now I'm running with 50 threads per process and all requests are distributed between processes equally.

Every process is effectively a thread, as threads are execution contexts of the same process.

For such a reason there is nothing like "a process executes it instead of a thread". Even without threads your process has 1 execution context (a thread). What i would investigate is why you get (perceived) poor performances when using multiple threads per process. Are you sure you are using a stable (with solid threading support) uWSGI release ? (1.4.x or 1.9.x)

Have you thought about dynamically spawning more processes when the server is overloaded ? Check the uWSGI cheaper modes, there are various algorithm available. Maybe one will fit your situation.

The GIL is not a problem for you, as from what you describe the problem is the lack of threads for managing new requests (even if from your numbers it looks you may have a too much heavy lock contention on something else)

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