zero gravitySOLUTIONS
← All insightsJAVA & PERFORMANCE / BENCHMARK METHODOLOGY

A fair Spring MVC and WebFlux benchmark

QUICK ANSWER

A fair MVC–WebFlux comparison holds business semantics, resource budgets, dependencies, and offered load constant while documenting execution-model differences. Compare latency, useful throughput, errors, and operational complexity across realistic workloads; a single fastest endpoint cannot select an architecture.

Inside this article 5 sections

A benchmark can accurately measure two programs and still make an unfair architecture comparison. If one uses a warm cache and the other performs a database read, or one accepts more concurrent connections, the result does not isolate the framework choice. Begin by stating the decision the experiment should inform.

For example: can an account-reporting service sustain a declared arrival rate within its latency objective and memory budget while one dependency becomes slow? That question creates a useful experiment. “Which framework is faster?” leaves too many assumptions hidden.

Separate controlled isolation from realistic architecture

Use two comparison lanes. In the controlled lane, keep business behavior, dependency latency, resource allocation, and response payload equivalent while varying the execution model as deliberately as possible. This helps identify mechanisms. In the realistic lane, implement each stack in an idiomatic way appropriate to the actual product and report the resulting differences openly.

The second lane may compare JDBC with a reactive driver, or include virtual threads in the MVC variant. Those are valid architecture choices, but they change more than the web framework. Name every variant precisely. An MVC result using platform threads should not be presented as evidence about all MVC configurations, and a WebFlux result with blocking persistence should not represent a fully non-blocking design.

Two complementary benchmark lanes
LaneHold constantWhat it can answer
Controlled mechanismBusiness operation, resource budget, dependency behavior, payload, arrival patternHow the declared execution variants behave under a known constraint
Realistic implementationProduct requirements and deployment budgetWhich complete design best meets the service objective and operating needs
The realistic lane permits justified implementation differences. Those differences must remain visible when interpreting the result.

Publish enough environment detail to repeat the run

Create a versioned experiment directory containing application variants, workload definitions, dependency fixtures, and run instructions. Record the JDK vendor and build, Spring Boot and framework versions, client and driver versions, operating system, container limits, processor allocation, heap settings, and relevant garbage collector configuration.

Include server and client connection limits, database pool size, executor settings, request timeouts, and retry policies. Record the database version, schema, indexes, dataset size, and cache preparation. A small default difference in a pool can dominate the result while remaining invisible in the application source.

Store workload seeds and fixture versions with the results. Separate raw observations from derived charts so calculations can be inspected. If the environment is shared, record competing work or move the experiment to a controlled allocation. Run the load generator on sufficient separate capacity and measure whether it becomes the bottleneck.

Use workloads that expose different constraints

A small in-memory response is useful for detecting configuration mistakes, but it rarely represents a business service. Add a database operation, a variable-latency external call, a mixed read-and-write flow, and a CPU-heavy transformation only if those resemble the product. Keep response semantics and error handling equivalent within each scenario.

Test steady load, bursts, and dependency degradation. Declare whether arrivals follow a fixed schedule or depend on previous completions. A closed-loop client reduces offered traffic when responses slow, which can conceal the backlog produced by independent customer arrivals. Report offered load and completed load so that effect remains visible.

Warm up each variant deliberately and retain the warm-up observations separately. JVM compilation, cache state, connection establishment, and class loading can change early behavior. Also measure cold starts separately if they matter to the deployment. Combining warm and cold behavior into one unexplained average makes neither case understandable.

Measure useful work and failure behavior together

Report successful business completions, request percentiles, errors, rejections, timeouts, CPU, memory, and dependency utilization. Include the count and observation interval behind tail percentiles. Aggregate compatible histograms when combining instances; averaging per-instance p99 values does not produce a fleet p99.

Inspect queueing locations. One variant may consume less thread memory while buffering more pending requests. Another may reject earlier and protect dependency latency. Neither is inherently the winner without the service objective. A throughput gain accompanied by unbounded waiting is different from a gain at the required latency and error budget.

Measure recovery after the disturbance. Stop or slow a dependency, restore it, and observe how long outstanding work persists. Check cancellation, connection release, and whether retries amplify the recovery load. Framework selection should account for behavior outside the smooth steady-state interval.

Reject conclusions that the experiment cannot support

Repeat runs and vary their order to reduce dependence on one favorable sequence. Investigate large variance before presenting a winner. Keep the raw result even when it contradicts the expected outcome. A comparison that changes several settings until one stack wins is a tuning story, not an isolated framework measurement.

Finish with a bounded conclusion: which declared variant met which objective, under which resource and workload assumptions, with what implementation and operating cost. The execution-model guide frames the choice, and p99 analysis explains tail interpretation. Architecture design turns those findings into a decision without claiming that one local experiment ranks every Java application.

FROM INSIGHT TO ACTIONSoftware architecture consulting

Choose a Java execution model with credible evidence.

We can build representative experiments and interpret performance alongside failure behavior and implementation effort.

Explore architecture consultingDiscuss your architecture

Start with your goals.
We’ll work through the next step together.