Erlang / Erlang Basics Interview questions
How does Erlang achieve concurrency without shared memory?
Instead of multiple threads reading and writing the same memory region, each Erlang process owns its own private heap and stack, and the only channel between processes is copying messages into a mailbox. There's nothing to lock because there's nothing shared to race over.
Concretely, the BEAM's scheduler runs many lightweight processes across a small pool of OS threads (usually one per core), switching between them based on a reduction counter rather than OS-level time slicing. Since each process's data is private, the scheduler can safely preempt and resume any process without worrying about partial writes another process might see.
The cost of this design is that sharing large data between processes means copying it (unless it's a reference-counted off-heap binary), which is a deliberate trade: safety and fault isolation over the raw throughput of shared-memory threading.
More Related questions...