Skip to content

Comparison between WebClient and RestTemplate, in a Spring MVC application on Wildfly

Notifications You must be signed in to change notification settings

infantesimone/rest-template-vs-web-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RestTemplate vs WebClient

The goal of this project is to compare WebClient and RestTemplate in a Spring MVC application on Wildfly.

WebClient is part of the WebFlux reacive stack, but it can improve the performance of a classic application, for example a Spring MVC application on Wildfly.

This repository contains two simple application:

  • rest-template-vs-web-client: Spring App that exposes two endpoints:
    • /resttemplate/samples/{id}: call the service exposed by slow-application using RestTemplate;
    • /webclient/samples/{id}: call the service exposed by slow-application using WebClient;
  • slow-application: a very simple node application in order to simulate a slow app (response time 2 seconds).
    • /samples/:id and return a json like this { id: 1, details : "Exmplae details"};

Getting started

In order to build and run this project are required:

  • Apache Maven;
  • JDK 8+;
  • Wildfly;
  • Node.

An alternative is to run the docker compose:

docker-compose up

Test

You can compare the two modules with Apache Bench:

  1. RestTemplate

    ab -n 5000 -c 500 http://127.0.0.1:8080/rest-template-vs-web-client/api/resttemplate/samples/7
    
  2. Webclient

    ab -n 5000 -c 500 http://127.0.0.1:8080/rest-template-vs-web-client/api/webclient/samples/7
    

About

Comparison between WebClient and RestTemplate, in a Spring MVC application on Wildfly

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published