Write path · Go · cmd/api + cmd/worker

Scalable & Low-Latency Go System Design

Click i on a plane for the whole step, or on a box for its Go. Zoom in like a map for streets — G-M-P inside each Go process, patterns around the TX, row locks vs mutexes.

Idle

Which layer helps

fast ACKsame TXpoisonreads
1Client / app
  • POST /v1/invoices
  • Idempotency-Key
2Load balancer / gateway
  • TLS · routing · rate limit
3Go API servers
  • cmd/api · HTTP fleet
api-1api-2api-3
cacheRedis
  • Idempotency · RL
readReplica
  • Catalog · tax
AInput validation
  • Schema · reject first
BAuthn / Authz
  • Tenant · RBAC
CCreate invoice
  • errgroup fan-out
DDatabase transaction
  • BEGIN · FOR UPDATE · COMMIT
dbPrimary DB
  • Write + row locks
ECommit successful
  • 201 now · events after
201API response
  • Fast ACK
evtOutbox row
  • Same TX as write
pubOutbox relay process
  • cmd/relay
FBroker / queue
  • Dedicated cluster
broker-1broker-2broker-3P0 emailP1 pdfP2 analytics
GGo worker servers
  • cmd/worker · not API
worker-1worker-2worker-3NotifyPDFAnalytics
dlqDead letter
  • Poison · replay
72%Overview

Zoom in like a map · streets: G-M-P, patterns, locks

Why Go helps