Autoscaler Stuck at Max: A Quadratic Webhook Bug

Autoscaler stuck at maximum pods after a quadratic webhook bug

Sentry’s Control RPC deployment normally idles near a floor of about 32 pods. One day it was holding at its ceiling of 256 and stayed there for hours. External traffic was up about 2x, but the deployment had scaled up about 8x. With the autoscaler stuck at maximum, Sentry’s engineers spent weeks finding out why.

The autoscaler stuck at its ceiling turned out to be doing what it was told. The cause was three separate bugs in the GitLab integration that together could turn one incoming webhook into millions of internal RPC calls.

Why Control RPC is a shared resource

Sentry runs several isolated Region silos and one Control silo. Control holds data shared across organizations or required to be globally unique, such as users, organization slugs and integrations. Regions can’t read that data directly, so they make remote procedure calls to Control. Code in any region can therefore generate load on the same deployment.

The first suspect: why the autoscaler stuck at max

The deployment had just moved to new infrastructure, with several small changes, including autoscaler tweaks made after recent incidents. KEDA scales the pods against five metrics: CPU utilization, requests per second, the P95 busyness of the Granian HTTP servers, active connections per pod and backpressure on Granian workers. Each counts equally, so one tight target can force a scale-up.

P95 busyness often sat at 100%, while RPC latency was normal and average CPU was very low. Raising the busyness target by 15% changed nothing.

The reason is structural. A P95 target tracks the busiest slice of workers. A few slow, IO-heavy requests keep that number high however many pods you add, so the target can never be met. Scale-down made it worse: the rules added 4 pods every minute and a half but removed only 2 every two and a half minutes, after a five-minute wait. Each burst ratcheted the count up and left the autoscaler stuck high.

The engineer moved to P75 busyness with a slightly lower target and a higher per-pod request limit. Pods scaled down more often, but during the weekly peak from Tuesday evening to Thursday afternoon the count still sat near the top.

Dead ends, and what AI tools did and didn’t do

Granian worker memory limits were next, because an earlier incident involved a too-low limit on the old uWSGI workers. CPU was far lower this time, so that was a red herring.

The engineer then gave the tedious metric and manifest digging to AI tools, including Claude and an internal triage agent. Results were mixed: some good findings, plenty of dead ends, and a habit of overstating how much a metric mattered. Narrower prompts and cross-checking produced six leads, from elevated Postgres query times to crashlooping pods. None explained the severe scale-ups.

The per-method breakdown that cracked it

A new latency monitor on Control RPC began firing sporadically. Breaking call counts down by method showed what the flat totals had hidden. One moderately expensive method, integrations.get_organization_integrations, had risen about 10x in a week. It returns the installations attached to an integration and runs on user actions or on webhooks from providers such as GitHub and GitLab.

The owning engineers took over, two triage runs pointed to the same code path, and a teammate shipped a patch. Control dropped almost to its baseline pod count and stayed there the next week.

Three bugs combined

  • Four years ago, a feature let GitLab users include all their groups by leaving the group path empty. On https://gitlab.com it also grouped unrelated installations under one shared Integration record, which gathered more than 2,000 installations.
  • Earlier this year, Sentry added GitLab issue assignment syncing, with a backfill of webhook triggers that was broken at launch. A mid-September fix set up webhooks across every installation under that shared record.
  • The assignment sync code looked up installations by parent integration for each installation. Every lookup was an RPC call, so a webhook meant about 2,000 calls, repeated for each result. One webhook could mean millions.

Alone, none would have hurt. The N² lookup is harmless when N is 1.

Results and what’s unsolved

The weekly average fell from about 150 pods to about 42, roughly 72% fewer. Sentry says the headroom matters more than the savings. A puzzle remains: when the P75 change was rolled back, the deployment spiraled up again, so some pods still run hot for reasons the team doesn’t yet understand.

Checks for your own services

If you run a shared internal service behind an autoscaler, confirm that your scaling metric falls when pods are added. Hundreds of pods at near-idle CPU is a warning sign. Compare scale-up and scale-down speeds, break RPC volume down by method, look for N+1 and N² calls that cross a network boundary, and find the largest N in production, not the typical one.

Source: Sentry Blog

Written by

Saksham Bhargava

Saksham Bhargava runs Alteroid and has been writing about consumer technology for over five years, covering iPhone, Android, Windows, AI tools and gaming. With an MCA and six years of hands-on web development experience, he tests the features he writes about on his own devices and focuses on clear, practical guides that solve real problems. Away from the screen, he enjoys travelling to places most tourists skip.