r/elixir

Revenant - What if GenServer flushed its state into PostgreSQL?
▲ 12 r/elixir+1 crossposts

Revenant - What if GenServer flushed its state into PostgreSQL?

I've been using and actively fascinated by Oban over the last 4 years, and recently I wondered, why can't we make GenServers behave similarly to Oban jobs and:

  • Recover their state after a crash or termination
  • Terminate themselves when not used
  • Store a trace of their execution
  • And do all that without any additional dependencies, using the database we're already used to

I can think of a ton of cases where this might be useful in... Durable GenServers? LiveViews? Distributed GenServers that share state? Hot/Cold executions? Slow/Fast pools?

So I created a PoC library that does just that:

https://github.com/dimamik/revenant

defmodule Account do
  use Revenant, repo: MyApp.Repo

  def initial_state(_id), do: %{balance: 0}

  def handle_call({:deposit, amount}, _from, state) do
    {:reply, :ok, %{state | balance: state.balance + amount}}
  end

  def handle_call(:balance, _from, state) do
    {:reply, state.balance, state}
  end
end

Revenant.call({Account, "acct_42"}, {:deposit, 100})
#=> :ok  - the new state is committed to Postgres before you see this

Please let me know what you think of the concept!

u/Unusual_Shame_3839 — 7 hours ago
▲ 47 r/elixir

Introducing AetherS3: A self-hostable, distributed, S3-compatible object store that runs on the BEAM.

​Hi everyone,

​I’ve been working on AetherS3, a project focused on providing an S3-compatible storage interface built natively in Elixir.

​The goal is to leverage the BEAM’s concurrency model to handle high-performance binary throughput and zero-copy memory management, aiming for a robust, distributed storage solution. It’s currently in early development, but the core architecture for S3-compatible operations is taking shape.

​I’d appreciate any feedback on the design, particularly regarding the handling of high-concurrency I/O and the memory management approach. Feel free to check out the repo and let me know your thoughts.

github.com
u/wizenink — 13 hours ago
▲ 85 r/elixir+3 crossposts

How does Elixir 1.20's type system actually differ from what TypeScript or Dialyzer do - and does the distinction matter in practice?

New BEAM There, Done That with Annette Bieniusa (RPTU, Germany) and Guillaume Duboc (Dashbit, PhD from IRIF Paris) on the theoretical and practical story behind what's shipping in Elixir 1.20.

The episode covers the set-theoretic foundation, the gradual design, and the long history of failed attempts at typing Erlang since 1995. But the thing that stuck with me most was the framing of what the type system is and isn't trying to do:

The BEAM ran telecoms for 25 years without static types, with seconds of downtime per year. Supervision trees and let it crash handle an entirely different class of failures from what a type checker catches. The argument for types here isn't that the runtime is broken - it's that type errors are a separate cost (restarts, latency, overprovisioning) that supervision handles but doesn't eliminate. Even catching 5% of those at compile time instead has measurable infrastructure impact.

What got me thinking: the episode raises the false confidence risk - developers seeing types and writing fewer supervision trees, less defensive code, no recovery strategy. Has anyone here actually observed this shift in teams adopting typed languages? And do you think the BEAM community is more or less susceptible to it than others, given how explicitly OTP teaches you to expect failure?

https://youtu.be/X_CPDt3PeDE?si=yJTRAwlAaf7h2rlZ

u/rtrusca — 3 days ago
▲ 26 r/elixir

Atomic Bucket - fast single node rate limiter implementing Token Bucket algorithm

In case someone missed the forum post I'm providing a copy here.

I was tired of bugs in Hammer so I wrote efficient and fast rate limiting library. Token Bucket supports flexible bursts and IMO is fit to serve as the main rate limiting algorithm for most cases.

The goal of the library is to provide dependable solution that JustWorks™ with a focus on performance, correctness and ease of use. Bucket data is stored using :atomics module. Bucket references are stored in ETS and optionally cached as persistent terms.

