Open gtalarico opened 3 years ago
Add gunicorn config for finer control
info ">>> Starting Gunicorn" # config path will be mounted at root /service/gunicorn_config.py gunicorn api.wsgi -c gunicorn_config.py
from gunicorn import glogging from gunicorn.instrument.statsd import Statsd # TODO config port bind = f"0.0.0.0:{{ PORT }}" proc_name = "gunicorn" preload_app = True backlog = 2048 workers = 2 worker_class = "sync" worker_connections = 1000 timeout = 30 keepalive = 2 class CustomGunicornLogger(Statsd): # Custom Logger Breaks Statsd # https://github.com/benoitc/gunicorn/issues/1564 def access(self, resp, req, environ, request_time): # disable healthcheck logging if req.path in ["/health"]: return super().access(resp, req, environ, request_time) capture_output = True # Redirect stdout/stderr to specified file in errorlog. loglevel = "info" errorlog = "-" accesslog = "-" # access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"' # Add Response Time Logging access_log_format = ( '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s [%(L)s sec] "%(f)s" "%(a)s"' ) logger_class = CustomGunicornLogger
ps: should benchmark heroku staging with 1/2/3/4 workers and see performance, CPU and memory ps
Add gunicorn config for finer control
ps: should benchmark heroku staging with 1/2/3/4 workers and see performance, CPU and memory ps