Articles

The Solo Stack: Elixir and Phoenix When the Site Has to Do Things

When a project outgrows the static web and there is still only one of me: Elixir, Phoenix and the BEAM doing the heavy lifting.

Duration18 minute read
Published
ReadingElixir in Action by Saša Jurić (2019)
TopicsElixir, Distributed systems, Self-hosting, Developer tooling, Entrepreneurship
In short

The static blueprint stops at five signs: accounts, many writers, real time, heavy or secret work, and data that does not fit a build. Each of them maps to something Phoenix or the BEAM already ships. What a typical stack splits into a web tier, a cache, a broker, a websocket service and a cron box, the BEAM runs as one release next to one database, which is what makes it a stack one person can hold in their head. Phoenix 1.8 generates authentication with magic links and scopes into your own code, LiveView and Presence handle live state without a JavaScript app, and Oban keeps background jobs in the database you already have. Three of my six Phoenix apps run on SQLite and three ship Rust NIFs for the CPU-heavy parts, and broodwar.live shows the honest middle: a static Zola site in front of a small Phoenix JSON API. It hurts in known places: a small hiring pool, types still arriving, CPU-bound work that belongs in Rust, generated auth code that never updates itself, and Archipelag.io still needing NATS to talk to its Rust workers.

A Blueprint for the Static Web ends where most of my projects eventually go: the moment a site has to do things. Its last practical section lists the signs that you need a backend: people have accounts, many people write, things happen in real time between users, the work is heavy or long or secret, or the data no longer fits in a build. When two or more are true, I build one.

The problem is that I am one person. I have a day job, more than ten projects, and evenings that are already spoken for. A backend that needs a web tier, a Redis, a job broker, a websocket service and a cron box is not a backend I can run by night. So for anything that has to do things, live, for many people, I reach for the same stack almost every time: Elixir, Phoenix, and the BEAM underneath them.

I made the short case for Elixir in Almost Irrelevant: processes, supervision trees, Oban, the types that are arriving. This piece is the long one, about everything that article skipped. Accounts, live views, presence, deploys, operations, and the places where it hurts.

Five signs, five answers

The Blueprint’s five signs are a good spine, because each of them maps to something Phoenix or the BEAM already ships. That mapping is most of my argument.

The signWhat answers itWhat I do not have to run
People have accounts and their own datamix phx.gen.auth: magic links, scopes, sudo mode, generated into my codean identity service
Many people writeEcto and a database (Postgres or SQLite), with changesets and scopesan ORM fight
Things happen in real time between usersLiveView, Phoenix.PubSub, Presence, Channelsa separate websocket service and a pub/sub broker
The work is heavy, long, or secretOban jobs in the same database; Rust NIFs for CPU worka job broker and a worker fleet
The data does not fit in a buildPhoenix as an API, with the static site still in fronta second front end

The right-hand column is the point. Every row is a system I would otherwise operate, patch, monitor and pay for. On the BEAM most of them are libraries inside one release.

One runtime instead of five

David Heinemeier Hansson called Rails “The One Person Framework” in 2021: “A toolkit so powerful that it allows a single individual to create modern applications upon which they might build a competitive business.” I agree with him about Rails, and about Laravel and Django too. They get one person to a solid application with a database, forms and accounts very quickly.

My claim is narrower. Rails gets one person to a CRUD application. The BEAM gets one person to the parts that usually need a second system: thousands of open connections, live state shared between users, a cluster, a pub/sub bus, jobs that survive restarts. Those are the parts where a small stack quietly turns into a large one.

  a typical web stack                     the solo stack
  ┌──────────────────────────┐            ┌────────────────────────────────┐
  │ web tier (n instances)   │            │ one release (mix release)      │
  ├──────────────────────────┤            │  ├─ Endpoint: HTTP, websockets │
  │ websocket service        │            │  ├─ LiveView: per-user state   │
  ├──────────────────────────┤            │  ├─ PubSub + Presence          │
  │ Redis: pub/sub, cache    │            │  ├─ Oban: queues, cron, retry  │
  ├──────────────────────────┤            │  └─ NIFs: Rust for hot loops   │
  │ job broker + workers     │            └───────────────┬────────────────┘
  ├──────────────────────────┤                            │
  │ cron box                 │                            ▼
  ├──────────────────────────┤                  Postgres or SQLite
  │ database                 │
  └──────────────────────────┘
       six things to deploy                    two things to deploy

None of this is new. Joe Armstrong’s 2003 thesis describes a research program “started in 1981 to find better ways of programming Telecom applications”, and its premise is the one that matters to a solo developer: “We assume that such programs do contain errors, and investigate methods for building reliable systems despite such errors.” The slogans are in section 4.3: “Let some other process do the error recovery.” and “Let it crash.” When you are the only person on call, a runtime that expects failure and restarts the failed part without waking you is not a philosophy. It is a staffing plan.

If you want to understand the model properly, Saša Jurić’s Elixir in Action is still the book I recommend, and his talk The Soul of Erlang and Elixir shows it in forty minutes of live demos.

What Phoenix puts in the box

Accounts, generated into your code

