diff --git a/README.md b/README.md index 8a192cf..f18114a 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,24 @@ But, how fast is it? Being blazingly fast is relative. When compared with a simple GO HTTP server, a simple zig zap HTTP server performed really good on my machine: +**Update**: I was intrigued comparing to a basic rust HTTP server. +Unfortunately, knowing nothing at all about rust, I couldn't find one and hence +tried to go for the one in [The Rust Programming +Language](https://doc.rust-lang.org/book/ch20-00-final-project-a-web-server.html). +Wanting it to be of a somewhat fair comparison, I opted for the multi-threaded +example. It didn't work out-of-the-box, but I got it to work and changed it to +not read files but outputting a static text just like in the other examples. +**maybe someone with rust experience** can have a look at my +[wrk/rust/hello](wrk/rust/hello) code and tell me why it's surprisingly slow, as +I expected it to be faster than the basic GO example. I'll enable the +GitHub discussions for this matter. My suspicion is the use of mutexes. + ![](wrk_table_summary.png) - zig zag was nearly 30% faster than GO - zig zag had over 50% more throughput than GO +- let's better not talk about the rust results. I don't know what causes them. + Probably bad mutex performance. ![](wrk_summary.png) diff --git a/blazingly-fast.md b/blazingly-fast.md index f2644fd..64376ac 100644 --- a/blazingly-fast.md +++ b/blazingly-fast.md @@ -14,6 +14,18 @@ You can check out the scripts I used for the tests in [./wrk](wrk/). You can see the verbatim output of `wrk`, and some infos about the test machine below the code snippets. +**Update**: I was intrigued comparing to a basic rust HTTP server. +Unfortunately, knowing nothing at all about rust, I couldn't find one and hence +tried to go for the one in [The Rust Programming +Language](https://doc.rust-lang.org/book/ch20-00-final-project-a-web-server.html). +Wanting it to be of a somewhat fair comparison, I opted for the multi-threaded +example. It didn't work out-of-the-box, but I got it to work and changed it to +not read files but outputting a static text just like in the other examples. +**maybe someone with rust experience** can have a look at my +[wrk/rust/hello](wrk/rust/hello) code and tell me why it's surprisingly slow, as +I expected it to be faster than the basic GO example. I'll enable the +GitHub discussions for this matter. My suspicion is the use of muteces. + ![](wrk_tables.png) ### requests / sec @@ -292,6 +304,71 @@ Running 10s test @ http://127.0.0.1:8080 Requests/sec: 5004.06 Transfer/sec: 649.95KB (base) rs@ryzen:~/code/github.com/renerocksai/zap$ + + + +(base) rs@ryzen:~/code/github.com/renerocksai/zap$ ./wrk/measure.sh rust + Finished release [optimized] target(s) in 0.00s +======================================================================== + rust +======================================================================== +Running 10s test @ http://127.0.0.1:7878 + 4 threads and 400 connections + Thread Stats Avg Stdev Max +/- Stdev + Latency 1.20ms 1.38ms 208.35ms 99.75% + Req/Sec 34.06k 2.00k 38.86k 75.25% + Latency Distribution + 50% 1.32ms + 75% 1.63ms + 90% 1.87ms + 99% 2.32ms + 1356449 requests in 10.01s, 71.15MB read + Socket errors: connect 0, read 1356427, write 0, timeout 0 +Requests/sec: 135446.00 +Transfer/sec: 7.10MB + + +(base) rs@ryzen:~/code/github.com/renerocksai/zap$ ./wrk/measure.sh rust + Finished release [optimized] target(s) in 0.00s +======================================================================== + rust +======================================================================== +Running 10s test @ http://127.0.0.1:7878 + 4 threads and 400 connections + Thread Stats Avg Stdev Max +/- Stdev + Latency 1.21ms 592.89us 10.02ms 63.64% + Req/Sec 32.93k 2.91k 37.94k 80.50% + Latency Distribution + 50% 1.31ms + 75% 1.64ms + 90% 1.90ms + 99% 2.48ms + 1311445 requests in 10.02s, 68.79MB read + Socket errors: connect 0, read 1311400, write 0, timeout 0 +Requests/sec: 130904.50 +Transfer/sec: 6.87MB + + +(base) rs@ryzen:~/code/github.com/renerocksai/zap$ ./wrk/measure.sh rust + Finished release [optimized] target(s) in 0.00s +======================================================================== + rust +======================================================================== +Running 10s test @ http://127.0.0.1:7878 + 4 threads and 400 connections + Thread Stats Avg Stdev Max +/- Stdev + Latency 1.26ms 2.88ms 211.74ms 99.92% + Req/Sec 33.92k 2.04k 38.99k 74.00% + Latency Distribution + 50% 1.34ms + 75% 1.66ms + 90% 1.91ms + 99% 2.38ms + 1350527 requests in 10.02s, 70.84MB read + Socket errors: connect 0, read 1350474, write 0, timeout 0 +Requests/sec: 134830.39 +Transfer/sec: 7.07MB + ``` ## test machine diff --git a/shell.nix b/shell.nix index 781ce5c..b7dafc3 100644 --- a/shell.nix +++ b/shell.nix @@ -14,6 +14,11 @@ pkgs.mkShell { pkgs.bat pkgs.wrk pkgs.python3 + pkgs.rustc + pkgs.cargo + pkgs.gcc + pkgs.rustfmt + pkgs.clippy ]; buildInputs = [ diff --git a/wrk/measure.sh b/wrk/measure.sh index a183b45..e8a7f94 100755 --- a/wrk/measure.sh +++ b/wrk/measure.sh @@ -31,6 +31,13 @@ if [ "$SUBJECT" = "python" ] ; then URL=http://127.0.0.1:8080 fi +if [ "$SUBJECT" = "rust" ] ; then + cd wrk/rust/hello && cargo build --release + ./target/release/hello & + PID=$! + URL=http://127.0.0.1:7878 +fi + sleep 1 echo "========================================================================" echo " $SUBJECT" diff --git a/wrk_requests.png b/wrk_requests.png index bf53e0c..db0e1c2 100644 Binary files a/wrk_requests.png and b/wrk_requests.png differ diff --git a/wrk_summary.png b/wrk_summary.png index 23906a8..63b201d 100644 Binary files a/wrk_summary.png and b/wrk_summary.png differ diff --git a/wrk_table_summary.png b/wrk_table_summary.png index 0cb3094..2eadf18 100644 Binary files a/wrk_table_summary.png and b/wrk_table_summary.png differ diff --git a/wrk_tables.png b/wrk_tables.png index 97476fb..96de8ea 100644 Binary files a/wrk_tables.png and b/wrk_tables.png differ diff --git a/wrk_transfer.png b/wrk_transfer.png index 7c4dc98..82dc7ba 100644 Binary files a/wrk_transfer.png and b/wrk_transfer.png differ