Lesson 01: The Bottleneck

Request-Response vs Events

When you build your first web app, you use the Synchronous Request-Response model. A user clicks "Register", your browser makes an HTTP POST request, the server writes to the database, and returns a 200 OK.

This works beautifully until your business grows. Now, when a user registers, you must:

Compound Latency

If you execute these API calls sequentially within your Registration endpoint, the user has to stare at a loading spinner for 3.5 seconds. Even worse, if the third-party CRM API goes down, your Registration endpoint crashes, meaning users cannot sign up for your app because your sales tool is broken.

The Synchronous Bottleneck Simulator

Watch what happens when a user tries to register using synchronous HTTP REST calls. Notice how the total request time compounds.

POST /api/register
0.0s
1. INSERT INTO users...
2. HTTP POST /email/welcome...
3. HTTP POST /billing/trial...
4. HTTP POST /crm/sync...
Waiting for user request...

The Solution: Fire and Forget

The user who just clicked "Register" doesn't care if the CRM synced. They only care that their account was created.

To fix this, we need to decouple the core action from the side effects. The Registration API should simply write to the Database, and then immediately broadcast a message saying: "User 123 Registered." Then, it can instantly return a 200 OK to the user.

The Email, Billing, and CRM services can listen for that message and do their work in the background. This is called Event-Driven Architecture.

Check yourself

1. In a complex microservice architecture, why is a synchronous Request-Response chain dangerous?

In a synchronous chain, the availability of the system is the product of the availability of all its dependencies. If you depend on 5 services, and one goes down, your system goes down.