Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.

Commit 51bf3f1

Browse files
committed
docs: update architecture diagram and docs for DO rate limiter
- Architecture diagram: add RateLimiter DO, note Consumer writes R2/D1 - Status table: rate limiting changed from KV-based to DO-based - Component table: clarify Consumer and KV roles - SECURITY.md: update rate limiter description (DO + in-memory two-layer)
1 parent 34e4dd5 commit 51bf3f1

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Webhooks are deceptively simple — until they aren't. Providers send them once
4242
| Export / Import / Migrate | ✅ Stable | Instance-to-instance migration with ID remapping |
4343
| Idempotency (KV-based deduplication) | ✅ Stable | Configurable TTL |
4444
| Payload archive (R2) | ✅ Stable | Configurable retention |
45-
| Rate limiting (per-source ingress) | ✅ Stable | KV-based with `X-RateLimit` headers |
45+
| Rate limiting (per-source ingress) | ✅ Stable | DO-based precise global limiting with in-memory pre-check |
4646
| `hookflare dev` (local tunnel + signature verification) | ✅ Stable | Cloudflare Quick Tunnel, auto-downloads cloudflared |
4747
| `hookflare connect` (one-shot setup) | ✅ Stable | Source + destination + subscription in one command |
4848
| `hookflare providers` (provider catalog) | ✅ Stable | Browse providers and event types |
@@ -159,21 +159,23 @@ Webhook Source (Stripe, GitHub, ...) Your Application (API)
159159
| ^
160160
v |
161161
[Ingress Worker] --> [Queue] --> [Consumer] --> [Delivery DO] --> fetch()
162-
| | |
163-
v v v
164-
[KV] [D1] [R2]
165-
idempotency config/logs payload archive
162+
| | | |
163+
v v v v
164+
[Rate [KV] [D1] [R2]
165+
Limiter idempotency config/logs payload archive
166+
DO]
166167
```
167168

168169
| Component | Cloudflare Service | Role |
169170
|---|---|---|
170171
| **Ingress Worker** | Workers | Receives webhooks, verifies signatures, enqueues |
172+
| **Rate Limiter** | Durable Objects | Per-source precise global rate limiting |
171173
| **Message Queue** | Queues | Durable buffer — guarantees no event loss |
172-
| **Consumer Worker** | Workers | Reads from queue, resolves routing, dispatches |
174+
| **Consumer Worker** | Workers | Reads from queue, archives payload (R2), records event (D1), dispatches |
173175
| **Delivery Manager** | Durable Objects | Per-destination retry state machine with backoff |
174176
| **Config & Logs** | D1 (SQLite) | Sources, destinations, subscriptions, delivery logs |
175-
| **Idempotency Cache** | KV | Deduplication keys with TTL |
176-
| **Payload Archive** | R2 | Long-term storage for webhook payloads |
177+
| **Idempotency Cache** | KV | Deduplication keys with TTL (read on ingress, write on accept) |
178+
| **Payload Archive** | R2 | Long-term storage for webhook payloads (written by consumer, not ingress) |
177179

178180
## Delivery Guarantee
179181

SECURITY.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ A fresh deployment exposes `POST /api/v1/bootstrap` (unauthenticated) to create
6262

6363
**Mitigation**: Bootstrap immediately after deployment, or set `API_TOKEN` via `wrangler secret put API_TOKEN`. The env var always takes priority and can recover a compromised bootstrap.
6464

65-
### Rate limiter is per-edge-location
65+
### Rate limiter granularity
6666

67-
The in-memory rate limiter operates per Cloudflare edge isolate, not globally. Under distributed traffic from many edge locations, the effective global limit may exceed the configured per-source limit.
67+
The rate limiter uses a two-layer design: in-memory pre-check (per-isolate, fast) + Durable Object counter (global per-source, precise). The DO layer eliminates the race conditions of the previous KV-based approach. However, under extreme distributed traffic hitting many edge locations simultaneously, brief bursts above the limit are theoretically possible before the DO serializes the count.
6868

69-
**Mitigation**: Use Cloudflare WAF rules for strict global rate limiting. The built-in limiter is designed for abuse prevention, not billing-grade enforcement.
69+
**Mitigation**: For strict enforcement, use Cloudflare WAF rate limiting rules at the platform level.

0 commit comments

Comments
 (0)