More Programming

Elixir interview questions

Elixir interviews test whether you think in processes and data transformation rather than objects and shared state. Expect pattern matching and immutability early, then OTP: GenServer, supervision trees, and how you design a system that is allowed to crash. Senior rounds add BEAM internals, distribution, and Phoenix.

10 questions (2 easy · 5 medium · 3 hard), each with what a strong answer covers and where people lose the point. Free to read, no account.

On this page (10 questions)

1.What does the = operator do in Elixir, and how do you use pattern matching in function heads?

Warm-up

What a strong answer covers

  • = is the match operator, not assignment. It asserts that the right side fits the shape on the left and binds any variables on the left; if it does not fit, it raises a MatchError.
  • Multiple function clauses with different patterns replace most if/else branching. The first clause that matches runs, so order matters and the catch-all goes last.
  • Guards (when is_integer(x) and x > 0) add conditions a pattern alone cannot express.
  • A strong answer shows a real use, such as matching {:ok, value} and {:error, reason} from a function that can fail.

Where people lose the point

  • Calling = assignment and missing that a failed match raises.
  • Forgetting the pin operator (^) when matching against an existing value instead of rebinding it.
Link to this question

2.Data in Elixir is immutable. What does that mean in practice, and why does it matter?

Warm-up

What a strong answer covers

  • A value never changes after it is created. Functions return new values; a variable can be rebound to a new value, but the old value is untouched.
  • Because nothing is shared and mutated, processes can run concurrently without locks, and a function's behaviour depends only on its inputs.
  • Persistent data structures share unchanged parts, so updating a large map does not copy all of it.
  • State that has to change over time lives in a process (a GenServer, for example), which holds the current value and replaces it on each message.

Where people lose the point

  • Saying rebinding a variable mutates the data.
  • Assuming immutability means every update copies the whole structure.
Link to this question

3.How are Elixir processes different from operating system threads?

Core

What a strong answer covers

  • They are lightweight processes managed by the BEAM virtual machine, not the OS. Creating one is cheap, so systems routinely run very large numbers of them.
  • Each process has its own heap and mailbox and shares no memory with others. They communicate only by sending messages, which are copied.
  • The BEAM scheduler runs one scheduler per CPU core and preempts processes after a budget of work, so one busy process cannot starve the rest.
  • Garbage collection is per process, so there is no global stop-the-world pause.

Where people lose the point

  • Treating processes like threads that share memory.
  • Ignoring that large messages are copied between process heaps (large binaries are the exception, they are reference-counted).
Link to this question

4.Walk me through a GenServer. When would you use call versus cast?

Core

What a strong answer covers

  • A GenServer is a process that holds state and handles messages through callbacks: init/1 sets the starting state, handle_call/3 answers synchronous requests, handle_cast/2 handles asynchronous ones, and handle_info/2 handles any other message.
  • call waits for a reply and has a timeout (5 seconds by default), so the caller gets back-pressure and knows the work happened.
  • cast returns immediately with no confirmation. It is fine for fire-and-forget work, but nothing slows a fast sender down, so the mailbox can grow without bound.
  • Every request is handled one at a time by that single process, so a popular GenServer can become a bottleneck.

Where people lose the point

  • Defaulting to cast everywhere and losing back-pressure.
  • Putting slow work (HTTP calls, heavy computation) inside handle_call and blocking every other caller.
Link to this question

5.What is a supervision tree, and how do you choose a restart strategy?

Core

What a strong answer covers

  • A supervisor starts child processes and restarts them when they crash. Supervisors can supervise other supervisors, which forms a tree.
  • :one_for_one restarts only the child that died. :one_for_all restarts every child, for processes that cannot work without each other. :rest_for_one restarts the failed child and those started after it, for ordered dependencies.
  • max_restarts and max_seconds stop a crash loop: if children die too often, the supervisor itself exits and its parent decides what to do.
  • Child restart values (:permanent, :transient, :temporary) say whether a child should come back at all.

Where people lose the point

  • Picking :one_for_all by default and restarting healthy processes for no reason.
  • Not explaining what happens to the state of a process when it is restarted (it starts fresh from init).
Link to this question

6.What does "let it crash" mean, and when is it the wrong approach?

Core

What a strong answer covers

  • Instead of defensive code for every unexpected state, a process fails fast and its supervisor restarts it in a known good state.
  • It keeps the happy path simple and isolates failure: one crashed process does not corrupt others, because they share no memory.
  • It still means handling expected errors. Invalid user input or a missing record should return {:error, reason}, not crash.
  • It is the wrong fit when a restart loses state that cannot be rebuilt, or when the failure is permanent and restarting only produces a crash loop.

Where people lose the point

  • Using it as a reason to skip error handling altogether.
  • Not mentioning that supervisors and restart limits are what make it safe.
Link to this question

7.When would you use ETS instead of keeping state in a GenServer?

Hard

