Never Look Back - Performance, Scalability, and Peace of Mind
Chapter 6: Performance, Scalability, and Peace of Mind
This brings us back to the foundation: the BEAM. All these amazing features—LiveView, the concurrency—are possible because of the underlying runtime.
-
Massive Concurrency is the Default
Every user connected to a LiveView has their own process on the server. This means you can have tens of thousands, or even hundreds of thousands, of simultaneous users connected to a single server, and the system barely flinches. Each process has its own state, completely isolated from the others. A crash in one user’s LiveView process has zero impact on any other user.
This is the “fault tolerance” that Erlang is famous for. The philosophy is not to write defensive code to prevent crashes. The philosophy is “let it crash.”
-
Supervisors: The Safety Net
In an Elixir/Phoenix application, your processes are organized into a supervision tree. A supervisor’s only job is to watch its child processes. If a child process dies for any reason—an unhandled exception, a bug, a database connection dropping—the supervisor will, according to a strategy you define, restart it.
This creates an incredibly resilient system. A transient error might kill a single user’s LiveView process, but the supervisor will instantly restart it in a known, clean state. The user might see a flicker on their screen, but the application as a whole remains healthy. This gives you a level of operational peace of mind that is hard to describe until you’ve experienced it. You sleep better at night.
Read prev: The Real-Time Revolution with LiveView | Read next: Why I Haven’t Looked Back