Elixir
A functional programming language for building servers and other software that handles many tasks at once. It runs on BEAM, the same virtual machine as Erlang.
What it is
Elixir is a general-purpose language often used for web backends, chat systems, and background processing. Its runtime is a good fit when an application has many independent things to keep track of, such as open client connections. Elixir is the language; Phoenix is a web framework built with it.
How it works
Elixir compiles to bytecode that runs on BEAM, the Erlang virtual machine. Elixir code can call Erlang functions directly. The language favors transforming immutable values: updating a map gives you a new map without changing the original. Pattern matching lets you check the shape of a value and extract its parts in one step.
BEAM runs concurrent work in lightweight processes. Despite the name, these are not operating system processes. BEAM schedules many of them across scheduler threads. Each process has its own state and a mailbox. Instead of directly changing another process's state, a process sends it a message and lets the recipient decide what to do with it.
Example: send a request and wait for a reply
worker = spawn(fn ->
receive do
{:double, number, reply_to} ->
send(reply_to, {:result, number * 2})
end
end)
send(worker, {:double, 21, self()})
receive do
{:result, value} -> IO.puts(value)
after
1000 -> IO.puts("No reply")
end
The worker matches a tuple tagged :double, extracts the number, and sends the result back to the process identified by self() in the request. The request's send does not wait for the worker to run. The caller waits separately with receive, which prints 42 if the reply arrives within the one-second wait. This is a one-off worker; it exits after handling the message.
What production applications add
Applications usually rely on Erlang/OTP, a collection of components and conventions for structuring concurrent systems. A GenServer gives a long-lived process a standard way to keep state and handle requests one at a time. A supervisor starts child processes and can restart them according to a configured policy. Restarting a crashed worker does not recover its in-memory state or guarantee the interrupted work gets done. If a job must survive a crash, design for that explicitly, for example by storing it in a durable queue.
What comes up in interviews
Be ready to explain when to use GenServer.call versus GenServer.cast. A call waits for a reply, subject to a timeout; a cast returns without waiting for an acknowledgment from the server. A useful follow-up is what happens when producers use casts to send work faster than the server can handle it. The mailbox can grow, increasing memory use and queueing delay. Asynchronous messaging alone does not provide backpressure.