Make gunicorn worker count scale automatically and be configurable

Fixes https://jira.coreos.com/browse/QS-117
This commit is contained in:
Joseph Schorr 2018-01-12 16:19:37 -05:00
parent 18f1ccf80b
commit 4cd3d110db
5 changed files with 43 additions and 5 deletions

View file

@ -2,13 +2,16 @@ import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))
import multiprocessing
import logging
from Crypto import Random
from util.log import logfile_path
logconfig = logfile_path(debug=False)
bind = 'unix:/tmp/gunicorn_verbs.sock'
workers = 4
workers = max(int(os.getenv("WORKER_COUNT_VERBS", multiprocessing.cpu_count())), 2)
pythonpath = '.'
preload_app = True
timeout = 2000 # Because sync workers
@ -18,3 +21,7 @@ def post_fork(server, worker):
# Reset the Random library to ensure it won't raise the "PID check failed." error after
# gunicorn forks.
Random.atfork()
def when_ready(server):
logger = logging.getLogger(__name__)
logger.debug('Starting verbs gunicorn with %s workers and sync worker class', workers)