---
title: "Pumas, Routers & Keepalives—Oh my!"
description: "Elevated tail latency seen by some Puma apps after enabling Heroku Router 2.0 turned out to be a Puma bug, not a router problem."
url: "https://swe.quest/articles/pumas-routers-keepalives-oh-my-4b676798ea4106ef"
canonical: "https://www.heroku.com/blog/pumas-routers-keepalives-ohmy/"
source: "Heroku Engineering"
published: "2024-11-21"
difficulty: "medium"
kind: "Article"
reading_minutes: 17
tags: ["debugging","performance","ruby","load-balancing","networking"]
---

# Pumas, Routers & Keepalives—Oh my!

A post on [Heroku Engineering](https://swe.quest/sources/heroku.md), published 2024-11-21, 17 min read, Article. Original: [https://www.heroku.com/blog/pumas-routers-keepalives-ohmy/](https://www.heroku.com/blog/pumas-routers-keepalives-ohmy/)

## Summary

Elevated 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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Ruby](https://swe.quest/tags/ruby.md) (Languages)
- [Load balancing](https://swe.quest/tags/load-balancing.md) (Infrastructure)
- [Networking](https://swe.quest/tags/networking.md) (Infrastructure)

## Prerequisites

- HTTP keepalive
- TCP connection states ([easy posts on Networking](https://swe.quest/tags/networking.md?difficulty=easy))
- Ruby web servers ([easy posts on Ruby](https://swe.quest/tags/ruby.md?difficulty=easy))

## Keywords

Puma, Heroku Router 2.0, Go net/http, hey, ApacheBench, Rails

## Related posts

- [Learn How to Lower Heroku Dyno Latency through Persistent Connections (Keep-alive)](https://swe.quest/articles/learn-how-to-lower-heroku-dyno-latency-through-persistent-connections-keep-alive-3816d278b532e549.md): Heroku Engineering · 2025-11-04 · Medium · 6 min read · Networking, Performance engineering, Ruby, Cloud platforms
  HTTP keep-alive connections cut latency by reusing TCP connections, so repeat requests skip the handshake and TCP slow start and run at full bandwidth.
- [Upgrade to Puma 7 and Unlock the Power of Fair Scheduled Keep-alive](https://swe.quest/articles/upgrade-to-puma-7-and-unlock-the-power-of-fair-scheduled-keep-alive-798a2f5419631b82.md): Heroku Engineering · 2025-11-05 · Medium · 11 min read · Ruby, Concurrency, Performance engineering, Networking
  Puma 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.
- [Tips & Tricks for Migrating to Router 2.0](https://swe.quest/articles/tips-tricks-for-migrating-to-router-2-0-d21a58134b52266a.md): Heroku Engineering · 2024-11-21 · Medium · 5 min read · Load balancing, Networking, Cloud platforms, Deployment
  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.
- [The Vanishing Thread and Postgresql TCP Connection Parameters](https://swe.quest/articles/the-vanishing-thread-and-postgresql-tcp-connection-parameters-955a883b4bb1ed12.md): Instacart Tech · 2022-04-15 · Medium · 16 min read · PostgreSQL, Networking, Linux, Resilience, Debugging
  Instacart traced Puma threads that hung for about 15 minutes, ignoring application and database timeouts, to TCP retransmission storms between the app and an AWS NLB in front of PgBouncer.
- [Battling database performance](https://swe.quest/articles/battling-database-performance-5c5eb431f69f9020.md): incident.io · 2023-04-20 · Medium · 10 min read · PostgreSQL, Performance engineering, Observability, Go, Incidents & postmortems
  Intermittent API timeouts at incident.io over two weeks traced back to requests blocking on Go's database/sql client-side connection pool, with no single slow query or pool to blame.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
