SentryGabriel VillalobosIncident / postmortem
How one quadratic webhook handler pinned our autoscaler at its ceiling
Summary
Our Control RPC deployment normally runs 32 pods but scaled to 256 for hours, an 8x increase against 2x more traffic. The KEDA autoscaler’s P95 busyness target caused infinite scaling because adding pods does not reduce the busiest pod’s metric, analogous to hiring lemonade-stand helpers when any helper looks busy. Raising the target by 15 percent and switching to P75 helped only slightly; the pod count stayed near ceiling during peaks. The root cause was three bugs in the GitLab integration: a grouping error, a race condition, and an N-squared lookup loop that turned each webhook into millions of internal RPC calls across the silo boundary. After patching, the average pod count dropped from 150 to 42, a 72 percent reduction, but the autoscaler still spirals when the P75 busyness metric is restored.
Context
Sentry runs isolated Region silos and a single Control silo that stores shared data like users and integrations. Region code makes RPC calls to Control when it needs this data. The Control RPC deployment is a shared resource any product code can generate load on. The autoscaler uses KEDA with five metrics including P95 busyness.
Approach / What changed
The team patched three bugs in the GitLab integration: a grouping error that ignored project scoping, a race condition on webhook processing, and a degenerate N-squared lookup loop that made RPC calls for every installation per webhook.
Takeaways
A P95 busyness autoscaling target cannot be satisfied because adding pods does not reduce the busiest pod’s busyness; average metrics like P75 or mean work better.
Fast scale-up combined with slow scale-down causes the pod count to ratchet upward from every traffic burst, staying near the ceiling.
Total RPC call counts can mask a single method’s 10x increase; breaking volume down by method reveals hidden regressions.
FAQ
Why did the P95 busyness target cause infinite scaling?
The P95 busyness metric looks at the busiest pod, and adding more pods does not reduce that pod's busyness if it is handling a slow IO-heavy request. The autoscaler consequently never sees the metric drop and keeps scaling up until it hits the ceiling.
How can I prevent similar autoscaling failures?
Check that your scaling metrics actually drop when you add pods, sanity-check against CPU, compare scale-up and scale-down speeds, break internal RPC volume down by method, look for N+1 and N^2 calls across network boundaries, and watch for shared records that grow without limit.
What were the three bugs in the GitLab integration?
A grouping error that ignored project scoping, a race condition where webhook updates were missed, and a degenerate N-squared lookup loop that made RPC calls for every installation per webhook, effectively turning a single webhook into millions of internal RPC calls.
Source and freshness
- Source
- blog.sentry.io
- Published
- Added to Yomu
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.