
PostHog has rewritten one of its highest-traffic endpoints in Rust, delivering dramatic infrastructure savings and performance gains. The company's feature flag local evaluation endpoint now runs on 56 times less memory and 24 times fewer CPU cores than its Django predecessor, while serving the same load with significantly lower latency.
The endpoint handles polling requests from server-side SDKs every 30 seconds to fetch feature flag definitions. It's a read-heavy workload by design: the endpoint pulls cached data from Redis with no flag evaluation logic and no database queries on the hot path. Despite the minimal compute requirements, the Django implementation consumed substantial resources.
The Numbers
Before the rewrite, PostHog's Django-based endpoint ran on approximately 30 pods with 60 CPU cores and 270GB of total memory. The infrastructure required a dedicated pool of memory-optimized instances and PGBouncer sidecars to handle connections.
The Rust version handles identical traffic on 5 pods, 2.5 CPU cores, and 4.8GB of memory. The memory-optimized node pool has been eliminated entirely, along with the PGBouncer sidecars that managed database connection overhead.
Latency improvements were equally substantial. Median response time dropped from 40ms to 4ms, a 90 percent reduction. The 95th percentile fell from 95ms to 20ms, while the 99th percentile decreased from 170ms to 37ms.
Why the Endpoint Was Ripe for Migration
The feature flag local evaluation endpoint performs almost no computation, which made it an ideal candidate for consolidation into PostHog's existing Rust flags service. Server-side SDKs poll the endpoint frequently to stay current with flag definitions, but each request simply reads pre-computed data from Redis cache.
The Django implementation worked but carried significant overhead. Python's memory model and the web framework's per-request resource allocation meant each concurrent connection held onto more memory than necessary for such straightforward data retrieval. Rust's zero-cost abstractions and efficient memory management delivered immediate gains without changing the endpoint's behavior or API contract.
According to PostHog's announcement on LinkedIn, the migration was led by Patricio Tarantino and the flags team. The detailed engineering post walks through the before-and-after metrics and implementation decisions.
Infrastructure Impact
The resource savings translate directly to lower cloud costs and simpler operations. Eliminating the memory-optimized node pool removes an entire class of infrastructure that required separate provisioning, monitoring, and maintenance. The reduced pod count and CPU allocation free up capacity for other workloads.
PostHog has been shipping several AI-powered features recently, including Autoresearch Mode for autonomous code optimization. Infrastructure efficiency gains like this Rust migration help the company scale those compute-intensive capabilities without proportional increases in baseline costs.
The company's flags infrastructure now runs leaner while delivering faster responses to SDK clients. For teams evaluating feature flag providers, the endpoint's performance characteristics matter: faster local evaluation means less latency in application code paths that check flags before rendering features or routing traffic.
PostHog's full engineering writeup on the migration is available on their blog, detailing the implementation process and trade-offs involved in moving the endpoint from Django to Rust.
Sources
1 checkedHow we cover tool news: Create With's tool desk drafts these reports with AI from the sources listed above and checks them against those sources before publishing.





