Simulating a real-world system in Go
summary
A Go simulator models a coffee shop as four 1 ms stages and measures latency and throughput concretely it reports 1 ms per stage and 250 lattes/sec per CPU and shows the ideal sequential worker scales linearly until contention on a single grinder forces throughput to plateau at ~1000 lattes/sec The code reveals a data race flagged by the race detector caught data races experiment fixes include per‑machine mutexes, buffered channels (sizes 1 and 10), pipelined workers and adding machine replicas which restore parallelism and change the bottleneck to CPUs
AI-written summary · about
chapters (17)
- 0:00Intro
- 3:46An ideal latte
- 4:15The ideal function
- 5:24Reality strikes
- 5:59Lesson: Use the race detector
- 8:02Fine-grain locking performance
- 8:21Lesson: Minimize locked duration
- 9:05Structural limits
- 10:32Two sets of machines
- 10:57Multi machine performance
- 11:10Lesson: Identify the limiting factor
- 12:50A coffee pipeline
- 13:19Pipeline vs. locking Median latency (ms)
- 15:02Buffered vs. unbuffered
- 15:20Major vs. minor optimizations
- 16:22Many more scenarios
- 17:28Get the simulator
related talks
24mMastering Concurrency in Go: From Patterns to Production
28mGo Make Something Real – The Potential for Go on the Factory Floor
18mApplied concurrency in Go
35mGo’s Trace Tooling and Concurrency
47mQueues, Fairness, and The Go Scheduler
44mGo Profiling and Observability from Scratch
36mGolang's Realtime GC in Theory and Practice
54mComplex Concurrency Patterns with Go