Since Phoenix 1.8 (August 2025), mix phx.gen.auth “now uses magic links by default for login and registration”, and it introduces scopes, “a new first-class pattern in Phoenix, designed to make secure data access the default.” A scope is a struct that carries who is asking, and the generated code passes it into every query:

# lib/my_app/notebooks.ex, as the 1.8 generators shape it (illustrative)
def list_notebooks(%Scope{} = scope) do
  Repo.all_by(Notebook, user_id: scope.user.id)
end

def get_notebook!(%Scope{} = scope, id) do
  Repo.get_by!(Notebook, id: id, user_id: scope.user.id)
end

The forgotten WHERE user_id = ? is one of the oldest bugs on the web. Making the scope the first argument of every function turns it into something you have to remove on purpose.

The detail I value most: the code is generated into the app, where I can read and change it. The guide says so plainly: “you now have complete freedom to modify the authentication system”, and “it will not be updated after it’s been generated.” That is the right trade for one person who wants to understand every line between a login form and a session, and it is also a cost I come back to below.

Live state without a JavaScript app

LiveView reached 1.0 in December 2024, “six years after the first LiveView commit”, and Chris McCord’s stated goal was to build rich applications “without writing JavaScript.” In How We Got to LiveView he describes the idea in one line: the server can “model the entire user visit as a cheap bit of concurrency on the server.” Each visitor is a process holding their state; events come in over a websocket, and only the changed parts of the page go back out.

Add PubSub and Presence and a page becomes shared. Cyanea has a version of this for showing who else has a notebook open. Stripped down, the shape is:

# who is looking at this notebook, live (illustrative)
def mount(%{"id" => id}, _session, socket) do
  topic = "notebook:" <> id
  if connected?(socket) do
    Phoenix.PubSub.subscribe(MyApp.PubSub, topic)
    MyAppWeb.Presence.track(self(), topic, to_string(socket.assigns.current_scope.user.id), %{})
  end
  {:ok, assign(socket, topic: topic, viewers: MyAppWeb.Presence.list(topic))}
end

def handle_info(%Phoenix.Socket.Broadcast{event: "presence_diff"}, socket) do
  {:noreply, assign(socket, viewers: MyAppWeb.Presence.list(socket.assigns.topic))}
end

Two things happen under that code that would be separate systems elsewhere. Phoenix.PubSub by default “uses Distributed Elixir, directly exchanging notifications between servers”, so there is no Redis in the middle. And Presence sits on Phoenix.Tracker, which uses “a heartbeat protocol and CRDT to replicate presence information across a cluster in an eventually consistent, conflict-free manner. Under this design, there is no single source of truth or global process.” A conflict-free replicated data type, shipped in the box, so that a list of who is online survives a node going away.

A dashboard you did not build

LiveDashboard ships with every new app and shows telemetry, processes, ETS tables, and the operating system, live, in the browser. For one person it covers most of what I would otherwise wire into a metrics stack on day one. When a project grows up, the Zentinel control plane shows the next step: OpenTelemetry instrumentation for Phoenix and Ecto, exported like any other service.

Data, jobs, and the boring rest

Data. Ecto keeps queries composable and validation explicit, in changesets, and it leaves the database in plain view. The database does not have to be Postgres. Three of my six Phoenix apps run on SQLite, which for a single node on a single machine removes one more thing to operate.

Jobs. Oban stores jobs in Postgres, SQLite3 or MySQL, which means retries, uniqueness, cron and queues live in the database I already back up. Oban Web became open source in January 2025 under Apache 2.0, so the job dashboard is free too. Oban Pro costs $150 a month; none of my apps need it.

Releases. mix release “Assembles a self-contained release” that includes the runtime, so the server needs nothing installed. One myth to retire: the BEAM’s famous hot code upgrades are not something Elixir releases do for you. The docs say so: “The reason we don’t provide hot code upgrades is because they are very complicated to perform in practice.” What people actually do is a rolling or blue-green deploy.

Deploys. I wrote the long version of my own path in How AI Makes Bare Metal Viable Again: from Kubernetes, via Fly, to one Hetzner server and Vela, a single Rust binary that knows how to run a BEAM release with blue-green deploys. If you would rather not write a deployer, Fly’s clustering guide gets several nodes talking with dns_cluster and a shared cookie, and Kamal deploys any container to your own machines. Most solo apps do not need a cluster at all. One node, with its own supervision tree inside and a process supervisor outside, goes a long way.

What my own apps actually use

The stack is easier to judge in use than in a feature list. Six of my Phoenix apps, as their repositories show them:

AppFront endDatabaseJobsNative codeNotes
Archipelag.ioLiveView, ChannelsPostgresOban, five queuesnoneNATS carries jobs to the Rust host agents
broodwar.live APInone: JSON for a Zola siteSQLiteOban, with a cron pluginRust replay parserthe hybrid below
HumankindLiveView, PresencePostgres and pgvectorOban, eight queuesRust for audio, crypto, imagespasskeys, field encryption
CyaneaLiveView, PresenceSQLiteOban, seven queuesRust analysis corethe heaviest NIF user
Zentinel control planeLiveView, GraphQLPostgres or SQLiteObannoneOpenTelemetry, OIDC, SAML
DriftscapeLiveViewSQLitenonenoneearly

