Scrivio Interview library
ScenarioIntermediate6 min read · updated 12 November 2026

Plan a load test for a new Spring Boot order service before launch. What do you test, how, and what do you collect?

I would set targets from expected peak traffic: throughput, p99 latency and error rate. The test runs against production-like data volumes, payloads and dependencies, or realistic stubs that add latency, and the JVM is warmed up before measuring. I would run a ramp to find the breaking point, a soak test to find leaks and a spike test for sudden bursts, and collect JVM, pool and database metrics and profiles during the test, not only the client-side results.

Why this question is asked

A new order service that has never been under real load is a risk the business can see on launch day, when the marketing email goes out and traffic arrives all at once. A load test is how we find the bottleneck first, but a careless one gives false confidence. Interviewers ask this scenario to see whether we know what makes a test realistic and what evidence to collect. In this answer, we will set targets, prepare a realistic environment, warm up the JVM, run the three kinds of test and decide what to collect and how to read it.

1Start From Targets, Not From the Tool

A load test answers a question, so we write the question down first. We get the expected peak from the business, for example 300 orders per minute on a normal day and 1,500 per minute in the first hour of a sale. Orders are not the only traffic: each order may come with ten reads of the order status, so we model the whole mix of endpoints, not just POST /orders.

The targets then say what passing means: the service handles 1,500 orders per minute, which is 25 per second, plus 250 status reads per second, with p99 latency under 400 ms for creating an order and under 100 ms for reads, and an error rate below 0.1 percent. We also add headroom, usually testing to at least twice the expected peak, because forecasts are often wrong on launch day.

Load test targets for the order service
MeasureExpected peakTest to (2x)Pass if
POST /orders25/s50/sp99 < 400 ms
GET /orders/{id}250/s500/sp99 < 100 ms
Error rate--< 0.1%
DB CPU at test peak--< 70%

2Make the Environment and Data Realistic

Results only mean something if the system under test behaves like production. Data volume matters most: a query that is fast on a table of 1,000 rows can be slow on 50 million, because the database chooses a different plan or the index no longer fits in memory. So we load the database with a production-like volume and distribution, for example generated data shaped like production rather than real customer data, to avoid privacy issues.

Payloads should be realistic too: orders with 1 to 30 lines, not always one. Dependencies are the hard part. If the order service calls payment and inventory, we either use real test instances of them, or stubs that answer with realistic latency and occasional errors. A stub that answers in 0 ms hides the effect of slow dependencies on threads and pools, which is often the real bottleneck.

YAML
# WireMock-style stub for the payment service: realistic latency, not 0 ms
{
"request": { "method": "POST", "urlPath": "/payments" },
"response": { "status": 201,
"delayDistribution": { "type": "lognormal", "median": 120, "sigma": 0.4 } }
}
# median 120 ms with a realistic long tail

3Warm Up the JVM Before Measuring

A freshly started JVM runs our code in the interpreter, then compiles the hot methods with the JIT, just-in-time, compiler as it sees them used. The first minutes are slower, and class loading, connection pool filling and cache warming add to it. If we measure from the first second, we mix warm-up with steady state and the results are noisy and pessimistic.

So every run starts with a warm-up phase, for example 3 to 5 minutes at moderate load, and we discard it from the results. Separately, if fast startup under load matters, for example for autoscaling, we measure the cold behaviour as its own scenario on purpose.

4Three Tests: Ramp, Soak and Spike

A ramp test increases the arrival rate step by step, say from 10 to 100 orders per second over 30 minutes, until latency or errors break the targets. The point where that happens is the breaking point, and the resource that hit its limit first, CPU, the connection pool, a downstream or the database, is the bottleneck. We use an open, arrival-rate model so the test keeps sending load when the service slows down.

A soak test holds expected peak load for hours, for example 4 to 8 hours. It finds problems that only grow with time: memory leaks, connections that are never returned, log files filling disks, caches without size limits.

A spike test jumps from normal load to several times peak in seconds, like the marketing email. It checks that the service survives the jump, that autoscaling reacts in time and that it recovers when the spike ends.

Step throughLoad test plan for the order service
  1. Warm up 5 minmoderate load, results discarded
  2. Ramp: 10 -> 100 orders/s over 30 minfind the breaking point and bottleneck
  3. Breaking point above 2x peak?
    YesContinueNoFix the bottleneck, re-run the ramp
  4. Soak: peak load for 6 hleaks, pool exhaustion, disk
  5. Spike: 5x peak for 2 minsurvive, scale, recover

5 steps in order. Play them, or step through them one at a time.

5Collect Server-Side Evidence During the Test

Client-side results say that latency rose at 60 orders per second; they do not say why. So we collect server-side metrics during every run, on the same timeline. From the JVM: CPU, heap after garbage collection, GC pause times and thread counts. From the pools: HikariCP active and pending connections, HTTP client pool usage and Tomcat busy threads. From the database: CPU, active sessions, slow queries and lock waits. From dependencies: their latency as seen by our clients.

We also take profiles while the load is running, for example a Java Flight Recorder recording or an async-profiler flame graph at the breaking point. That shows where CPU or waiting time goes, so we can fix the actual cause.

Text
# During the ramp, at 60 orders/s:
hikaricp_connections_active 10 / 10 # pool full
hikaricp_connections_pending 45 # threads waiting
http_server_requests p99 POST /orders 1.9 s
db: top query by time SELECT ... FROM order_line WHERE order_id = ? (seq scan)
# Conclusion: missing index on order_line(order_id), not a small pool

Notice what this evidence prevents. Looking only at the pending connections, someone would raise the pool size. With the database view, we see that a missing index makes each query slow, and that is the real fix.

6Follow-up questions

Should we load test in production instead?

Before launch, the service has no production traffic to observe, so a dedicated environment is usually the right place for the first tests. After launch, carefully controlled tests in production, such as synthetic traffic at quiet times with isolated test data, can complement it. For a launch, I would do both: an environment test to find bottlenecks and a smaller production rehearsal to check the real infrastructure.

How long should a soak test run?

Long enough for slow problems to show, which is at least a few hours and ideally covers a full cycle of scheduled jobs, cache expiry and connection lifetimes. A leak of 10 MB per hour will not show in 20 minutes but will crash a 1 GB heap within days.

What do you do when the breaking point is below target?

Find the bottleneck from the server-side evidence, fix it, and run the ramp again, one change at a time so we know what helped. Common fixes are an index, a smaller transaction, a missing timeout on a downstream or a cache. Adding pods only helps if the bottleneck is the service itself and not a shared database.

7Conclusion

In this answer, we planned a load test for a new order service. We set targets from expected peak traffic with headroom, prepared production-like data, payloads and dependency stubs with realistic latency, warmed up the JVM before measuring, and ran a ramp for the breaking point, a soak for leaks and a spike for sudden bursts. During each run we collected JVM, pool and database metrics and profiles, so we could explain the results and fix the real bottleneck.

What to say in the interviewAbout 80 seconds aloud

Open with

I would start with targets from the business forecast: peak orders per second, the realistic mix of reads and writes, p99 latency per endpoint and an error rate, and I would test to about twice the peak.

Then, if they want more

Then I would make it realistic: a database loaded with production-like volume, realistic order sizes, and either real test instances of payment and inventory or stubs with realistic latency and some errors, because a zero-millisecond stub hides pool exhaustion.

Each run starts with a few minutes of warm-up that I discard, because the JIT compiler, class loading and pool filling distort the first minutes.

Then three tests: a ramp with an arrival-rate model to find the breaking point and the bottleneck, a soak at peak for several hours to catch leaks and connection problems, and a spike to several times peak to check survival, autoscaling and recovery.

During every run I collect server-side data on the same timeline: GC and heap, Hikari active and pending, Tomcat threads, database CPU and slow queries, plus a JFR recording or flame graph at the breaking point. Client numbers tell me when it breaks; the server data tells me why, so I fix the actual bottleneck instead of guessing.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Plan a load test for a new Spring Boot order service before launch. What do you test...": https://scrivio-interview-library.netlify.app/spring-boot/service-performance/9fdaa96e85/