🧠 Explanation (System Design – Simple & Interview-Ready)
🧠 Explanation (System Design – Simple & Interview-Ready)
This looks like magic on the app.
In reality, it’s a real-time streaming + event-driven system.
Here’s how it works 👇
⸻
1️⃣ Delivery Partner Sends Live GPS Updates
The delivery partner’s app continuously sends GPS coordinates (latitude, longitude) every few seconds.
These updates go to the backend via:
• lightweight network calls
• optimized for battery + bandwidth
⸻
2️⃣ Backend Pushes Updates (Not Pulling)
Your app does not keep asking:
“Where is the rider now?”
Instead, the backend pushes updates using:
• WebSockets
• Server-Sent Events (SSE)
• or long-lived connections
This avoids page refresh and polling overload.
⸻
3️⃣ Real-Time Channel per Order
Each order gets a unique real-time channel:
• order_id → live location stream
• only users related to that order receive updates
This keeps traffic isolated and scalable.
⸻
4️⃣ Caching for Speed
Latest rider location is stored in:
• in-memory cache (Redis)
So:
• map updates are instant
• database is not hit every second
⸻
5️⃣ Frontend Just Re-renders the Marker
The map itself doesn’t reload.
Only this changes:
• rider marker position
• route polyline (optional)
This makes the UI feel smooth and real-time.
⸻
6️⃣ Why This Scales to Millions
Because:
• GPS events are small
• updates are async
• DB is not on the hot path
• real-time infra is horizontally scalable
⸻
🎯 Interview Angle
If asked in an interview, keywords to mention:
• WebSockets / SSE
• real-time event streaming
• geo-location updates
• Redis caching
• push-based architecture
Comments
Comments from the original post on Instagram
No comments yet
