Skip to content

Commit

Permalink
Switch from gunicorn to granian (#540)
Browse files Browse the repository at this point in the history
I've chosen to start with 2 workers to support the 2 cores we get on GOV PaaS. When we migrate to the DBT Platform we will need to revisit the granian config.
  • Loading branch information
SamDudley authored Nov 8, 2024
1 parent 68b63f7 commit 95b6e49
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 262 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: python manage.py migrate --noinput && python manage.py clearcache && python manage.py collectstatic --noinput && gunicorn config.wsgi:application --config config/gunicorn.py --worker-class gevent --worker-connections 1000 --bind 0.0.0.0:$PORT --timeout 300 --log-file -
web: python manage.py migrate --noinput && python manage.py clearcache && python manage.py collectstatic --noinput && granian --interface wsgi config.wsgi:application --workers 2 --host 0.0.0.0 --port $PORT
worker: celery -A config worker -l info
6 changes: 0 additions & 6 deletions config/gunicorn.py

This file was deleted.

2 changes: 2 additions & 0 deletions config/settings/paas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from .base import *


SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")

# TODO (DWPF-1696): Remove ECS formatter
LOGGING["handlers"]["console"]["formatter"] = "ecs"

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
- DATABASE_URL=psql://postgres:postgres@db:5432/fido
- CELERY_BROKER_URL=rediss://redis:redis@redis:6379/0
command: python manage.py runserver 0.0.0.0:8000
# command: granian --interface wsgi config.wsgi:application --workers 2 --host 0.0.0.0 --port 8000
ports:
- "0.0.0.0:8000:8000"
volumes:
Expand Down
374 changes: 131 additions & 243 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ django-staff-sso-client = "^4.2.2"
django-tables2 = "^2.4.0"
djangorestframework = "^3.15.2"
elastic-apm = "^6.2.2"
gunicorn = "^22.0.0"
psycopg2 = "^2.8.6"
django-chunk-upload-handlers = "^0.0.14"
sentry-sdk = "^2.8.0"
Expand All @@ -39,6 +38,7 @@ django-storages = "^1.14.2"
openpyxl = "^3.0.5"
requests = "^2.32.0"
redis = "^5.0.3"
granian = "^1.6.3"

# Are these packages still needed?
django-import-export = "^3.3.07"
Expand All @@ -49,8 +49,6 @@ django-log-formatter-asim = "^0.0.4"
optional = true

[tool.poetry.group.prod.dependencies]
gevent = "^24.2.1"
psycogreen = "^1.0.2"
django-audit-log-middleware = "^0.0.5"

[tool.poetry.group.dev]
Expand Down
12 changes: 3 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ boto3==1.35.38 ; python_version >= "3.12" and python_version < "4.0"
botocore==1.35.38 ; python_version >= "3.12" and python_version < "4.0"
celery==5.4.0 ; python_version >= "3.12" and python_version < "4.0"
certifi==2024.8.30 ; python_version >= "3.12" and python_version < "4"
cffi==1.17.1 ; platform_python_implementation == "CPython" and sys_platform == "win32" and python_version >= "3.12" and python_version < "4.0"
cfgv==3.4.0 ; python_version >= "3.12" and python_version < "4"
charset-normalizer==3.4.0 ; python_version >= "3.12" and python_version < "4.0"
click-didyoumean==0.3.1 ; python_version >= "3.12" and python_version < "4.0"
Expand Down Expand Up @@ -46,11 +45,9 @@ ecs-logging==2.2.0 ; python_version >= "3.12" and python_version < "4"
elastic-apm==6.23.0 ; python_version >= "3.12" and python_version < "4"
et-xmlfile==1.1.0 ; python_version >= "3.12" and python_version < "4.0"
filelock==3.16.1 ; python_version >= "3.12" and python_version < "4"
gevent==24.10.2 ; python_version >= "3.12" and python_version < "4.0"
googleapis-common-protos==1.65.0 ; python_version >= "3.12" and python_version < "4.0"
greenlet==3.1.1 ; python_version >= "3.12" and python_version < "4.0" and platform_python_implementation == "CPython"
granian==1.6.3 ; python_version >= "3.12" and python_version < "4.0"
grpcio==1.66.2 ; python_version >= "3.12" and python_version < "4.0"
gunicorn==22.0.0 ; python_version >= "3.12" and python_version < "4.0"
identify==2.6.1 ; python_version >= "3.12" and python_version < "4"
idna==3.10 ; python_version >= "3.12" and python_version < "4.0"
importlib-metadata==6.11.0 ; python_version >= "3.12" and python_version < "4.0"
Expand Down Expand Up @@ -78,14 +75,12 @@ opentelemetry-sdk-extension-aws==2.0.2 ; python_version >= "3.12" and python_ver
opentelemetry-sdk==1.22.0 ; python_version >= "3.12" and python_version < "4.0"
opentelemetry-semantic-conventions==0.43b0 ; python_version >= "3.12" and python_version < "4.0"
opentelemetry-util-http==0.43b0 ; python_version >= "3.12" and python_version < "4.0"
packaging==24.1 ; python_version >= "3.12" and python_version < "4.0"
packaging==24.1 ; python_version >= "3.12" and python_version < "4"
platformdirs==4.3.6 ; python_version >= "3.12" and python_version < "4"
pre-commit==3.8.0 ; python_version >= "3.12" and python_version < "4"
prompt-toolkit==3.0.48 ; python_version >= "3.12" and python_version < "4.0"
protobuf==4.25.5 ; python_version >= "3.12" and python_version < "4.0"
psycogreen==1.0.2 ; python_version >= "3.12" and python_version < "4.0"
psycopg2==2.9.9 ; python_version >= "3.12" and python_version < "4.0"
pycparser==2.22 ; platform_python_implementation == "CPython" and sys_platform == "win32" and python_version >= "3.12" and python_version < "4.0"
python-dateutil==2.9.0.post0 ; python_version >= "3.12" and python_version < "4.0"
pyyaml==6.0.2 ; python_version >= "3.12" and python_version < "4.0"
redis==5.1.1 ; python_version >= "3.12" and python_version < "4.0"
Expand All @@ -100,6 +95,7 @@ tablib[html,ods,xls,xlsx,yaml]==3.5.0 ; python_version >= "3.12" and python_vers
typing-extensions==4.12.2 ; python_version >= "3.12" and python_version < "4.0"
tzdata==2024.2 ; python_version >= "3.12" and python_version < "4.0"
urllib3==2.2.3 ; python_version >= "3.12" and python_version < "4"
uvloop==0.21.0 ; sys_platform != "win32" and platform_python_implementation == "CPython" and python_version >= "3.12" and python_version < "4.0"
vine==5.1.0 ; python_version >= "3.12" and python_version < "4.0"
virtualenv==20.26.6 ; python_version >= "3.12" and python_version < "4"
wcwidth==0.2.13 ; python_version >= "3.12" and python_version < "4.0"
Expand All @@ -108,5 +104,3 @@ wrapt==1.16.0 ; python_version >= "3.12" and python_version < "4"
xlrd==2.0.1 ; python_version >= "3.12" and python_version < "4.0"
xlwt==1.3.0 ; python_version >= "3.12" and python_version < "4.0"
zipp==3.20.2 ; python_version >= "3.12" and python_version < "4.0"
zope-event==5.0 ; python_version >= "3.12" and python_version < "4.0"
zope-interface==7.1.0 ; python_version >= "3.12" and python_version < "4.0"

0 comments on commit 95b6e49

Please sign in to comment.