This benchmark is based on a load test script for a simple API, unique endpoint that returns the number of requests it has processed.
Commands to create a project:
mkdir gin163; cd $_ go mod init gin163
to build it, export this environment variable export GO111MODULES="on" go build
Commands to create a project:
cargo new actixweb20
to build project cargo build --release
The load test is a bash script and I'm using multiple tools for this:
How it works is:
Always hits /helloWork
endpoint, it triggers bursts in different sequences
- hits once
- hits 100k using 100 connections
- sleep for 10s
- hits 100k using 100 connections
- sleep for 10s
- hits 100k using 100 connections
- sleep for 10s
- hits for 30 seconds using 100 connections
- hits only once
you can check this script
these are the results for each app:
Since I did not look for any tool to get profiling data for each app I don't have much information to compare but I'll show screenshots from Activity Monitor app from MacOS
-
Both apps keep very low memory consumption with just slightly difference for Go app with ~1Mb less.
-
What was very notorious is CPU usage for Go app as you can see in CPU history from screenshot.
-
What is really dominant for Rust app is the incredible amount of requests processed, at least 2x versus Go app.
-
Go with Gin 1.6.3: 1,682,359
-
Rust with Actix-web 2.0: 3,556,243