Skip to content

Commit bd828d6

Browse files
anth-volkclaude
andcommitted
Recycle gunicorn workers to bound memory growth
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2fb195f commit bd828d6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

gcp/cloud_run/start.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ done
6363
# multi-minute app import (which happens in the worker, post-fork, because
6464
# --preload is NOT set). --timeout 0 is required: a worker mid-import does
6565
# not heartbeat, and the default 30s watchdog would kill it before boot.
66+
# --max-requests recycles workers to bound the slow memory growth seen in
67+
# the Stage 2 30-minute soak (69% of 16Gi at --concurrency 4; OOM SIGKILL
68+
# at 8); jitter staggers recycling — a recycled worker re-imports for ~3
69+
# minutes, halving instance capacity while it does.
6670
gunicorn policyengine_api.asgi:app \
6771
--worker-class uvicorn.workers.UvicornWorker \
6872
--workers "$WEB_CONCURRENCY" \
6973
--bind "0.0.0.0:${PORT}" \
7074
--timeout 0 \
7175
--keep-alive 5 \
76+
--max-requests 500 \
77+
--max-requests-jitter 100 \
7278
--forwarded-allow-ips '*' &
7379
server_pid="$!"
7480

0 commit comments

Comments
 (0)