Skip to content

    System Design

    Load, Stress and Soak Testing

    Learn what load, stress, soak and spike tests each answer, open versus closed workloads, and run a deterministic Spring model that counts, not times.

    By Published 11 min read

    Share

    Standard lessonintermediateSpring Boot labBackend System Design

    Before this: The Testing Pyramid for Backend Systems

    What you'll learn: By the end of this lesson you will be able to say which question a load, stress, soak, spike and breakpoint test each answers, write a pass criterion before running one, tell an open workload from a closed one and say why it matters, explain why a short test can pass a system that a long one breaks, and read a deterministic Spring lab that counts accepted and rejected requests in each kind of run. The lab is a model; it is not a benchmark and it shows no timings.

    Think of a lift. The plate inside says how many people it carries: that is the number you check on an ordinary day. An inspector might load it past the plate to see how it fails and whether it still works afterwards. And a lift that runs fine for an hour can still wear out a cable over a year. Three different questions, three different tests, and none of them is answered by riding the lift once.

    A service has the same three questions. Does it meet its goals at the traffic you expect? What happens beyond that, and does it recover? Does it stay healthy for as long as it will really run? The earlier lessons on load shedding and retry storms, backpressure and connection pooling explain what happens inside an overloaded service. This lesson is about how to put a service under load on purpose and read the result.

    Verified with Spring Boot 4.1.2, Java 25 and the Grafana k6 documentation, on 2026-12-02. k6 is cited for its definitions; no load tool is run in this lesson.

    The core idea

    A performance test is an experiment: a stated load shape, a stated duration, and a pass criterion written before the run. The shape and duration decide which question you are asking, and the criterion decides whether you learned anything.

    Three illustrations run through the lesson:

    • Minimal example: the lab, a Spring controller behind a counting load model, with four runs.
    • Realistic example: ShopStream's order service before a sale, in "In practice".
    • Failure example: a connection leak that a 100-tick run never sees and a 1,000-tick run exposes.

    The test types and what each asks

    The k6 documentation names these shapes. The durations are its typical values, not rules.

    Type Question (k6's wording, shortened) Typical shape
    Smoke Does the script work and does the system cope with minimal load? Low load, seconds or minutes
    Average load How does the system perform under expected normal conditions? Average production load, 5 to 60 minutes
    Stress How does it perform at its limits when load exceeds the expected average? Above average, 5 to 60 minutes
    Soak Is it reliable and performant over extended periods? Average load for hours
    Spike Does it survive sudden, short, massive increases? Very high load for a few minutes
    Breakpoint Where are the capacity limits? Load rises until the system breaks

    The k6 page on load testing adds two practical points. Know the number of users and the typical throughput before you start, taken from monitoring or from the business. And plan a ramp-up of about 5% to 15% of the total duration, then hold the load for at least five times the ramp-up length. It also warns that tests can crash applications and staging environments, so start small.

    The soak page says what a long run looks for: "response time degradation, memory or other resource leaks, data saturation, and storage depletion", and that it checks for "common performance defects that show only after extended use". Its typical durations run from hours to 48 to 72 hours.

    A load test: generator, service, shared resourcesLoad generator to Order service (requests); Order service to Connection pool (borrow); Order service to Database (queries); Order service to Monitoring (metrics)Load generator: profile of arrivalsLoad generatorprofile ofarrivalsOrder service: system under testOrder servicesystem under testConnection pool: shared resourceConnectionpoolshared resourceDatabase: downstreamDatabasedownstreamMonitoring: errors, saturationMonitoringerrors,saturationrequestsborrowqueriesmetrics

    Figure 1. What a load test connects. How to read this: the generator is the only thing the tester controls. Everything the service shares, such as the connection pool, can run out; the monitoring on the lower arrow is how you see it happen.

    Open and closed workloads

    A generator can drive load in two ways. In the k6 documentation's words, "in the closed model, VU iterations start only when the last iteration finishes", whereas "in the open model, on the other hand, VUs arrive independently of iteration completion". When a closed-model test stresses a system and it slows, the test waits, which tapers the arrival rate; k6 notes that "in some testing literature, this problem is known as coordinated omission".

    Real users behave more like an open workload: people arrive whether or not the service is keeping up. A closed model asks "how fast can N users loop", an open model asks "what happens at this arrival rate". The stress question is nearly always the open one, because the failure you want to see is arrivals outrunning capacity. The lab's generator is open: its arrivals per tick come from a fixed profile and do not wait for completions.

    Pass criteria first

    A run without a stated pass criterion is a demo. Write the criterion before the run:

    • Error budget: the share of failed or rejected requests allowed at this load.
    • Latency target: a percentile and a limit, for example "the 99th percentile under a number the product agreed". Percentiles belong to real runs on real hardware and are not shown in the lab; see the tail latency lesson, written separately.
    • Saturation limits: pool use, queue depth and CPU stay below stated levels.
    • Recovery: after the load drops, the queue drains and the error rate returns to normal.
    stateDiagram-v2 accTitle: Service behaviour as load rises and falls accDescr: A service is healthy below capacity. Above capacity its queue grows and it becomes saturated. When the queue is full it sheds load by rejecting requests. When load falls it drains the queue and recovers. A leak can leave it stalled even at normal load. [*] --> Healthy Healthy --> Saturated: arrivals exceed capacity Saturated --> Shedding: queue full Shedding --> Recovering: arrivals drop Saturated --> Recovering: arrivals drop Recovering --> Healthy: queue empty Healthy --> Stalled: leaked resource exhausted Stalled --> [*]: restart

    Figure 2. The states a stress and a soak test look for. How to read this: a stress test drives the service from Healthy to Saturated and Shedding and checks it reaches Recovering. A soak test looks for the quieter path from Healthy straight to Stalled.

    Build it: a deterministic load model in Spring

    This is the minimal example, and it is a model. The lab is examples/spring-labs/labs/load-stress-soak-model/. It is not a benchmark and it shows no timings. Time is a count of ticks, the service is a few counters, and no thread, clock, socket or load tool is involved, so the output is the same on every machine. That is deliberate: wall-clock numbers from a laptop would say nothing about any real service.

    The load generator sends each tick's arrivals to a real Spring MVC controller through MockMvc (in-process, no server, no Docker) and counts the status codes. The controller answers 202 when an order is queued and 503 when the queue is full.

    Goal. See, with counts only, what a load test, a stress test and a soak test can and cannot find in the same service.

    Setup. From examples/spring-labs:

    ./gradlew :labs:load-stress-soak-model:test

    How it works. The service model completes at most 10 orders per tick, queues up to 50, and borrows a connection from a pool of 100 for each order. In the two soak runs every tenth completed order never returns its connection:

    public void tick() {
        int budget = capacityPerTick;
        while (budget > 0 && queued > 0 && pool.hasFreeConnection()) {
            queued--;
            budget--;
            completed++;
            pool.complete();
        }
    }

    The four runs: load is 8 arrivals per tick for 100 ticks. stress starts at 4 per tick and adds 4 every 10 ticks up to 40, then 60 quiet ticks. soak-short is the load run with the leak. soak-long is the same leak for 1,000 ticks.

    Expected output, captured from a real run (Spring Boot 4.1.2, compiled with --release 25):

    # Deterministic load model: counts per tick, not timings. This is not a benchmark.
    # Service: 10 orders per tick, queue limit 50, connection pool 100, leak every 10 completions where stated.
    
    run         ticks   sent    202    503 completed peakQ  endQ  firstReject   firstStall leaked
    load          100    800    800      0       800     8     0            -            -      0
    stress        160   2200    960   1240       960    50     0           33            -      0
    soak-short    100    800    800      0       800     8     0            -            -     80
    soak-long    1000   8000   1050   6950      1000    50    50          131          125    100
    
    # firstReject: first tick with a 503. firstStall: first tick where work was waiting and nothing finished.
    # '-' means it never happened.

    What to notice. The load run passes: 800 sent, 800 accepted, nothing queued at the end. The stress run finds a breaking point: the first rejection comes at tick 33, when the arrival rate has reached 16 per tick against a capacity of 10, and 1,240 orders are rejected. It also recovers: the queue is empty at the end and every accepted order completed (960 of 960). The soak-short run passes with 80 connections leaked of 100, so a 100-tick test would call this service healthy. The soak-long run stalls at tick 125, when the pool is exhausted, and from then on nothing completes: only 1,000 of 8,000 orders finish, the queue sits full and 6,950 are rejected. The same leak at the same load, found only by the longer run.

    The lab model: generator, controller, gate, poolLoad generator to Controller (arrivals); Controller to Gate (offer); Gate to Pool (complete)Load generator: MockMvc, per tickLoad generatorMockMvc, per tickController: 202 or 503Controller202 or 503Gate: queue limit 50Gatequeue limit 50Pool: 100, leaksPool100, leaksarrivalsoffercomplete

    Figure 3. What the lab actually runs. How to read this: arrivals enter the controller, the gate queues or rejects them, and each finished order touches the pool. A leak in the last box eventually freezes the gate.

    Choosing a test

    flowchart TD accTitle: Which performance test answers which question accDescr: A decision flow. If the question is whether the system meets goals at expected traffic, run a load test. If it is what happens above that, run a stress or breakpoint test. If it is how it survives a sudden burst, run a spike test. If it is whether it stays healthy for a long time, run a soak test. A[What do you need to know?] --> B{Meets goals at expected traffic?} B -- yes, check --> C[Load test] B -- beyond that --> D{Sudden burst or gradual?} D -- sudden --> E[Spike test] D -- gradual --> F[Stress or breakpoint test] A --> G{Stays healthy for as long as it runs?} G -- check --> H[Soak test]

    Figure 4. The question picks the test. How to read this: start from what you need to know. Most services need a load and a soak test routinely and a stress or breakpoint test before a known peak.

    Concern Short load test Stress test Long soak test
    Finds capacity limits Not by design Yes No
    Finds slow leaks No Rarely Yes
    Cost to run Low Medium High: time and an environment held for hours
    Risk to shared environments Low High Medium

    In practice: ShopStream's order service before a sale

    This is the realistic example, an educational scenario on the course's running example ShopStream. Every number is illustrative.

    This is a realistic scenario, not a case history.

    The situation

    ShopStream plans a weekend promotion and expects far more orders than an ordinary weekend. The order service has passed its tests and a short load test at the usual traffic. The team wants to know three things: will it hold at the expected peak, what happens above it, and will it stay healthy through a three-day event.

    Starting architecture

    ShopStream order path under testLoad generator to Order service (orders); Order service to Payments stub (authorise); Order service to Order database (write)Load generator: open arrivalsLoad generatoropen arrivalsOrder serviceOrder servicePayments stub: test doublePayments stubtest doubleOrder database: test copyOrder databasetest copyordersauthorisewrite

    Figure 5. A test environment with a payments stub and a database copy. How to read this: the real payment provider is replaced by a stub, because load must never reach a third party that did not agree to it.

    Options considered

    Option What it tells you Weakness
    A. One short run at expected peak Whether the goals hold briefly Says nothing about limits or leaks
    B. Load, then stress with an open workload, then an overnight soak All three questions Needs a production-like environment and time
    C. Test only in production during the sale Real traffic The first failure is a customer's

    The decision

    Option B, with the pass criteria written first: an error budget at expected peak, a pool use limit, a queue that must drain after the stress run, and a soak in which pool use and queue depth stay flat. The shape of the stress run is a ramp with a hold, as the k6 guidance advises, not repeated rises and falls.

    Rollout and verification

    Smoke first, then the load test at the agreed average, then stress, then the soak overnight. For each run the team records the criteria, the environment and the result next to the commit under test. Verification is that every criterion was met, or that a miss is written up with an owner. Because the environment is smaller than production, the results are read as "this build holds this load in this environment", not as a production forecast.

    The 2 a.m. failure

    The overnight soak shows pool use climbing in a straight line. By morning the order queue is full and orders fail, while CPU is low. The checks: compare pool use with completed orders over time, look for requests that borrow a connection and exit on an error path without returning it, and confirm the leak is steady, not bursty. The mitigation is to restart and fix the error path; the lasting fix is a soak test in the pipeline for every release that touches data access, with an alert on pool use that rises without traffic rising.

    Architect's notes

    • Write the question and the pass criterion first. A test with no criterion cannot fail.
    • Prefer an open workload for stress. It keeps arrivals coming when the service slows, which is when you want to see the failure.
    • Size the run to the defect. A leak that costs one connection per hundred requests needs more requests than a short test sends.
    • Say what the environment is. A smaller or differently configured environment gives results about that environment.
    • Never aim load at third parties. Stub or sandbox them.
    • Do not treat model output as capacity. The lab's capacity of 10 per tick says nothing about any real service.

    Common mistakes

    • Declaring success from a short run. The soak-short row passed with 80 of 100 connections already gone.
    • Testing only the happy rate. Load at the expected average cannot show what happens above it.
    • A closed workload for a stress test. The generator slows with the service and hides the overload.
    • Averages only. An average hides the tail; use percentiles in real runs.
    • Running against shared staging unannounced. Load can crash staging, as the k6 guidance warns.
    • No recovery check. A service that rejects load is only half the story; does it drain afterwards?

    Key takeaways

    • Load, stress and soak tests ask different questions: meets goals at expected load, behaviour above it, health over time.
    • Write the pass criterion before the run.
    • Open workloads keep arrivals independent of completions; closed ones taper as the system slows.
    • A short test can pass a system that a long one breaks.
    • The lab is a deterministic model that counts; it is not a benchmark and shows no timings.

    Practice exercises

    Exercise 1 (20 min). Run the lab and, from the table alone, say which test found each problem and which could not.

    Exercise 2 (45 min). Change the leak to every 20th completion and predict whether soak-long still stalls and at which tick before you run it. Restore the code and re-run.

    Exercise 3 (1 hour). Raise the queue limit to 500 and re-run the stress profile. Explain what a larger queue buys and what it costs in a real service.

    Exercise 4 (2 hours). Write the load, stress and soak plan for ShopStream's checkout: the shape, the duration, the pass criteria and the environment, and what you would not test.

    Official documentation

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments