N
N
niko832012-06-26 18:25:52
Python
niko83, 2012-06-26 18:25:52

Which is better in uWSGI Python configuration: workers or threads?

What is preferred multiple independent processes: or one process and multiple threads:
<workers>4</workers>

<workers>1</workers>
<enable-threads />
<threads>4</threads>

or a hybrid (threads and processes):
<workers>4</workers>
<enable-threads />
<threads>2</threads>

Who sets up their own uWSGI, what tricks and pitfalls can be here. What are the benefits?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yngvie, 2012-06-26
@Yngvie

At one time, they used the Siege test to check various possible configurations.
Here, one must take into account the peculiarity of python and, in particular, the GIL, so that tasks that require processor time cannot be paralleled using threads, even if there are several CPUs. On the other hand, for tasks that require I / O, threads give their growth, in addition, the thread consumes less memory than the entire process.
If your program does not rely on single threading, then it makes no sense to have a number of processes significantly larger than the number of CPUs/cores. It would be better to use a hybrid, the number of processes for the number of CPUs, the number of threads ... well, it depends more on how much memory. We usually have 5-25 threads on different projects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question