Part of series: System Design Roadmap
Week 6 Day 2: Service Communication - APIs & RPC
In a Monolith, you call userService.getUser(id).
In Microservices, you make a network request.
1. REST (JSON over HTTP)
- Format: JSON text. Human readable.
- Pros: Standard, easy to debug, works in browser.
- Cons: Slow (Filesize large, parsing text is slow).
2. gRPC (Protocol Buffers)
- Format: Binary. Not human readable.
- Pros: Extremely fast (smaller payload), Type-Safe (generates code).
- Cons: Harder to debug, browser support is limited (needs proxy).
- Use Case: Internal service-to-service communication.
3. GraphQL
- Format: Query Language.
- Pros: Client fetches exactly what it needs (No over-fetching).
- Cons: Complexity on server side.
- Use Case: Public API for Frontends.
4. Sync vs Async
- Sync (Request/Response): βI need user data now.β (User waits).
- Async (Events): βUser signed up. Do whatever you need to.β (Fire and forget).
Tomorrow: Who controls traffic to all these services? API Gateway. πͺ