Go reverse proxy sped up 3.8x by reusing HTTP transport instead of rebuilding it
A developer building a production-grade reverse proxy in Go discovered a significant performance bottleneck through load testing. The root cause was that a new httputil.ReverseProxy instance — and with it a new http.Transport — was being created for every incoming request, eliminating connection pooling entirely. Without connection reuse, each request bore the full cost of establishing a fresh upstream connection, causing a persistent tail of slow responses under load. The fix involved caching one ReverseProxy instance per upstream using sync.Map, ensuring the HTTP transport and its connection pool are built only once and reused across all requests. This single structural change resulted in a 3.8x throughput improvement on a proxy performing real work such as policy evaluation, field transformation, and PII detection.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in