简体   繁体   中英

Gunicorn with gevent workers and threads

I have a server with 4 cores.

When setting up Gunicorn with workers and threads can I assign the same number of workers and threads to the cpu's since they will be doing different things?

for example

from gevent import monkey
monkey.patch_all()
import multiprocessing

workers = multiprocessing.cpu_count() * 2 + 1
bind = "127.0.0.1:5000"
worker_class = 'gevent'
worker_connections = 1000
threads = multiprocessing.cpu_count() * 2 + 1

Or should I instead do this

from gevent import monkey
monkey.patch_all()
import multiprocessing

workers = 2 * 2 + 1
bind = "127.0.0.1:5000"
worker_class = 'gevent'
worker_connections = 1000
threads = 2 * 2 + 1

With worker_class='gevent' setting threads is irrelevant. See the quote from the documentation,

Since Gunicorn 19, a threads option can be used to process requests in multiple threads. Using threads assumes use of the gthread worker. Gunicorn Design

Also from threads setting documentation,

This setting only affects the Gthread worker type. Gunicorn Settings

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM