System Design for Beginners #17: What Is WebSocket? (How Real-Time Apps Actually Work)
Imagine sending a message on WhatsApp.
System Design for Beginners #17: What Is WebSocket? (How Real-Time Apps Actually Work)
Imagine sending a message on WhatsApp.
You type:
Hey
And instantly:
- message delivered
- typing indicator appears
- double ticks update
- other user receives it live
No refresh button.
How?
Using:
🔌 WebSockets

🧠 First, Think About Phone Calls vs Letters
Traditional web requests are like: 📨 Sending letters
You:
- send request
- wait for response
- connection closes
But WebSockets are like: 📞 Phone calls
Connection stays open continuously.
Both sides can talk anytime.
Traditional HTTP Problem
Normally websites work like this:
Client → Request
Server → Response
Connection closes
Every update requires: 👉 new request
This works for:
- normal websites
- blogs
- static pages
But terrible for:
- chat apps
- live games
- real-time dashboards
Without WebSockets
Browser keeps asking:
Any new messages?
Any new messages?
Any new messages?
This is called:
Polling
Problems:
- wasteful
- high latency
- too many requests
Very inefficient at scale.
Enter WebSockets
WebSocket creates:
A persistent two-way connection between client and server
Once connected:
- server can push updates instantly
- client can send data anytime
No repeated reconnecting.
Simple WebSocket Flow
Flow:
- Client opens WebSocket connection
- Connection stays alive
- Both sides exchange data instantly
This enables: ⚡ real-time communication
Real WhatsApp Example
When you send message:
User A → WebSocket Server → User B
Server instantly pushes message to other user.
That’s why chats feel live.
Why WebSockets Are Powerful
1️⃣ Real-Time Communication
Updates happen instantly.
Perfect for:
- chats
- multiplayer games
- stock trading
- collaborative apps
2️⃣ Lower Latency
No need for repeated HTTP requests.
Communication becomes much faster.
3️⃣ Efficient Connections
One persistent connection: ✅ less overhead ✅ fewer requests ✅ better performance
Apps Using WebSockets
Real-time systems heavily depend on them:
- Discord
- Figma
- TradingView
Without WebSockets: 👉 these apps wouldn’t feel real-time.
WebSockets Create Scaling Challenges
This is IMPORTANT.
Persistent connections sound great…
Until millions connect simultaneously.
The Problem
Imagine:
- 10 million active WebSocket connections
Now servers must:
- keep all connections alive
- track state continuously
- manage memory efficiently
Huge scaling challenge.
Load Balancing WebSockets
Modern systems solve this using:
- sticky sessions
- distributed pub/sub systems
- event-driven architectures
- horizontal scaling
This becomes advanced real-time systems engineering.
WebSockets vs HTTP

Important Insight
WebSockets are NOT replacements for HTTP.
Most systems use:
- HTTP for normal APIs
- WebSockets for real-time features
Hybrid architecture is common.
Real Engineering Insight
Modern apps feel alive because: 👉 servers continuously push updates.
That changes everything:
- chats
- notifications
- collaboration
- live tracking
Real-time systems transformed the internet.
What You Just Learned
- What WebSockets are
- Why polling is inefficient
- Persistent connections
- Real-time communication basics
- Scaling challenges in live systems
메타데이터
- post_id
- a96c9ecf52d3
- slug
- system-design-for-beginners-17-what-is-websocket-how-real-time-apps-actually-work-a96c9ecf52d3
- url
- https://medium.com/@kawaldeepsingh/system-design-for-beginners-17-what-is-websocket-how-real-time-apps-actually-work-a96c9ecf52d3
- canonical_url
- https://medium.com/@kawaldeepsingh/system-design-for-beginners-17-what-is-websocket-how-real-time-apps-actually-work-a96c9ecf52d3
- author_url
- https://medium.com/@kawaldeepsingh
- status
- ok
- fetched_at
- 2026-06-09 15:37:30