DDD and FSM: tackling complexity with state machines
summary
Moves a managed Kubernetes cluster creation from a brittle three-step Kafka pipeline into per-domain FSMs that store each entity state in Postgres and drive transitions with Kafka events, using an outbox pattern to avoid async inconsistencies and a DB root lock to prevent races. Node creation is split into four distinct states (VM, OS, config, run); example cluster has 3 masters and 5 workers in 2 groups. Implementation uses long switch cases implemented in Go and fits CQRS/hexagonal services, and it proves resilient in production.
AI-written summary · about
chapters (19)
- 0:00DDD and FSM introduction
- 1:20Finite state machines
- 2:03Managed Kubernetes service
- 3:05Fault-tolerant pipeline refactor
- 4:11DDD for cluster logic
- 5:36Parallel operations with aggregates
- 6:40Worker node complexity
- 7:23Node lifecycle state machine
- 8:47Error handling in state machines
- 9:50State tracking in aggregates
- 10:11Event propagation in cluster
- 11:57Error propagation in state machines
- 13:24Technical challenges
- 14:29Race conditions and locks
- 14:51Messaging inconsistency
- 16:15Batch operations
- 17:18State-matched error processing
- 19:03Current implementation
- 20:26Q&A
related talks
20mFine Grained Replicated State Machines for a Cluster Storage System
46mWriting Stateful Frameworks
27mEmpowering Resilient Scalability: The Power of Choreography in Distributed Systems
25mCloudstate—Towards Stateful Serverless
38mState is Hard: An SDK for Building Stateful Applications
47mTackling Cloud Complexity - Recipes From Real World Projects
33mDistributed Scheduler Hell
33mCloudstate Towards Stateful Serverless
