IplanRio2026in production
Rio Queue
Admission control that keeps the City of Rio's digital services available during demand peaks.
1,000
concurrent sessions admitted on the tax guide queue
- 2
- protected systems, one of them legacy ASP.NET
- 1
- script tag to onboard an application, with no backend changes
The problem
Around tax deadlines and large campaigns, traffic to Nota Carioca and the SuperApp rises abruptly and exceeds the capacity of the origin systems. Nota Carioca is a legacy ASP.NET application, which makes any capacity work inside the system itself slow and costly.
The solution
I built a self-hosted virtual waiting room in Python (FastAPI on Granian) backed by Valkey. A protected application only adds one script tag. When demand exceeds the configured limit, users join a queue that reports their position and estimated wait in real time over Server-Sent Events. Admission follows a rate and a session cap, and each token is valid only on the queue that issued it.
Technical notes
Same-domain integration through a cookie for the SuperApp, and cross-domain integration through a token handoff for Nota Carioca.
Operated from a command line with normal, pause (the queue is frozen without losing positions) and block (admitted users return to the waiting room) modes, plus direct access for internal staff and admission by session code for support.
Per-queue session extensions and automatic removal of abandoned sessions.
CDN-distributed script that works under a strict-dynamic Content Security Policy in Next.js, with per-request nonces.
Outcome
The service runs in production in front of Nota Carioca's tax guide issuance. In one operating snapshot, 515 people were queued and 422 of 1,000 slots were in use, with the origin application stable.