質問

Lets say I have a django project running on uwsgi emperor mode, with this config

processes = 4

Running on a dual core cpu with hyperthreading enabled, does that mean I can have [close to] true parallelism of processing 4 requests at the same time?

Would it have significant performance advantage over a dual core cpu without hyperthreading enabled?

And how about this config on CPU with/without hyperthreading?

processes = 4
threads = 8
enabled-threads = true
役に立ちましたか?

解決

Since you already use multiprocess uWSGI, enable-threads will not increase performance. It can only save you some RAM, so if you're not short on memory, you should stay away from threads because of GIL.

As for hyper-threading, don't guess it, test it! Performance gain (or loss) totally depends on the app, so try different setups, including processes. It's unlikely that you get 2x gain from HT, but still it may be significant.

他のヒント

Yes, multiple processes can (potentially) run on different processors concurrently.

The same is not (completely) true for python threads, as a thread in python has a lock (the GIL) preventing it from running concurrently with another thread.

Before throwing away threads, take in account that the GIL is released in blocking operations and basically whenever you make use of the uWSGI api (if you use it), so threads can be almost good and (more important) they give you a cheap way for increasing concurrency (that is different from parallelism) that is more important than parallelism in the web world.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top