This document outlines the Parallel and Distributed Computing (PDC) concepts integrated into the QueueLess backend architecture and explains their specific roles in ensuring system stability, scalability, and real-time responsiveness.
The system follows a classic Distributed Client-Server model. The Django REST Framework (DRF) acts as the centralized server, while various clients (Web, Mobile, and the Institution Mock API) interact with it via stateless HTTP requests.
- Decoupling: Allows the frontend and backend to evolve independently.
- Scalability: The server-side logic is centralized, making it easier to deploy to cloud environments.
- API Configuration: See
queueless_backend/settings.py(Lines 59-72) for the application definition andqueue_tracker/views.pyfor endpoint logic.
QueueLess utilizes Django Channels backed by a Redis Channel Layer. This implements a Publish-Subscribe (Pub/Sub) pattern where the server "publishes" queue updates, and specific "subscriber" clients receive them instantly via WebSockets.
In a queueing system, latency is critical. Traditional polling is inefficient; distributed messaging allows the system to be event-driven, only sending data when something changes.
- Redis Channel Layer: See
queueless_backend/settings.py(Lines 255-270) where Redis is configured as the message broker for real-time notifications.
To handle multiple simultaneous requests, the system uses Pessimistic Locking via .select_for_update().
QueueJoinView: When a user joins a queue, the system locks the specificInstitutionrow to ensure thecurrent_serving_numberis read and validated accurately.- Auto-Tick Logic: Uses atomic transactions to ensure no ticket numbers are skipped or duplicated.
In a high-traffic environment, hundreds of users might join at the same millisecond. Without these synchronization primitives, the system would suffer from Race Conditions.
- Row Locking: See
queue_tracker/views.py(Line 49) for the use ofselect_for_update()inside a transaction.
The system implements Rate Limiting (Throttling) using DRF's distributed throttling classes to manage resource allocation.
Throttling ensures that no single "heavy" client can monopolize the distributed system's resources, maintaining "Liveness" for all other users.
- Global Rates: See
queueless_backend/settings.py(Lines 190-203). - View Scoping: See
queue_tracker/views.py(Line 29) forthrottle_scope = "join".
The mock_api app simulates a distributed environment where QueueLess interacts with external, third-party institution APIs.
By architecting a separate mock_api that "talks" to the queue_tracker, we simulate the inter-process communication (IPC) and network latency found in truly distributed systems.
- Service Simulator: See the entire
queueless_backend/mock_api/directory.
To verify the system's ability to handle high concurrency and distributed load, a Locust load-testing framework was implemented.
- Scalability Testing: The system was subjected to 100+ simultaneous virtual users.
- Self-Protection (Throttling): Under extreme stress, the system correctly returned HTTP 429 (Too Many Requests) for the
joinendpoint. This demonstrates the "fail-safe" mechanism of distributed traffic management, preventing the database from crashing during a request spike. - Concurrency Stability: Despite the high load, the row-level locking ensured that no duplicate ticket numbers were issued (Data Consistency).
- Test Script: See
locust_tests/locustfile.pyfor the implementation of the simulated distributed user behavior.