Skip to content

ProstoyVadila/ws_servers_metrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebSocket servers under high load

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.

Metrics

My custom metrics

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

Other default metrics

k6 metricshere

cadvisor metrics - here

Results

RESULTS.md

Dashboard

You can check metrics here after setting up docker containers

grafana - http://localhost:3000

My custom dashboard - here

Quick Start

Local Load

  1. Install k6

On mac:

brew install k6

More about k6 installation

  1. Set up containers
docker compose up -d
  1. run k6 load
K6_PROMETHEUS_RW_SERVER_URL=http://localhost:9090/api/v1/write \
k6 run -o experimental-prometheus-rw k6/scripts/both.js

Container Load

  1. Uncomment k6 container manifest in compose.yaml
  2. set up all containers
docker compose up -d

Cleanup

docker compose down

Load Options

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 ...

k6 metrics

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

Ideas for Improvement

Feel free to add more scenarios and metrics.

Issues

It seems values of CPU usage by container from cadvisor in grafana are lower than should be. Values from Docker Desktop are more correct.

About

rust and python ws servers under high load

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published