--- title: "MockServer Performance Benchmarks: Throughput & Latency" shortTitle: "Scalability & Latency" description: "MockServer performance benchmarks: one instance serves 32,000+ req/sec at sub-millisecond median latency, with flat request matching as expectations scale." layout: page pageOrder: 3 section: 'Performance Testing' subsection: true sitemap: priority: 0.8 changefreq: 'monthly' lastmod: 2026-06-24T08:00:00+01:00 keywords: mockserver performance, mockserver benchmark, mock server throughput, api mock latency schema_faq: - question: "How fast is MockServer?" answer: "On six CPU cores a single instance holds sub-millisecond median latency up to 32,000 requests/sec, saturating near 36,000 req/s. Latency stays flat until that knee — p50 is 0.19 ms, p95 around 4 ms — then degrades predictably rather than collapsing." - question: "How many requests per second can MockServer handle?" answer: "A single six-core instance sustains up to 32,000 requests/sec at sub-millisecond median latency, saturating near 36,000 req/s. Beyond one instance, run several instances behind a load balancer — serving capacity scales horizontally." - question: "Does MockServer slow down with many expectations?" answer: "No. MockServer indexes expectations so each request is compared only against a small candidate set rather than scanning every expectation. At 5,000 expectations matching is up to 177× faster than a naive linear scan, keeping matching cost nearly flat as expectations grow." - question: "How do I tune MockServer for high throughput?" answer: "The most impactful lever is the in-memory request log: set maxLogEntries lower or disable logging (disableLogging=true) to free heap and reduce GC pressure. Additional levers include the native epoll transport on Linux, thread-pool sizes, and forward-proxy connection pooling. See the Scalability Configuration section for details." ---

A single MockServer instance holds sub-millisecond median latency up to 32,000 requests/sec on six CPU cores, and request matching stays flat — up to 177× faster than a linear scan — as you scale to thousands of expectations.

Page Question it answers
Scalability & Latency How much traffic can one instance serve as a mock?
Load Injection How do I drive load from MockServer?
Load Injection Performance How much load can MockServer inject, and how does it scale?

MockServer is built for high throughput and low, predictable latency from a single instance. The figures below come from an automated performance suite that runs on a dedicated, core-pinned CI machine; every chart is regenerated from the measured data on each run, so what you see is reproducible rather than cherry-picked. Jump to how MockServer is performance tested for the methodology, or run the suite yourself from mockserver-performance-test/.

Performance at a glance

 

As offered load increases, achieved throughput tracks it almost exactly while latency percentiles stay flat — right up to the point the single instance saturates. That flat region is the headroom you can rely on; beyond it, latency rises predictably rather than collapsing.

MockServer throughput vs latency: latency stays flat as throughput increases until the instance saturates, and achieved throughput tracks offered load  

Mock servers are often run with hundreds or thousands of expectations. MockServer keeps matching cheap at scale by narrowing each request to a small set of candidate expectations instead of testing every one. The difference grows with the number of expectations:

Request matching time per request stays flat with MockServer's candidate index as the number of expectations grows, versus a steeply rising linear scan  

Even at the knee — around 32,000 requests/sec — the latency tail stays tight: a 0.19 ms median, a p95 of about 4 ms and a p99 under 10 ms.

MockServer response latency distribution at the throughput knee showing p50, p90, p95, p99 and p99.9  

The same actions measured over HTTP/1.1 and over HTTPS with HTTP/2 show that TLS and HTTP/2 add only a fraction of a millisecond — even a forwarded request or a large templated response stays within single-digit milliseconds:

Median latency by action (match, forward, template, large body) over HTTP/1.1 versus HTTPS with HTTP/2

What makes MockServer scale

The throughput and latency above come from a few deliberate design choices:

Most of these are configurable — thread-pool sizes, native transport, and matcher behaviour are covered under scalability configuration below.

 

How MockServer is performance tested

The numbers on this page are produced by a performance suite (mockserver-performance-test/) built around k6 for load generation and the JMH microbenchmark harness for component-level measurement. A few principles make the results trustworthy:

Measurement environment for the figures on this page: a single MockServer instance (current snapshot build) pinned to six CPU cores on a dedicated CI host, running the low-pause ZGC garbage collector with an 8 GB heap and full request logging enabled (the default — every request is recorded for later verification). The load generator runs on separate cores so it never steals cycles from the server. Real-world throughput and latency depend on your hardware, core count, payload size, expectation complexity and JVM/configuration tuning — more CPU cores and disabling request logging both raise peak throughput — so treat these as a solid reference and benchmark your own workload.

