4 ms·
Can someone make a comparison between this and the Elixir Phoenix 2m websocket conmections example. I want to sleep.
by cuddlecake 8y ago
Can someone make a comparison between this and the Elixir Phoenix 2m websocket conmections example.
I want to sleep.
- brightball 8y agoI remember seeing a talk on the 2m websocket Elixir example and one of the keys to it was that the sockets were actually being used and processing messages intermittently during the test. Important thing to keep in mind vs simply opening. The other thing I'd be interested to see Elixir demonstrate would be doing a hot deployment to avoid triggering all 2m connections to try reconnect at the same time. The other important note with the Phoenix example was that they were starting 3 processes for each socket (to supervisor, handle failures/reconnects) if I remember correctly.
- e-r-a-n 8y agoIf you look at the server implementation, the client messages are also read and parsed, but are not printed to stdout for demonstration purposes (otherwise it hard to keep track) You can uncomment that printf instruction and see that it still performs nearly the same way
- zensavona 8y agoWith Elixir/OTP there would be no disconnection/reconnection. The way hot code push works with OTP is that each "channel" (OTP "process"/websocket connection) has a GenServer, which is basically a state machine, and when there is a new version of the function available in the VM, the current state is passed into a function (supplied by you) to mutate it into a shape compatible with your new change, then next time the data is passed around the loop to the state management function, it goes to the new one instead. Because the state data is stored quite separately to the actual functions who mutate it, there is no need to disconnect or do any mass purging of memory when there's a hot code deployment.
- Casperin 8y agoI recorded an example of what that looks like about a year ago https://www.youtube.com/watch?v=CZWMc2cXUAw https://www.youtube.com/watch?v=CZWMc2cXUAw -- I no longer work in Elixir, but this magic still kind of blows my mind.
- ponyous 8y agoI did hot code upgrades on a server with WS connections active and I don't remember connections being broken.
- mcintyre1994 8y agoDo you have a link to that Elixir one by any chance?
- brad0 8y agohttps://phoenixframework.org/blog/the-road-to-2-million-websocket-connections https://phoenixframework.org/blog/the-road-to-2-million-webs...
- deleted 8y ago[deleted]