From 0398dad1ae63013166bf69e1c81c92ea0692f4e1 Mon Sep 17 00:00:00 2001 From: jross Date: Mon, 6 Jul 2026 10:00:37 -0600 Subject: [PATCH] fix(deploy): prevent App Engine request starvation under burst load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prod cycled between 0-1 instances and returned site-wide 500/503 with "Request was aborted after waiting too long to attempt to service your request." Requests died in the pending queue (blank instanceId, ~2ms latency), not in app code — App Engine never scaled out past one instance despite max_instances=10. Root cause: the scheduler had no visibility into real per-instance concurrency (gunicorn -w 4), so it kept routing bursts to a single saturated instance instead of spinning up more. min_instances=0 added cold-start pile-ups on top. - app.template.yaml: add max_concurrent_requests: 6 so the scheduler scales out before an instance saturates (2-worker headroom for bursts) - CD_production.yml: MIN_INSTANCES 0 -> 1 to kill cold-start pile-ups - CD_production.yml: gunicorn -w 4 -> -w 8 for more concurrency per F4 Co-Authored-By: Claude Opus 4.8 --- .github/app.template.yaml | 1 + .github/workflows/CD_production.yml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/app.template.yaml b/.github/app.template.yaml index 3abdacb68..f2b4e92bc 100644 --- a/.github/app.template.yaml +++ b/.github/app.template.yaml @@ -8,6 +8,7 @@ inbound_services: automatic_scaling: min_instances: ${MIN_INSTANCES} max_instances: ${MAX_INSTANCES} + max_concurrent_requests: 6 handlers: - url: /.* secure: always diff --git a/.github/workflows/CD_production.yml b/.github/workflows/CD_production.yml index a823ae1a1..5a0acce62 100644 --- a/.github/workflows/CD_production.yml +++ b/.github/workflows/CD_production.yml @@ -148,8 +148,8 @@ jobs: run: | export MAX_INSTANCES="10" export SERVICE_NAME="ocotillo-api" - export ENTRYPOINT="gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app" - export MIN_INSTANCES="0" + export ENTRYPOINT="gunicorn -w 8 -k uvicorn.workers.UvicornWorker main:app" + export MIN_INSTANCES="1" envsubst < .github/app.template.yaml > app.yaml - name: Deploy to Google Cloud