4 ms·
Can a LiveView process migrate to a different machine/VM? Liveview makes no assumptions about the client connection or even stickiness of client to nodes in a
by throwawaymaths 3y ago
Can a LiveView process migrate to a different machine/VM?
Liveview makes no assumptions about the client connection or even stickiness of client to nodes in a cluster. If you store critical data in the liveview you could be in for some trouble. Always store important stuff into a recoverable, network aware datastore. The nice thing is that liveview is designed to be tolerant to client or client connection failures, you should design to be able to repopulate state sanely in the on_mount call.
While this sounds bad, think of it as isolating the client connection failure domain from the data failure domain, so you should organize your code in those domains respectively
If you want some sort of ephermal network state that lives on one node and not the database only (e.g. a game), the liveview should connect into that. If you want to store that in a genserver, a strategy like this is doable:
https://youtu.be/nLApFANtkHs https://youtu.be/nLApFANtkHs