At present, the mainstream frameworks in the market are basically Spring bucket series, and Srping’s ecological improvement is one of the reasons why many developers like this framework very much. But today we’ll look at the differences between Quarkus and Spring Boot mainly in terms of memory management and performance.
What is Quarkus?
Quarkus is a full-stack Kubernetes native Java framework for Java Virtual Machines (JVMS) and native-compiled Java, designed specifically for container optimization of Java to make it an effective platform for serverless, cloud and Kubernetes environments.
A builder
To visually compare the differences between the two frameworks, both programs will introduce only Spring Web dependencies.
Build the Quarkus app
We can build our Quarkus application on the Quarkus website. Note that we have chosen only Spring Web API dependencies.
Once the download code is opened using the IDE, we’ll see that there is a default SpringGreetingController class:
@RestController
@RequestMapping("/hello-spring")
public class SpringGreetingController {
@GetMapping
public String hello(a) {
return "Hello Spring"; }}Copy the code
Build the Spring Boot program
We don’t need to say much about the Spring Boot build method, and we only chose the Spring Web dependency.
Let’s modify the Spring built code and add SpringGreetingController to the Spring Boot project.
Performance comparison
Having done that, I don’t know if you noticed that Quarkus doesn’t have a Main startup function like Spring Boot, nor is it deployed to a Web container. From the introduction of Quarkus official website, we can see that we only need one line command to start Quarkus program: MVNW compile Quarkus :dev. We use MVNW compile spring-boot:run to run the Spring Boot project.
We used jConsole, the Java monitoring GUI tool provided by the JDK itself, to check the performance of both processes.
Quarkus
An overview of
class
Spring Boot
An overview of
class
A direct comparison of both applications shows that Quarkus uses less memory when launching the application. Spring Boot uses about 145 Mb of memory, while Quarkus uses about 122 Mb. Quarkus loaded about 5,303 classes, while Spring Boot loaded about 4,785 classes.
conclusion
The test results were somewhat different from what I saw in the video, which showed that Quarkus’ performance was much better than Spring Boot’s. My test is just to give you a reference, hands-on ability can go to practice.
Quarkus vs Spring Boot-Performance