2 ms·
If you can't get Elixir to work well in k8s, you're simply doing it wrong. Yeah you can build a lot of what k8s offers on the BEAM on a bare server but you don'
by ch4s3 1y ago
If you can't get Elixir to work well in k8s, you're simply doing it wrong. Yeah you can build a lot of what k8s offers on the BEAM on a bare server but you don't have to at all. Elixir offers modern telemetry that works really well with pretty much any monitoring tool, and give you a lot of introspection into the internals of the VM if you need it. "Let it fail" works just fine in k8s, you can run a supervision tree in a container and have it manage process restarts internally just fine, its just an added layer of fault tolerance. Sure, you can't easily have long running stateful processes if you're doing a lot of blue-green deployments, but you probably don't need to do that most of the time.
If you don't know Elixir and the BEAM well, of course you're going to have a bad time. That's true of any language.
- benmmurphy 1y agophoenix live view is effectively built around the assumption that the server process never dies and never restarts. its a very dubious model for a production deployment. > what happens when the server restarts / connection is lost / server dies? > you lose all of the current client state but you can work around this by persisting all the client state somewhere. > oh, so why am i using live view again?
- ch4s3 1y ago> phoenix live view is effectively built around the assumption that the server process never dies and never restarts. Not exactly, it's built to hold state in memory by default but doesn't assume how you want to handle deploys or server restarts. There's a built in restore mechanism for forms and it's trivial to shuffle state off to either the client/redis/your db[1]. You'd have the same problem if you were storing all your state in memory for any web application regardless of your library choice. Or you conversely have the problem that refreshing the page trashes client state. So there are two thinks here, you don't have to use live_view to use elixir or phoenix, and if you do you just need to actually think about how you're solving problems. The state can get trashed anywhere for any number of reasons. Tossing on the client and forgetting about it just moves the problem. [1] https://hexdocs.pm/phoenix_live_view/deployments.html https://hexdocs.pm/phoenix_live_view/deployments.html
- benmmurphy 1y agothe way live-view is sold is some kind of alternative to writing javascript. if you have a very rich client side application then you can easily end up with a bunch of state which would be in the clients memory but now is in the servers memory. but if its in the servers memory the data ends up being much more fragile because any failure of the client or the server means the live view state is lost. whereas if the data was just in client memory then it would only be lost if there is a problem in the browser. ideally people would write applications that are tolerant to both faults. but i think in practice live-view practitioners just ignore the problem and then you are left in a worse situation. i realize there is still a dataloss problem when there is state on the client but there is a lot of simple stuff that causes problems if you are effectively reloading the page if the server disappears due to a redeploy or a crash. for example i'm reading an email in my message client. i've scrolled half-way down the email. but now the server crashes i reconnect to live view and my scroll position when reading the email is reset. when i look at live view i feel like its written by people that have never deployed something in production. of course this is not really true but i feel like it would be better if live-view people were more honest about the tradeoffs. its a very complicated situation and having some bad outcomes might be worth the increase in developer productivity but i feel like live-view people just ignore the bad outcomes. also, take a cloud deployment. websockets seem to be an inherent problem in cloud deployments especially AWS. as far as i know AWS does not expose some event to a instance that is part of a load balancer that it is about to die. ideally if you have a websocket instance with a client and you realize you are scheduled to be reaped you would message the client that it needs to reconnect. then the client would reconnect to a server that would not be reaped and everything would be dandy. but AWS doesn't seem to have this functionality (or its not easy to implement!) but more importantly live view does not expose any kind of hooks so you can have 'safe' server redeployment out of the box.
- ch4s3 1y agoI'm not sure who from the core group of developers is overselling it in the way you're claiming. Yeah, I wouldn't try to build figma or gmail with liveview, but I'd be fine building an app for a bank for example. Tools exist in a mesh of other tools and problem spaces where they may or may not be appropriate.
- benzible 1y agoThis isn't true. LiveView has buit-in form recovery: https://hexdocs.pm/phoenix_live_view/form-bindings.html#recovery-following-crashes-or-disconnects https://hexdocs.pm/phoenix_live_view/form-bindings.html#reco...
- benmmurphy 1y agoit really depends on what you are doing. if you have a complex application then the automatic recovery might not be enough for a fault free user experience. i feel like live view is sold as some kind of magic where the developer does not have to write javascript and you can just implement the server side purely in elixir as you would javascript without writing to a database, or some session storage. but if you do this then you are in a worse situation than javascript when it comes to network faults, or server processes restarting.