Hacker News new | ask | show | jobs
by yannoninator 1862 days ago
Looking into Elixir, but from what i've heard, Elixir isn't very memory efficient when it comes to web servers.

Is that still the case?

Also where does one host Elixir apps these days? Heroku, Vercel or Bare metal?

14 comments

For a frame of reference, an Erlang VM running all of Phoenix will consume 16MB memory on startup, so we need more details on what exactly you've heard and for what usecases. For the Phoenix channels 2M connection benchmark, some folks claimed go uses less memory for websockets, but neglected to consider our realtime layer monitors connections for multiplexed messaging, handles distributed PubSub, etc, so it wasn't a proper comparison. There are certainly nuanced convos we could have about memory usage vs other platforms, but a blanket "non memory efficient for web" anecdote is inaccurate :)
This runs on 256mb VMs and works well even when it gets busy: https://liveview-counter.fly.dev

And I'm biased, but we are a pretty good place to run an Elixir app: https://fly.io/docs/getting-started/elixir/

> Looking into Elixir, but from what i've heard, Elixir isn't very memory efficient when it comes to web servers.

It really depends on your reference point and what your web servers are doing. The Elixir website has a series of cases and perhaps you can find an example closer to what you are doing: https://elixir-lang.org/cases.html - there are also cases where companies reduced the number of nodes in production once they migrated to Elixir.

Regarding deployments, Heroku, Gigalixir, Fly.io, Droplets, K8s, etc are all viable options.

Because of the way that Phoenix handles HTML templates it’s probably one of the most memory efficient.

https://bignerdranch.com/blog/elixir-and-io-lists-part-2-io-...

My Elixir backend, doing background processing, admin interface, data ingestion and serving data via GraphQL consumes 300 MB RAM on average, which is 20% less memory than the Node/Next.JS React frontend. YMMV.
I host a pet project Slack bot on a Digital Ocean droplet. You can compile an Elixir app into an executable that treeshakes the BEAM. I can't speak to memory usage, but deployment for me is as easy as compiling an executable and putting it on the server.
Is it just "mix build" that you run, or something more special?
For me, it's: libcluster (automatic clustering with Kubernetes Service) + horde (distribute workload across cluster) + Kubernetes Deployment

Whenever I need to upgrade, I perform a rollout, new OTP application instances perform a takeover, once it's done previous pods are taken down.

I've heard some stories, mostly around XML handling if I recall well, and also due to people not using a form of streaming when it would have been necessary.

I'm curious to know what you have heard with more precision, if possible.

I have https://elixirdaily.link (an elixir/beam news aggregator running) on the smallest, free Gigalixir VM just fine. Does a ton of memory intensive work and doesn't go OOM (had to be careful with # outbound http connections).
Oops I think we broke your app.
Something something demo gods
HN hug of death strikes again
> Elixir isn't very memory efficient when it comes to web servers.

I'm serving (https://domovik.app) for a few dozen people on a few dozens MB of RAM. Sure, it's not Google scale, but I really can't complain about memory usage.

Just to get a frame of reference, what is memory efficient for web servers?
You could create a Phoenix project, launch it and use the erlang observer or the Phoenix LiveDashboard to monitor memory consumption and decide if that suits you.
Huh? Elixir isn't memory effecient, compared to what exactly :)?
It also really depends what you're doing - if you need millions of processes almost nothing is more memory efficient.
assembly probably /s
Render.com does a great job at running distributed Elixir.