Rust — Actix vs Axum: Hello World performance

Mayank Choubey
Tech Tonic
3 min readNov 10, 2023

--

In this article, I’m going to take a look at the performance battle between two popular Rust frameworks — Actix & Axum, for a simple hello world case. Actix is well known, popular framework. Axum is relatively unpopular, though it comes from the makers of Tokio.

Test setup

The tests are executed on MacBook Pro M2 with 16G of RAM.

The software versions are:

  • Rust 1.73.0
  • Actix web 4.4.0
  • Axum 0.6.20

The hello world HTTP server code in both cases is as follows:

Actix

use actix_web::{get, App, HttpServer, Responder};

#[get("/")]
async fn index() -> impl Responder {
"Hello World!"
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().service(index))
.bind(("127.0.0.1", 3000))?
.run()
.await
}

Axum

use axum::{
routing::get,
Router,
};

#[tokio::main]
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello World!" }));

axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
}

Both applications have 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

The basic performance of the “hello world” test is identical for both. There is no noteworthy distinction. Perhaps any dissimilarity becomes more apparent in more intricate scenarios, like a static file server or database operations, for instance.

Thanks for reading!

--

--