Skip to content
Get started
Get started
Kubernetes Cluster Simulator: Live HA, Failover & Fencing
View Markdown
simulator · kubernetes + postgresql 19

Break pods. Kill Postgres. Verify zero loss.

A live discrete-event model of bunqueue’s multi-broker Kubernetes runtime. Scale stateless replicas, inject SIGTERM drains, SIGKILL crashes, network partitions, node power-offs, and database restarts while watching /ready probes, lease handoffs, and stale ACK fencing in real time.

t+00:00
k8s: 4/4 Ready · PG Online
Scenarios:4 stateless pods balanced behind Service/bunqueue with steady load.

Live cluster topology

Service/bunqueue endpoints: 4/4 · click a pod to inspect
Service/bunqueueTCP :6789 · HTTP :6790 · PDB min=2bq-a1200 Ready0 leases · 173M · node-1bq-b2200 Ready0 leases · 174M · node-2bq-c3200 Ready0 leases · 175M · node-3bq-d4200 Ready0 leases · 176M · node-1postgres-0 (PG 19.0 · v22)ONLINE · 24/100 conns · 0 SKIP LOCKED/s · 0 NOTIFY/s

Pods & Nodes

kubectl -n bunqueue get pods -o wide · rev 1
PodNodePhase/readyLeasesRSSInject fault
bunqueue-a1node-1Running2000173 / 512M
bunqueue-b2node-2Running2000174 / 512M
bunqueue-c3node-3Running2000175 / 512M
bunqueue-d4node-1Running2000176 / 512M

Conservation & Invariant Proof

Enqueued (0) = Waiting + Active + Completed + DLQ
Waiting0
Active leases0
Completed0
Lost / Dupes0 / 0
Fenced ACKs0
Handoffs0
p99 pickup4 ms

Throughput

0 jobs/s · DLQ 0

Cluster Events

  • 00:00[endpoints]Service/bunqueue :6789 routing across 4 Ready endpoints
  • 00:00[kube]Deployment/bunqueue Ready (4/4) · PostgreSQL 19.0 Schema v22

How the simulation maps to real bunqueue v2.9.25

Section titled “How the simulation maps to real bunqueue v2.9.25”
BehaviorWhat you see hereReal bunqueue + Kubernetes runtime
Pod identityEach recreated pod gets a fresh <pod>:<pid>:<hex> broker IDOmit static BUNQUEUE_BROKER_ID so restarted containers skip the 30 s fencing lockout
Graceful drain (SIGTERM)/ready flips to 503, Service/bunqueue removes the endpoint, owned leases hand off to siblingsbeginDrain() stops lease reassignment onto draining pods; measured 4 s drain
Pod crash (SIGKILL)Pod dies with active leases; PostgreSQL DB clock expires leases and RecoverySweeper reclaims themSurviving broker increments generation token and re-queues without manual intervention
Split-brain partitionPartitioned pod finishes locally and sends a late ACK; PostgreSQL rejects it and increments Fenced ACKsLease generation fencing guarantees two workers never both complete the same job
PostgreSQL restartAll pods flip /ready 503 while postgres-0 restarts, then auto-heal back to N/N ReadyconnectionTimeout: 5s + bounded retry loop recovers in 5-6 s
PodDisruptionBudgetVoluntary SIGTERM drains stop when ready <= minAvailablePodDisruptionBudget (minAvailable: 2) protects cluster capacity during node drains
Schema upgrade (Recreate)Drains old pods, holds pg_advisory_lock(bunqueue:schema), boots new revision cleanlyPrevents mixed binary versions against one PostgreSQL namespace during schema bumps

Ready to deploy this exact topology? Follow the Step-by-Step Kubernetes Guide or explore the single-node Queue Engine Simulator.