From 26ad881ed4a1de7d6c6726b055cf5c136900c2e4 Mon Sep 17 00:00:00 2001 From: rrader2890 Date: Mon, 6 Jul 2026 17:25:30 -0400 Subject: [PATCH] fix(puma): raise production worker_timeout 12s->60s (env-tunable) 12s was too tight under CPU pressure: a worker starved past 12s is killed by the Puma master, causing mass worker thrash on busy nodes -> /health has no worker -> k8s liveness kills the pod. This drove intermittent prod login outages on billing.thinkfleet.ai. Default to Puma's 60s and expose PUMA_WORKER_TIMEOUT so it can be tuned without an image rebuild. Co-Authored-By: Claude Opus 4.8 (1M context) --- config/puma.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/puma.rb b/config/puma.rb index cd01f62a3bb6..3e631b48f8c2 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -14,7 +14,10 @@ # terminating a worker in development environments. # worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" -worker_timeout 12 if ENV.fetch("RAILS_ENV", "production") == "production" +# In production a worker that misses its heartbeat is killed by the master. The +# previous 12s was too tight under CPU pressure and caused mass worker thrash on +# busy nodes. Default to Puma's 60s and allow tuning without an image rebuild. +worker_timeout ENV.fetch("PUMA_WORKER_TIMEOUT", 60).to_i if ENV.fetch("RAILS_ENV", "production") == "production" worker_shutdown_timeout 30 on_worker_boot do