I made my Go reverse proxy 3.8x faster by fixing one line
I've been building a reverse proxy in Go. Not a hello world one, something meant to sit in production, in the actual path of every request, doing real work on each one before forwarding it along.
For a while I didn't think much about its raw throughput. It worked, requests came in, got processed, got forwarded, came back. Then I actually sat down to benchmark it properly, and the number I got back was rough. Nothing was broken. Nothing errored. It was just slow in a way I couldn't immediately explain.
The setup
The proxy uses Go's standard library httputil.ReverseProxy under the hood, which is the normal, idiomatic way to build something like this in Go. It's a well-built piece of the standard library. The problem wasn't the tool. It was how I was using it.






