← The table of explainers · 5 min read

Explainer · Concurrency≈ in everyday life

Multiple chefs sharing one kitchen.

Concurrency isn't about doing everything at the exact same instant. It's about not blocking on any one thing.

The Docerity teamEngineers who explain for a living
  • Concurrency
  • Performance

The problem: one slow task blocking everything else

If your system handles one task completely before starting the next, a single slow task (a big file upload, a slow network call) holds up every task behind it, even ones that have nothing to do with it and could easily run in the meantime.

What concurrency actually means

Concurrency means multiple tasks make progress over the same stretch of time, by interleaving: working on one, stepping away while it waits on something (like the network or a disk), and picking up another in the meantime. This is different from true parallelism, where tasks run on genuinely separate CPU cores at the same instant; concurrency can happen even on a single core.

The catch: shared resources

The moment two tasks touch the same shared thing (a variable, a file, a database row) at the same time, you risk a race condition: the outcome depends on timing you don't control, and it can be different every run. This is why concurrent systems need rules for who gets to touch what, and when.

Why it's worth the complexity

Done well, concurrency means your system keeps serving other users while one slow operation is still in flight, instead of everyone waiting in a single-file line behind it.

Written by

The Docerity teamEngineers who explain for a living

One explainer, now and then.

When a new piece goes out, it comes to you. Nothing else, and one click to leave.

Or follow along by RSS.