r/devops • • Oct 21 '26

Tools ‎How do you simulate realistic user traffic in load testing?

‎We are looking to overhaul our load testing, since our current script only slams 10k users in 60 seconds and gives us garbage data. It exhausts connection pools and creates artificial bottlenecks that would not show under any kind of normal use case.

‎Real users ramp up slowly, and idle on pages, and don't jump from one to another without a second thought, they do not fire off database transactions with zero pause.

‎We should be reflecting real behavior, not inducing cold start failures.

‎Has anyone modeled this at scale? Should we make the step curves with warm up times to let caches and other systems warm up before hitting the expected load? We want to reflect real user behaviour, not just trigger cold start failures.

‎

32 Upvotes

24 comments sorted by

20

u/Prudent_Design_9782 Oct 21 '26

You definitely need to set up curves. Going from 0 to 10k instantly does not test your app, it just tests how fast things break under a massive spike, and it is useful, but not really a concern, except if you are making the next big social network. We usually do a warm up at a fraction of the load to get caches populated and pods spun up[ before hitting the final target.

6

u/mralex215 Oct 21 '26

This is called "Thundering herd". If you think you ever are going to process 10k rps you should ALWAYS test at N + your buffer. Always.

26

u/mrswats Oct 21 '26

Try using something like k6

7

u/Alzyros Oct 21 '26

I second k6

17

u/[deleted] Oct 21 '26

[removed] — view removed comment

-3

u/Adonerbez Oct 21 '26

2

u/bot-sleuth-bot Oct 21 '26

Analyzing user profile...

Suspicion Quotient: 0.00

This account is not exhibiting any of the traits found in a typical karma farming bot. It is extremely likely that u/HystericalDigger is a human.

Dev note: I have noticed that some bots are deliberately evading my checks. I'm a solo dev and do not have the facilities to win this arms race. I have a permanent solution in mind, but it will take time. In the meantime, if this low score is a mistake, report the account in question to r/BotBouncer, as this bot interfaces with their database. In addition, if you'd like to help me make my permanent solution, read this comment and maybe some of the other posts on my profile. Any support is appreciated.

I am a bot. This action was performed automatically. Check my profile for more information.

23

u/reallydontaskme Oct 21 '26

We release it to prod, no better load testing environment /s

7

u/SadFaceSmith Platform Security Engineer Oct 21 '26

3

u/Abe_Bazouie Oct 21 '26

The first thing I’d change is stop modeling the test around “10k users” and start modeling it around what production actually does.
I usually want to know:
what does normal requests/sec look like?
what does peak look like?
what percentage of traffic hits each endpoint?
how long do users actually pause between actions?
how long do sessions live?
what does concurrency look like during a real peak?
Then build a few realistic user journeys around that instead of having every virtual user hammer the same path as fast as possible.
I’d also separate different tests.
A steady-state/load test should usually have a warm-up period so caches, connection pools, JIT, autoscaling, etc. can settle before you start measuring.
But cold-start behavior is still worth testing. I’d just test it separately instead of accidentally turning every load test into a cold-start test.
Same with stress testing. If I intentionally want to find the breaking point, then sure, ramp aggressively. But that answers a different question from “can we handle Tuesday afternoon traffic?”
If you have production telemetry, that’s gold. Build the traffic mix from real request distributions rather than guessing.
And watch more than latency. I’d be looking at DB connections, pool saturation, queue depth, CPU, memory, errors, retries, autoscaling behavior, and downstream dependencies.
One other thing: if your tool supports arrival-rate style testing, I prefer that for a lot of these scenarios. It lets you say “send roughly X requests/second” instead of coupling traffic generation to how fast the system responds.
Otherwise once the app slows down, your load generator can accidentally back off and make the system look healthier than it really is.

4

u/Duente_Zaibatsu Oct 21 '26

I used Gatling, it was free, we could create sustainable scenarios, like ramp up, ramp down, random and burst, that was reliable and computationaly cheap to emulate.

We used to test warm up, parallel start-up and cache and queue reliability.

I do not recall details, but our ramp was something like 0 - 2k - 500k in 1 minute intervals, and we had a producer / consumer / API pattern.

If I recall correctly, 150k Users per minute was our production expected usage at the average, and 250k at the peak.

It was expensive to test due to server costs, so we ran it about once a month for UAT and TOS validations

2

u/sp_dev_guy Oct 21 '26

Mirror traffic is lowest effort assuming you have 24hr traffic or dont need to be doing the stress tests at weird hours. Otherwise you need to analyze/capture your traffic footprint & rebuild it

1

u/kdotp5 Oct 21 '26

ramp/warmup helps but the real issue is you’re running a closed model. 10k VUs looping as fast as they can means your request rate is set by how slow your server is, which is backwards. real traffic is an arrival rate, people show up whether you’re slow or not

grab a day of prod logs and look at what sessions actually do. which flows, how many requests, gaps between them. think time is super long tailed irl, not sleep(2)

ramp over 10-15 min, hold steady 30+ min, only measure the steady part. still do one test where you slam it on purpose so you know where it falls over

k6 ramping-arrival-rate or gatling open injection both handle this out of the box

1

u/bezcurhq Oct 21 '26

One thing to check alongside the curve is the executor. ramping-vus is a closed model: a VU only starts its next iteration when the last one finishes, so once the system slows down the test quietly sends less load (k6's docs call this coordinated omission). ramping-arrival-rate starts new iterations at the rate you set no matter how slow responses get, which is closer to real users who show up independently. Keep the randomized sleeps inside each iteration as the think time.

1

u/JungleCatHank Oct 21 '26

Locust is good for this. It scales up users at a configurable rate so you can see where things start to bog down. You can also script requests in python to simulate user activity.

1

u/mralex215 Oct 21 '26
  1. there are services that allow you to do it. They emulate browser behavior. A lot of them use browsermob under the hood.
  2. you should have telemetry for all API calls on your backends. Your middleware request routing layer should take that data and dump it into prometheus or something like that. You can strip it before handing it to the end user or you can encrypt it. I would strip it.
  3. you should have ability to spinup AWS instances that will consume test requests from a queue and synchronize them across your test fleet so you can emulate thundering herd situation. You should *always* test the thundering herd. If you do not, you *will* go down on the thundering herd and it just so happens that the thundering herd typically is a very visible event so if you go down during it your reputation will take a massive hit.

-1

u/singh_abinashi Oct 21 '26

Your instinct is right: the 10k in 60 seconds script is testing your cold start behavior, not your capacity.

Real traffic ramps, pauses, and reuses warm state, so a test that skips all three measures a system your users never meet.

What worked for me as a shape: ramp in steps, hold each step long enough for caches and pools to reach steady state, and only then judge the numbers at that level.

The hold matters as much as the ramp.

A cache that looks fine at minute one of a step can be evicting hard by minute ten, and a pool that survives the jump can still leak connections slowly under held load.

Give each virtual user a think time distribution, not a fixed delay.

Zero pause traffic turns your test clients into a DDoS tool and produces the pool exhaustion you are seeing, because no real user fires the next transaction the instant the last one returns.

One more thing to separate: keep a cold start test, but label it as one.

Knowing how the system behaves from cold is useful.

It just should not be the run you tune capacity from.