Thriftpy/gunicorn_thrift

Can't use multiple CPU cores when starting thrift server with multiple workers

Closed this issue · 1 comments

Hi,
I did a test and found a problem that bothered me.
I start gunicorn_thrift server and set --worker with the number of my cpu cores, it is 8.
Then I did the stress testing to the multiple workers server.
I found the total cpu usage of these 8 worker process is less than 100%, and the stress testing is broken.
I doubt if multiple worker server can use multiple cpu cores. Is it really a multi process with python server? Whether or not related to GIL with python.
Or, it is totally my program problem...

The following is some data of my testing:
    THREAD_NUM = 100    // thread number per round
    ONE_WORKER_NUM = 1000    // loop number of each thread
    LOOP_SLEEP = 0.1    // time interval of each loop

    PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                  
    20   0  221136  30468   7380 S  23.9  0.2   0:40.24 gunicorn: worker [PythonServer:processor]
    20   0  221196  30456   7380 S  20.9  0.2   0:33.67 gunicorn: worker [PythonServer:processor]
    20   0 2626964  18972   3564 S  19.6  0.1   0:03.06 python stress_test.py                                                                                                                  
    20   0  221116  30444   7380 S  17.0  0.2   0:29.29 gunicorn: worker [PythonServer:processor]
    20   0  221104  30440   7380 S  14.0  0.2   0:24.07 gunicorn: worker [PythonServer:processor]                                                                                       
    20   0  221100  30428   7380 S  11.3  0.2   0:18.64 gunicorn: worker [PythonServer:processor]
    20   0  221476  30416   7380 S   7.6  0.2   0:14.29 gunicorn: worker [PythonServer:processor]
    20   0  221332  30408   7380 S   6.6  0.2   0:11.93 gunicorn: worker [PythonServer:processor]
    20   0  221008  30144   7308 S   5.7  0.2   0:10.69 gunicorn: worker [PythonServer:processor]

Hi,

because gunicorn is using a pre-fork model, it is possible that load won't be balanced across all workers. But it tends to even out as load increases. I think the bottle neck is somewhere else.