[uWSGI] Processor affinity

Roberto De Ioris roberto at unbit.it
Fri Mar 11 07:49:54 CET 2011


>
> On 09/03/2011, at 4:47 PM, Roberto De Ioris wrote:
>> There is no specific policy set. This is up to the os scheduler.
>> On Linux (for example) a process should run always on the same cpu (to
>> get
>> the best from local processor cache).
>>
>> Do you know cases for which it can be useful to migrate processes to
>> other
>> cores (or when can be useful to bind to specific one)?
>
> Yes- in my case, I have several sites- one 8 processes, one 4, the others
> just 1 or 2. But my CPU usage is not spread between 4 cores evenly. See
> pic below. If you can't see the pic, the averages are 11.7, 2.8, 2, and
> 1.4. Core 1 is having all the fun.
>
>

Try the latest tip

--cpu-affinity <n>

where n is the number of cpus to dedicate per-worker

Example

(4 cpu, 4 workers, affinity 1)

worker 1 cpu 0
worker 2 cpu 1
worker 3 cpu 2
worker 4 cpu 3


(2 cpu, 4 workers, affinity 1)

worker 1 cpu 0
worker 2 cpu 1
worker 3 cpu 0
worker 4 cpu 1

(4 cpu, 4 workers, affinity 2)

worker 1 cpu 0 1
worker 2 cpu 2 3
worker 3 cpu 0 1
worker 4 cpu 2 3

(4 cpu, 8 workers, affinity 3)

worker 1 cpu 0 1 2
worker 2 cpu 3 0 1
worker 3 cpu 2 3 0
worker 4 cpu 1 2 3
worker 5 cpu 0 1 2
worker 6 cpu 3 0 1
worker 7 cpu 2 3 0
worker 8 cpu 1 2 3


-- 
Roberto De Ioris
http://unbit.it


More information about the uWSGI mailing list