Features

  • lock-free and race-free with compare-and-swap operations
  • BlazingFast™ performance, see provided benchmarks. Req/s go brrrrrr
  • monotonic timer for correct calculations
  • millisecond tick supporting wider range of parameters and preventing request starvation
  • automatic calculation of bucket parameters based on target rate and burst size (for fixed cost requests)
  • handy timeouts for retries
  • support for token "refunds" and variable cost requests
  • compile-time validation of arguments when possible

https://hex.pm/packages/atomic_bucket

u/a3kov — 2 days ago
▲ 26 r/elixir

Broadway Google Pubsub 2.0.0-rc.0 released!

Hello there!

I'm pleased to announce the release of broadway_cloud_pub_sub 2.0.0-rc.0, and looking for more testers to give feedback and try it out.

The 2.0 release adds, an set as the default, a new GRPC Streaming producer instead of the HTTP long polling. The HTTP producer can still be used, but it's not the default.

This is a significant improvement, bringing the library on par with Google's official Pub/Sub libraries. We have been using it in production for a couple of months now, with both Gun and Mint adapters, and if I had pick two main reasons to upgrade they would be what you least expect: the graceful shutdown and the improved observability.

Here is a summary of the features that the new GRPC Streaming producer provides, but for more details you can check the pull request, the 2.0 migration guide and the official google's documentation about pull methods.

  • Dual GRPC connection, one to receive messages and one for ack/management. Decoupling both to survive reconnects.

  • Server-side flow control via max_outstanding_messages and max_outstanding_bytes

  • Backpressure integrated with Broadway demand. Internally the producer tracks "outstanding" messages (dispatched, waiting for ack) and "buffered" messages (received from the stream, waiting for downstream demand). Outstanding, buffered and pending demand survive reconnects.

  • Automatic lease extension while messages are being processed, with adaptive p99-based ack deadlines.

  • Reconnection handling with configurable backoff.

  • Exactly-once delivery support, auto-detected from SubscriptionProperties at runtime. (I know real exactly-once delivery don't exist, this is what Google calls exactly-once delivery, it has different guarantees and flow requirements)

  • Graceful shutdown with a configurable drain_timeout_ms (default 30s). This is actually what made me develop the GRPC Streaming producer, you can find more details on the PR or ask about it =D

  • Telemetry events that allow for much better observability: stream lifecycle (connect, disconnect, reconnect, drain), ack batch flush timings and sizes, unary RPC spans, lease extension cycles, outstanding/buffered message gauges, pending demand and drain status. Include also a producer "telemetry_metadata" option that lets you attach static or dynamic (MFA) extra metadata to every event. This is huge for observability, you can see if your subscribers have buffere messages (it's processing slow), high pending demand (you can scale it down), shutdown drain timings and status, and much more!

If you use the library, or just want to take a look, you are totally welcome to try it, ask anything here or in the pull request :)

reddit.com
u/rock_neurotiko — 2 days ago
▲ 36 r/elixir+3 crossposts

Code BEAM Europe 2026: Keynotes, Full Tech Lineup, and Community Spaces

Hi everyone,

Code BEAM Europe 2026 is happening this October 21-22 in Haarlem, NL, and online! The schedule is locked in, and we are excited to finally share the full lineup and core tracks with the community.

Here is a look at what we have lined up for this year:

Keynote Speakers

We are thrilled to have two incredible visionaries taking the main stage to kick things off:

  • Brooklyn Zelenka: Distributed systems researcher, founder of Fission, and author of Elixir libraries like Witchcraft. She will be sharing her deep expertise in local-first access control and open distributed standards.
  • Sam Aaron: The creator of Sonic Pi! An internationally renowned live coding performer and Computer Science PhD, Sam will bring his unique blend of science, code, and live music to the BEAM community.

Core Themes & Subjects

The regular sessions are packed with core team members, maintainers, and production engineers covering the cutting edge of the ecosystem. You can expect deep dives into the rise of Gleam and frontend architectures with Lustre, alongside advanced Erlang and OTP core updates directly from the team at Ericsson. We will also explore real-world Elixir battle stories—from taming LiveView at scale to prototyping BlueSky's DataPlane—while tackling the intersection of AI, security, and modern developer experience. Finally, we'll take the BEAM out of the server room with talks on embedded systems, AtomVM, hardware design, and safe native interop via Rustler and C nodes.

Check all speakers and their talks at: https://codebeameurope.com/#speakers

Beyond the Stage: The Informal Space

Some of the best moments happen off the main stage. This year, we are introducing a community-driven sandbox running alongside the main tracks for everything that doesn't perfectly fit a standard talk format. Expect live demos, hacking sessions, panel debates, lightning talks, and games. If you have an idea for an activity you want to coordinate, let us know and help shape the space!

Submit your ideas here!

Join Us in Haarlem

Whether you are looking to level up your skills, hack on new projects, or just grab a coffee and talk shop with fellow BEAMers, we would love to see you there.

Early Bird tickets are currently LIVE.

This is the absolute best time to secure your spot at the lowest possible price point.

Grab them here: https://codebeameurope.com/#register

And Also! For the full details, check our website: https://codebeameurope.com/

See you in October!

- The Code BEAM Europe Team

u/Code_Sync — 3 days ago
▲ 34 r/elixir+2 crossposts

ElixirConf US Early Bird tickets end June 24

Hey everyone,

Just dropping a quick reminder that the Early Bird pricing for ElixirConf US 2026 is wrapping up on June 24.

If you are planning to join us in Chicago this September, this is your best shot to get the lowest price possible.

After this date, we will be moving to standard pricing. 

Whether you are coming for the training days, the main conference tracks, or just to catch up with the community in person, grabbing your pass now is the best way to save.

👉 Get your Early Bird ticket here: https://elixirconf.com/#register

See you in Chicago!

u/Code_Sync — 3 days ago
▲ 3 r/elixir

Is this the right way to stopping a request when there is no refresh token? (send_resp)

In my application I have a pipeline

  pipeline :auth do
    plug(AppWeb.RefreshPlug)
    plug(AppWeb.Auth.Pipeline)
    plug(AppWeb.Auth.SetAccount)

    # we can always run conn.assigns.account
  end

My refresh plug works in a way that if there is a refresh token it will issue a new access token in the header, otherwise...

defp put_access_token_in_headers(conn) do
    refresh_token = get_session(conn, :refresh_token)

    case refresh_token do
      nil ->
        put_status(conn, 404)

      _a ->
       # some code
    end
  end

We return a 404, Nice and good, my expectation was that the response would be sent there, however it still went to the next plug and then finally my application via the guardian library decided to give a response from there being no access token, not the core issue and I started to get worried,

what if functions run in general on conn’s with bad status codes!!! I don’t know if that’s a real concern maybe someone knows but anyways

I was thinking okay, what if I just use Halt, but that made it so I didn't get any response at all, so I would just want to stop there and send the response maybe, send_resp https://plug.hexdocs.pm/Plug.Conn.html#send_resp/1

So I just added send_resp(conn, 404, "No refresh token"), it seems to work, but is this the proper way to do it? And the question above, in pipelines is it good to just stop the connection and send_resp when there is a bad status code or something you don't like?

edit: In retrospect the post title isn't very clear about what the post is about, sry about that

reddit.com
u/BrotherManAndrew — 3 days ago
▲ 75 r/elixir

LiveStash v1.0.0: Persist Phoenix LiveView state across reconnects

Hi, we just released LiveStash v1.0.0!

LiveStash is a lightweight, modular library that backs up and restores your Phoenix LiveView assigns when a user drops their connection (like switching tabs or entering an elevator)

What's New in v1.0.0:

  • ⚡ Mnesia Adapter: Added full cluster state replication with split-brain auto-heal.
  • 🔒 Explicit Security (Breaking): You must now explicitly set :security_mode (:sign or :encrypt) for the browser memory adapter.
  • 🛡️ Stability and performance improvements: we've tested the library with 25,000 concurrent users on a distributed cluster and created a blogpost with the results

With this release, LiveStash is entering maintenance mode. We won't be adding new features, but we will actively fix bugs, review PRs, and keep it fully compatible with future Phoenix updates.

Performance Blogpost: https://swmansion.com/blog/live-stash-performance-tests/

GitHub: https://github.com/software-mansion-labs/live-stash

u/kraleppa — 4 days ago
▲ 54 r/elixir

Hologram v0.10: Events, Middleware, and More

Hologram v0.10 is out - now with a proper event system and server-side middleware! 🎮

New to Hologram? It's a framework for full-stack web apps written entirely in Elixir, no JavaScript to write. The Elixir runtime runs in the browser, so the same language powers the client and the server. Local-First is on the roadmap.

This release is mostly about events. The client-side event system grew up. You can now handle keyboard, scroll, resize, click-outside and scroll-edge events, bind handlers to the window and document, and debounce or throttle the noisy ones. It all lives in your templates and gets checked at compile time.

To show it off, I rebuilt Space Invaders in pure Elixir. A full game in the browser, no game engine, tiny bundle.

There's a new server-side middleware layer too, for things like auth and request enrichment. And comprehensions and error handling (try/rescue and friends) now behave the same in the browser as on the server.

Thanks to everyone who reported the bugs that got fixed in the 0.9.x patches along the way. It genuinely helps.

Thanks to our sponsors for making sustained development possible: Curiosum (Main Sponsor), Erlang Ecosystem Foundation (Milestone Sponsor), and our GitHub sponsors - Innovation Partner: @sheharyarn, Framework Visionaries: @absowoot, Oban, @robertu, Moss Piglet, and all other GitHub sponsors.

Full details in the blog post: https://hologram.page/blog/hologram-v0-10

Website: https://hologram.page

u/BartBlast — 5 days ago
▲ 23 r/elixir

Continuum - a library for durable and crash-resistant workflows

Continuum is an OTP-native durable execution engine for Elixir, backed by Postgres. IIt’s an Elixir-native answer to Temporal in other ecosystems: running a multi-step business process that survives crashes, restarts, and deploys.

You can write your workflow as ordinary Elixir. Side effects go through activities, whose results are journaled on first run. If the process dies or the node restarts, Continuum resumes the workflow exactly where it left off, by replaying its event history through the same code with identical state.

Determinism is enforced at compile time. Workflow code is scanned for non-deterministic calls (time, randomness, IO, and so on), so replay safety is checked by the compiler rather than left to discipline.

On top of the core engine, Continuum provides durable timers and signals, activity retries, sagas and compensation, parent/child workflows, continue_as_new for long-running loops, workflow versioning, a LiveView observer, OpenTelemetry, and optional clustering. Activities run on a built-in worker pool by default, or on Oban if you already operate one.

u/account18anni — 6 days ago
▲ 9 r/elixir

How Can I Add File/Line Context to Elixir Error Messages?

I want to make Elixir have better error messages.

When running

Enum.eah(0..9, fn x -> IO.puts(x) end),

the error generated is

** (UndefinedFunctionError) function Enum.eah/2 is undefined or private. Did you mean: ....

The only line number in the error is the function called that created the error, not the line number the error occurred on.

I want to add a small piece of text to the beginning of error messages with the file name, line number, and line where the error occurred.

Running the same code as the previous example would output something like

File "~/Desktop/test.exs", line 3
Enum.eah(0..9, fn x -> IO.puts(x) end)

** (UndefinedFunctionError) function Enum.eah/2 is undefined or private. Did you mean: ...

I think this would make writing Elixir much easier, as instead of having to ctrl-f for the error or search manually, you know exactly what file and line the error occurred on.

However, I do not know how the Elixir compiler/runtime works.

Does anyone know how to do this and is willing to help me, or willing to do this themselves?

reddit.com
u/mehonje — 5 days ago
▲ 59 r/elixir+2 crossposts

Why did "compile Erlang to native C" lose to bytecode, even though it was 10-20x faster on paper?

New BEAM There, Done That episode with Björn Gustafsson (OTP team since 1996) tracing the BEAM's origins through three competing VMs - JAM, Robert Virding's V, and Bogdan's original BEAM.

The most counterintuitive part: native-compiled Erlang showed massive sequential speedups in isolation, but once concurrency entered the picture, the real-world gain shrank to about 2x, because message passing was already implemented in C regardless of compilation target.

Also covered: the BEAM Validator, built after a compiler bug caused weeks of debugging pain, and the BEAM loader - Björn's own invention, still running in production decades later.

https://youtu.be/1Ty_MHZu9nM?si=L99dI6FvwNJi46S2

u/rtrusca — 7 days ago
▲ 9 r/elixir

Coverage you'll actually read

Hi,

I've enhanced the check tool with dense coverage.

Problem:

Coverage output is too noisy. On large projects, it prints percentages for thousands of modules, even if I only changed a handful of files. The information I care about gets lost in the noise.

Solution:

al_check now diffs against the base branch and reports coverage only for new and modified files, grouped by change type with per-group average coverage.

Try it

{:al_check, "~> 0.1.24"}

mix deps.get

mix check.install # or: mix check.build && ./deps/al_check/scripts/check

check # run everything, get the change-scoped coverage report

more details -> Coverage you'll actually read

u/user000123444 — 7 days ago
▲ 21 r/elixir

New Website for Choreo - System Design and Analysis Library for Elixir

https://code-shoily.github.io/choreo/ added a new website and a few advanced LiveBooks to get you started.

Advanced Mermaid and ExCalidraw integration for LiveBooks is coming up next

Choreo is a graph based system design and analysis tool for Elixir programmers.

You write one of the 13 preset diagrams to define your system - all in macro free Elixir, and you have zoomable, filterable diagram and a set of operations to get metrics from it (ie: is there a cycle in the dependency? What is the most critical node? SPOF? etc).

reddit.com
u/Plus_Shop_6927 — 7 days ago
▲ 30 r/elixir

What are you building with Elixir? I'd love to see some projects!

Would love to see what the community is building!

reddit.com
u/pkim_ — 10 days ago
▲ 7 r/elixir+1 crossposts

Automatically syncing your blog to atproto and standard.site

I’ve previously written about publishing your existing blog to atproto and standard.site, this post follows up with talking about how to automate things with a little service that discovers content from your blog feed and automatically publishes it for you.

atproto as a technology has so much potential and I’m really enjoying hacking on it

jola.dev
u/joladev — 7 days ago
▲ 7 r/elixir+1 crossposts

For Networking Engineers

I have a question for network engineers. If you know what ZTP and a Spine/Leaf configuration is, this post is for you.

Regarding network orchestration & Intent-based networking it seems like Elixir/Erlangs concurrency system would be great for mass configuration and monitoring of network switches.

Looking at different the tools online, I don't see anything in this domain that uses Elixir.

I'm curious if there is an obvious reason for this (and I am naive ) or if this might be a good idea that simply requires work that nobody has done yet.

I imagine each switch modeled as a genserver. This gives you isolation so a crash or hang on one switch (bad SSH session, gNMI stream dying, slow device) (ideally) can't take down or corrupt the handling of any other switch.

Any thoughts?

reddit.com
u/Less_Play_3523 — 10 days ago
▲ 64 r/elixir

[Podcast] Thinking Elixir 306: Don't Exhaust Your Atoms

Security is front and center with atom exhaustion CVEs and an urgent hackney security upgrade. Elixir 1.20's type system catching real bugs, a new BEAM-native coding agent called "vibe", and more!

youtube.com
u/brainlid — 13 days ago