This repository is a proof-of-concept (PoC) demonstrating a multi-worker approach spawned from a discussion at zauberzeug/nicegui#4483: zauberzeug/nicegui#4483
Important: this repository is experimental and intended only for exploration and discussion. It is NOT production-ready.
Why this exists
- To explore how multiple NiceGUI worker processes might be coordinated for higher throughput or fault tolerance.
- To capture ideas and prototype approaches that came out of the linked GitHub discussion.
Production recommendation For production deployments you should not rely on this PoC as-is. Instead, use a battle-tested reverse proxy / load balancer and session-affinity strategy such as:
- Traefik
- Nginx
- HAProxy
- Cloud load balancers that support sticky sessions / session affinity
Why sticky sessions (or a shared session store) matters:
- NiceGUI (and many web frameworks that use WebSockets or long-lived connections) commonly require session affinity so a user stays connected to the same backend worker for the duration of a session.
- If you cannot use sticky sessions, you must implement shared session/state storage (e.g., Redis, database) and ensure WebSocket connections are proxied correctly between clients and backend workers.
Recommendations for production
- Use a reverse proxy that supports WebSocket proxying and sticky sessions (Traefik and Nginx both support this when configured correctly).
- Terminate TLS at the proxy and enforce secure headers.
- Configure health checks and automatic retries.
- Use a shared session store (Redis, memcached, database) if you need horizontal scaling without sticky sessions, and ensure your application is written to use that shared state.
- Monitor and test failover behavior (what happens to active WebSocket connections if a worker dies).
- Load-test under realistic conditions before going live.
Limitations of this repository
- Experimental code and configuration only — likely missing robust error handling, retries, security hardening, observability, and deployment automation.
- Not supported for production-level SLAs.
Contributing and discussion
- If you want to continue exploring these ideas, please join the conversation at the original issue: zauberzeug/nicegui#4483
- Feel free to open issues or PRs against this repository with concrete, tested improvements that make the approach safer and more production-ready.
License
- MIT License