In previous posts, I compared Kourier with Rust/Hyper and Go/http regarding performance and memory consumption, where I showed Kourier’s unbeatable performance and incredibly low memory consumption.
Although Kourier is truly a wonder of software engineering and delivers never-before-seen performance, many frameworks sacrifice HTTP conformance to be faster.
In this post, I compare Kourier with Rust/Hyper and Go/http regarding compliance with HTTP syntax.
Kourier is open source, and all the assets used on the benchmarks are publicly available and container-based, ensuring you can reproduce the results on your local machine quickly and easily. All assets used on the benchmarks are available on the Kourier repository.
The results show that Kourier is, by far, the most compliant server.
All Docker images used in this benchmark can be easily built using the build script contained in Kourier’s repository.
I start the servers with the following commands:
# Kourier. The server listens on port 3275
docker run --rm -d --network host kourier-bench:kourier -a 127.0.0.1 -p 3275 --worker-count=1
# Rust (Hyper). The server listens on port 8080
docker run --rm -d --network host kourier-bench:rust-hyper
# Go (net/http). The server listens on port 7080
docker run --rm -d --network host kourier-bench:go-net-http
I use the kourier-bench:http-compliance Docker container to test the servers. This container generates malformed requests containing invalid characters for the URL’s absolute path, query, and header field names and values.
In Kourier’s repository, you can check the source file Src/Tests/Resources/Benchmarks/HttpCompliance/src/main.cpp to see how the requests are generated.
I run the container to test a server’s compliance with HTTP’s syntax with the following command:
# PORT is 3275 for Kourier, 8080 for Rust (Hyper), or 7080 for Go (net/http).
docker run --rm --network host -it kourier-bench:http-compliance -a 127.0.0.1 -p PORT
Results 🔗
# Testing Kourier server at 127.0.0.1:3275
glauco@ldh:~$ sudo docker run --rm --network host -it kourier-bench:http-compliance -a 127.0.0.1 -p 3275
Testing HTTP compliance...
Finished testing HTTP compliance.
175 requests with invalid URL absolute path detected.
0 requests with invalid URL absolute path undetected.
175 requests with invalid URL query detected.
0 requests with invalid URL query undetected.
178 requests with invalid header name detected.
0 requests with invalid header name undetected.
30 requests with invalid header value detected.
0 requests with invalid header value undetected.
61692 requests with invalid pct-encoded hex digits in URL absolute path detected.
0 requests with invalid pct-encoded hex digits URL absolute path undetected.
61692 requests with invalid pct-encoded hex digits URL query detected.
0 requests with invalid pct-encoded hex digits URL query undetected.
# Testing Rust (Hyper) server at 127.0.0.1:8080
glauco@ldh:~$ sudo docker run --rm --network host -it kourier-bench:http-compliance -a 127.0.0.1 -p 8080
Testing HTTP compliance...
Finished testing HTTP compliance.
165 requests with invalid URL absolute path detected.
10 requests with invalid URL absolute path undetected.
165 requests with invalid URL query detected.
10 requests with invalid URL query undetected.
178 requests with invalid header name detected.
0 requests with invalid header name undetected.
30 requests with invalid header value detected.
0 requests with invalid header value undetected.
55332 requests with invalid pct-encoded hex digits in URL absolute path detected.
6360 requests with invalid pct-encoded hex digits URL absolute path undetected.
55332 requests with invalid pct-encoded hex digits URL query detected.
6360 requests with invalid pct-encoded hex digits URL query undetected.
# Testing Go (net/http) server at 127.0.0.1:7080
glauco@ldh:~$ sudo docker run --rm --network host -it kourier-bench:http-compliance -a 127.0.0.1 -p 7080
Testing HTTP compliance...
Finished testing HTTP compliance.
35 requests with invalid URL absolute path detected.
140 requests with invalid URL absolute path undetected.
34 requests with invalid URL query detected.
141 requests with invalid URL query undetected.
177 requests with invalid header name detected.
1 requests with invalid header name undetected.
30 requests with invalid header value detected.
0 requests with invalid header value undetected.
61692 requests with invalid pct-encoded hex digits in URL absolute path detected.
0 requests with invalid pct-encoded hex digits URL absolute path undetected.
16252 requests with invalid pct-encoded hex digits URL query detected.
45440 requests with invalid pct-encoded hex digits URL query undetected.
Conclusion 🔗
Kourier is the next level of network-based communication. It is on another league regarding performance, compliance, and memory consumption. Kourier leaves everything else in the dust, including enterprise network appliances.
Creating the fastest server ever requires much more than a stellar HTTP parser. From ring buffers to socket programming, to a custom timer implementation. I implemented it all and open-sourced all of it alongside Kourier.
I developed Kourier with strict and demanding requirements, where all possible behaviours are comprehensively verified in specifications written in the Gherkin style. To this end, I created Spectator, a test framework that I also open-sourced with Kourier. You can check all files ending in spec.cpp in the Kourier repository to see how meticulously tested Kourier is. There is a stark difference in testing rigor between Kourier and other frameworks.
Kourier can empower the next generation of network appliances/solutions, making businesses that rely on them run at a fraction of their infrastructure cost and in a much more HTTP-compliant way.
You can contact me if your Business is not compatible with the requirements of the AGPL and you want to license Kourier under alternative terms.