Francisco Dorado

I am a software developer focused on back-end and specialized in Java and Spring.


Reactive vs Non-Reactive Spring Performance

(Reading time: 2 mins)
26 Jun 2019 » spring

Result Chart

The goal of this article is to compare the performance between Spring MVC (Non-Reactive) and Spring WebFlux (Reactive). For this task we have taken into account three differents implementations:

  • Using Spring MVC synchronous
  • Using Spring MVC asynchronous
  • Using Spring WebFlux


Using Spring MVC synchronous

For this implementation the next endpoints have been defined:

public Message findById(@PathVariable(value = "id") String id) {
    return nonReactiveRepository.findById(id).orElse(null);
public Message post(@Valid @RequestBody Message message) {

Using Spring MVC asynchronous

Java 8 CompletableFuture library has been used to get asynchronous methods.

public CompletableFuture<Message> findById(@PathVariable(value = "id") String id) {
    return CompletableFuture.supplyAsync(() -> nonReactiveRepository.findById(id).orElse(null));
public CompletableFuture<Message> post(@Valid @RequestBody Message message) {
    return CompletableFuture.supplyAsync(() ->;

Using Spring WebFlux

The reactive version including MongoDB Reactive Repository.

public Mono<Message> findByIdReactive(@PathVariable(value = "id") String id) {
    return reactiveRepository.findById(id);
public Mono<Message> postReactive(@Valid @RequestBody Message message) {

The Test

Using JMeter we have created a test with the next characteristics:

  • Each iteration will be composed by one create operation (POST) and one find operation (GET) to MongoDB.
  • For each test, we are defining the number of concurrent users/threads


  • MacBook Pro (15-inch, 2016)
  • 2,6 GHz Intel Core i7
  • 16 GB 2133 MHz LPDDR3


The results shown in the following table refer to a one-minute execution with a one-second ramp-up period.

Result Table

Now, we can extract the following conclusions based in our tests:

  • Spring MVC Sync vs Async are similar in performance but with the asynchronous implementation we have a less error rate at beginning of the execution
  • Spring WebFlux allows an increment in performance greater than 60% respect to Spring MVC


[1] Link to the project in Github