I benchmarked axum and actix-web against other web servers and found the performance to be surprisingly low

165 points bigpigfoot 64 comments

benchmarks

As title says

I'm load testing all web servers in Docker containers and hitting them with k6. Can someone take a look at my rust code and let me know what I'm doing wrong or help me interpret my results? Much appreciated

  • hardware: Apple Silicon M4 (10 cores) 32GB RAM
  • runtime: Docker Desktop 4.53 (8 cores, 24GB RAM, 4GB swap)
  • database engine: Postgres 17.5 (Docker)
  • database pooler: pgcat 0.2.5
  • load tester: grafana/k6
  • load test duration: 3m sustained
  • load success threshold: error rate < 0.01
Web Server SQL Driver VUs RPS[K] min[ms] max[ms] avg[ms] p90[ms] p95[ms]
go net/http lib/pq w/o p. stmt 100 1.8 1.2 510 43 87 115
jackc/pgx w/o p. stmt 100 7.1 0.79 169 3 6 9
jackc/pgx 100 8.6 0.21 128 1 2 13
130 9.1 0.30 114 4 8 11
500 6.3 0.67 2.4s 68 166 252
1K 5.7 57 3.7s 176 273 362
jackc/pgx + pgcat 100 7.9 10 243 12 14 15
130 8.4 0.69 77 5 10 15
250 7.0 10 .9s 35 72 99
500 6.6 14 1s 64 105 135
2K 6.5 233 1.3s 305 357 388
4K 6.5 61 2.1s .6s .7s .7s
6K 6.9 151 2.3s .8s 1s 1s
10K 5.7 451 3.7s 1.7s 2.1s 2.4s
fastapi asyncpg 100 3.7 11 156 16 20 23
130 3.7 2 356 24 31 35
200 3.2 16 .8s 51 66 75
psycopg 100 3.0 2.3 272 22 36 45
200 2.7 14 1.6s 62 141 191
psycopg + pgcat 100 2.8 14 328 35 51 62
200 2.4 15 1.5s 69 157 203
express.js node-postgres 100 5.8 0.83 291 7 9 10
250 4.8 4.0 1.2s 51 61 66
porsager/postgres 100 5.2 0.43 329 9 13 15
250 4.9 4.3 1.1s 41 48 51
next.js porsager/postgres 100 2.6 4.1 543 37 43 47
250 2.4 8.5 3.3s 94 112 119
spring boot + webflux postgresql r2dbc 100 7.7 0.29 46 3 5 7
130 7.5 1.9 81 7 10 13
250 7.7 3.2 83 33 26 27
500 7.0 27 192 60 70 77
1000 6.8 31 250 136 153 160
postgresql r2dbc + pgcat 10000 4.4 59 3.6s 2.2s 2.7s 2.8s
rust axum 0.7 sqlx 25 4.0 0.22 106 1.0 2.2 4.4
100 2.5 0.46 772 29 67 88
150 1.9 11 1.0s 77 165 214
250 1.8 0.64 1.7s 130 300 392
1000 0.348 6.0 33.9s 2.86s 6.64s 8.69s
rust actix-web 4 sqlx 20 3.5 0.3 23 0.6 0.9 1.1
25 4.1 0.3 94 1.0 1.9 3.5
50 3.1 0.38 194 11 25 33
100 2.4 0.45 584 35 81 107