Tips & Tricks for Migrating to Router 2.0
Heroku Router 2.0 is now generally available and will become the default, so apps should be validated on a staging copy first by enabling the http-routing-2-dot-0 feature and restarting dynos to drop legacy-router connections. You can confirm which router is in use through the Via response header (heroku-router vs. vegur) or through router log fields: protocol now reads http2.0/http1.1, and there are new tls and tls_version fields. HTTP/2 is on by default for custom domains with valid TLS. It terminates at the router, which forwards HTTP/1.1 to dynos. Keepalives to dynos are always on, which lowers latency but triggers a Puma connection-handling bug that inflates tail latency. Both HTTP/2 and keepalives can be disabled through labs flags.
Related posts
- Router 2.0 Common Runtime Router: The Road to Beta
Heroku Engineering mediumAdeptHeroku is replacing Hermes, its decade-old Erlang Common Runtime router, with Router 2.0 written in Go. Hermes became hard to upgrade: Erlang expertise declined, its dependencies were pinned, and features like HTTP/2 were blocked. The new L7 router runs in-memory behind an existing L4 proxy that also terminates TLS. Using the Strangler pattern, it routes per-app traffic either through Hermes or directly to dynos, and it shares an HTTP library with the Private Spaces router. Before beta, the team added gated deployment automation, continuous load testing tied to SLOs, and W3C Network Error Logging to measure real client routing failures.
- Learn How to Lower Heroku Dyno Latency through Persistent Connections (Keep-alive)
Heroku Engineering mediumAdeptHTTP keep-alive connections cut latency by reusing TCP connections, so repeat requests skip the handshake and TCP slow start and run at full bandwidth. HTTP/1.0 opened one connection per request; HTTP/1.1 decoupled requests from connections through pipelining and keep-alive. Heroku Router 2.0 now uses keep-alive to dynos by default. Ruby apps that disabled keep-alives over earlier latency spikes should upgrade to Puma 7.1.0+ and can check settings with PUMA_LOG_CONFIG and the http-disable-keepalive-to-dyno labs flag.
- Pumas, Routers & Keepalives—Oh my!
Heroku Engineering mediumAdeptElevated tail latency seen by some Puma apps after enabling Heroku Router 2.0 turned out to be a Puma bug, not a router problem. Under load with roughly 200ms of server-side work, keepalive connections pushed p95/p99 response times above 2 seconds. The cause was traced by reproducing it locally with hey and ab, which showed the slowdown occurs with any keepalive client hitting Puma directly. Tuning Go's http.Transport MaxIdleConnsPerHost reduced connection churn but did not fix latency. Puma 7.0.4 or later fixes the bug.
- The Adventures of Rendezvous in Heroku’s New Architecture
Heroku Engineering mediumAdeptMoving Heroku's Rendezvous proxy, which splices CLI and one-off dyno connections across NATs, from EC2 Classic to VPC behind AWS Network Load Balancers with TLS termination broke one customer's request-scoped one-off dyno workflow with H12 router timeouts. The root cause was a single-threaded agent loop using IO.select on the raw TCP socket. The NLB's larger TLS frames left decrypted bytes buffered inside OpenSSL's SSLSocket where IO.select couldn't see them, so the loop blocked until an idle timeout longer than the router's 30s limit. The fix split the agent into one thread per direction and changed the read logic so buffered SSL data is drained before selecting again.
- Upgrade to Puma 7 and Unlock the Power of Fair Scheduled Keep-alive
Heroku Engineering mediumAdeptPuma 6 and earlier let a single keep-alive connection monopolize a thread for up to 10 requests via the "fast inline" loop originally built for HTTP pipelining, so under overload about one in ten requests waited roughly 10x longer while later keep-alive requests cut the line. Puma 7 fixes this by requeuing pipelined and keep-alive requests at the back of the queue and removing the wait_until_not_full block on the accept loop. To keep load balanced across workers, it extends wait_for_less_busy_worker with a proportional sleep, so busier workers wait longer before accepting. Capacity is unchanged, but overload delay is now spread fairly; upgrading to 7.1.0+ is recommended, especially for Heroku Router 2.0 users who disabled keep-alives.