October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Elixir OTP vs. Plain Processes: When Should You Use a GenServer?

A GenServer is an Elixir process, not a separate execution primitive. Choose functions for stateless logic, plain processes for genuinely custom loops, and OTP behaviours when standard process protocols and supervised lifecycle help.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use ordinary functions for calculations and business logic that do not need a runtime process. Use a plain Elixir process when you deliberately need a custom message loop or a small, specialized lifecycle. Choose a GenServer or another OTP behaviour when a component needs persistent process state, a standard request protocol, system-message support, or a supervised lifecycle.

These are not different kinds of BEAM execution: a GenServer is an Elixir process with a conventional interface and lifecycle support. The useful question is not “OTP or processes?” but “What runtime behavior does this component actually need?”

Do I need a GenServer for this?

Usually not for logic that can be expressed as a direct function call. Elixir’s GenServer documentation cautions against using a GenServer merely to organize code: funneling unrelated operations through one server adds message handling and can serialize work behind a single mailbox. That is an architectural risk, not proof that GenServers are always slower; profile the real workload when throughput matters.

The documentation’s concise rule is: “If you don’t need a process, then you don’t need a process.” For a calculator, for example, add/2 and subtract/2 should ordinarily be functions, not requests routed through a GenServer. See the GenServer guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When should I use a GenServer?

Use a GenServer when the component has a meaningful runtime identity and benefits from the standard client-server process model. It is an ordinary Elixir process that can retain state and run code asynchronously; the behaviour provides callbacks and standard interfaces for synchronous calls and asynchronous casts.

  • State that lives between requests: a process can own mutable in-memory state and update it as messages arrive.
  • A defined request protocol: callers can use standard call and cast interactions rather than each module inventing its own conventions.
  • OTP lifecycle integration: a GenServer can be started as a child under a supervisor, making startup, shutdown, and recovery policy part of the application structure.
  • System-level process needs: GenServer supports system messages, including periodic messages and monitoring events, and can be registered under a name.

The behaviour also supplies tracing and error-reporting functionality and abstracts the receive loop. Keep domain logic in ordinary functions where that makes it reusable and independently testable; callbacks should coordinate the process protocol rather than become a home for all application logic. The GenServer reference documents the callbacks and supported interactions.

When should I use a plain Elixir process?

A plain process is a reasonable choice when you genuinely need a message loop but GenServer’s conventional call/cast protocol and lifecycle abstraction do not fit. For example, a specialized receive protocol or unusual lifecycle can justify handling messages directly. That flexibility comes with responsibility: you must design message handling, termination, monitoring, and failure behavior rather than assuming OTP has supplied them.

Processes communicate by sending messages. Links can propagate abnormal exits to linked processes that are not trapping exits, but a bare spawn is not a restart strategy. If the application depends on a process being restarted or on coordinated shutdown, specify that lifecycle intentionally, commonly through a supervisor. The Process reference describes process and link behavior.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a single concurrent computation rather than a long-lived stateful service, consider a task abstraction or a small plain process according to the required lifecycle. Make result collection, cancellation, and failure handling explicit; concurrency alone does not imply that a GenServer is needed.

When should I use OTP behaviours?

Use the OTP behaviour that matches the component’s protocol and lifecycle needs. GenServer is the familiar client-server option, but the broader decision is whether the component needs the standard interfaces and system integration that a behaviour provides. The goal is not to add OTP ceremony everywhere; it is to use common process machinery when it makes the runtime contract clearer and easier to manage.

A supervisor is itself a process. It manages child processes in a hierarchy called a supervision tree, which provides a structure for fault tolerance and for application startup and shutdown. A module using use GenServer supplies a child specification so it can be started beneath a supervisor. Supervision defines lifecycle and recovery around a process; it does not make that process a different execution primitive. See the Supervisor reference.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose by runtime requirement, not by code organization

Situation Starting point Reason
Calculation, validation, transformation, or domain logic Functions and modules No process identity or retained runtime state is required.
One isolated concurrent computation A task abstraction or a small plain process The work is concurrent, but may not need a long-lived stateful server. Choose based on lifecycle and make result and failure handling explicit.
Long-lived in-memory state with serialized updates GenServer or a more specific OTP behaviour The process owns state and handles a protocol through standard callbacks.
Named service, periodic work, system messages, monitoring, or supervised lifecycle GenServer or the behaviour matching the protocol OTP offers conventional process interfaces and integrates children with supervision.
Custom receive protocol or unusual lifecycle Consider a plain process if the custom behavior is a real requirement GenServer abstracts the receive loop and its system interactions; custom loops require deliberate lifecycle and failure handling.

This is a starting-point guide, not a performance ranking. A single GenServer can become a serialization point when unrelated requests share its mailbox, but there is no universal speed result for “plain process versus GenServer.” Measure the application’s actual workload if performance is decisive.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check version compatibility before relying on release details

As of October 4, 2026, the official Elixir documentation index lists v1.20.4 as stable and Erlang/OTP 27, 28, and 29 as supported for that Elixir release. This compatibility information is time-sensitive; check the index and the requirements of your own project before choosing an installation or upgrade target.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.