Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to gevent workers to better handle IO-bound workloads #2701

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this make tests slower? Why do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gevent doesn't really interoperate with python multiprocessing correctly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests aren't using gunicorn/gevent though, are they?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well tests are using gevent without gunicorn so they do have this issue.

- 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