Rio Queue
A virtual waiting room that absorbs traffic spikes on Nota Carioca and the SuperApp.
My role
I built and maintain it. 167 of the 224 commits are mine.
- 75%
- of the commits
- 1,000
- concurrent sessions on the tax guide queue
- 2
- protected systems, one of them legacy ASP.NET
Problem
Around tax deadlines and campaigns, traffic to Nota Carioca and the SuperApp jumps all at once and the backends fall over. Nota Carioca is legacy ASP.NET, so changing it is slow and expensive.
Solution
A self-hosted service in Python (FastAPI on Granian) backed by Valkey. The protected app adds one script tag with two attributes and nothing else. Anyone over the limit lands in a waiting room that streams their position and ETA over SSE. Admission follows a rate and a session cap, and a token is only valid on the queue that issued it.
Highlights
- Works on the same domain (a .dados.rio cookie for the SuperApp) and across domains (token handoff to Nota Carioca on .gov.br).
- Operated from a CLI with normal, pause (freezes the queue and keeps positions) and block (sends admitted users back to the room) modes, plus a bypass for internal staff and admission by session code for support.
- Per-queue session extensions ("I need 5 more minutes") and cleanup of ghost users.
- CDN-served script that works under a strict-dynamic CSP in Next.js with per-request nonces.
Result
Live in front of Nota Carioca's tax guide issuance. In one production snapshot, 515 people were waiting and 422 of 1,000 slots were in use, with the app still up.