If your backends set the correct HTTP headers, you can use the http-keepalive option. Your backends must either set a valid Content-Length in each response, or you can use chunked encoding with http-auto-chunked. Simply setting “Connection: close” is not enough.,Also remember to set “Connection: Keep-Alive” in your response. You can automate that using the add-header = Connection: Keep-Alive option.,If you use Amazon’s ELB (Elastic Load Balancer) in HTTP mode in front of uWSGI in HTTP mode, either a valid Content-Length must be set by the backend, or chunked encoding must be used, e.g., with http-auto-chunked. The ELB “health test” may still fail in HTTP mode regardless, in which case a TCP health test can be used instead.,With the http-auto-gzip option, uWSGI can automatically gzip content if the uWSGI-Encoding header is set to gzip while Content-Length and Content-Encoding are not set.
. / uwsgi--http 127.0 .0 .1: 8080--master--module mywsgiapp--processes 4
. / uwsgi--master--http 127.0 .0 .1: 8080--http - to / tmp / uwsgi.sock
[uwsgi]
http = 0.0 .0 .0: 8080
http = 192.168 .173 .17: 8181
http = 127.0 .0 .1: 9090
master = true
http - to = /tmp/uwsgi.sock
[uwsgi]
http = 0.0 .0 .0: 8080
http = 192.168 .173 .17: 8181
http = 127.0 .0 .1: 9090
master = true
http - to = /tmp/uwsgi.sock
http - to = 192.168 .173 .1: 3031
http - to = 192.168 .173 .2: 3031
http - to = 192.168 .173 .3: 3031
In my case, I faced with random 502 responses from aws ALB / ELB. I provided configuration by .ini file like:
http - keepalive = true
After receiving a restart signal, workers have this much time to finish serving requests. Workers still alive after the timeout (starting from the receipt of the restart signal) are force killed.,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 damage of memory leaks.,Worker Processes workers worker_class threads worker_connections max_requests max_requests_jitter timeout graceful_timeout keepalive ,Workers silent for more than this many seconds are killed and restarted.
$ GUNICORN_CMD_ARGS = "--bind=127.0.0.1 --workers=3"
gunicorn app: app
% ({
x - forwarded -
for
}
i) s
def on_starting(server): pass
def on_reload(server): pass
def when_ready(server): pass
def pre_fork(server, worker): pass