ARCHOS 525 BLUEPRINT · /d/dgm_rate-limiter-failover
Distributed Rate Limiter (cache sharding and failover)
12 COMPONENTS · 11 FLOWS · UPDATED 2026-11-19
GITHUB README / PR PREVIEW CARD
[](https://archos.sageideas.dev/d/dgm_rate-limiter-failover) *Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_rate-limiter-failover)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_rate-limiter-failover" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="Distributed Rate Limiter (cache sharding and failover) — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
gw_0["API gateway"]
rl_1[("Rate limiter")]
router_2["Shard router"]
tsdb_3[("Time-series database (TSDB)")]
alerting_4[("Alerting")]
p1_5[("Distributed cache")]
r3_6[("Hot standby")]
p2_7[("Distributed cache")]
r1_8[("Hot standby")]
p3_9[("Distributed cache")]
r2_10[("Hot standby")]
capacity_11["Capacity Estimate"]
gw_0 -->|"1. Asks for decision (mTLS) · gRPC"| rl_1
rl_1 -->|"1b. Returns decision · gRPC"| gw_0
rl_1 -->|"2. Looks up shard · in-process call"| router_2
router_2 -->|"3a. Shard 1 of 3 · RESP"| p1_5
router_2 -->|"3b. Shard 2 of 3 · RESP"| p2_7
router_2 -->|"3c. Shard 3 of 3 · RESP"| p3_9
p1_5 -->|"4a. Replicates asynchronously · RESP"| r1_8
p2_7 -->|"Votes · cluster bus"| r1_8
p3_9 -->|"Votes · cluster bus"| r1_8
rl_1 -->|"Exports (OTLP) · OTLP"| tsdb_3
tsdb_3 -->|"Supplies metrics · HTTP"| alerting_4COMPONENT STACK (11)
- API gatewaySTATELESSAsks the limiter for a decision on each request
- Rate limiterSTATEFULAllows a shard's keys until a replica is promoted
- Shard routerSTATELESSClient library in the limiter; maps key to shard
- Time-series database (TSDB)STATEFULStores failover and fail-open counts over time
- AlertingSTATEFULPages on-call when a shard has no primary
- Distributed cacheSTATEFULShard 1 primary, first third of the key space
- Hot standbySTATEFULShard 3 replica, promoted if its primary fails
- Distributed cacheSTATEFULShard 2 primary, middle third of the key space
- Hot standbySTATEFULShard 1 replica, promoted by a vote of primaries
- Distributed cacheSTATEFULShard 3 primary, last third of the key space
- Hot standbySTATEFULShard 2 replica, promoted if its primary fails
REQUEST & DATA FLOW (11)
- API gateway → Rate limiter (Asks for decision (mTLS))[gRPC]
- Rate limiter → API gateway (Returns decision)[gRPC]
- Rate limiter → Shard router (Looks up shard)[in-process call]
- Shard router → Distributed cache (Shard 1 of 3)[RESP]
- Shard router → Distributed cache (Shard 2 of 3)[RESP]
- Shard router → Distributed cache (Shard 3 of 3)[RESP]
- Distributed cache → Hot standby (Replicates asynchronously)[RESP]
- Distributed cache → Hot standby (Votes)[cluster bus]
- Distributed cache → Hot standby (Votes)[cluster bus]
- Rate limiter → Time-series database (TSDB) (Exports (OTLP))[OTLP]
- Time-series database (TSDB) → Alerting (Supplies metrics)[HTTP]