I'm building a web app that allows users to join a queue and view live updates about their position and estimated wait time. This kind of system is commonly found in clinics, service centers, and support desks. Users will be able to join the queue via their phones or browsers, while the staff manages it through a dashboard. It's crucial that as soon as someone is served or a new user joins, everyone in the queue sees their updated position immediately.
I'm particularly interested in the architecture needed for this system. Besides managing real-time updates, I want to ensure that the queue remains consistent, especially with high user interaction. I'm considering using WebSockets for real-time communication, a Node.js backend, and Redis for queue management. However, I'm curious about other possible approaches—should I stick to WebSockets, try server-sent events, or maybe even use polling? What's the best way to handle queue state to prevent issues when several users join or leave simultaneously? And lastly, how might this system scale if we have thousands of users? I'd love to hear suggestions from experienced developers!
5 Answers
Yeah, WebSockets plus Redis should work well. Keep the queue in Redis, leveraging atomic operations to manage joins and leaves consistently. You can use a backend setup with Node and Socket.io to handle substantial user loads. Generally, this combination performs well under pressure.
If you're looking for simplicity, you might consider Server-Sent Events (SSE) unless you absolutely need two-way communication. SSE is easy to implement and automatically reconnects, which might save you some headaches in user management. Using Redis for your queue updates fits nicely with this.
A simplified approach could involve having various "lobbies" for different types of requests. The staff lobby would hold high-priority requests, while the public lobby serves regular users. This setup lets you control queue changes effectively while keeping the process manageable.
Using WebSockets with Redis is a solid choice for this kind of application. You can keep the queue state in Redis to safely handle race conditions, and broadcast updates through WebSockets whenever changes happen in the queue.
Be cautious with polling, as it tends to overload the server. WebSockets are really the way to go here, especially for real-time updates. Plus, using Redis sorted sets allows you to manage user positions seamlessly.

Related Questions
How to Build a Custom GPT Journalist That Posts Directly to WordPress
Cloudflare Origin SSL Certificate Setup Guide
How To Effectively Monetize A Site With Ads