> ## Content Index
> Fetch the complete content index at: https://stalin-pereira.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Decoupling Microservices: Moving from REST to Events
- URL: https://stalin-pereira.com/decoupling-microservices-moving-from-rest-to-events/
- Published: 2025-12-17T10:38:00.000Z
- Updated: 2026-10-16T19:08:14.000Z
- Description: The trade-off between coupling (HTTP) and latency (Events)
- Author: Stalin Pereira
- Tags: Distributed Systems

**Stop Coupling Services with HTTP**

The case for Async-First communication.

## The Temporal Coupling Trap

- **The Call** — Order Service calls Inventory Service via HTTP POST.
- **The Dependency** — If Inventory is down, Order Service fails. The user cannot buy.
- **The Chain** — In a chain of 5 services, if *any* one is slow, the whole request is slow.

## The Event-Driven Shift

Fire and Forget

- **The Event** — Order Service saves order and publishes event: `OrderCreated`.
- **The Response** — Order Service returns 'Success' to user immediately. Fast.
- **The Process** — Inventory Service listens for `OrderCreated` and updates stock later.

## Benefits of Events

- **Resilience** — If Inventory is down, the event sits in the queue (Kafka/SQS) until it recovers.
- **Extensibility** — Want to send an email? Just add an Email Service listener. No code change in Orders.
- **Throttling** — The consumer processes events at its own pace, preventing overload.

## The Trade-off: Complexity

- **Eventual Consistency** — The stock isn't updated *instantly*. The UI must handle this lag.
- **Debugging** — Tracing a flow through queues is harder than following a stack trace.

## When to use which?

- **Use HTTP (Sync)** — When the user needs the answer *right now* (e.g., Logging in).
- **Use Events (Async)** — For side effects: Sending emails, analytics, updating search index.

## Summary: Cut the Cord

Embrace the queue.

> Tight coupling creates fragile systems. Events create resilient ones.

---

Synchronous or Asynchronous? How do your services talk?