infra: agent backend cannot scale beyond a few concurrent users
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 30/100
- Type d'issue
- Fonctionnalité
- Clarté
- À clarifier
- Activité
- Calme
- Stack technique
- postgresql, python, redis, sqlite, typescript
Piste de recherche
Start with apps/agent/main.py, apps/agent/src/bounded_memory_saver.py, render.yaml, and apps/app/src/app/api/copilotkit/route.ts; reproduce the concurrency failure described in #63 before choosing a phase. The work is done only when the selected scaling, persistence, backpressure, or load-testing goals are implemented and verified at the stated target concurrency.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Problem
The agent backend runs on a single uvicorn worker process with an in-memory checkpointer on a 512MB Render starter instance. This is a global bottleneck — not per-user. All concurrent users share the same event loop, the same memory pool, and the same 200-thread checkpoint limit.
Currently the app breaks at ~3 concurrent connections (#63). At production scale (100-1000 users), it would be effectively unusable.
Architecture bottlenecks
1. Single worker process
- uvicorn runs with 1 worker (default) — all requests share one Python event loop
- Each GPT-5.4 visualization call takes 10-30s
- LangGraph has synchronous sections that block the event loop
- Throughput: ~2-6 visualization requests/minute
2. In-memory checkpointer (BoundedMemorySaver)
- All conversation state stored in RAM — shared global pool of 200 threads
- FIFO eviction: after 200 conversations across ALL users, oldest threads are silently deleted
- Users lose conversation context mid-session with no error
- Not thread-safe — designed for single-process async only
- On 512MB starter plan, memory pressure builds well before 200 threads
3. No backpressure or error surfacing
- When the backend is saturated, requests hang silently — no timeout, no error, no retry
- Frontend shows no indication that the agent is overloaded
- Health check at
/healthreturns 200 even when the event loop is blocked
Scale projections
| Concurrent users | Behavior |
|---|---|
| 1-5 | Works fine |
| 10-20 | Noticeable latency, requests queue |
| 50+ | Requests timeout, SSE connections drop |
| 100+ | Effectively down, health checks fail, Render restarts |
Proposed solution
Phase 1 — Quick wins (config changes only)
- Add
--workers 4to uvicorn startCommand inrender.yaml— multiplies throughput ~4x - Upgrade agent service from starter (512MB) to standard (1GB+) in
render.yaml - Enable rate limiting (
RATE_LIMIT_ENABLED=true) with reasonable limits (e.g. 20 req/min per IP)
Phase 2 — Persistent checkpointer
- Replace
BoundedMemorySaverwith PostgreSQL or SQLite async checkpointer - Conversation state survives restarts and doesn't consume RAM
- No more silent thread eviction — threads persist until explicitly cleaned up
- Render already supports managed Postgres — can add as a service in
render.yaml
Phase 3 — Error handling and backpressure
- Add frontend timeout — show error after ~30s of no response instead of hanging forever
- Add backend concurrency limit — return 503 "busy" when at capacity rather than queuing indefinitely
- Add connection health monitoring — detect dropped SSE connections and surface to user
- Reuse thread IDs per browser tab (
sessionStorage) to avoid creating unnecessary threads
Phase 4 — Horizontal scaling
- Use Gunicorn with uvicorn workers for proper process management
- Verify Render auto-scaling (1-3 instances) works correctly with persistent checkpointer
- Add Redis or Postgres for shared state across instances
- Load test at target concurrency (100+ users) to validate
Related issues
- #63 — Agent stops responding after multiple concurrent tabs (symptom of this)
- #58 — Quality regression (long-running visualization calls exacerbate the single-worker bottleneck)
- #62 — Planning step before visualization (adds an extra round-trip, making concurrency even more critical)
Key files
apps/agent/main.py— uvicorn config, BoundedMemorySaver(max_threads=200)apps/agent/src/bounded_memory_saver.py— FIFO eviction logicrender.yaml— Render service config (starter plan, no worker config)apps/app/src/app/api/copilotkit/route.ts— Frontend → agent connection
- Langage dominant
- TypeScript
- Étoiles
- 3.9k
- Forks
- 414
- Merge moyen
- 4 h
- PR mergées (30 j)
- 6
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de CopilotKit/OpenIntelligentUI
-
Script dedup key truncation may cause collisionsPeut-être pris @saschabuehrle l’a pris il y a 215 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
CopilotKit/OpenIntelligentUI#37 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
CopilotKit/OpenIntelligentUI#29 ·
Les mainteneurs répondent en général sous 1 jour
-
Self-host with Docker Compose and optional server-held keysPeut-être pris @kannan983 l’a pris il y a 15 jours. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 18/100
CopilotKit/OpenIntelligentUI#98 ·
Les mainteneurs répondent en général sous 1 jour
-
Support OpenAI-compatible gateways (OpenRouter) via vendor/model namesPeut-être pris @kannan983 l’a pris il y a 15 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 25/100
CopilotKit/OpenIntelligentUI#97 ·
Les mainteneurs répondent en général sous 1 jour
-
UIOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 8/100
CopilotKit/OpenIntelligentUI#96 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de CopilotKit/OpenIntelligentUI
Issues similaires
-
a10y a10y-audit ai-driven-qa claude
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
linagora/twake-directory-manager#219 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
type: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
Les mainteneurs répondent en général sous 1 jour
-
0️⃣ phase/new
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Pulse v7: buildPreferencesFromTelos() bypasses telosSectionOrFile(), renders empty on unified-TELOS installsPeut-être pris @zephyr91 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
danielmiessler/LifeOS#2393 ·
Les mainteneurs répondent en général sous 4 jours