Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Websockets in python Quart with multiple workers?

Websockets in python Quart with multiple workers?

Is there a solution to broadcast a message when my app is launched across multiple workers - for example using hypercorn?

I'm currently launching my app like this:

$ hypercorn -b 127.0.0.1:8000 -w 4 wsgi:app

But the documented solution is to keep the connected clients in memory, with no way to broadcast to others that subscribed to the same event.

Any ideas? I was thinking to use Redis to achieve this, but I would like a simpler solution.

like image 547
go-pera Avatar asked Feb 04 '26 19:02

go-pera


1 Answers

I don't think there is a simpler solution than Redis (or similar third party tool) for this.

It is possible to run Hypercorn with memory shared across the workers, but it isn't simple to setup. Start here if you want to try this. At some point though you may have workers across multiple machines, in which case shared memory no longer works.

like image 91
pgjones Avatar answered Feb 07 '26 19:02

pgjones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!