Repository navigation
Built a small library to limit active concurrent streams (SSE / LLM tokens) in FastAPI #16506
agustin18
started this conversation in
Show and tell
Replies: 2 comments 2 replies
|
Quick update for anyone dealing with long-lived streaming endpoints: Following feedback and the feature in Python Weekly (#767), we've added a few production-focused updates:
Feedback on the Redis Sentinel failover handling or OpenTelemetry metric tags is very welcome! |
0 replies
|
Small update: v0.6.4 is out, with a local browser demo that runs with docker compose up --build demo at http://localhost:8080. It shows two SSE panels sharing one session cookie. Tab B is rejected with 429 by the per-session lease, and the slot is released when Tab A finishes or disconnects. The per-IP guard is set to 2 so the two-tab demo can reach the session limit. No hosted service or API keys required. Feedback welcome. |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
Sharing a small library I built to solve an issue we had in production with streaming endpoints.
Standard rate limiters (like SlowAPI or token bucket middlewares) count requests per minute. But for LLM chat completions or SSE streams, a connection stays open for 30-60 seconds. A single user could open 5 or 10 parallel tabs and tie up worker sockets or run up API costs, while the rate limiter only saw 5 requests and allowed them all.
I built
fastapi-stream-leaseto limit active open connections right now rather than requests over time:https://github.com/agustin18/fastapi-stream-lease
How it works:
Just released v0.6.0 with 1-line exception handling (
manager.register_exception_handlers(app)).Feedback or critiques are very welcome!
All reactions