Rust ws server is based on Rocket framework.
Python ws server is based on Tornado.
It's not a comparison of languages or frameworks. The main idea was to take real world applications (simplified versions of course) and find out how they will behave under high load and handle almost instantaneous sessions.
WS_CONNECTIONS [Gauge] - amount of ws connections at the moment
ALL_WS_CONNECTIONS_TOTAL [Counter] - all ws connections
WS_CLOSED_CONNS_ERRORS_TOTAL [Counter] - amount of closed websocket connections errors
WS_BROADCAST_DURATION_SECONDS [Histogram] - duration of broadcasting message to all connections in seconds
WS_MESSAGE_HANDLING_DURATION_SECONDS [Histogram] - duration of handling message with json de/serialization and fields validation in seconds
k6 metrics – here
cadvisor metrics - here
You can check metrics here after setting up docker containers
grafana - http://localhost:3000
My custom dashboard - here
- Install k6
On mac:
brew install k6
More about k6 installation
- Set up containers
docker compose up -d
- run k6 load
K6_PROMETHEUS_RW_SERVER_URL=http://localhost:9090/api/v1/write \
k6 run -o experimental-prometheus-rw k6/scripts/both.js
- Uncomment k6 container manifest in compose.yaml
- set up all containers
docker compose up -d
docker compose down
Only rust ws app:
k6 run k6/scripts/rust.js
Only python ws app:
k6 run k6/scripts/python.js
Add logs from console debug output
k6 run -v ...
To push metrics from k6 to prometheus you need to specify
K6_PROMETHEUS_RW_SERVER_URL env variable and add -o experimental-prometheus-rw
flag to k6 run
. More here
Feel free to add more scenarios and metrics.
It seems values of CPU usage by container from cadvisor in grafana are lower than should be. Values from Docker Desktop are more correct.