Benchmarking performance of x concurrent requests sent per second by given implementation. All commands can be found in the justfile
Implementation | Parallelism model | HTTP Library |
---|---|---|
Python | threading | requests |
Rust | async (tokio) | ureq |
Read more about how to add another another language implementation (A language in combination with a parallelism model and a http client). Further docs can be found in the benchmark bash script.
- Install just command runner:
cargo install just
- Install virtual environments for python:
just install-python-env
- Run benchmarks:
just benchmark
- Start dev-server:
just py-server
[enter]
- Stop dev-server:
just py-server-kill
- Start Jaeger (log-collector server)
just jaeger
# Start jaeger tracing server
just jaeger
# Compile and run rust threaded ureq implementation with one request
cd ./rust-client
cargo run -- --trace-remote --trace-stdout threads-ureq 1
Todo
Why do reqeusts made by hyper
have 'keep-alive' on connection inspection with ss
?
-
Setup flask server on remote server
-
Gunicorn handle signals for communiation
-
Add nginx as reverse proxy
-
-> The Flask server was not optimized
-
Create small blog-post or writeup.
-
Rewrite benchmark script with python for cross platform testing.
-
Rewrite just recipes with python.
Don't mind the notes below
For my own sanity
Make sure to run rust with release profile and turn on debug
option
~/Dev/Rust/async_vs_threads (main ✗) cargo flamegraph --example async_request_tasks -- 4
VALUE WAS 4 CHANGED TO -1 FOR MONITORING CPU INSTRUCTIONS/PROFILEING WITH
perf
sudo sh -c 'echo kernel.perf_event_paranoid=1 > /etc/sysctl.d/local.conf'
~/Dev/Rust/async_vs_threads (main ✗) cat /proc/sys/kernel/kptr_restrict
1
~/Dev/Rust/async_vs_threads (main ✗) echo 0 > /proc/sys/kernel/kptr_restrict
zsh: permission denied: /proc/sys/kernel/kptr_restrict
~/Dev/Rust/async_vs_threads (main ✗) sudo bash
root@patrik-ThinkPad-T15-Gen-1:/home/patrik/Dev/Rust/async_vs_threads# echo 0 > /proc/sys/kernel/kptr_restrict
root@patrik-ThinkPad-T15-Gen-1:/home/patrik/Dev/Rust/async_vs_threads# exit
exit
https://crates.io/crates/opentelemetry https://crates.io/crates/tracing-timing
https://blog.logrocket.com/an-introduction-to-profiling-a-rust-web-application/
https://github.com/flamegraph-rs/flamegraph
Max parallel requests per domain using h2 configuration option #2641