Basecamp runs Puma in cluster mode with preload_app! and 63 single-threaded workers per 48-core host. The master process loads the app once, then forks workers that share memory copy-on-write. That design reduces memory costs, but it doesn't eliminate per-worker first-use work: anything initialized on first use after fork runs independently in each worker.
What was being done repeatedly by workers
- YJIT compilation: methods compiled only after several calls, so the master calls very little during boot and workers compile hot methods independently.
- Compiled templates: the first render of an ERB template compiles it into a Ruby method.
- Inline caches and memoized values used by Ruby, Rails, and the application.
In a test environment with YJIT enabled, a cold first request to a project page took 652 ms, of which 151 ms was YJIT compiling. The same request to a warm process took 28 ms. In production, CPU time per request peaked around 200 ms while traffic moved to the new container, versus roughly 30 ms once workers were warmed.
Why the architecture magnified the problem
Early mitigations that were tried and ruled out included pre-opening worker database connections in before_worker_boot. That change made no difference, indicating the issue wasn't merely connection setup. The root cause was first-use work that happens only when the code path is exercised.
They cut post-deploy request queues by running signed-in requests through the already-loaded Puma master before it forked workers. Doing this triggers YJIT compilation, template compilation, schema reads, and other memoizations in the master process. The workers inherit those warmed resources via fork and copy-on-write, so they don't repeat the costly first-use work when they start serving traffic.
On the busiest hosts this adjustment reduced the CPU spikes and long request queues seen during deploys, avoiding the need for immediate hardware additions. The change relies on the preload_app! + fork approach and leverages the master's single-instance warm-up to amortize cold-start costs across all workers.