Posts tagged Concurrency
Unpredictable Game RNG in Production, Replayable in Tests: Separating the Two in Go
Use a Source interface to keep production RNG unpredictable and tests reproducible. Covers HMAC-seeded ChaCha8, recorded draws for disputes and an AES-CTR deadlock.
The WebSocket Hub: Go's Take on the Actor Model
Gortex's WebSocket Hub is the actor model in Go: one goroutine owns all state, callers reach it over channels instead of locks, and slow consumers are dropped.
Concurrent Counting and Resilience: Sharded Metrics and a Circuit Breaker
How gortex shards one metrics lock into sixteen, counts with atomics, keeps a three-state circuit breaker consistent, and why a channel is the wrong tool here.
Memory and Sync Primitives
Go zero-allocation needs escape analysis, sync.Pool reuse and the right primitive: atomic for one value, Mutex for a block of state, RWMutex if reads dominate.
Goroutines and Channels
Goroutines are cheap but leak without an exit, channels synchronise, and one goroutine owning state needs no lock. Plain counters want a mutex or atomic.
The Event Loop Is Not Multithreading: The Most Common Concurrency Misconception in Node.js
Node's non-blocking I/O looks like parallel execution, but it runs on a single-threaded event loop, and that difference bites hard once work turns CPU-heavy.