Quarkus (Java) vs Rocket (Rust): Hello world performance
In the following article, we will delve into the performance analysis of two widely used frameworks: Quarkus & Java with Rocket & Rust. It’s important to note that this comparison focuses specifically on the frameworks and not the underlying programming languages.
Rocket is a web framework for Rust that makes it simple to write fast, secure web applications without sacrificing flexibility, usability, or type safety. Quarkus was created to enable Java developers to create applications for a modern, cloud-native world. Quarkus is a Kubernetes-native Java framework tailored for GraalVM and HotSpot, crafted from best-of-breed Java libraries and standards.
Setup
All tests are executed on MacBook Pro M2 with 16G RAM. For load testing, we’ve used Bombardier test tool. The software versions are:
- Quarkus 3.5.1 with Java v21
- Rocket 0.5-rc with Rust 1.73.0
The application code is as simple as:
Quarkus (Java)
package org.acme;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import io.smallrye.common.annotation.NonBlocking;
@Path("/")
public class HelloWorldApplication {
@GET
@NonBlocking
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello World!";
}
}
Rocket (Rust)
#[macro_use] extern crate rocket;
#[get("/")]
fn index() -> &'static str {
"Hello world!"
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![index])
}
The rust application has been built in release mode.
Results
All tests are executed for 10 million requests using 50, 100, and 300 concurrent connections. The results in chart and tabular form are as follows:
Conclusion
When it comes to speed, Quarkus (Java) outpaces Rocket (Rust), which may be surprising given that the Java Virtual Machine (JVM) demonstrates faster performance compared to machine code. In terms of resource utilization, Rocket uses high CPU usage. Nevertheless, it’s noteworthy that the memory consumption of Quarkus is significantly higher than that of Rocket.
Thanks for reading this article!