Setting up nginx + multiple NiceGUI instances #3038
Replies: 3 comments 5 replies
-
You are right. It should be possible to serve several instances of the same NiceGUI app if you use a reverse proxy (load balancer) which supports session affinity. The open feature request #1539 is more about Gunicorn/Uvicorn which do not have this capability. Specifically, it should be fairly simple to set something up with |
Beta Was this translation helpful? Give feedback.
-
I'll try to understand how it should work because we're currently talking not about multiple servers, rather about multiple worker processes on the same server, right? |
Beta Was this translation helpful? Give feedback.
-
It seems that currently nicegui prevents you from running with multiple workers on a single machine: https://github.com/zauberzeug/nicegui/blob/main/nicegui/ui_run.py#L157 Even though if you remove this and make a small adjustment to https://github.com/zauberzeug/nicegui/blob/main/nicegui/ui_run.py#L186 Are there implications of doing this beyond global state loss / non session affinity balancer in front? Would it be possible to change that |
Beta Was this translation helpful? Give feedback.
-
I'm setting up a server to run the NiceGUI application on. So far so good: I installed nginx and set it up to proxy the requests to NiceGUI app (didn't use Docker container for NiceGUI - maybe in the future). Seems to work.
There's a note at https://nicegui.io/documentation/section_configuration_deployment#server_hosting, specifically:
If I understand correctly, NiceGUI runs with one worker by default (https://github.com/zauberzeug/nicegui/blob/main/examples/fastapi/start.sh). Does that note imply that it's possible to run multiple worker processes for NiceGUI app? If so, how do we make sure that the websocket connection maps to the same worker process that served the page to the client?
Beta Was this translation helpful? Give feedback.
All reactions