From 9307f54d9a79439fe7585a00a689b7c97341dbd4 Mon Sep 17 00:00:00 2001 From: Athanasios Voutsadakis Date: Tue, 6 Feb 2018 11:24:01 +0000 Subject: [PATCH 1/3] Use eventlet workers for gunicorn Cap their parallel connections to 1/4 of the default to play it safe while we keep an eye on our resources utilisation --- manifest-api-base.yml | 2 +- requirements.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/manifest-api-base.yml b/manifest-api-base.yml index 301e3e1b7..10e16baae 100644 --- a/manifest-api-base.yml +++ b/manifest-api-base.yml @@ -1,7 +1,7 @@ --- buildpack: python_buildpack -command: scripts/run_app_paas.sh gunicorn -c /home/vcap/app/gunicorn_config.py --error-logfile /home/vcap/logs/gunicorn_error.log -w 5 -b 0.0.0.0:$PORT application +command: scripts/run_app_paas.sh gunicorn -c /home/vcap/app/gunicorn_config.py -k eventlet --worker_connections 256 --error-logfile /home/vcap/logs/gunicorn_error.log -w 5 -b 0.0.0.0:$PORT application services: - notify-db env: diff --git a/requirements.txt b/requirements.txt index dcfc3b10c..ed28b8bb9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ Flask-Migrate==2.1.1 Flask-SQLAlchemy==2.3.2 Flask==0.12.2 click-datetime==0.2 +eventlet==0.22.0 gunicorn==19.7.1 iso8601==0.1.12 jsonschema==2.6.0 From 650455806dd10f83d397128cb66213f35a2851b2 Mon Sep 17 00:00:00 2001 From: Athanasios Voutsadakis Date: Tue, 6 Feb 2018 11:50:40 +0000 Subject: [PATCH 2/3] Use - not _ --- manifest-api-base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest-api-base.yml b/manifest-api-base.yml index 10e16baae..2ba8d8f11 100644 --- a/manifest-api-base.yml +++ b/manifest-api-base.yml @@ -1,7 +1,7 @@ --- buildpack: python_buildpack -command: scripts/run_app_paas.sh gunicorn -c /home/vcap/app/gunicorn_config.py -k eventlet --worker_connections 256 --error-logfile /home/vcap/logs/gunicorn_error.log -w 5 -b 0.0.0.0:$PORT application +command: scripts/run_app_paas.sh gunicorn -c /home/vcap/app/gunicorn_config.py -k eventlet --worker-connections 256 --error-logfile /home/vcap/logs/gunicorn_error.log -w 5 -b 0.0.0.0:$PORT application services: - notify-db env: From dc772fab3b9a084c152fb62b279e8ee9c685f42b Mon Sep 17 00:00:00 2001 From: Athanasios Voutsadakis Date: Tue, 6 Feb 2018 15:12:12 +0000 Subject: [PATCH 3/3] Move config from command line args to gunicorn_config.py --- gunicorn_config.py | 7 +++++++ manifest-api-base.yml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gunicorn_config.py b/gunicorn_config.py index 477320ed0..b3e7ddf90 100644 --- a/gunicorn_config.py +++ b/gunicorn_config.py @@ -1,6 +1,13 @@ +import os import sys import traceback +workers = 5 +worker_class = "eventlet" +worker_connections = 256 +errorlog = "/home/vcap/logs/gunicorn_error.log" +bind = "0.0.0.0:{}".format(os.getenv("PORT")) + def on_starting(server): server.log.info("Starting Notifications API") diff --git a/manifest-api-base.yml b/manifest-api-base.yml index 2ba8d8f11..025459ef3 100644 --- a/manifest-api-base.yml +++ b/manifest-api-base.yml @@ -1,7 +1,7 @@ --- buildpack: python_buildpack -command: scripts/run_app_paas.sh gunicorn -c /home/vcap/app/gunicorn_config.py -k eventlet --worker-connections 256 --error-logfile /home/vcap/logs/gunicorn_error.log -w 5 -b 0.0.0.0:$PORT application +command: scripts/run_app_paas.sh gunicorn -c /home/vcap/app/gunicorn_config.py application services: - notify-db env: