Flow 2 · Go · interview path

Concurrency and correctness

The same payment twice, many users on one seat, two buyers and one item — uniqueness, reservations, and a single atomic UPDATE.

Duplicate request

Scenarios

  • Healthy
  • Active
  • Bottleneck
  • Failed
  • Protective
HTTPdrainreadycachewritesreplicateasyncpoisontraces
clientClient
  • POST /v1/orders
  • Idempotency-Key
edgeCDN or API Gateway
  • TLS · routing
  • GET cache at edge
protectRate Limiter
  • Inbound 429
  • tenant key
spreadLoad Balancer
  • Ready only
  • drain
fleetStateless Go instances
  • cmd/api · no affinity
go-1go-2go-3
cacheRedis cache
  • Hits · idempotency
  • TTL holds
writePrimary database
  • Writes · pool
  • invariants
readRead replica
  • SELECT only
  • browse lag OK
vNOld version
  • Drain · rollback
vN+1New version
  • Ready first
cbCircuit breaker
  • Fail fast
  • not inbound RL
downPayment service
  • Downstream
  • of Order
stockInventory service
  • Atomic decrement
  • last item
sideNotification service
  • Off the request path
bufferQueue
  • Durable · partitioned
poolWorker pool
  • Bounded G
w-1w-2w-3
poisonDLQ
  • Park
seeMetrics, logs, tracing, alerts
  • p95 / p99 · find the bottleneck first
62%

Click a box or a plane · packets follow the request

Why this answer holds