Simple Virtual Waiting Room (VWR)
1. The Problem
Our website can only handle 10 users per minute. If more than 10 people try to access it at once, the server will crash. We need a system that:
Counts incoming users.
Redirects "overflow" users to a waiting page.
Admits them back to the main site one by one as space becomes available.
2. Intern Tasks
Create a Gateway: A simple script that checks:
if (active_users < 10) { allow } else { send to queue }.Build the Queue: Use a simple list (FIFO) to store user IDs.
The Wait Page: A basic HTML page that says: "You are number X in line. Estimated wait: Y minutes."
Admission Logic: Every 30 seconds, pull the next user from the queue and "admit" them.
3. Sample Datasets (Simulation)
Provide these two datasets to the interns. They should write a script to "read" these files and simulate how their system reacts.
Dataset A: The Traffic Surge (Input)
This file simulates users arriving at the site. The interns' code should process this and decide who goes to the "Live Site" and who goes to the "Queue."
| Timestamp | User ID | Action | Result (Expected) |
| 09:00:01 | User_01 | Request Access | Admitted (Spot 1/10) |
| 09:00:05 | User_05 | Request Access | Admitted (Spot 5/10) |
| 09:00:15 | User_11 | Request Access | Queued (Position #1) |
| 09:00:20 | User_12 | Request Access | Queued (Position #2) |
| 09:00:45 | User_25 | Request Access | Queued (Position #15) |
Dataset B: Server Capacity (Constraints)
Interns must hard-code these limits into their logic to test "stress" scenarios.
| Parameter | Value | Description |
| MAX_CAPACITY | 10 | Maximum users allowed on the site at once. |
| ADMIT_RATE | 2 | Number of users to pull from the queue every 60 seconds. |
| SESSION_TIMEOUT | 5 | Minutes a user can stay on the site before they must leave. |
Comments
Post a Comment