Detailed results

Throughput vs latency

Offered request rate against achieved throughput and response-latency percentiles for a single instance matching a simple expectation:

offered req/sachieved req/sp50p95p99errors
2,0001,9950.170.260.390%
4,0003,9910.180.290.400%
8,0008,0000.150.220.290%
16,00016,0000.160.280.500%
32,00031,7510.194.149.620%
48,00036,32423.12125.14195.660%
64,00030,87197.36170.66230.510%
80,00033,041112.65181.17262.940%

Latencies are in milliseconds. Achieved throughput tracks the offered rate up to about 32,000 req/s; beyond that the six-core instance saturates near 36,000 req/s and latency climbs predictably rather than collapsing. (More CPU cores raise the ceiling; this run pins the server to six.)

These figures are per instance. The ~36,000 req/s saturation point is the throughput of a single six-core instance — you scale beyond it by adding instances. Scaling beyond one instance: for more serving capacity (handling more inbound mock traffic) or high availability, run several instances as a cluster behind a load balancer — see Centralised Deployment. To drive more load injection (generating more outbound traffic with Load Scenarios), run injector instances in parallel — see Load Injection Performance, which measures how injected throughput scales near-linearly with the number of instances.

Matcher scaling (time per request match)

Microbenchmark of a single request match against a growing set of literal expectations, worst case (no match, so every candidate is examined): MockServer's candidate index versus a naive linear scan.

expectationslinear scancandidate index (default)speed-up
10.34 µs0.35 µs
102.3 µs0.21 µs~11×
10021 µs0.32 µs~67×
1,000218 µs1.5 µs~147×
5,0001,378 µs7.8 µs~177×

Times are microseconds per match. At one expectation the index adds negligible overhead; as expectations grow it keeps matching cheap where a linear scan grows roughly linearly with the number of expectations.

Tuning for your workload

The defaults are tuned for general use. For sustained high throughput, large payloads, or long-running instances, the most effective levers are memory/log sizing and a few scalability settings — covered in detail below. The single most common cause of an instance slowing down over time is the in-memory request log filling the heap; see memory & troubleshooting.

{% include_subpage _includes/clustering.html %} {% include_subpage _includes/performance_configuration.html %}

Historical benchmarks (Apache Bench & Locust, Java 13)

The results below are from an earlier benchmarking exercise and are kept for reference. They are historical and indicative — measured on an older Java 13 JVM on specific hardware using a closed-model client-count load (which is subject to coordinated omission), so they are not directly comparable with the open-model figures above. They showed an average of 1.58 ms and a p99 of 4 ms for 150 parallel clients sending 95,228 requests per second.

The scenario was four basic expectations (method, path and headers), with a GET request matching the third expectation. MockServer was run on a Java 13 JVM with:

java -Xmx500m -Dmockserver.logLevel=WARN -Dmockserver.disableLogging=true -jar ~/.m2/repository/org/mock-server/mockserver-netty/{{ site.mockserver_version }}/mockserver-netty-{{ site.mockserver_version }}-no-dependencies.jar -serverPort 1080

Note: the benchmark used -Dmockserver.disableLogging=true to disable all logging and log event processing, with -Dmockserver.logLevel=WARN as a safeguard. To suppress only system-out while still recording log events for verification, use -Dmockserver.disableSystemOut=true instead.

 

Apache Bench results

Apache Benchmark was executed as:

ab -k -n 10000000 -c <parallel clients> http://127.0.0.1:1080/simple
parallel clients50%66%75%80%90%95%98%99%requests/smean
100000000077,1220.13
501111111185,7650.58
1001111122392,8461.08
1501222223495,2281.58
2503333457886,4702.89
5006666778983,2096.01
7509910101111121575,5549.93
1000111213131416172175,42313.26
2000242425262729313582,19124.33
3000373940404346515878,17138.38
4000525557596470829173,55254.38
50006567707175799010274,06567.51
6000808488909710412213770,43285.19
 

Locust results

Locust was executed as:

locust --loglevel=WARNING --headless --only-summary -u <parallel clients> -r 100 -t 180 --host=http://127.0.0.1:1080
parallel clients50%66%75%80%90%95%98%99%99.90%99.99%requests/smean
100011111255110
500011111235500
10001111223481000
15011112334561490
2502334567815462452
500223345679464792
7503456810121429346993
10003466810131636529093
200047101222344959871101626.148
30005178991101601802202402903102629.9254