Home » Java » Enterprise Java » Raw performance numbers – Spring Boot 2 Webflux vs Spring Boot 1

About Biju Kunjummen

Biju Kunjummen

Raw performance numbers – Spring Boot 2 Webflux vs Spring Boot 1

My set-up for the performance test is the following:

The sample applications expose an endpoint(/passthrough/message) which in-turn calls a downstream service. The request message to the endpoint looks something like this:

  "id": "1",
  "payload": "sample payload",
  "delay": 3000

The downstream service would delay based on the “delay” attribute in the message (in milliseconds).


Spring Boot 1 Application

I have used Spring Boot 1.5.8.RELEASE for the Boot 1 version of the application. The endpoint is a simple Spring MVC controller which in turn uses Spring’s RestTemplate to make the downstream call. Everything is synchronous and blocking and I have used the default embedded Tomcat container as the runtime. This is the raw code for the downstream call:

public MessageAck handlePassthrough(Message message) {
    ResponseEntity<MessageAck> responseEntity = this.restTemplate.postForEntity(targetHost 
                                                            + "/messages", message, MessageAck.class);
    return responseEntity.getBody();

Spring Boot 2 Application

Spring Boot 2 version of the application exposes a Spring Webflux based endpoint and uses WebClient, the new non-blocking, reactive alternate to RestTemplate to make the downstream call – I have also used Kotlin for the implementation, which has no bearing on the performance. The runtime server is Netty:

import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import org.springframework.web.reactive.function.BodyInserters.fromObject
import org.springframework.web.reactive.function.client.ClientResponse
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.bodyToMono
import org.springframework.web.reactive.function.server.ServerRequest
import org.springframework.web.reactive.function.server.ServerResponse
import org.springframework.web.reactive.function.server.bodyToMono
import reactor.core.publisher.Mono

class PassThroughHandler(private val webClient: WebClient) {

    fun handle(serverRequest: ServerRequest): Mono<ServerResponse> {
        val messageMono = serverRequest.bodyToMono<Message>()

        return messageMono.flatMap { message ->
                    .flatMap { messageAck ->

    fun passThrough(message: Message): Mono<MessageAck> {
        return webClient.post()
                .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
                .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
                .flatMap { response: ClientResponse ->

Details of the Perfomance Test

The test is simple, for different sets of concurrent users (300, 1000, 1500, 3000, 5000), I send a message with the delay attribute set to 300 ms, each user repeats the scenario 30 times with a delay between 1 to 2 seconds between requests. I am using the excellent Gatling tool to generate this load.


These are the results as captured by Gatling:

300 concurrent users:

Boot 1Boot 2




1000 concurrent users:

Boot 1Boot 2




1500 concurrent users:

Boot 1Boot 2




3000 concurrent users:

Boot 1Boot 2




5000 concurrent users:

Boot 1Boot 2




Predictably when the number of concurrent users remains low (say less than 1000) both Spring Boot 1 and Spring Boot 2 handle the load well and the 95 percentile response time remains milliseconds above the expected delay of 300 ms.

At higher concurrency levels, the Async Non-Blocking IO and reactive support in Spring Boot 2 starts showing its colors – the 95th percentile time even with a very heavy load of 5000 users remains at around 312ms! Spring Boot 1 records a lot of failures and high response times at these concurrency levels.

I have all the samples and the load scripts available in my github repo – https://github.com/bijukunjummen/boot2-load-demo.

Published on Java Code Geeks with permission by Biju Kunjummen, partner at our JCG program. See the original article here: Raw performance numbers – Spring Boot 2 Webflux vs Spring Boot 1

Opinions expressed by Java Code Geeks contributors are their own.

(0 rating, 0 votes)
You need to be a registered member to rate this.
2 Comments Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
Laurent BIZE
Laurent BIZE
4 years ago

Hello. There is a typo in the table, for 300 users : in Spring Boot 1 column,
max value is lesser than 99th percentile.
Thanks for your post.


Ferdinand von den Eichen
Ferdinand von den Eichen
4 years ago

Mind pushing it a bit further to see when Spring Boot 2 Starts collapsing?