Back

Backend / Distributed Systems

Decoupling for Resilience

Instead of one person doing everything, we split tasks among many helpers who send messages to each other. If one is busy, the others keep working.

1 Sync coupling

If one service dies, the others die with it

When services call each other directly over HTTP, they wait for each other. If one slows down or crashes, every caller hangs. The fix is messages on a queue. Services don't need to be alive at the same time.

Kill a node in Sync mode. Watch the failure cascade. Switch to Async and try again.

2 Message queue

A queue absorbs traffic spikes

Traffic comes in bursts. A queue sits between the front and the back. The front adds messages as fast as they arrive. The back processes them at a steady pace. Spikes fill the queue; they don't crash the workers.

Add traffic faster than workers can process. Watch the queue fill instead of crashing the server.

3 Pub/Sub

One event triggers many independent jobs

When an order is placed, three things need to happen: send a receipt, update stock, log analytics. Instead of doing them in a chain, you publish one event. Three subscribers each do their job in parallel.

Order placed once. Emails, inventory, and analytics all hear about it in parallel.

4 Dead letter queue

Bad messages go to a separate inbox

Some messages can't be processed — bad data, missing fields, a broken format. Without a plan, they jam the queue forever. The fix is to move failed messages to a dead letter queue after a few tries. Engineers can inspect them later, and the main pipe keeps flowing.

Watch a poison message bounce out of the main flow and land in the inspection bin.

Let's Talk Systems