ARCHOS 525 BLUEPRINT · /d/dgm_rate-limiter
Distributed Rate Limiter (token bucket on a sharded counter store)
11 COMPONENTS · 13 FLOWS · UPDATED 2026-11-19
GITHUB README / PR PREVIEW CARD
[](https://archos.sageideas.dev/d/dgm_rate-limiter) *Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_rate-limiter)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_rate-limiter" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="Distributed Rate Limiter (token bucket on a sharded counter store) — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
client_0[("API Client")]
rs_1["Resource server"]
lb_2["Layer 7 load balancer"]
gw_3["API gateway"]
rl_4[("Rate limiter")]
secrets_5[("Secrets manager")]
cache_6[("Distributed cache")]
standby_7[("Hot standby")]
tsdb_8[("Time-series database (TSDB)")]
alerting_9[("Alerting")]
capacity_10["Capacity Estimate"]
client_0 -->|"1. Calls with a JWT · HTTPS"| lb_2
lb_2 -->|"2. Forwards (mTLS) · HTTP/2"| gw_3
gw_3 -->|"3. Asks for decision (mTLS) · gRPC"| rl_4
rl_4 -->|"4. Runs bucket script (mTLS) · RESP"| cache_6
cache_6 -->|"5a. Returns token count · RESP"| rl_4
cache_6 -->|"5b. Replicates asynchronously · RESP"| standby_7
rl_4 -->|"6. Returns decision · gRPC"| gw_3
gw_3 -->|"7a. Forwards allowed (mTLS) · HTTP/2"| rs_1
gw_3 -->|"7b. Returns HTTP 429 · HTTP/2"| lb_2
lb_2 -->|"8. Relays HTTP 429 · HTTPS"| client_0
rl_4 -->|"Exports (OTLP) · OTLP"| tsdb_8
tsdb_8 -->|"Supplies metrics · HTTP"| alerting_9
secrets_5 -->|"Supplies credentials · HTTPS"| rl_4COMPONENT STACK (10)
- API ClientSTATEFULCalls the API from an untrusted network
- Resource serverSTATELESSBackend API that sheds load when overloaded
- Layer 7 load balancerSTATELESSEnds TLS, stamps a trace id, spreads requests
- API gatewaySTATELESSChecks the JWT and scope, then asks the limiter
- Rate limiterSTATEFULToken bucket decision; fails open if the cache is down
- Secrets managerSTATEFULHolds the cache password and TLS certificates
- Distributed cacheSTATEFULRedis Cluster: the limiter picks the shard by key
- Hot standbySTATEFULReplica of each shard, kept in a different zone
- Time-series database (TSDB)STATEFULStores allow and reject counts over time
- AlertingSTATEFULPages on-call when rejects or errors spike
REQUEST & DATA FLOW (13)
- API Client → Layer 7 load balancer (Calls with a JWT)[HTTPS]
- Layer 7 load balancer → API gateway (Forwards (mTLS))[HTTP/2]
- API gateway → Rate limiter (Asks for decision (mTLS))[gRPC]
- Rate limiter → Distributed cache (Runs bucket script (mTLS))[RESP]
- Distributed cache → Rate limiter (Returns token count)[RESP]
- Distributed cache → Hot standby (Replicates asynchronously)[RESP]
- Rate limiter → API gateway (Returns decision)[gRPC]
- API gateway → Resource server (Forwards allowed (mTLS))[HTTP/2]
- API gateway → Layer 7 load balancer (Returns HTTP 429)[HTTP/2]
- Layer 7 load balancer → API Client (Relays HTTP 429)[HTTPS]
- Rate limiter → Time-series database (TSDB) (Exports (OTLP))[OTLP]
- Time-series database (TSDB) → Alerting (Supplies metrics)[HTTP]
- Secrets manager → Rate limiter (Supplies credentials)[HTTPS]