gunicorn icon indicating copy to clipboard operation
gunicorn copied to clipboard

gunicorn gevent master process distribute request to worker process unequally.

Open joejiafeng opened this issue 1 year ago • 1 comments

I have 11 workers, but gunicorn master always distributes request to certain process, not to all process equally.

image image

my gunicorn.conf.py

# -*- coding: utf-8 -*-
from gevent import monkey
monkey.patch_all()
bind = '0.0.0.0:10001' 
preload_app = True
workers = 11
worker_connections = 1000
# Any value greater than zero will limit the number of requests a worker will process before automatically restarting.
# This is a simple method to help limit the memory leaks damage.
max_requests = 2000
# The jitter causes the restart per worker to be randomized by randint(0, max_requests_jitter).
# This is intended to stagger worker restarts to avoid all workers restarting at the same time.
max_requests_jitter = 20
backlog = 2048
timeout = 60 * 15
worker_class = "gevent"
proc_name = 'gunicorn.proc'
pidfile = '/tmp/gunicorn.pid'
loglevel = 'info'
# https://docs.gunicorn.org/en/stable/settings.html#access-log-format
access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(T)s %(b)s %(f)s" "%(a)s"'

application is running in docker container, docker host has 24 core CPU.

joejiafeng avatar Dec 05 '23 12:12 joejiafeng

See if --reuse-port` helps. I believe that it should, under Linux. We were going to make this a default but it caused some issues during development, if I remember correctly.

tilgovi avatar Dec 28 '23 00:12 tilgovi

no activity since a while. closing

benoitc avatar Jul 23 '24 00:07 benoitc

(Linking relevant PR #2938 for anyone in the future stumbling across this)

pajod avatar Jul 23 '24 18:07 pajod