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
tungstenitedirectly isn't a real option withaxumdue to theAPIit requires. - The default
axumsetting uses128Kbuffer which is too big for more cases, makingaxum-twsa better option (tried changingaxum-twsconfig but saw no real diferences in results). - The difference between
axumandaxum-twsis over1.3GBversus77MB, very significant. malloc_trim(0)seems to be able to reclaim the most memory butjemallocis known to help in memory fragmentation and not far behind in performance, whilemimallocis lagging considerably.