VulCode

Elixir: what we build with it and why

We pick Elixir on the Erlang virtual machine for processes that must survive a neighbour's failure: request routers, streaming connections and caches.

All technologies

When Elixir, and when something else

A technology has to fit the place the code will run and the team that will take it over. The final choice is made in the quote, together with you.

We pick Elixir

A command router on a node

The Flaem router on every node holds the command stream from the core, the job queue and the reports. A slow Proxmox call runs in a separate task, so it does not deafen the rest of the node.

Recovering from failure

An OTP supervisor restarts a process that crashed while the rest of the system keeps running. A closed stream to the core ends in a reconnect, not in a service failure.

A report on what really runs

When the core asks, the node lists the machines that exist in Proxmox and the game servers it hosts. An error while gathering ends in an error report, not in a stopped command stream.

Local node state

The node keeps its servers, assigned addresses, tunnels and SFTP credentials in SQLite through Ecto. A process restart does not lose what the node knows about itself.

A Redis-compatible cache

excache speaks the RESP protocol, so ordinary Redis clients connect to it. The keys are split between supervised processes, and each process handles its own keys in turn, with no locks.

Every connection in its own process

Erlang VM processes are light, so in excache every client connection gets its own. A stuck or dropped client does not block the others.

This is how we write it in our services

We pick something else

Interfaces and sites

The Flaem panel is in React and TypeScript, while Elixir works on the nodes, where there is no screen at all. An interface in TypeScript is easier to hand to the next team.

Heavy computation

The Erlang virtual machine is built for input and output, not for number crunching. We write numeric computation and cryptography in Rust.

An agent in a client's machine

An Elixir release carries its own ERTS runtime. An agent inside a client's VPS should be one small binary, so we write it in Go.

A billing core

Elixir checks types mostly at run time, so a wrong shape of data shows up only when the code runs. Billing and KSeF in the Flaem core are in Rust, where the compiler checks them.

A service for a team without Erlang

There are fewer Elixir developers than Go or TypeScript ones. When the client's team will take the service over and supervision is not central, we pick Go.

Scripts and automation

A one-off script or a bot needs no supervisors and no releases. Python is on every Linux box and gets it done sooner.

Elixir compared, point by point

Each need on a row of its own, with what each of the two columns gives you on it side by side.

ServiceElixirGo

Thousands of connections and supervision

Built into OTP
Written by hand

A single binary

A release with its own ERTS
Yes

Developer availability

Lower
Higher

One part failing

The supervisor restarts just that part
An unhandled panic ends the whole program

A hanging external call

A separate process, the rest keeps answering
A separate goroutine with a timeout

Types

Checked mostly at run time
Static, checked at compile time

Heavy computation

A weak spot of the Erlang VM
Faster machine code

Elixir in all our code

How many lines we have written in Elixir, and what part of everything we have written that is. We count the lines added in the commits of our repositories, language by language.

91,810
lines written in Elixir
1.7%
of all the lines we have written
2
repositories with Elixir code
9th
place among 26 languages

The libraries these projects stand on

From the dependency files of our repositories. With each, one sentence on what we use it for.

Installing an app on a VPS in the Flaem panel: the app catalogue and the install progress
Service status in the Flaem phone app: component availability and planned work
  • grpc and protobuf

    The command stream from the core.

  • Bandit and Plug

    The node's local API.

  • Ecto and SQLite

    Local node state.

  • Joken

    Access tokens.

Other technologies, and where their code runs

Each has its own page with projects on real screens and a comparison with the alternatives.

Websites and web apps

What you see in a browser, and its back end.

Mobile apps

Native Android and iOS clients.

Desktop apps

Programs for Windows, macOS and Linux without a browser inside.

Back end and infrastructure

Cores, server agents and real-time services.

Bots and automation

Discord, scripts and monitoring.

Questions about Elixir

Answers about Elixir, our projects and the numbers on this page.

A project in Elixir?

Describe what you want to build. We reply within an hour and tell you plainly whether this technology is a good choice.