In the final part of our System Design series, we’re focusing on how to deliver real-time data effectively, balancing complexity, latency, and reliability.
We’ll cover:
- Serialization – JSON, Avro, Proto
- Real-Time Delivery – Polling, SSE, WebSockets
1. Serialization
TL;DR: Choose the right format to balance speed, size, and compatibility.
- JSON: Easy to debug, human-readable, but large and slow to parse.
- Avro: Compact, schema evolution support, good for Kafka.
- Protobuf: Highly efficient, strict schema, widely used in gRPC.
👉 Example: Use Protobuf for high-throughput internal RPC between microservices, JSON for external APIs.
👉 Interview tie-in: "Why not use JSON everywhere?" — Size and parsing speed trade-offs.
2. Real-Time Delivery
TL;DR: Choose the right mechanism based on use case and scale.
- Polling: Simple but inefficient; periodic client requests.
- Server-Sent Events (SSE): Server pushes updates over HTTP, uni-directional.
- WebSockets: Full-duplex communication, ideal for bidirectional interaction.
👉 Example: Stock trading platform uses WebSockets for real-time price updates. Simple dashboards use SSE for infrequent updates.
👉 Interview tie-in: "When would you use SSE over WebSockets?" — SSE for simple streaming, WebSockets for interactive apps.
✅ Takeaways
- Pick serialization format based on throughput, compatibility, and schema evolution.
- Use polling only if absolutely necessary; prefer SSE or WebSockets for real-time.
💡 Practice Question:
"Design a live sports score app that supports thousands of concurrent users. How do you handle real-time updates efficiently and ensure message order?"
Top comments (0)