matthias_toepp

matthias_toepp

I posted the following also in rust’s reddit https://www.reddit.com/r/rust/comments/1f39vhz/how_much_more_crashproof_is_a_server_with/

My understanding is that because elixir uses the beam vm it has per process isolation which is basically used to guarantee that the whole server will not crash on any one request. As I understand it, this is an advantage over what a framework like Rust’s Axum offers, is this correct? How significant of an advantage is this really over presumably just restarting the whole server? (I get that there is a performance tradeoff for gaining this robustness).

Showing Posts 1 to 10

LostKobrakai

LostKobrakai

This is comparing apples with oranges. Rust is all about preventing crashes. The BEAM is about allowing for crashes by isolating them as best as possible and letting the system as a whole stay up even in the face of things going sideways in a context, where things going sideways by definition cannot be prevented – distributed systems communicating over networks.

16
Post #1
matthias_toepp

matthias_toepp OP

“Comparing apples with oranges” to me implies the question is inappropriate or invalid.

I’m wanting to know if a phoenix server will crash less often than an Axum server and how much that really matters.

LostKobrakai

LostKobrakai

It’s not that, but there simply is not general answer to your question. What even is “crashproof”? I can build you a server, which never gets any work done e.g. just returning a 500 on any request, but their process never stops. Is that “crashproof”? Probably depending on the definition. Is it useful? Not at all.

Wojciech

Wojciech

I’m not sure what do you mean by that, Rust’s main goal is no bugs in runtime, elixir puts more focus on graceful recoveries from crashes.

It depends on a use case, i tried Axum when i already read most of the rust book but it was still really hard for me to do even simple crud so i gave up as i figured out that maybe i don’t need that much safety and performance.

I picked elixir because it was easy to learn, offered nice syntax, was relatively safe and very performant in areas that matter for a web development project while being fault-tolerant.

matthias_toepp

matthias_toepp OP

By crashing I mean that a server has been started and no longer responds to requests.

dimitarvp

dimitarvp

Elixir does not do that. It will always tell you something even if you wait 30s for it. You’ll still get an error, or the OS process will be killed by f.ex. Linux’s out-of-memory reaper and then obviously nothing will get served as the server will not be there.

Your original question’s answer is: Rust can still crash and burn. You can write very defensively f.ex. never use .unwrap but maybe your colleague will have had a bad morning and will put it in. Then when you hit that place in the code and there’s no (or errored) value the entire OS process aborts.

Elixir does not do that – one error never brings down the entire OS process.

dimitarvp

dimitarvp

To expand a little on Rust: both Axum and ActixWeb are amazing frameworks and I am certain you’ll never have an OS process crash because of them. Still, you the developer can write a non-crash-proof code inside your responders / handlers and then all bets are off.

In Elixir you can straight up try writing this inside your controller function(s):

something = nil
IO.inspect(something.inserted_at)

Which is an error, but nothing will stop, just one request will fail and everything else goes as normal with zero capacity affected.

In Rust, if you write this:

value = None;
stuff = value.unwrap();

Then your entire program might get aborted and die on the spot. Though final disclaimer: I haven’t looked at Axum and ActixWeb in at least a year so maybe double-check; maybe they have added protections against defective code like this since the last time I checked them out.

jhogberg

jhogberg

Erlang Core Team

A quick glance shows that there are some plugins to catch panics, but I feel compelled to add that “added protections” of this kind give people a false sense of security.

Yes, they let you ignore the error that just happened, but in doing so you also ignore any side-effects that occurred up to the point of the crash, potentially leaving your program in an inconsistent state (from the program’s point of view, not necessarily the language’s). Half the selling point of Elixir/Erlang, IMO, is that it gives you decent tools to handle this.

dimitarvp

dimitarvp

Yes. Rust has no runtime to speak of (tokio is kind of sort of a runtime but it’s not nearly rich on features as the BEAM VM) so basically if you don’t code defensively all bets are off.

Though in the spirit of a balanced discussion, Rust’s ecosystem has world-class tooling to help you scan for e.g. unsafe (via cargo-geiger) and you can also use a variety of linters or even roll your own (through ast-grep, gritql or just plain old grep or rg) and just disallow stuff like .unwrap at all. So a diligent Rust programmer – and I’ve worked with 15+ of them – will still have programs that don’t crash ever. But you’re right: that’s because the programmers are diligent and is not owed to the runtime. With Erlang / Elixir, the runtime is always there to catch us when we fall.

D4no0

D4no0

This is not a thing that is possible once external things that can misbehave are added to the equation. The simplest example would your controller doing a http request to another service. You can have a lot of things that can go wrong:

  1. The service is down;
  2. The service decided that they want to make a breaking change to their contract;
  3. The network request failed for a reason or another;
  4. You are hitting a timeout.

Unless you have covered all these edge-cases and more, you are never guaranteed that this thing will not blow up in your face, no matter how many compile-time guarantees you have. I think this is the exact point where defensive code becomes a liability and the perfect place where erlang VM excels, the system continues to work and you can decide later if you want to handle specific edge cases or some partial errors are acceptable.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews