r/elixir • u/Reckless_Dev1045 • 22d ago
One 16-core Phoenix server held 2,000,000 active users with 0 errors
I've been building Stampede, a load tester for Phoenix that speaks Channels and LiveView, and I wanted to see how far one server could go with realistic traffic. Last time I got to 600,000 users on a 4-core server, so this time I scaled up.
Setup:
- One AWS r7g.4xlarge (16 cores, 128 GB) running a fresh Phoenix app, with only its connection limits raised
- Eight r7g.xlarge machines running Stampede
- Every user acts like the Phoenix JS client: joins a channel, sends a heartbeat every 30 seconds and a message every 30 to 60
- The load went up 250,000 users at a time, each step held for a minute, and a step only passed with joins and messages under 1 second at p95 and 0 errors
Results:
- 1,000,000 users: held, server at 37-48% CPU, 52 GB memory
- 1,500,000 users: held, 54-60% CPU, 77 GB
- 2,000,000 users: held, 78-84% CPU, 103 GB
- 2,250,000 users: the CPU ran out
The first error came at 2.07M, so 2M is the number. Memory worked out to about 51 KB per user, and CPU was what ran out, since 2 million users send well over 100,000 heartbeats and messages a second.
For comparison, the Phoenix team held 2M idle connections on a 40-core machine back in 2015. This was 16 cores with every user active, which says a lot about how far the BEAM has come.
Everything to rerun it, plus the logs from this run, is in the repo: https://github.com/mandar1045/stampede
Happy to answer questions about the setup. Getting past the ~64k ports per client address took a few tricks.
17
u/sanjibukai 22d ago •
Meanwhile in benchmarks for AI generated codes Elixir versions are performing poorly... So we still have a bit of time before getting replaced in here :)
3
u/Repsol_Honda_PL 22d ago
How much RAM was on 4 core VPS? EDIT: From GH I see a 32 GB.
128 GB servers on cloud are relatively expensive (VPSes are way cheaper), but - in the other hand - 2 millions of users is huge number - Very impressive! It is about 10-20 milions users per day or 300-600 per month (I think). So on this small box you can have a really big web portal.
I am thinking is your scenario really realistic (I don't say no, just ask)? How many request pers second can handle similar app on 4-core/ 32 GB and 16-core/ 128 GB servers?
Thx!
3
u/yachtyyachty 21d ago
I’m running lasso.sh (Phoenix + Liveview) on small 4x shared CPUs fly.io machines across 4 regions and it is shockingly performant at 100s of requests per second and a pretty high volume of cluster-wide PubSub events
Great tech
1
u/Pepper_pusher23 17d ago
Not sure if this is a repost because I don't see my reply anymore. The good code is coming in the next episode. These are all the worst performers. So I suspect we'll see a better Elixir implementation in that episode with more realistic results.
0
u/[deleted] 21d ago
[deleted] — view deleted comment