acrolink
Hi,
I am developing a chat-bot using Phoenix and LiveView. My question, as the application gets more users, I will have to scale it up by adding more machines (using Kubernetes, AWS Elastic Beanstalk, AWS ECS etc). Would Phoenix handle this out-of-the-box?
Basically, there will be a load balancer routing incoming requests to different machines in a cluster (all running the same Phoenix application). Would LiveView and Sockets behave normally? Or does LiveView assume a single server machine running?
How to do that while scaling up horizontally?
Thank you.
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Latest Phoenix Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LostKobrakai
There is no expectation that you run a single machine. But there is an expectation that you run
Phoenix.PubSubconnected across all nodes (through one of their available adapters) if you want to make use of cluster wide PubSub. LV doesn’t technically need that, but given you’re talking about chat you might be using PubSub for message delivery between LV processes.acrolink
Thanks. If the chat data (actually sent always to
Chat-GPT) i.e. the chain is stored inconn.assignsthen I thinkPhoenix.PubSubis not needed ?!Nicodemus
That is correct. If each LiveView is isolated, meaning it doesn’t communicate with any other process, nor save any data on the local machine, then you can scale horizontally infinitely. Every client will get a LV process started on an available node in the cluster, which will be “sticky” in that it has an open websocket. On every refresh it will start a new LV process on perhaps a different node. You don’t even need to use BEAM distribution if all you do is save data as needed with a central repository, such as a shared database. The only thing you might have issues with is to make sure your load balancer supports websockets, and long lived connections for long-polling for those clients that fall back.
LostKobrakai
If clients fall back to long polling you either need sticky sessions or pubsub needs to work for LV to move state between nodes when the client eventually is routed to a different node on a new long poll request.
acrolink
Same applies and holds true if using
Channelswhere each channel is merely aserver <==> specific user communication?Nicodemus
Yup, LiveView is build on Phoenix Channels, so it behaves the same way with either.
Nicodemus
If the websocket or long poll request is closed, a new request will be made to the load balancer, which might choose a new web server, but then a whole new Channel/LiveView process is created from scratch, so sticky sessions or state migration shouldn’t be needed. (Unless you’re doing something really really weird, like saving state locally on the machine.)
In the case of LiveView, the
mount/3might actually be called once in normal http (unconnected) mode, then when the phoenix.js takes over and creates a new websocket/long poll connection, a whole new machine could be selected, and themount/3will run the second time on a different machine. As long as you aren’t storing anything locally between those two requests, it’s fine that they happen on completely different machines. Each request should be atomic.LostKobrakai
That’s not the case for long polling. With long polling you get a request per each message being sent on a channel (applies to LV as well given it uses channels). So it’s not one request/connection per livecycle of a channel process, but many. Hence you either need clustering to be able to connect to the process across the whole cluster or sticky sessions to not be routed to a different node.