How good is Elixir throughput?

Where did you get this number from? I’ve created systems which handled more requests per second with Elixir (on multiple instances)

2 Likes

From one of the laptops I have lying around. :smiley: I bombarded it from my workstation and it could hold 50K almost without a problem.

8 Likes

Added the above two posts to your original post Dimi - just so anyone coming to the thread doesn’t think the 50K figure is an Elixir limit :upside_down_face:

4 Likes

Tbh , Elixir is the language of future, where performance is common, parallel ingestion & fault tolerance(hott reload) is not.

1 Like

I’ve never trusted any of these benchmarks because I regularly have elixir outpace the other things I’m integrating it with. To the point where it crashes/locks up the other software with too much throughput, because it’s incredibly easy to parallelize just about anything I want to do and processes are tiny and cheap.

I also run https://approximated.app, which at this point manages clusters for almost 200k domains/subdomains. And while it’s not elixir running on each cluster (though I wish it was), it is a single elixir phoenix instance handling the millions of API reqs. And much more intensively, performing the constant monitoring of each of those domains. Monitoring means a DNS check, SSL check, and hitting the actual url of the domain to check status, response headers, etc.

As of this writing, that instance runs on 8gb of ram and 4vcpu (about $40/month). 99% of the time it uses about a quarter of it, but it gives me a lot of room if something really extraordinary happens. It’s never crashed, and only ever become slightly slower a couple of times.

One was due to not having rate limits on the api, and a user mistakenly automated deleting and then recreating their domains in approximated every time a request for that domain hit their app. Including requests for assets that happen in the background. The other was a poorly thought out recursive loop I manually ran from iex, and then went for lunch. Both times it maxed out the cpus for the duration but nothing failed or crashed. Just took longer to complete.

Anyways, hopefully that real world example gives you a better sense of elixir performance and throughput.

18 Likes

Was this testing done using Cowboy? Bandit from my understanding is lot faster.

Yes. Never used Bandit yet, and I’m not working with Phoenix for a while now as well – I’m focused on API backends.

4 Likes

What would you recommend for API backends? My understanding was that Phoenix is still a good fit, with the HTML-related parts stripped out.

1 Like

I’d recommend Plug

2 Likes

Yep, just Plug and your own code – plus any Plug-related libraries e.g. flood protection.

2 Likes

Love the funny self introspection.

1 Like

Hey, I just read this thread because I got the weekly forum summary. Could you please elaborate why you use just Plug instead of Phoenix which uses Plug under the hood? I like Elixir and want to keep up with good advice so I can use it when I have an idea where Elixir is a good fit.

1 Like

There are several reasons that vaguely summarize to “bloat” – of which Phoenix has almost zero in terms of runtime performance btw (if it’s not outright zero even!) – but my reasons are:

  1. Less files in the project. To me that’s invaluable. (Even as it is currently, IMO most Elixir project generators still produce too many separate files but that’s a very, VERY separate topic.)
  2. Easier to track what’s going on – just having plugs for the request/response management has proven priceless for a peace of mind development; especially in API projects you don’t need views and templates. And you could easily do without controllers as well.

I heard other arguments but again, they were a bit vague to me, or maybe I wasn’t interested enough to hear them because my two are plenty enough for me. Hopefully other people will chime in and give their arguments.

2 Likes

Not only loving it; such post are actually important for the health of this community. It helps people with imposter syndrome (and there are lots of devs with imposter syndrome)

I myself once made a screenshot of a branch José Valim created, full of his commit messages which went something like “WTF?” and “Whatever”. Not two, but at least 10! It reminds me on bad days that even The One has such days and I should not doubt myself too much :slight_smile:

3 Likes

Yea, I remember looking at the rules and then looking at some of the code. It was clear that, regardless of what the rules were people were just optimizing for the benchmark.

My real world Phoenix code was so fast the first time with no caching at all that I never bothered looking back.

My primary optimization is productivity. Rails is king here, but Elixir is the only language I’ve seen that comes anywhere in the range of competition.

2 Likes

Depends on how much elixir experience you have, phoenix was designed as an improvement over rails but in elixir. I have used phoenix and liveview for years and when I wanted to see how the very popular Rails behaved, I had mixed feelings.

On one hand, starting a new rails project is very easy, everything works out of the box, you can fiddle with the application without even knowing ruby that well. The official documentation is pretty good, for someone using rails for the first time, it was painless to use.

The downsides however are more than I expected:

  • A lot of poor community answers - typical answers with try this with a lot of upvotes, no further information;
  • Rails doing too much magic under the hood - while it is nice that you can just add some files and have new controllers, views, it is also a problem when something doesn’t work. For example I found that classes should be named exactly as their source files, otherwise it won’t load (I mean WTF).
  • Lack of a well-written language server - I’ve tried to use IDE features like autocompletion and go to source without any success in vscode after a few hours of trying;
  • Lack of any type-checking support - while elixir is weakly typed, it does have types under the hood and you can enforce however much you need them (start with dynamic unchecked types and end with guards and typespecs), I find this as the biggest weakness of ruby itself;
  • Mixed configuration systems - If I recall correctly the configuration for the database is located in a .yml file (where you can use erb templating?), while other configurations are located in ruby source files.

I think that elixir problem has always been the advanced features it has and the big infrastructure it runs on (OTP), they are very different from what there already is on the market, so the developers need to relearn a lot of things. If we were to talk about productivity between 2 experienced developers in elixir and ruby, elixir will always be on top: pure functions, immutability, fault tolerance, typespecs, refined concurrency model, performance, interaction with runtime are just things that ruby will never be able to offer.

2 Likes

Minor quibble but I think elixir is technically strongly but dynamically typed. Strong because no implicit type conversion occurs and dynamic because types are enforced on values at runtime rather than variables at compile time.

5 Likes

Yep, technically Elixir is strongly but dynamically typed – whereas languages like e.g. Haskell, OCaml, Golang, Rust are both strongly and statically typed (“static” means “types are enforced at compile-time”).

1 Like

To each their own I suppose. I’ve never had a need for stricter type checking on web apps backed by a database because the database and ORM becomes responsible for it.

The malleability of Ruby enables the closest thing to Aspect Oriented Programming that I’ve seen in any language. It’s the reason the gem ecosystem is so polished and powerful.

It’s where the magic comes from but you have to learn to appreciate why it works to stop fighting it.

2 Likes

To answer the question as to whether anyone uses these top-performing web frameworks, one ought to review the download statistics at the bottom of the page for the Rust-specific frameworks at crates.io. Actix-web and Axum are the legitimate Rust web frameworks listed:

Both web frameworks are used in production environments with significant load. Both have very similar architectures, with actix-net (core of actix-web) being closer to SMP runtime as it uses a dedicated async runtime per core whereas axum uses a shared, multi-core async runtime. There are tradeoffs for each.

To put this into perspective, Phoenix is the only web framework in Elixir town and has the following download stats: phoenix | Hex

1 Like