1. Introduction

In this tutorial, we’ll explore the @Async annotation in Spring MVC, and then we’ll get familiar with Spring WebFlux. Our goal is to have a better understanding of the difference between these two.

2. Implementation Scenario

Here, we want to choose a scenario to show how we can implement a simple web application with each of these APIs. Moreover, we’re especially interested to see more about thread management and blocking or non-blocking I/O in each case.

Let’s choose a web application with one endpoint that returns a string result. The point here is that the request will pass through a Filter with a small 200ms delay, and then the Controller needs 500ms to calculate and return the result.

Next, we’re going to simulate a load with  Apache ab on both endpoints and monitor our app behavior with  JConsole.

It may worth mentioning that in this article, our goal is not a benchmark between these two APIs, just a small load test so we can trace the thread management.

#reactive #spring mvc #webflux #spring-boot

Spring MVC Async vs. Spring WebFlux
14.75 GEEK