Skip to content

ydedev/go-websocket-benchmark

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-websocket-benchmark

  • support 1m-connections client

before running the test

  • make sure setting the correct system env, for example:
sysctl -w net.ipv4.ip_local_port_range="1024 65535"
sysctl -w fs.file-max=2000500
sysctl -w fs.nr_open=2000500
sysctl -w net.nf_conntrack_max=2000500
ulimit -n 2000500
sysctl -w net.ipv4.tcp_mem='131072  262144  524288'
sysctl -w net.ipv4.tcp_rmem='8760  256960  4088000'
sysctl -w net.ipv4.tcp_wmem='8760  256960  4088000'
sysctl -w net.core.rmem_max=16384
sysctl -w net.core.wmem_max=16384
sysctl -w net.core.somaxconn=2048
sysctl -w net.ipv4.tcp_max_syn_backlog=2048
sysctl -w /proc/sys/net/core/netdev_max_backlog=2048
# sysctl -w net.ipv4.tcp_tw_recycle=1 # client nat tcp-handshak problem
sysctl -w net.ipv4.tcp_tw_reuse=1

nbio 1m-connections-benchmark

run:

git clone https://github.com/lesismal/go-websocket-benchmark.git
cd go-websocket-benchmark
./script/1m_conns_benchmark.sh

here is the result on my ubuntu vm:

--------------------------------------------------------------
BenchType  : Connections
Framework  : nbio_nonblocking
Connections: 1000000
Concurrency: 5000
Success    : 1000000
Failed     : 0
Used       : 41.56s
TPS        : 24061
Min        : 20ns
Avg        : 192.57ms
Max        : 41.52s
TP50       : 30ns
TP75       : 30ns
TP90       : 30ns
TP95       : 31ns
TP99       : 31ns
--------------------------------------------------------------
BenchType  : BenchEcho
Framework  : nbio_nonblocking
Conns      : 1000000
Concurrency: 50000
Payload    : 1024
Total      : 5000000
Success    : 5000000
Failed     : 0
Used       : 47.02s
CPU Min    : 0.00%
CPU Avg    : 340.08%
CPU Max    : 386.93%
MEM Min    : 1.76G
MEM Avg    : 1.91G
MEM Max    : 1.94G
TPS        : 106348
Min        : 436.16us
Avg        : 465.78ms
Max        : 2.42s
TP50       : 412.36ms
TP75       : 600.92ms
TP90       : 779.92ms
TP95       : 1.04s
TP99       : 1.35s
--------------------------------------------------------------------------

benchmark for all frameworks

run:

git clone https://github.com/lesismal/go-websocket-benchmark.git
cd go-websocket-benchmark
./script/benchmarkN.sh

# if you want to change the benchmark config, just read the script and edit:
# go-websocket-benchmark/script/config.sh

Some benchmark results on my ubuntu vm:

