mandar1045

mandar1045

Stampede 1.2 is out, and I finally got to try it at a bigger scale.

What’s new

  • --find-limit: instead of a fixed number of users, it adds load a step at a time and checks your thresholds on each step. The first step that breaks one ends the run, and the summary tells you the most users that held. find_limit: [by: :rate] does the same with an arrival rate.
  • --badge badge.svg writes a README badge with the result.
  • mix stampede.compare --format markdown, so CI can post a before/after comparison as a PR comment. The CI guide has the workflow.
  • mix stampede.gen.scenario --rate generates a rate-based scenario.
  • Finished runs on the dashboard can be downloaded as the HTML report or the JSON.
  • Every second, a run records how busy the load test itself is. Past 90% the summary warns you, since the load test’s own delays end up in its timings.

400k users on one Phoenix server

I ran it on AWS: a fresh Phoenix 1.8 app with Bandit on one r7g.xlarge (4 Graviton cores, 32 GB), and Stampede on a second one. The only change to the app was raising Bandit’s connection limit and the listen backlog. Each user acts like the Phoenix JS client: it joins room:lobby, sends a heartbeat every 30 seconds and a message every 30 to 60, and stays. --find-limit added 100k users per step at 1,000 a second, and held each step for a minute.

Users Join p95 Message p95 Errors Server CPU Server memory
100,000 5.71ms 0.57ms 0 1% 4.9 GB
200,000 6.84ms 1.35ms 0 3% 9.5 GB
300,000 9.42ms 2.67ms 0 9% 13.9 GB
400,000 12.46ms 4.07ms 0 24% 18.1 GB

CPU and memory are while each step held. While users were joining, the server peaked at 47%.

Phoenix didn’t log a single warning the whole run. That’s where the test stops: past 400k, the one machine running Stampede ran out of CPU before Phoenix did, so the server’s real ceiling is higher. Finding it needs more load machines than my AWS account allows yet.

What it found in Stampede

Testing at this size turned up problems in Stampede itself, all fixed in 1.2:

  • When you connect to an address given as a string, Erlang looks it up through its native resolver, even a plain IP like "172.31.46.102". That’s one process and four OS helpers for the whole node, and under heavy load those lookups started failing as :nxdomain. Stampede now parses IPs itself and caches host names for 5 minutes. This one could bite anything that opens lots of connections from one node, not just load tests.
  • An overloaded run could stall instead of finishing. The run’s own processes now run at high priority, and progress printing can’t hold it up.
  • Failing VUs retried every 100ms, which piles on when things are already going badly. They now back off, much like the Phoenix JS client does before reconnecting.

Everything to rerun it is in bench/million, with every number it measured. The three runs cost about $1.30 of AWS credit.

{:stampede, "~> 1.2", only: [:dev, :test]}

If you try --find-limit on your app, I’d love to hear what limit it found and whether the output made sense.

GitHub:

Showing Posts 1 to 3

iyjim

iyjim

A few days ago, I came across this video:

Since the server used in that benchmark had only 1 vCPU, I wasn’t particularly surprised by the Erlang result. My understanding has always been that the BEAM tends to become much more interesting when it has more cores available to work with.

Then a couple of days ago, the same YouTuber posted another challenge:

The challenge is here:

This time the application server has 16 vCPUs and 32 GB RAM, so I became much more curious about how Erlang/Elixir would perform.

There are still at least two BEAM submissions waiting to be benchmarked:

Erlang:

Elixir:

But one Elixir submission has already been tested:

According to the current leaderboard, it reached about 650K users rather than the 1M maximum:

That result surprised me a little.

What made me even more curious was this Stampede benchmark. A Phoenix server on only 4 Graviton cores with 32 GB RAM was already able to hold 400K connected users, and apparently the load generator became the bottleneck before Phoenix itself did.

At first glance, that made me think that 1M users on a 16-core machine should be quite achievable for Erlang/Elixir.

However, after looking at the two tests a little more carefully, I suspect I may be comparing apples and oranges.

The Stampede test seems to be mostly about maintaining a very large number of Phoenix Channel connections, with relatively light activity per connection: a heartbeat every 30 seconds and a message every 30–60 seconds.

The Million Users Challenge is quite different. At 1M simulated users it generates roughly 42K HTTP requests/sec, and every request also involves PostgreSQL work according to the benchmark specification.

So perhaps the interesting question is not really:

“Why can Phoenix handle 400K users on 4 cores but Elixir cannot reach 1M on 16 cores?”

but rather:

“Where does the bottleneck move to in the Million Users Challenge, compared with a mostly connection-oriented Phoenix Channels workload?”

I haven’t had time yet to dig deeply into the implementations, profiling results, scheduler utilization, PostgreSQL driver behavior, connection pools, JSON encoding, etc.

Maybe someone more familiar with these workloads can spot the main difference just by looking at them?

I’m also very curious to see how the pending Erlang and Elixir submissions perform. :slightly_smiling_face:

mandar1045

mandar1045 OP

@iyjim You’ve got it right, it’s apples and oranges.
In my 400K run each user sends a heartbeat every 30 s and a ping every 30–60 s, and the channel just echoes it back. There’s no database and no broadcast. That came to about 22K tiny frames a second, and Phoenix used about a quarter of 4 cores for it. It’s mostly a test of how cheaply the server can hold idle connections.

Users in the challenge send at about the same rate (one request every ~24 s), but each request does much more work: HTTP parsing, a JWT check, a Postgres round trip, JSON for 20 posts and gzip. So the bottleneck moves from the connections to the database path. The entries at 1M nearly all pipeline their Postgres queries, and as far as I know Postgrex doesn’t, so I’d look there first.

Memory matters too. My Phoenix server used about 45 KB per connection, which on a 32 GB box runs out around 700K. And 400K wasn’t Phoenix’s limit, just the point where my one load machine ran out of CPU.
I’m really curious how the gen_tcp entry does.

mandar1045

mandar1045 OP

I checked, and Postgrex really doesn’t pipeline, not even on current master. Each query holds a pooled connection until its result comes back. With the challenge’s 512-connection cap, that probably hurts a lot.

If anyone wants to dig into the Elixir side, the tbsvttr entry’s README is a good read. They got memory down from about 240 KB to about 30 KB per connection (socket backend, GC after every request, ERL_FULLSWEEP_AFTER 0) and compared it to Bun and Node loc

— All posts loaded —

Where Next? Top

Trending in News & Updates Top

mat-hek
Popcorn, the library that runs Elixir code in the browser, is now stable :popcorn: This is possible because it now builds on a very stab...
New
bartblast
Hologram UI is in the works - the official component library for Hologram - and the waiting list is now open. A common reaction when I m...
New
bartblast
This thread is for updates on the Hologram website (docs, new pages, roadmap, feature status, etc.). You can watch this thread to get no...
New
mandar1045
Stampede 1.2 is out, and I finally got to try it at a bigger scale. What’s new --find-limit: instead of a fixed number of users, it add...
New
uzaydurdu
Hey Elixir folks, I’ve been working on Xenia 0.2.0, and it’s nearly ready. This release focuses on performance, easier integration, and...
New
rodloboz
Hi all, I’ve just released Sake 0.5.0, and I want to explain better what it’s for, because I think many Phoenix apps can use it now. Wh...
New
Potions
I’m working to make Potions the easiest way to deploy Elixir applications, and the next step in that journey is live: you can now bring y...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
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