Edge Computingbeta

Edge Rate Limiter

A globally distributed rate limiter built on Cloudflare Workers and Durable Objects. Token-bucket and sliding-window algorithms, sub-5ms decisions almost anywhere in the world, per-IP and per-key configuration. I built it because most rate limiters I have seen in production are either too slow (round-trip to a central Redis) or too lenient (eventually-consistent counters). Durable Objects let you do consistent counting at the edge, which is the actually interesting bit.

Cloudflare WorkersDurable ObjectsTypeScriptHono

What this is

A lab, not a product.

A globally distributed rate limiter built on Cloudflare Workers and Durable Objects. Token-bucket and sliding-window algorithms, sub-5ms decisions almost anywhere in the world, per-IP and per-key configuration. I built it because most rate limiters I have seen in production are either too slow (round-trip to a central Redis) or too lenient (eventually-consistent counters). Durable Objects let you do consistent counting at the edge, which is the actually interesting bit.

5

Features

4

Learnings

4

Technologies

Capabilities

What it does

The features that actually got built and run in this prototype.

feature_01.ts
Sub-5ms rate-limit decisions globally with strongly consistent counters per key
feature_02.ts
Token-bucket and sliding-window algorithms, swappable per route
feature_03.ts
Per-IP, per-user, and per-API-key keys with composable rules
feature_04.ts
Burst handling and graceful degradation when Durable Objects are unhealthy
feature_05.ts
Integrates with the API security playbook as a drop-in middleware

The stack

What it is built with

The libraries and runtimes I picked for this lab and why they earned their place.

Cloudflare Workers
Durable Objects
TypeScript
Hono

What I learned

Learnings, in order of how much they surprised me

The things I would tell another engineer before they tried the same experiment.

01
Durable Objects make consistent counting at the edge surprisingly clean once you accept their sharding model
02
Latency budgets shrink fast. Every microsecond in the hot path matters when you are aiming for sub-5ms
03
Falling open on Durable Object errors is safer than failing closed for most APIs. Pick a side and document it
04
Rate limiters are a contract between you and your users. Tell them the limit, do not just block requests silently

Note: This is an experimental project in the beta stage. It is a learning exercise and technical exploration rather than a production-ready solution. Patterns and code may change.

Want me to build something like this for you?

If this kind of work fits your roadmap, I take on a small number of paid projects each quarter.