- read

Ultimate 2023 Web Server Benchmark: NodeJS vs Java vs Rust vs Go

Aleksei Novikov 66

It’s 2023 and it’s time for a new web server benchmark!

The results were a bit unexpected for me!

A web server must be able to process tons of requests despite the bottleneck being IO. I decided to compare the performance of the most popular trending and blazingly fast modern frameworks this time.

There are a lot of details about the implementations below. If you need results, just go to the bottom of the article to save time. If you are interested in the way how testing has been performed, read further then :)

Our bottleneck is going to be a Postgres DB with some data inside. So, our web server will have to process as many requests per second as possible without blocking. After receiving the data it should serialize the answer into JSON and return a valid HTTP response.

What technologies are going to be tested:

  • Spring WebFlux + Kotlin
    - Traditional JVM
    - GraalVM Native Image
  • NodeJS + Express
  • Rust
    - Rocket
    - Actix Web

My setup:

CPU: Intel Core i7–9700K 3.60 GHz (8 cores with no hyper-threading)

RAM: 32 GB

OS: Windows 11 (ver. 22h2)

Docker: Docker for Desktop (Windows edition) version 4.16.3 with WSL2 support enabled — default resource configuration provided by Microsoft

Postgres: Started with the following docker command

docker run -d --name my-postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=goods -p 5432:5432 postgres:15.2

DB connection pool size: 50 connections max. This amount is going to be used by every web server to be in the same conditions.

Database initialization:

CREATE TABLE goods(
id BIGSERIAL NOT NULL PRIMARY KEY ,
name VARCHAR(255) NOT NULL,
description TEXT NULL,
price INT NOT NULL
);

INSERT INTO goods (name, description, price)
VALUES ('Apple', 'Red fruit', 100),
('Orange', 'Orange fruit', 150),
('Banana', 'Yellow fruit', 200),
('Pineapple', 'Yellow fruit', 250),
('Melon', 'Green fruit', 300);