Comparing the default axum , axum-tws and tungstenite (with 1,024 sized buffer).
Adding into the comparions, different memory allocators.
We first measure idle, then 10,000 connections, then we disconnect all connections.
Measurments are in MB done via memory-stats crate with always_use_statm
feature.
Example | Idle | 10K | Diconnect |
---|---|---|---|
axum-example | 6.62 | 1334.125 | 45.46 |
axum-tws-example | 6.62 | 78.0 | 77.86 |
tungstenite-example | 5.37 | 69.5 | 49.88 |
Example | Idle | 10K | Diconnect |
---|---|---|---|
axum-example | 6.5 | 1334.5 | 9.98 |
axum-tws-example | 6.37 | 78.12 | 9.54 |
tungstenite-example | 5.37 | 51.91 | 16.67 |
Example | Idle | 10K | Diconnect |
---|---|---|---|
axum-example | 7.0 | 1294.12 | 416.96 |
axum-tws-example | 6.87 | 72.75 | 54.66 |
tungstenite-example | 5.87 | 44.69 | 36.86 |
Example | Idle | 10K | Diconnect |
---|---|---|---|
axum-example | 9.75 | 1332.25 | 24.26 |
axum-tws-example | 9.37 | 73.73 | 15.55 |
tungstenite-example | 7.87 | 47.24 | 14.19 |
- Using
tungstenite
directly isn't a real option withaxum
due to theAPI
it requires. - The default
axum
setting uses128K
buffer which is too big for more cases, makingaxum-tws
a better option (tried changingaxum-tws
config but saw no real diferences in results). - The difference between
axum
andaxum-tws
is over1.3GB
versus77MB
, very significant. malloc_trim(0)
seems to be able to reclaim the most memory butjemalloc
is known to help in memory fragmentation and not far behind in performance, whilemimalloc
is lagging considerably.