Fly.ioIncident / postmortem
How to make Rust leak memory (also: how to make it stop)
Summary
fly-proxy, a Rust-based proxy, leaked memory because its obsolete custom HoneycombLayer retained child spans under a long-lived parent span. The post follows a request from browser input through DNS, TCP, TLS, HTTP/2, and asynchronous Rust components including an aya-built eBPF program, tokio, hyper, and tracing, before explaining how the leak surfaced. In the custom layer, every closed child span was added to its parent’s collection, so each request consumed a small amount of memory while a high-level async task remained alive. Removing that legacy code fixed the primary problem: memory usage barely exceeded 50MB during a load test, while remaining growth came from queues and latency data retained for processing rather than the identified leak.
Context
The Rust-based fly-proxy proxy was experiencing memory growth in long-running operation. Its custom Honeycomb tracer retained data associated with requests under a high-level task that stayed alive until the proxy restarted.
Approach / What changed
The investigation traced request handling and async span lifecycles, identified the obsolete custom HoneycombLayer as the source of retained child spans, and removed that legacy tracing code. Memory profiler graphs were then used to distinguish the fixed leak from bounded queue and latency-storage allocations.
Takeaways
A custom HoneycombLayer added each closed child span to its parent, causing a small memory leak for every request whose high-level parent span remained open.
Removing the legacy tracer implementation reduced memory usage to barely above 50MB during the load test.
Some post-fix allocation growth came from queues and latency data retained for queueing and percentile calculations; the source describes this as acceptable when bounded.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.