mandar1045

mandar1045

Hi everyone,

I’ve been building Stampede, a load testing library for Phoenix apps. Load tests are plain Elixir modules, and it speaks the Channels and LiveView protocols itself, so you don’t have to rebuild joins, refs, heartbeats or the LiveView CSRF dance by hand like you do with k6 or Tsung.

A LiveView test looks like this:

defmodule MyApp.Load.Counter do
  use Stampede.Scenario

  @impl true
  def options do
    [vus: 500, duration: [minute: 1], thresholds: [{"live.event", p95: 100}]]
  end

  @impl true
  def run(_vu) do
    {:ok, view} = Stampede.LiveView.connect("http://localhost:4000/counter")
    {:ok, _reply} = Stampede.LiveView.click(view, "inc")
    Process.sleep(1_000)
  end
end
$ mix stampede.run loadtest/counter.exs --html report.html

connect/2 loads the page like a browser, keeps cookies, follows redirects and joins with the page’s tokens. From there you can click, change, submit, patch and navigate.

What else is in there:

  • Phoenix Channels: join, push, cast, await broadcasts, both serializers
  • HTTP with keep-alive, and plain WebSockets
  • VUs with stages, or a fixed arrival rate
  • checks and thresholds, so mix stampede.run can fail CI
  • percentiles within 1%, a per-second timeline, JSON and HTML reports
  • mix stampede.compare to catch regressions between two runs
  • splitting one test across several nodes

On my laptop, with the server on the same machine, it held 3,000 LiveView users, and 6,000 channel users split over 3 nodes, without errors.

the API can still change, which is why I’m posting now. If you try it against your app, I’d really like to hear what breaks or what’s missing.

Hex: stampede | Hex
Docs: https://stampede.hexdocs.pm
GitHub:

Showing Posts 1 to 1

mandar1045

mandar1045 OP

I’ve been load testing a single Phoenix server on AWS with Stampede, and it just held 2,000,000 users with 0 errors on one 16-core machine.

The setup

  • Server: one r7g.4xlarge (16 Graviton cores, 128 GB) running a fresh mix phx.new app on Bandit. The only changes were Bandit’s connection limit and listen backlog, plus OS limits like open files.
  • Load: eight r7g.xlarge machines running Stampede over Erlang distribution, each connecting from 14 extra private addresses to get past the ~64k ports per address.
  • Users: each one behaves like the Phoenix JS client. It joins room:lobby, sends a heartbeat every 30 seconds and a message every 30 to 60, and stays.
  • Steps: --find-limit, starting at 1M and adding 250k per step, ramping over 250 seconds and holding for 60. A step passes only with joins and messages under 1s at p95 and 0 errors.

Results

Users Server CPU Server memory
1,000,000 37–48% 52 GB held
1,250,000 47–52% 64 GB held
1,500,000 54–60% 77 GB held
1,750,000 67–71% 90 GB held
2,000,000 78–84% 103 GB held
2,250,000 out of CPU failed

The first error came at 2,067,672 users, while ramping to the next step, so 2,000,000 is the number. The kernel’s own count peaked at 2.1 million established connections, and AWS’s connection tracking limit was never hit.

Memory came to about 51 KB per user, everything included, so 128 GB would have room for more. CPU was the limit: at 2 million users the heartbeats and messages alone are well over 100,000 a second.

Compared to 2015

The well-known Phoenix result is the core team’s 2 million connections in 2015, on a 40-core, 128 GB machine. Those connections joined a channel and then sat idle. This run used 16 cores, and every user was sending heartbeats and messages, so it’s a harder test on less than half the cores. It isn’t a strict apples-to-apples comparison, since the hardware and the Erlang and Phoenix versions are all a decade apart, but it’s nice to see how far the BEAM has come.

Everything to rerun it is in bench/million in the repo, with the logs and numbers from this run: GitHub - mandar1045/stampede: Load testing for Phoenix: Channels, LiveView, HTTP and WebSockets, in plain Elixir · GitHub

I’d love to hear what you’d measure next. I’m thinking LiveView at this scale.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

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
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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
danschultzer
I’ve moved the strategies out of PowAssent and created a multi-provider framework for Elixir. This way the strategies can be used in any ...
New
gtcode
Aloha gang, There’s a new class of AI model out from TypeSafe. Jev is their flagship model. You can learn about it here: ...
New
danschultzer
I needed something like premailer for rails, and after searching, I decided to make an easy-to-use library to handle inline styles and co...
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
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
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
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
AstonJ
With advancements in AI gathering pace and set to increasingly accelerate, perhaps it’s worth having an annual thread on the topic - feel...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews