Spring MVC Async vs. Spring WebFlux

Spring MVC Async vs. Spring WebFlux

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. Learn about Spring Async and Spring WebFlux both theoretically and practically with a basic load test

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

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Spring MVC Async vs Spring WebFlux

Spring MVC Async vs Spring WebFlux. Learn about Spring Async and Spring WebFlux both theoretically and practically with a basic load test

Spring MVC Async vs Spring WebFlux

Spring MVC Async vs Spring WebFlux. Learn about Spring Async and Spring WebFlux both theoretically and practically with a basic load test

Creating a Reactive Restful API with Spring Boot

In this article I want to show how easily it is to create a reactive REST API with Spring Boot. I would like to take a simple Use Case and use this example to show how quick it is possible to create an “active” non-blocking REST API with Spring Boot.

Build a reactive Microservices Architecture using Spring Cloud Gateway, Spring Boot and Spring WebFlux

In this article, you'll learn how you can build a reactive microservices architecture using Spring Cloud Gateway, Spring Boot, and Spring WebFlux.

Build and Deploy a Spring Boot App on Kubernetes | spring Boot Docker Kubernetes

You will learn how to deploy a Java 11 Spring Boot application on a Kubernetes cluster and how to build and deploy a spring boot application on kubernetes us...