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 working

Example:

Frontend β†’ GET /users β†’ Backend
Frontend ← user data ← Backend

The 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 ──> Client

Example:

User uploads a video
        ↓
Backend puts job in RabbitMQ
        ↓
Backend immediately says "Upload accepted"
        ↓
Worker processes video in background
        ↓
Worker sends notification when finished

The user doesn’t have to keep waiting for the video processing to finish.


Quick comparison

SyncAsync
Sender waits?βœ… Yes❌ No
ResponseUsually immediateMay come later
Good forSimple request/responseLong-running/background work
ExampleREST APIRabbitMQ job
Mental modelPhone callEmail

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 Accepted

The 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

Back-End My-Journey-In-Codeless