Video in progress

Staff 🌱 Spring

In a SaaS system one big customer's heavy requests are slowing the system down for all other customers (noisy neighbor). How do you handle it?

First find out who is taking which resource using per-tenant metrics; then per-tenant rate limits and quotas, separate pools and queues (bulkhead), moving heavy work to the background, and if needed splitting big customers into their own "cell".

📖 Answer

  1. Make it visible. In many systems "who is generating the load" is invisible. Add a tenant tag to every metric (only for a bounded number of big tenants, the rest as "other", otherwise cardinality explodes), the tenant id in logs and traces, and a comment on queries in the database (/* tenant=42 */) or application_name. Then you see a concrete fact: "tenant 42's export is taking 60% of the CPU".

  2. Immediate protection: limits.

  • A per-tenant rate limit at the API level (token bucket, in Redis), tied to the pricing plan.
  • A concurrency quota for heavy operations (export, bulk import, reports): one tenant can't run more than 2 exports at once.
  • Limits on request size: page size, date range.
  1. Isolation (bulkhead).
  • Heavy work is moved off the HTTP path into a queue; the queue is read fairly per tenant, so one tenant's 10 thousand tasks don't block everyone else's.
  • Separate thread pools or pod groups: "interactive" and "batch" traffic are kept apart.
  • In the database: reports go to a replica, and long queries get a statement_timeout.
  1. The structural solution: cells. Customers are split into groups, and each group has its own copy of the application and database. The biggest customers sit in a cell of their own. The benefit: a failure or load is confined to one cell (blast radius). The cost: a routing layer (tenant → cell), deploys and migrations per cell, and tooling to move a customer between cells.

  2. The business side. Sometimes the right answer isn't technical: if a big customer uses more resources, it should show up in the pricing (an enterprise plan, separate infrastructure). I discuss this with the product team, because limits are a product decision too.

The order matters: measure → limit → isolate → cells. Jumping straight to a cell architecture is often a very expensive solution to a problem the first two steps would have solved.