App Servers benchmarked for: Ruby, Python, JavaScript, Dart, Elixir, Java, C#, Crystal, Nim, GO, Rust
Java C# Elixir Rust Dart JavaScript Other
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
servers
.gitignore
README.md

README.md

Table of Contents

Scope

The idea behind this repository is to benchmark different languages implementation of HTTP server.

Hello World

The application i tested is minimal: the HTTP version of the Hello World example.
This approach allows including languages i barely know, since it is pretty easy to find such implementation online.
If you're looking for more complex examples, you will have better luck with the TechEmpower benchmarks.

Disclaimer

Please do take the following numbers with a grain of salt: it is not my intention to promote one language over another basing on micro-benchmarks.
Indeed you should never pick a language just basing on its presumed performance.

Languages

I have filtered the languages by single runtime (i.e. Java on JVM): this way i can focus on a specific stack, keeping it updated to the last available version/APIs. Where possible i just relied on the standard library, but when it is not production-ready (i.e. Ruby, Python) or where the language footprint is deliberately minimal (i.e. Rust).

Ruby

Ruby 2.5.1 is installed via rbenv.
Ruby is a general-purpose, interpreted, dynamic programming language, focused on simplicity and productivity According to his creator Ruby is inspired by Lisp, Perl, Python and Smalltalk.

Python

Python 3.7.0 is installed via homebrew.
Python is a widely used high-level, general-purpose, interpreted, dynamic programming language.
It supports several programming paradigms and can count on a broad standard library.

JavaScript

Node.js version 10.1.0 is installed by official OSX package.
Node.js is based on the V8 JavaScript engine, optimized by Google and supporting most of the new language's features.

Dart

Dart version 1.24.3 is installed via homebrew.
Dart is an object-oriented, class defined, single inheritance language using a C-style syntax that transcompiles optionally into JavaScript. It is part of a Google ambitious project to use a single language to program server-side, client-side and mobile-side (cross-platforms).

Elixir

Elixir 1.6.4 is installed via homebrew.
Elixir is a purely functional language that runs on the Erlang VM.
While preserving Erlang key-features, Elixir is strongly influenced by Ruby syntax and supports compile-time metaprogramming with macros and polymorphism.

Java

Java JDK 10.0.1 is installed by official OSX package.
Java is a general-purpose language that is concurrent, class-based, object-oriented and, from version 8, supports functional paradigms. It is based on a battle-tested virtual machine (JVM) that kept the promise "write once, run anywhere".

C-sharp

C-sharp (C#) 7.0 language is part of the [.NET Core]((https://www.microsoft.com/net/core#macos) 2.1.3 framework.
C# is a simple, powerful, type-safe, object-oriented language. It inherited many features from Java, but recently added some desirable paradigms such as futures, pattern matching and deconstructions.

Crystal

Crystal 0.25.0 is installed via homebrew.
Crystal has a syntax very close to Ruby, but brings some desirable features such as statically typing and raw metal speed, thanks to ahead of time (AOT) compilation.

Nim

Nim 0.18.0 is installed via homebrew.
Nim is an efficient, Python inspired, statically typed language that comes with an ambitious compiler aimed to produce code in C, C++, JavaScript or ObjectiveC. Nim supports metaprogramming, functional, message passing, procedural, and object-oriented coding style.

GO

GO language version 1.10.3 is installed by official OSX package.
GO focuses on simplicity by intentionally lacking features considered redundant. GO takes a straight approach to parallelism, coming with built in CSP and green threads (go-routines).

Rust

Rust language version 1.27.0 is installed by official package.
According to the official site Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety.
These bounds are granted courtesy of Rust's pretty unique ownership model enforced by the compiler.

Tools

Wrk

I used wrk as the loading tool.
I measured each application server six times, picking the best lap (but for VM based languages demanding longer warm-up).

wrk -t 4 -c 100 -d30s --timeout 2000 http://0.0.0.0:9292

Platform

These benchmarks are recorded on a MacBook PRO 15 mid 2015 having these specs:

  • macOS High Sierra
  • 2.2 GHz Intel Core i7 (4 cores)
  • 16 GB 1600 MHz DDR3

RAM and CPU

I measured RAM and CPU consumption by using macOS Activity Monitor dashboard and recording max consumption peak.
For the languages relying on pre-forking parallelism i reported the average consumption by taking a snapshot during the stress period.

Benchmarks

Results

Language App Server Req./sec (local) RAM (MB) CPU (%)
Elixir Plug with Cowboy 43100.86 42.4 530.8
Nim Asynchttpserver 46263.57 5.7 99.8
Dart Dart HttpServer 54573.24 158.1 573.1
Ruby Puma 58710.33 > 100 > 390
JavaScript Node Cluster 87201.81 > 240 > 390
Crystal Crystal HTTP 95018.03 8.5 104.4
Rust Hyper 96881.29 2.9 502.4
GO GO ServeMux 97401.82 7.2 447.3
C-Sharp Kestrel 99359.00 959.7 495.4
Python Gunicorn with Meinheld 100932.26 > 40 > 350
Java Jetty NIO 104570.11 224.4 433.5

Puma

I tested Ruby by using a plain Rack application served by Puma.

Bootstrap

puma -w 8 -t 8 --preload servers/puma_server.ru

Gunicorn with Meinheld

I tested Python by using Gunicorn spawning Meinheld workers.

Bootstrap

cd servers
gunicorn -w 4 -k meinheld.gmeinheld.MeinheldWorker -b :9292 gunicorn_server:app

Node Cluster

I used the cluster module included into Node's standard library.

Bootstrap

node servers/node_server.js

Dart HttpServer

I used the async HTTP server embedded into the Dart standard library.

Bootstrap

dart servers/dart_server.dart

Plug with Cowboy

I tested Elixir by using Plug library that provides a Cowboy adapter.

Bootstrap

cd servers/plug_server
MIX_ENV=prod mix compile
MIX_ENV=prod mix run --no-halt

Jetty NIO

I tested Java by using Jetty with the non blocking IO (NIO) APIs.

Bootstrap

cd servers/jetty_server
javac -cp jetty-all-uber.jar HelloWorld.java
java -server -cp .:jetty-all-uber.jar HelloWorld

Kestrel

To test C# i opted for Kestrel: a cross-platform web server based on the libuv asynchronous I/O library.

Bootstrap

cd servers/kestrel_server
dotnet restore
dotnet run

Crystal HTTP

I used Crystal HTTP server standard library, not supporting parallelism yet.

Bootstrap

crystal build --release servers/crystal_server.cr
./crystal_server

Asynchttpserver

I used the asynchttpserver standard module of Nim, not supporting parallelism yet.

Bootstrap

nim c -d:release servers/nim_server.nim
./servers/nim_server

GO ServeMux

I used the HTTP ServeMux GO standard library.

Bootstrap

go run servers/go_server.go

Hyper

I tested Rust by using Hyper, a HTTP client/server based on the Tokio toolkit.

Bootstrap

cd servers/hyper_server
cargo run --release