Framework TPS Min Avg Max TP50 TP75 TP90 TP95 TP99 Used Total Success Failed Conns Concurrency Payload CPU Min CPU Avg CPU Max MEM Min MEM Avg MEM Max
fasthttp 236472 14.02us 21.12ms 112.12ms 20.32ms 26.06ms 33.34ms 39.00ms 51.30ms 8.46s 2000000 2000000 0 5000 5000 512 125.93 269.62 303.97 111.38M 116.93M 122.50M
gobwas 199529 21.48us 25.02ms 171.70ms 23.64ms 30.03ms 38.51ms 44.72ms 64.60ms 10.02s 2000000 2000000 0 5000 5000 512 0.00 303.06 356.25 48.86M 49.51M 49.88M
gorilla 235585 15.65us 21.19ms 142.65ms 20.22ms 26.07ms 33.67ms 39.37ms 53.48ms 8.49s 2000000 2000000 0 5000 5000 512 142.93 269.33 297.96 110.09M 115.75M 121.29M
gws 241793 13.16us 20.64ms 115.26ms 19.82ms 25.33ms 32.73ms 38.26ms 50.39ms 8.27s 2000000 2000000 0 5000 5000 512 74.87 250.86 290.97 83.86M 86.33M 87.98M
gws_std 243138 12.68us 20.51ms 123.45ms 19.75ms 25.50ms 32.88ms 37.94ms 50.84ms 8.23s 2000000 2000000 0 5000 5000 512 43.93 256.14 296.10 140.76M 157.20M 168.02M
hertz 216575 17.75us 23.04ms 113.47ms 22.07ms 28.39ms 36.19ms 42.69ms 56.46ms 9.23s 2000000 2000000 0 5000 5000 512 68.91 302.87 340.26 248.04M 293.02M 314.79M
hertz_std 227549 13.40us 21.94ms 180.43ms 20.56ms 27.23ms 35.96ms 41.77ms 56.44ms 8.79s 2000000 2000000 0 5000 5000 512 0.00 261.08 311.95 153.61M 159.75M 165.70M
nbio_blocking 234597 13.62us 21.27ms 160.83ms 19.90ms 26.51ms 34.55ms 40.26ms 54.00ms 8.53s 2000000 2000000 0 5000 5000 512 154.81 283.82 317.98 90.73M 105.22M 118.71M
nbio_mixed 235479 13.00us 21.20ms 113.62ms 20.17ms 26.08ms 34.30ms 40.39ms 51.54ms 8.49s 2000000 2000000 0 5000 5000 512 141.91 279.44 311.49 99.27M 149.77M 200.90M
nbio_nonblocking 207926 69.18us 24.00ms 107.70ms 23.06ms 29.91ms 36.99ms 41.84ms 53.31ms 9.62s 2000000 2000000 0 5000 5000 512 190.95 305.77 327.70 72.79M 75.87M 77.86M
nbio_std 241856 15.67us 20.64ms 123.82ms 19.76ms 25.68ms 33.21ms 38.73ms 49.25ms 8.27s 2000000 2000000 0 5000 5000 512 73.88 267.60 305.96 99.43M 114.62M 134.80M
nettyws 226121 15.42us 22.06ms 116.44ms 21.11ms 27.39ms 34.99ms 40.22ms 52.32ms 8.84s 2000000 2000000 0 5000 5000 512 0.00 293.07 346.96 145.62M 152.54M 156.08M
nhooyr 217452 23.78us 22.96ms 113.03ms 22.24ms 28.04ms 35.54ms 41.20ms 54.64ms 9.20s 2000000 2000000 0 5000 5000 512 66.97 346.47 385.94 173.53M 179.44M 188.95M
Framework TPS Min Avg Max TP50 TP75 TP90 TP95 TP99 Used Total Success Failed Conns Concurrency Payload CPU Min CPU Avg CPU Max MEM Min MEM Avg MEM Max
fasthttp 219910 14.13us 22.70ms 133.49ms 21.68ms 28.05ms 36.37ms 42.26ms 55.82ms 9.09s 2000000 2000000 0 5000 5000 1024 16.97 249.69 284.96 135.38M 135.57M 135.81M
gobwas 142450 24.47us 35.00ms 283.65ms 28.77ms 38.44ms 78.43ms 103.05ms 134.12ms 14.04s 2000000 2000000 0 5000 5000 1024 1.00 330.44 367.95 48.84M 49.91M 55.29M
gorilla 221218 14.70us 22.55ms 179.01ms 21.83ms 27.99ms 36.03ms 41.36ms 53.67ms 9.04s 2000000 2000000 0 5000 5000 1024 5.99 248.05 280.96 134.41M 136.59M 141.50M
gws 228484 12.73us 21.85ms 160.32ms 20.83ms 27.17ms 34.86ms 41.20ms 54.82ms 8.75s 2000000 2000000 0 5000 5000 1024 0.00 228.14 271.96 84.61M 89.45M 91.14M
gws_std 227729 14.10us 21.92ms 158.07ms 20.94ms 26.92ms 35.07ms 41.28ms 55.22ms 8.78s 2000000 2000000 0 5000 5000 1024 0.00 235.33 275.87 169.55M 171.91M 174.72M
hertz 202032 13.27us 24.69ms 128.74ms 23.41ms 30.35ms 38.93ms 45.57ms 58.91ms 9.90s 2000000 2000000 0 5000 5000 1024 0.00 296.02 342.96 349.86M 359.12M 360.79M
hertz_std 215185 14.51us 23.15ms 149.69ms 21.98ms 28.64ms 37.44ms 43.37ms 57.93ms 9.29s 2000000 2000000 0 5000 5000 1024 76.95 267.00 293.96 179.30M 185.15M 190.93M
nbio_blocking 217158 14.55us 22.99ms 146.29ms 21.92ms 28.68ms 36.84ms 43.07ms 56.70ms 9.21s 2000000 2000000 0 5000 5000 1024 40.96 267.00 303.77 120.46M 123.49M 125.66M
nbio_mixed 218090 14.34us 22.86ms 138.47ms 21.67ms 28.38ms 36.76ms 42.56ms 58.88ms 9.17s 2000000 2000000 0 5000 5000 1024 42.98 267.07 300.11 201.61M 204.82M 220.39M
nbio_nonblocking 188382 113.59us 26.50ms 126.05ms 25.47ms 32.95ms 40.74ms 46.33ms 59.59ms 10.62s 2000000 2000000 0 5000 5000 1024 190.89 308.24 326.94 77.86M 80.86M 81.43M
nbio_std 225617 14.77us 22.13ms 122.04ms 21.16ms 27.52ms 35.08ms 41.07ms 55.20ms 8.86s 2000000 2000000 0 5000 5000 1024 0.00 252.19 300.96 114.61M 118.23M 121.56M
nettyws 210130 18.36us 23.76ms 149.63ms 22.71ms 29.36ms 37.53ms 44.14ms 59.77ms 9.52s 2000000 2000000 0 5000 5000 1024 159.95 311.32 337.95 153.93M 160.14M 162.21M
nhooyr 204513 26.98us 24.39ms 142.40ms 23.27ms 29.86ms 38.24ms 44.54ms 58.18ms 9.78s 2000000 2000000 0 5000 5000 1024 0.00 329.69 379.96 269.47M 269.68M 270.04M
Framework TPS Min Avg Max TP50 TP75 TP90 TP95 TP99 Used Total Success Failed Conns Concurrency Payload CPU Min CPU Avg CPU Max MEM Min MEM Avg MEM Max
fasthttp 226234 390.11us 87.56ms 275.99ms 85.11ms 103.56ms 122.45ms 137.31ms 167.39ms 8.84s 2000000 2000000 0 20000 20000 512 0.00 299.70 371.34 421.14M 427.36M 433.19M
gobwas 188786 227.74us 105.23ms 278.84ms 102.37ms 119.74ms 139.30ms 154.06ms 188.77ms 10.59s 2000000 2000000 0 20000 20000 512 220.82 373.60 395.93 166.55M 167.28M 171.74M
gorilla 225850 26.05us 87.84ms 324.44ms 85.21ms 104.85ms 124.08ms 138.54ms 171.27ms 8.86s 2000000 2000000 0 20000 20000 512 0.00 299.26 360.93 421.72M 427.77M 433.89M
gws 233631 86.02us 85.02ms 307.52ms 82.18ms 101.67ms 122.96ms 136.95ms 166.93ms 8.56s 2000000 2000000 0 20000 20000 512 139.94 299.54 344.13 235.25M 283.54M 319.70M
gws_std 231880 1.02ms 85.54ms 284.33ms 82.70ms 102.44ms 123.81ms 137.54ms 170.51ms 8.63s 2000000 2000000 0 20000 20000 512 190.72 314.03 349.16 458.10M 509.03M 558.42M
hertz 177019 9.57ms 111.81ms 348.45ms 101.23ms 136.93ms 167.06ms 182.81ms 221.91ms 11.30s 2000000 2000000 0 20000 20000 512 84.87 282.24 318.96 860.32M 905.59M 949.60M
hertz_std 225099 4.10ms 88.03ms 262.77ms 85.72ms 105.12ms 123.59ms 136.14ms 162.18ms 8.88s 2000000 2000000 0 20000 20000 512 0.00 310.69 369.58 563.99M 569.92M 575.85M
nbio_blocking 230267 139.89us 86.26ms 300.98ms 84.05ms 103.08ms 122.08ms 134.33ms 158.61ms 8.69s 2000000 2000000 0 20000 20000 512 0.00 295.29 363.64 261.60M 278.30M 311.98M
nbio_mixed 200714 46.85us 98.80ms 866.23ms 53.99ms 71.93ms 105.48ms 591.91ms 771.95ms 9.96s 2000000 2000000 0 20000 20000 512 0.00 295.41 337.95 273.55M 358.44M 410.49M
nbio_nonblocking 193066 914.49us 102.81ms 303.79ms 100.98ms 123.08ms 146.20ms 161.25ms 194.29ms 10.36s 2000000 2000000 0 20000 20000 512 92.96 319.45 357.94 104.65M 123.46M 127.17M
nbio_std 226979 1.16ms 87.19ms 274.77ms 84.15ms 104.08ms 124.95ms 138.82ms 171.22ms 8.81s 2000000 2000000 0 20000 20000 512 0.00 288.76 351.94 309.54M 318.21M 343.30M
nettyws 204866 138.47us 96.91ms 268.60ms 93.73ms 113.49ms 135.31ms 149.40ms 176.93ms 9.76s 2000000 2000000 0 20000 20000 512 0.00 339.02 397.77 467.57M 540.05M 556.43M
nhooyr 185311 39.88us 106.93ms 288.98ms 104.71ms 121.68ms 140.23ms 155.25ms 192.32ms 10.79s 2000000 2000000 0 20000 20000 512 0.00 349.17 398.40 650.18M 663.77M 676.30M
Framework TPS Min Avg Max TP50 TP75 TP90 TP95 TP99 Used Total Success Failed Conns Concurrency Payload CPU Min CPU Avg CPU Max MEM Min MEM Avg MEM Max
fasthttp 212004 200.11us 93.48ms 304.68ms 90.14ms 111.68ms 133.00ms 147.06ms 180.89ms 9.43s 2000000 2000000 0 20000 20000 1024 138.91 328.58 363.94 718.11M 718.11M 718.11M
gobwas 139567 63.01us 142.19ms 729.35ms 138.61ms 147.35ms 159.17ms 177.52ms 319.32ms 14.33s 2000000 2000000 0 20000 20000 1024 105.87 365.94 392.14 164.26M 164.55M 164.64M
gorilla 211127 735.94us 93.82ms 297.39ms 90.90ms 112.49ms 134.20ms 148.35ms 179.65ms 9.47s 2000000 2000000 0 20000 20000 1024 146.92 332.94 376.95 577.53M 577.86M 578.47M
gws 212899 136.21us 93.05ms 290.15ms 90.27ms 112.72ms 134.20ms 150.31ms 182.03ms 9.39s 2000000 2000000 0 20000 20000 1024 87.87 294.24 326.94 327.71M 328.20M 328.33M
gws_std 219202 5.49ms 90.68ms 313.28ms 87.52ms 108.99ms 131.85ms 146.74ms 181.93ms 9.12s 2000000 2000000 0 20000 20000 1024 26.98 300.81 351.96 481.84M 532.14M 568.71M
hertz 164205 3.76ms 120.61ms 354.58ms 109.69ms 152.31ms 180.48ms 198.32ms 240.12ms 12.18s 2000000 2000000 0 20000 20000 1024 41.96 292.15 320.74 1.05G 1.11G 1.16G
hertz_std 207859 833.88us 95.59ms 282.41ms 93.09ms 114.19ms 136.48ms 150.84ms 178.44ms 9.62s 2000000 2000000 0 20000 20000 1024 210.72 354.83 384.09 834.16M 834.40M 834.58M
nbio_blocking 215549 72.30us 91.75ms 318.37ms 88.73ms 110.15ms 132.46ms 147.33ms 180.39ms 9.28s 2000000 2000000 0 20000 20000 1024 70.95 332.55 378.93 357.46M 357.64M 357.94M
nbio_mixed 192617 62.61us 102.99ms 905.39ms 56.39ms 75.36ms 108.03ms 654.66ms 801.17ms 10.38s 2000000 2000000 0 20000 20000 1024 122.85 317.94 344.95 411.68M 449.68M 460.59M
nbio_nonblocking 184081 164.63us 107.88ms 328.40ms 104.09ms 131.74ms 160.21ms 177.37ms 216.60ms 10.86s 2000000 2000000 0 20000 20000 1024 0.00 303.74 364.69 127.50M 127.50M 127.50M
nbio_std 218714 171.44us 90.87ms 275.98ms 88.28ms 111.01ms 132.43ms 145.98ms 177.70ms 9.14s 2000000 2000000 0 20000 20000 1024 0.00 318.95 368.66 314.81M 342.09M 367.88M
nettyws 191843 248.57us 103.56ms 323.70ms 99.62ms 121.42ms 145.33ms 160.89ms 197.92ms 10.43s 2000000 2000000 0 20000 20000 1024 157.79 366.42 398.45 546.78M 563.57M 577.98M
nhooyr 172401 7.13ms 115.21ms 326.85ms 111.71ms 132.37ms 155.01ms 173.34ms 209.53ms 11.60s 2000000 2000000 0 20000 20000 1024 223.84 375.98 397.71 715.09M 727.05M 738.95M

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 92.9%
  • Shell 7.1%