Skip to main content
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
[![Distributed Rate Limiter (cache sharding and failover) — ArchOS Architecture](https://archos.sageideas.dev/d/dgm_rate-limiter-failover/opengraph-image)](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_4

COMPONENT STACK (11)

  • API gatewaySTATELESS
    Asks the limiter for a decision on each request
  • Rate limiterSTATEFUL
    Allows a shard's keys until a replica is promoted
  • Shard routerSTATELESS
    Client library in the limiter; maps key to shard
  • Time-series database (TSDB)STATEFUL
    Stores failover and fail-open counts over time
  • AlertingSTATEFUL
    Pages on-call when a shard has no primary
  • Distributed cacheSTATEFUL
    Shard 1 primary, first third of the key space
  • Hot standbySTATEFUL
    Shard 3 replica, promoted if its primary fails
  • Distributed cacheSTATEFUL
    Shard 2 primary, middle third of the key space
  • Hot standbySTATEFUL
    Shard 1 replica, promoted by a vote of primaries
  • Distributed cacheSTATEFUL
    Shard 3 primary, last third of the key space
  • Hot standbySTATEFUL
    Shard 2 replica, promoted if its primary fails

REQUEST & DATA FLOW (11)

  1. API gateway → Rate limiter (Asks for decision (mTLS))[gRPC]
  2. Rate limiter → API gateway (Returns decision)[gRPC]
  3. Rate limiter → Shard router (Looks up shard)[in-process call]
  4. Shard router → Distributed cache (Shard 1 of 3)[RESP]
  5. Shard router → Distributed cache (Shard 2 of 3)[RESP]
  6. Shard router → Distributed cache (Shard 3 of 3)[RESP]
  7. Distributed cache → Hot standby (Replicates asynchronously)[RESP]
  8. Distributed cache → Hot standby (Votes)[cluster bus]
  9. Distributed cache → Hot standby (Votes)[cluster bus]
  10. Rate limiter → Time-series database (TSDB) (Exports (OTLP))[OTLP]
  11. Time-series database (TSDB) → Alerting (Supplies metrics)[HTTP]
Configure NGINX / Postgres / K8s →60-Sec L4–L7 Diagnostic →