Skip to content

Commit

Permalink
Switch to gevent workers to better handle IO-bound workloads
Browse files Browse the repository at this point in the history
  • Loading branch information
ttys0dev committed May 2, 2023
1 parent 55903a5 commit fa3086d
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
run: >
docker exec -e SELENIUM_DEBUG=1 -e SELENIUM_TIMEOUT=30 cl-django
python /opt/courtlistener/manage.py test
cl --verbosity=2 ${{ matrix.tag_flags }} --parallel
cl --verbosity=2 ${{ matrix.tag_flags }} --parallel=1
- name: cp selenium results from docker to host
if: failure()
run: |
Expand Down
4 changes: 2 additions & 2 deletions docker/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ FROM python-base as web-prod

CMD gunicorn cl_wsgi:application \
--chdir /opt/courtlistener/docker/django/wsgi-configs/ \
--config /opt/courtlistener/docker/django/wsgi-configs/gunicorn.conf.py \
--user www-data \
--group www-data \
# Set high number of workers. Docs recommend 2-4× core count`
--workers ${NUM_WORKERS:-48} \
--worker-class gthread \
--threads 10 \
--worker-class gevent \
# Allow longer queries to solr.
--limit-request-line 6000 \
# Reset each worker once in a while
Expand Down
5 changes: 5 additions & 0 deletions docker/django/wsgi-configs/gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from psycogreen.gevent import patch_psycopg


def post_fork(server, worker):
patch_psycopg()
6 changes: 6 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env python
from gevent import monkey

monkey.patch_all()
from psycogreen.gevent import patch_psycopg

patch_psycopg()
import os
import sys

Expand Down
Loading

0 comments on commit fa3086d

Please sign in to comment.