[Question] Multiple workers with Sanic
See original GitHub issueI have a Sanic app using python-socketio
.
The Websocket connection only works with app.run(workers=1)
; otherwise, Invalid session ...
is raised.
Although I uses the AsyncRedisManager
for the AsyncServer
, the app still doesn’t seem to use redis
to store the sessions:
app = Sanic(__name__)
mgr = socketio.AsyncRedisManager("redis://127.0.0.1:6379/0")
sio = socketio.AsyncServer(async_mode="sanic", cors_allowed_origins=[], client_manager=mgr)
sio.attach(app)
Is there a way for python-socketio
to support multiple workers on Sanic
?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Share a model object among multiple workers
I'm writing a websocket server in Sanic, which is to handle a frame sended from client, run an object-detection model and send the...
Read more >Multiple Sanic workers with Motor - Stack Overflow
Sanic is not multi-threaded. And, forking is only used to setup the workers. If you instantiate motor using one of the server life...
Read more >Deploying — Sanic 19.9.0 documentation
Sanic will automatically spin up multiple processes and route traffic between them. We recommend as many workers as you have available cores.
Read more >Route Triggered State Update Across Python Sanic Workers
Say you want to trigger an update across all Sanic workers simply by ... Note that the application has multiple (2) workers instantiated....
Read more >Rasa model loading twice (equal to number of Sanic workers)
Hi Rasa Team, I am trying to use RASA with 2 Sanic workers and ... I have a questions that is tensorflow or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@snguyenthanh Sanic does not do sticky session type load balancing when it runs multiple workers, so yes, you have to run multiple one worker Sanic apps, and put a proper load balancer that you can configure for sticky sessions.
I see. Thank you for the explanation.
I think I will just go with the multiple-1-worker-app approach.