Skip to content

Commit

Permalink
Auto-restart web dynos regularly (#2074)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahkagan authored Nov 19, 2024
1 parent b19e222 commit d8293c6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
release: ./heroku-release-phase.sh
web: gunicorn server.app:app --preload
# gunicorn runs multiple worker processes based on the WEB_CONCURRENCY
# environment variable (set by Heroku automatically based on dyno size).
# https://devcenter.heroku.com/articles/python-concurrency#common-runtime
# At the time of writing, we use Standard-2x dynos, which results in 4 workers.
# To tame slow memory leakage that we've observed but haven't solved, we
# configure gunicorn to restart each worker after a certain number of requests
# (with some random jitter). This threshold was set by observing how long it
# took for memory to rise to an unacceptable level during peak traffic, then
# counting the number of requests in that interval and dividing by the number
# of workers.
web: gunicorn server.app:app --preload --max-requests 1000 --max-requests-jitter 50
worker: python -m server.worker.worker
slack_worker: python -m server.activity_log.slack_worker

0 comments on commit d8293c6

Please sign in to comment.