In synchronous communication, the sender sends a request and waits (blocks) until it receives a response before doing anything else. The two parties must be available at the same time.
Think of it like a phone call:
| Protocol | Description | Use Case |
|---|---|---|
| REST (HTTP/HTTPS) | Text-based, uses JSON/XML, stateless | Web APIs, CRUD operations |
| gRPC | Binary protocol using Protocol Buffers, fast | Microservices, mobile backends |
| GraphQL | Query language over HTTP | Flexible data fetching |
A browser asks a server: "Give me user #42's profile."
GET /users/42 HTTP/1.1 Host: api.example.com
Server responds:
{
"id": 42,
"name": "Alice",
"email": "alice@example.com"
}
The browser waits for this response before showing the page.
gRPC uses .proto files to define services:
// user.proto
service UserService {
rpc GetUser (UserRequest) returns (UserResponse);
}
message UserRequest {
int32 user_id = 1;
}
message UserResponse {
int32 id = 1;
string name = 2;
string email = 3;
}
The client calls GetUser(user_id=42) and blocks until the server returns a UserResponse.