Sync vs Async Communication
This describes whether the sender has to wait for the receiver to respond before continuing.
1. Synchronous (Sync)
The sender waits for a response before continuing.
Mental model: π Phone call
Client ββ request ββ> Server
Client <ββ response ββ Server
β
continue workingExample:
Frontend β GET /users β Backend
Frontend β user data β BackendThe frontend waits for the response before it can use that data.
Common examples:
-
REST API request/response
-
Database query
-
Function call
2. Asynchronous (Async)
The sender doesnβt have to wait. It can continue doing other work while the operation happens.
Mental model: π§ Email
Client ββ message ββ> Server
β
continue working
...later...
Server ββ result/event ββ> ClientExample:
User uploads a video
β
Backend puts job in RabbitMQ
β
Backend immediately says "Upload accepted"
β
Worker processes video in background
β
Worker sends notification when finishedThe user doesnβt have to keep waiting for the video processing to finish.
Quick comparison
| Sync | Async | |
|---|---|---|
| Sender waits? | β Yes | β No |
| Response | Usually immediate | May come later |
| Good for | Simple request/response | Long-running/background work |
| Example | REST API | RabbitMQ job |
| Mental model | Phone call |
Important distinction
Async doesnβt necessarily mean βno response.β
It means the sender doesnβt block while waiting for the response.
For example:
Frontend β POST /video
Frontend β 202 AcceptedThe backend can process the video later and eventually notify the frontend through a WebSocket, SSE, email, polling, etc.
So in a typical application you might use both:
REST β synchronous request/response
RabbitMQ β asynchronous background processing
WebSocket β asynchronous real-time notification