Sweaty Imposter

Shared Memory + Locks Across Components Versus Actors / Message-Passing, Each Component Owns Its State

TradeoffConcurrencySeniorStaffUpdated

You're building a stateful service with many internal components mutating shared state. You want to keep it correct as it grows.

Short answer: Actors / message-passing, each component owns its state. Message passing eliminates whole categories of bugs (deadlock, race, torn read) by removing sharing, each actor is single-threaded inside.

The Two Options

A

Shared memory + locks across components

B

Actors / message-passing, each component owns its state

Drill This: Your Pick First

The Better Pick

Option B

Actors / message-passing, each component owns its state

Message passing eliminates whole categories of bugs (deadlock, race, torn read) by removing sharing, each actor is single-threaded inside. Scales to distributed systems trivially because the model is location-transparent.

When the Other One Wins

Shared memory + locks across components

Tight, low-latency loops over shared in-memory state (an in-process cache, a matching engine), locks plus careful design beat message-copy overhead.