Skip to main content
ARCHOS 525 BLUEPRINT · /d/dgm_distributed-lock-service

Distributed Lock Service (lease, fencing token, consensus store)

12 COMPONENTS · 15 FLOWS · UPDATED 2026-11-21
GITHUB README / PR PREVIEW CARD
[![Distributed Lock Service (lease, fencing token, consensus store) — ArchOS Architecture](https://archos.sageideas.dev/d/dgm_distributed-lock-service/opengraph-image)](https://archos.sageideas.dev/d/dgm_distributed-lock-service)

*Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_distributed-lock-service)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_distributed-lock-service" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="Distributed Lock Service (lease, fencing token, consensus store) — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
  client_0[("Job worker")]
  gw_1["API gateway"]
  lock_2[("Distributed lock")]
  leader_3[("Consensus leader")]
  f1_4[("Consensus follower 1")]
  f2_5[("Consensus follower 2")]
  res_6[("PostgreSQL")]
  pdp_7["Policy decision point (PDP)"]
  secrets_8[("Secrets manager")]
  tsdb_9[("Time-series database (TSDB)")]
  alerting_10[("Alerting")]
  capacity_11["Capacity Estimate"]
  client_0 -->|"1. Calls with JWT · HTTPS"| gw_1
  gw_1 -->|"2. Asks lock · HTTP/2"| lock_2
  lock_2 -->|"3. Creates key · HTTP/2"| leader_3
  leader_3 -->|"4. Revision · HTTP/2"| lock_2
  lock_2 -->|"5. Token · HTTP/2"| gw_1
  gw_1 -->|"6. Granted · HTTPS"| client_0
  client_0 -->|"7. Writes with token · SQL"| res_6
  res_6 -->|"8. Accepts or rejects · SQL"| client_0
  gw_1 -->|"Asks policy · HTTP/2"| pdp_7
  secrets_8 -->|"JWT keys · HTTPS"| gw_1
  leader_3 -->|"Replicates · TCP"| f1_4
  leader_3 -->|"Replicates · TCP"| f2_5
  lock_2 -->|"Exports (OTLP) · OTLP"| tsdb_9
  res_6 -->|"Exports (OTLP) · OTLP"| tsdb_9
  tsdb_9 -->|"Feeds alerts · HTTP"| alerting_10

COMPONENT STACK (11)

  • Job workerSTATEFUL
    Needs one writer at a time
  • API gatewaySTATELESS
    Checks the JWT, then forwards
  • Distributed lockSTATEFUL
    Grants a Lease and a Fencing token
  • Consensus leaderSTATEFUL
    Commits on a majority of 3 members
  • Consensus follower 1STATEFUL
    Copies the leader's log
  • Consensus follower 2STATEFUL
    Copies the leader's log
  • PostgreSQLSTATEFUL
    Rejects a token below the highest seen
  • Policy decision point (PDP)STATELESS
    Allows or denies a lock per name
  • Secrets managerSTATEFUL
    Holds the JWT verification keys
  • Time-series database (TSDB)STATEFUL
    Stores grants, expiries, rejections
  • AlertingSTATEFUL
    Pages on rejections and no leader

REQUEST & DATA FLOW (15)

  1. Job worker → API gateway (Calls with JWT)[HTTPS]
  2. API gateway → Distributed lock (Asks lock)[HTTP/2]
  3. Distributed lock → Consensus leader (Creates key)[HTTP/2]
  4. Consensus leader → Distributed lock (Revision)[HTTP/2]
  5. Distributed lock → API gateway (Token)[HTTP/2]
  6. API gateway → Job worker (Granted)[HTTPS]
  7. Job worker → PostgreSQL (Writes with token)[SQL]
  8. PostgreSQL → Job worker (Accepts or rejects)[SQL]
  9. API gateway → Policy decision point (PDP) (Asks policy)[HTTP/2]
  10. Secrets manager → API gateway (JWT keys)[HTTPS]
  11. Consensus leader → Consensus follower 1 (Replicates)[TCP]
  12. Consensus leader → Consensus follower 2 (Replicates)[TCP]
  13. Distributed lock → Time-series database (TSDB) (Exports (OTLP))[OTLP]
  14. PostgreSQL → Time-series database (TSDB) (Exports (OTLP))[OTLP]
Configure NGINX / Postgres / K8s →60-Sec L4–L7 Diagnostic →