A few patterns stand out. Every one of them uses the Phoenix 1.8 defaults (Bandit, DNSCluster, Req, telemetry) and almost nothing exotic: no Broadway, no Ash, no Oban Pro. Half run on SQLite. Half ship Rust through Rustler, which is my answer to the BEAM’s weakest spot.

The honest middle: broodwar.live

The project I would show someone first is the one with the least Phoenix in it. broodwar.live is a static Zola site, built exactly as the Blueprint describes, and behind it sits api.broodwar.live: a small Phoenix JSON API with no LiveView at all. Oban polls tournament streams every three minutes and ingests pages from Liquipedia, a Rust NIF parses StarCraft replays, and the data lives in one SQLite file.

That is the answer I give when someone asks how much backend they need. Keep everything that can be static static. Put the parts that have to do things behind a small API on the BEAM. The two halves deploy separately, fail separately, and each stays small enough to understand.

Agents write Elixir better than you might expect

The usual objection to Elixir is the hiring pool, and it is real: in the Stack Overflow Developer Survey 2025, 2.7% of respondents used Elixir and 2.4% used Phoenix. For a company that is a cost. For one person working with agents, it matters less than it used to.

Phoenix itself has noticed. New apps from 1.8 on include an AGENTS.md whose guidelines “correct common mistakes LLMs make with syntax, idioms, and critical API usage.” Tidewave, from Dashbit, connects a coding agent to the running application, so it can read logs, run code and query the database instead of guessing. And on AutoCodeBench, a 2025 benchmark of 3,920 problems in twenty languages, Elixir was among the strongest languages for frontier models: Claude Opus 4 scored above 80% Pass@1 on it, higher than on any other language. The caveat matters: the Elixir problems were produced by translating Python ones, so the benchmark measures how well models write Elixir, not how hard Elixir problems are.

The plausible reasons are plain ones: the language is small, the idioms are strong, and pattern matching puts the intent on the page. As I wrote in Almost Irrelevant, I still review agent-written Elixir more carefully than agent-written Rust, for the reason that opens the next section.

Where it hurts

Types are still arriving. Elixir 1.20, released in June 2026, can “perform type inference and gradually type check every Elixir program, without introducing type annotations”. Typed structs and type signatures are next on the roadmap, and the November post on narrowing with reverse arrows shows the work moving fast, but until signatures land a good share of correctness lives in tests. If that is the deciding factor, Gleam runs on the same VM with a full type system, and my own Refrakt is a Phoenix-like framework for it.

CPU-bound work does not belong on the BEAM. The scheduler is built for many small tasks, not one long one. The erl_nif documentation expects a well-behaved native function to return “within 1 millisecond”, and anything longer has to run on dirty schedulers. Worse, a crash in a NIF “brings the emulator down too.” Rustler exists for exactly this: its stated goal is that a Rust NIF “should never be able to crash the BEAM.” Discord made the same move in 2019: its sorted member list became a Rust NIF whose worst case was 3.68 microseconds across sets of 5,000 to 1,000,000 items, after one of the pure Elixir attempts had taken 640 microseconds for a single insert into a list of 250,000. Three of my apps do this. It works, and it costs a Rust toolchain in every build.

Generated code does not update itself. The same property I praised in phx.gen.auth means a security fix in the generator does not reach an app generated last year. Someone has to read the generator’s changelog and port the fixes by hand, and with generated code that someone is you.

Not everything stays on the BEAM. Archipelag.io is the exception to my own pitch. Its coordinator is Phoenix, but the hosts that run jobs are Rust agents, and talking to non-BEAM nodes still needs a broker, so it runs NATS. The BEAM removes the infrastructure between BEAM nodes; between languages, you still need some.

LiveView holds state per visitor. Every connected user is a process with memory on the server, and every interaction is a round trip. McCord himself writes that “When LiveView is close to your users, interactions are immediate”, which is also the condition. On a flaky mobile connection far from the server, a page that renders in the browser can feel better. For most of my apps the trade is worth it; for a public site with heavy anonymous traffic it would not be.

Clustering is easy until it is not. On Fly it is a DNS query and a cookie. On bare metal it is cookies, an open distribution port, and the question of what happens when two nodes stop seeing each other. My answer, for one person, is to avoid it: run one node until the day you cannot, and that day comes later than you think.

What I would not build this way

  • Heavy computation. Cyanea compiles Rust into its release for a reason. If the core of the product is number crunching, the BEAM should be the coordinator, not the worker.
  • A company’s shared services. When many teams own the code, I want the language they can all read, which is Go, and a platform shape built for many teams. That is the subject of The Enterprise Stack, the companion to this piece.
  • Anything a static site can do. The Blueprint still comes first. The best backend is the one you did not need to build.

For everything else, the projects where people log in, see each other, and wait for work to finish, the BEAM is the closest thing I know to a team in a box. What it does is shrink the system until one person is enough to run it.

References

    Open the full search →