Handling high traffic with the current 5-second polling mechanism? #20
|
Hi Bita, My question is regarding scalability: As the number of active drivers and customers grows, frequent 5-second HTTP polling requests might heavily strain the Django server and database. Have you considered moving towards WebSockets (via Django Channels) or Server-Sent Events (SSE) for a more event-driven real-time update in the future? Or do you have specific optimization/caching strategies in mind for the current polling mechanism? Thanks! |
Replies: 1 comment
|
Hi! Thanks for the great question. You've pointed out a very critical architectural challenge. You are completely right. As the system scales, having hundreds or thousands of active users hitting the Django server every 5 seconds via standard HTTP polling will inevitably lead to database bottlenecks and high CPU usage, even with optimized querysets. Here is my approach and how I see this evolving: 1. Current State (Why Polling?)For the initial version of this project, HTTP Live-Polling was chosen for a few reasons:
2. Next Steps for Optimization (Before WebSockets)Before completely rewriting the communication layer, we can optimize the current polling mechanism by:
3. The Future: Moving to WebSockets (Django Channels)To make this system truly production-grade and highly scalable, the ultimate roadmap definitely includes migrating to WebSockets via Django Channels:
I'd love to hear your thoughts on this! If you've implemented Django Channels for similar location/order tracking systems before, feel free to share any tips or pitfalls to avoid. |
Hi! Thanks for the great question. You've pointed out a very critical architectural challenge.
You are completely right. As the system scales, having hundreds or thousands of active users hitting the Django server every 5 seconds via standard HTTP polling will inevitably lead to database bottlenecks and high CPU usage, even with optimized querysets.
Here is my approach and how I see this evolving:
1. Current State (Why Polling?)
For the initial version of this project, HTTP Live-Polling was chosen for a few reasons: