Microservices

Small services, big failure modes. API gateway, service discovery, circuit breakers, config server, sync vs async messaging, sagas and observability.

Topics in this section

Monolith vs microservices

A monolith is one big restaurant kitchen: easy to run while it's small, chaos at scale. Microservices are a food court: each stall owns its menu, staff and fridge, and you can expand the busy one — but now you need walkways, signs and a plan for when a stall shuts.

API gateway

An API gateway is a hotel reception. Guests talk to one desk, which checks their key card, sends them to the right floor and stops anyone hammering the bell.

Service discovery

Service instances come and go like food trucks. Service discovery is the live map: every truck registers where it's parked, and customers look it up instead of memorising an address.

Circuit breaker & resilience

A circuit breaker is your home's fuse box. When the payment service keeps failing, the fuse trips (OPEN) and calls fail instantly with a fallback instead of piling up. After a cool-down it lets a few test calls through (HALF_OPEN). If they work, the power's back on (CLOSED).

Sync vs async: REST & Kafka

Synchronous is a phone call: you wait on the line for the answer. Asynchronous is a text message: you send it and get on with your day, and the reply arrives whenever it arrives.

Saga & transactional outbox

Booking a holiday means a flight, a hotel and a car from three different companies. There's no single undo button, so every booking has a matching cancellation. If the car falls through, you cancel the hotel and the flight. That's a saga.

Each topic pairs a plain-language explanation with code, interview questions, and related practice where available.