Edge 2026
Cybersecurity 8 min read Score: 0.98

Edge Rate Limiting: Leaky Bucket vs. Token Bucket Architectures in Cloudflare Durable Objects

High-concurrency stress testing comparing in-memory Durable Object actor state synchronization against Redis sliding-window algorithms for DDOS and credential stuffing mitigation.

Author: Dmitri Volkov, Edge Security Engineer
Published: 2026-10-25
Recommended Resource

Edge Security & Rate Limiting Framework

Deploy low-latency actor-based rate limiters to protect APIs

Launch Edge Rate Limit Sizer

Empirical Analysis & Findings

## Distributed Rate Limiting at Network Perimeters

Protecting public API surfaces from automated scraping, brute-force credential stuffing, and volumetric denial-of-service requires sub-millisecond rate evaluation. Evaluating rate quotas after a request reaches the origin application server squanders compute resources on malicious traffic.

### 1. Algorithm Comparison and Edge Performance

| Rate Limiting Model | Burst Tolerance | Smoothing Effect | Memory Footprint / Client | Synchronization Overhead |
|:--------------------|:---------------:|:----------------:|:-------------------------:|:------------------------:|
| Fixed Window Counter | High (Edge Spill) | None | 8 bytes | Low |
| Sliding Window Log | Zero | Strict | 128 - 512 bytes | High (List Pruning) |
| Token Bucket | Controlled Burst | Moderate | 16 bytes | Zero (Actor-Local) |
| Leaky Bucket | None | Maximum Smooth | 16 bytes | Zero (Actor-Local) |

### 2. Durable Object Actor Implementation

By routing client requests based on hashed client IP or API key to a dedicated Cloudflare Durable Object, state synchronization is maintained without external locks:

```python
class RateLimiterActor:
def __init__(self, capacity: int, refill_rate_per_sec: float):
self.capacity = capacity
self.refill_rate = refill_rate_per_sec
self.tokens = capacity
self.last_refill = time.time()

def allow_request(self, cost: int = 1) -> bool:
now = time.time()
elapsed = now - self.last_refill
self.tokens = min(self.capacity, self.tokens + elapsed * self.refill_rate)
self.last_refill = now
if self.tokens >= cost:
self.tokens -= cost
return True
return False
```

Linked Entities in the Autonomous Knowledge Graph

Cloudflare Durable Objects Redis OWASP Fastly Akamai

Frequently Asked Questions

Why do centralized Redis rate limiters struggle with global edge workloads?

Centralized Redis instances require edge nodes to traverse public networks for every API request, adding 40-150ms of cross-region latency to each authorization check.

What is the difference in traffic shaping between token bucket and leaky bucket?

Token bucket permits bursts up to bucket capacity while maintaining an average rate, whereas leaky bucket enforces a strictly smooth, uniform outflow rate regardless of burst spikes.

Related Research & Briefs