The Invisible Shield: How Contentstack Launch Protects Every Customer at Scale
At Contentstack Launch, our philosophy is simple: Rate limits shouldn’t bother you. They should be high enough that you never hit them, invisible enough that you never think about them — and when someone tries to force the issue with an attack, that's our problem to solve, not yours. We don't pass that cognitive cost on to you. No degraded service. No disrupted experience.
But making that promise requires real engineering behind it. The threat we're talking about is a Distributed Denial of Service (DDoS) attack — where thousands of compromised machines scattered across the globe simultaneously flood your endpoints with requests. Unlike a single-source attack that can be blocked by IP, a DDoS is designed to look like real traffic from real places. Its goal is simple: overwhelm your capacity until legitimate requests can't get through.
At Contentstack Launch, we serve hundreds of organizations simultaneously. A successful attack against one shouldn't hurt another — but without the right infrastructure in place, it easily could.
The Shield That Keeps Every Customer Protected
We strongly believe ‘One Customer’s Flood Shouldn't Be Another Problem’.
For this, there is a mechanism that controls how many requests a caller can make within a given time window — requests beyond that threshold are rejected before they ever reach your infrastructure. It's what makes isolation real — ensuring that no single organization, whether under attack or just surging, can consume more than its allocation and spill into someone else's capacity. The answer is rate limiting. At its core, it's a contract: every customer gets a fair share of the platform's capacity, no matter how much traffic they receive and no matter where it comes from.
For Contentstack Launch, this means each organization has a defined request-per-second limit — one that's set well above your average traffic, so it never gets in your way under normal conditions. If traffic exceeds that limit — whether it's a legitimate surge or a deliberate flood — excess requests are gracefully rejected before they can impact anyone else on the platform.
That's the shield. The harder question is: how do you build one that actually works at scale?
Fast, But Not Smart Enough
The first instinct when thinking about rate limiting is to push it as far to the edge as possible — ideally at the CDN (Content Delivery Network) layer. CDNs are fast, globally distributed, and sit right in the path of every request. On paper, it seems like the perfect place.
But it comes with real constraints.
A modern CDN operates through hundreds of Points of Presence (POPs) spread across the globe. Each POP is an independent node with its own local counter -- meaning without coordination, a single organization could consume far more than its intended limit across POPs simultaneously. You can work around this by designating one POP as a global coordinator, but now every request has to round-trip to that central node for counting. You've reintroduced latency into a layer that was supposed to eliminate it.
CDN-level rate limiting works well for broad, IP-based abuse protection. For accurate, per-organization enforcement with dynamic plan-aware limits and no added latency? We had to go deeper.
Three Strategies, One Winner
Once we ruled out the CDN, we evaluated three classic approaches for enforcing global per-organization limits:
| Strategy | How It Works | Strength | Weakness |
|---|---|---|---|
| Fixed Window | Count requests per fixed window (0–1s, 1–2s) | Simple | Boundary bursts: 2× limit possible at window edges |
| Sliding Window Log | Track every request timestamp, compute rolling count | Accurate | Expensive at scale — log storage per request |
| Token Bucket | Tokens replenish at fixed rate, one consumed per request | Burst-friendly, smooth | Complexity in a distributed system. — Where do you store the bucket? |
Token Bucket is the approach most production-grade rate limiters converge on — and so did we. But as the table hints, the hard part wasn't choosing the algorithm. It was figuring out where to store it.
What We Built: A Tiered Token Bucket
The naive implementation stores the bucket entirely in a centralized database that all servers share. That works — but at scale, every single request triggers a database round-trip. With hundreds of organizations and high request rates, that's unnecessary traffic on every request, added latency in the critical path, and a single point of contention under load.
We needed something smarter.
We built what we call a Tiered Token Bucket — a two-tier architecture that keeps a small local token reserve on each server, backed by a shared global pool in Database.
- Every server holds a per-organization bucket in local memory
- Each bucket starts with X local tokens — enough to serve a burst of requests instantly, with zero network calls
- When local tokens run out, the server reaches out to the global database, which atomically checks the organization's total usage against their plan limit and allocates more tokens if available
- The server stores the refilled tokens locally and continues serving — again without touching the database — until the next refill is needed
This design means ~95% of requests never touch the database at all. The fast path is entirely in-memory, on the same server handling the request. The database only enters the picture at the edges — when local reserves need replenishing, or when the global limit is close.
Frequently asked questions
How does Contentstack Launch protect customers from DDoS attacks and surges?
Contentstack Launch uses per-organization rate limiting with a token bucket algorithm to isolate traffic for each customer, ensuring one customer's traffic surge or attack cannot impact others.
Why not implement rate limiting at the CDN layer?
CDN-level rate limiting lacks the ability to enforce consistent per-organization quotas across globally distributed nodes without latency or loss of accuracy, so Contentstack implements rate limiting deeper in the stack.
What is a tiered token bucket, and why is it used?
A tiered token bucket stores a small token reserve locally on each server for fast access, with a global database-backed bucket for refills. This reduces database load and latency, ensuring fast and accurate rate limiting at scale.