Skip to content

Commit

Permalink
Celery tuning (#17262)
Browse files Browse the repository at this point in the history
* Celery tuning

Primarily focused on being able to explicitly set `--concurrency` in prod.

Unfortunately Celery doesn't respect an environment variable for this, so allow for setting additional Celery flags via the environment.

Also sets the dev worker to a concurrency of 1 to fix a locking issue with running Beat in the same process leading to many tasks being enqueued instead of one.

* specifically limit to --concurrency
  • Loading branch information
ewdurbin authored Dec 10, 2024
1 parent 84a11e2 commit b4378d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ release: bin/release
web: bin/start-web ddtrace-run python -m gunicorn.app.wsgiapp -c gunicorn-prod.conf.py warehouse.wsgi:application
web-api: bin/start-web ddtrace-run python -m gunicorn.app.wsgiapp -c gunicorn-prod.conf.py warehouse.wsgi:application
web-uploads: bin/start-web ddtrace-run python -m gunicorn.app.wsgiapp -c gunicorn-uploads.conf.py warehouse.wsgi:application
worker: bin/start-worker celery -A warehouse worker -Q default -l info --max-tasks-per-child 32
worker: bin/start-worker celery -A warehouse worker --concurrency=${CELERY_CONCURRENCY:-1} -Q default -l info --max-tasks-per-child 1024
worker-beat: bin/start-worker celery -A warehouse beat -S redbeat.RedBeatScheduler -l info
worker-traced: env DD_SERVICE=warehouse-worker bin/start-worker ddtrace-run celery -A warehouse worker -Q default -l info --max-tasks-per-child 32
worker-drain-sqs: env BROKER_URL=sqs:///?region=us-east-2&queue_name_prefix=pypi-worker bin/start-worker celery -A warehouse worker -Q default -l info --max-tasks-per-child 32
worker-traced: env DD_SERVICE=warehouse-worker bin/start-worker ddtrace-run celery -A warehouse worker --concurrency=${CELERY_CONCURRENCY:-1} -Q default -l info --max-tasks-per-child 32
worker-drain-sqs: env BROKER_URL=sqs:///?region=us-east-2&queue_name_prefix=pypi-worker bin/start-worker --concurrency=${CELERY_CONCURRENCY:-1} celery -A warehouse worker -Q default -l info --max-tasks-per-child 1024
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ services:
worker:
image: warehouse:docker-compose
pull_policy: never
command: hupper --shutdown-interval 10 --reload-interval 10 -m celery -A warehouse worker --beat --scheduler redbeat.RedBeatScheduler -l info
command: hupper --shutdown-interval 10 --reload-interval 10 -m celery -A warehouse worker --concurrency=1 --beat --scheduler redbeat.RedBeatScheduler -l info
volumes:
- ./warehouse:/opt/warehouse/src/warehouse:z
- packages:/var/opt/warehouse/packages
Expand Down

0 comments on commit b4378d9

Please sign in to comment.