{{announcement.body}}
{{announcement.title}}

Quarkus vs Spring Boot – Performance

DZone 's Guide to

Quarkus vs Spring Boot – Performance

In this article, we are going to compare the Quarkus and Spring Boot applications and how they behave in terms of memory management.

· Microservices Zone ·
Free Resource

In this article, we are going to compare the Quarkus and Spring Boot applications and how they behave in terms of memory management.

To be fair in comparison to both the applications, we will go with a standard set of dependencies. Both the application will include Spring Web dependencies only. They will be build using maven tool and jar files will be created. Both the application will have similar REST Endpoints.

quarkus vs spring boot

This comparison is going to be super crazy. We will create both applications from scratch.

Creating Quarkus Application

To create a quarkus application, go to https://code.quarkus.io/ and fill the below details.

quarkus homepage screenshot

Open this project in your preferred IDE.

Create a new class HomeController.java and add the below code in that class file.

Java
 




x
10


 
1
@RestController
2
@RequestMapping("/hello")
3
public class HomeController {
4
 
5
    @GetMapping
6
    public String hello() {
7
        return "hello";
8
    }
9
 
10
}


Now, to run this application, go to the terminal and run the below command. 

mvn clean package

Once the jar file is created, execute the below command to run the standalone jar file with the below command. 

java -jar code-with-quarkus-1.0.0.SNAPSHOT-runner.jar 

Creating a Spring Boot Application

To create a Spring Boot application, go to https://start.spring.io/ and fill the below details.

spring boot application homepage application

Open this project in your preferred IDE.

Create a new class HomeController.java and add the below code in that class file.

Java
 




xxxxxxxxxx
1
10


 
1
@RestController
2
@RequestMapping("/hello")
3
public class HomeController {
4
 
5
    @GetMapping
6
    public String hello() {
7
        return "hello";
8
    }
9
 
10
}


Now, to run this application, go to the terminal and run the below command.

mvn clean package 

Once the jar file is created, execute the below command to run the standalone jar file with the below command.

java -jar demo-0.0.1-SNAPSHOT.jar 

Comparison

Now, both the applications are running and we can compare the memory utilization by both the application using jconsole. Make sure that both the applications are running on different ports, so there are no port conflicts while starting the application

To open Jconsole, go to terminal and type jconsole command as shown in the below screenshot.

jconsole command

On executing the above command, it will open a prompt to select the process to check the resources. Below are the screenshots for selecting both Quarkus and Spring Boot applications resources.


spring boot resource

Select the appropriate processes for both the application and the new window will open to monitor those applications. 


quarkus using 27mb of memory
spring boot using 47mb of memory

The Straight forward comparison for both the application depicts that Quarkus uses way less memory while starting the application. Spring Boot is using around ~47 Mb of memory compared to Quarkus’s ~27 Mb of memory utilization.

Quarkus uses Ahead of Time compilation strategy while building the application, which gives the benefit to loading only the necessary classes which helps to start the application.

quarkus loads around 5,100 classes spring boot loads 7,100

In the above screenshot, we can see that Quarkus loads around ~5100 classes compared to ~7100 of the Spring Boot application. The comparison is too much considering that both the application has the same dependency and REST Endpoint.

Spring Boot is catching up with the support of GraalVM with the latest release. We need to wait and see in the future, how much benefit all the frameworks will get with increasing demands and use of GraalVM.

We will compare more in detail about all the other aspects of the application.

If you want to understand performance by video, click below.


Topics:
comparison, quarkus, quarkus tutorial, spring, spring boot, spring framework

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}