What a strong answer covers

  • ETS is an in-memory key-value table owned by a process. Many processes can read it directly, without sending a message to the owner.
  • It suits read-heavy shared data such as caches or lookup tables, where routing every read through one GenServer would make that process a bottleneck.
  • Options like read_concurrency and write_concurrency tune it for the access pattern. Data is copied in and out of the table.
  • The table disappears when its owner dies, so ownership and recovery need a plan, and ETS gives no transactions across multiple keys.

Where people lose the point

  • Reaching for ETS before measuring that the GenServer is actually the bottleneck.
  • Forgetting that the table dies with its owning process.
Link to this question

8.How would you run several independent HTTP requests concurrently and collect the results?

Core

What a strong answer covers

  • Task.async_stream over the list, with max_concurrency to cap how many run at once and a timeout for slow requests.
  • Or Task.async for each request followed by Task.await_many, when the list is small and fixed.
  • Under a Task.Supervisor, use async_nolink if one failure should not crash the caller.
  • A strong answer covers what happens when one request times out or fails, and how the results are matched back to the inputs.

Where people lose the point

  • Spawning an unbounded number of tasks against an external API.
  • Not handling timeouts, so one slow request holds up everything.
Link to this question

9.A GenServer in production is getting slower and using more memory. How do you investigate?

Hard

What a strong answer covers

  • Check the message queue length with Process.info(pid, :message_queue_len) or a tool like :observer. A growing queue means messages arrive faster than they are handled.
  • Look for slow work inside callbacks, casts with no back-pressure, or messages the process never matches, which sit in the mailbox forever.
  • Fixes include moving slow work into tasks, switching hot paths to call for back-pressure, splitting state across several processes, or moving reads to ETS.
  • Add telemetry or metrics so the queue length is visible before it becomes an incident.

Where people lose the point

  • Restarting the process and calling it fixed.
  • Not checking for unmatched messages accumulating in the mailbox.
Link to this question

10.How does Phoenix LiveView work, and what are its trade-offs?

Hard

What a strong answer covers

  • Each connected user gets a server-side process that holds the page state. Events go over a WebSocket, the server updates the state and re-renders, and only the changed parts are sent to the browser.
  • It lets a team build interactive pages without a separate JavaScript front end and its API layer.
  • Trade-offs: every interaction needs a round trip to the server, so latency matters, and there is a process and some memory per connected user.
  • Purely client-side interactions, such as toggling a menu, are better handled with JS hooks or small client-side commands.

Where people lose the point

  • Describing it as server-side rendering with page reloads.
  • Ignoring connection loss and what state survives a reconnect.
Link to this question
No account needed

Answer one real Elixir question now

A question a Elixir panel actually asks, answered out loud, scored on what you said and how you said it. Under two minutes, and nothing to sign up for.

“What does the = operator do in Elixir, and how do you use pattern matching in function heads?”

We never store the audio. Your answer is deleted within 24 hours unless you save the result.

How Elixir answers get judged

The weights a Elixir interviewer is holding, whether or not they say so out loud. Round Zero scores your practice answers against exactly these, and quotes your own words back as the evidence for each.

Language fundamentals

30%

Uses pattern matching, immutability and the pipe operator naturally, and explains what the code does with data rather than what it does to it.

OTP and process design

35%

Chooses between plain processes, GenServer, Task and Agent for a reason, and designs supervision so failures are contained and recovered.

Trade-offs and production judgement

20%

Names the cost of a design: mailbox growth, a GenServer as a bottleneck, ETS versus process state, and what changes when the system runs on several nodes.

Communication

15%

Explains concepts in plain terms, uses a concrete example from real work, and says clearly when something is outside their experience.

Related More Programming skills

All skills →

Now say them out loud

You have read what strong Elixir answers contain. The next thing that moves the needle is producing one under time, out loud, and finding out where it falls apart.

  • ✓ These questions asked back, with follow-ups
  • ✓ Flashcards for the ones you keep missing
  • ✓ A scored mock that quotes your own answers

Browse every skill

Practising Elixir: common questions

What Elixir interview questions should I practice?
Start with the core areas Elixir interviewers probe: What does the = operator do in Elixir, and how do you use pattern matching in function heads; Data in Elixir is immutable. What does that mean in practice, and why does it matter; How are Elixir processes different from operating system threads. This page outlines strong answers and common mistakes, and the scored path drills each one with follow-ups.
Is the Elixir practice free?
Yes. The Elixir path runs free inside Round Zero: lessons, practice questions and flashcards. Drills are unlimited on every plan, free included. So is the full scorecard. Free also covers 30 voice minutes and unlimited typed mock interviews, no card.
How is this different from a Elixir question list?
A static list gives you questions with no feedback. Round Zero runs a live scored practice that probes your actual answers, rotates difficulty, and tells you exactly what to fix, grounded in a Elixir rubric.
How should I prepare for a Elixir interview?
Learn the concepts, drill the questions until answers come fast, then prove it in a scored mock. Round Zero sequences all three so you know you are ready, not just that you read about Elixir.
How is a Elixir answer scored?
Elixir answers are scored on language fundamentals, otp and process design, trade-offs and production judgement, communication, with evidence quoted from what you actually said, so feedback is specific instead of generic praise.