Home

Awesome

go-websocket-benchmark

before running the test

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

env

            .-/+oossssoo+/-.               
        `:+ssssssssssssssssss+:`           -------------------------
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 20.04.6 LTS on Windows 10 x86_64
    .ossssssssssssssssssdMMMNysssso.       Kernel: 5.15.146.1-microsoft-standard-WSL2
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Uptime: 1 hour, 41 mins
  +ssssssssshmydMMMMMMMNddddyssssssss+     Packages: 739 (dpkg), 4 (snap)
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Shell: bash 5.0.17
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Terminal: Relay(527)
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   CPU: AMD Ryzen 9 7945HX with Radeon Graphics (32) @ 2.495GHz
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   GPU: f008:00:00.0 Microsoft Corporation Device 008e
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   Memory: 645MiB / 31951MiB
+sssshhhyNMMNyssssssssssssyNMMMysssssss+
.ssssssssdMMMNhsssssssssshNMMMdssssssss.
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/
  +sssssssssdmydMMMMMMMMddddyssssssss+
   /ssssssssssshdmNNNNmyNMMMMhssssss/
    .ossssssssssssssssssdMMMNysssso.
      -+sssssssssssssssssyyyssss+-
        `:+ssssssssssssssssss+:`
            .-/+oossssoo+/-.

10k connections, 1k payload, benchmark for all frameworks

run:

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

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

results:


20240403 16:31.05.050 [BenchEcho] Report

FrameworkTPSEERMinAvgMaxTP50TP75TP90TP95TP99UsedTotalSuccessFailedConnsConcurrencyPayloadCPU MinCPU AvgCPU MaxMEM MinMEM AvgMEM Max
fasthttp770272860.5019.22us12.92ms156.10ms11.08ms12.77ms19.26ms20.36ms32.31ms2.60s20000002000000010000100001024677.71895.151136.53335.48M335.48M335.48M
gobwas586901505.4215.13us16.83ms219.14ms11.93ms18.49ms28.34ms48.72ms103.06ms3.41s20000002000000010000100001024583.301161.221451.58400.59M415.20M429.80M
gorilla763962831.8514.81us13.04ms136.80ms10.97ms13.09ms19.61ms21.21ms48.99ms2.62s20000002000000010000100001024704.82918.391131.96288.24M288.24M288.24M
gws759921776.5011.82us13.12ms156.34ms10.83ms14.53ms19.60ms21.46ms46.94ms2.63s20000002000000010000100001024760.20978.651203.86216.65M216.65M216.65M
gws_std790027917.3416.70us12.60ms135.46ms10.59ms12.29ms19.02ms20.17ms51.95ms2.53s20000002000000010000100001024585.79861.211136.64217.44M217.44M217.44M
hertz475530764.061.07ms20.95ms72.61ms18.44ms22.35ms34.48ms36.80ms42.35ms4.21s20000002000000010000100001024164.81622.37780.84523.80M556.98M590.17M
hertz_std7246481041.2717.86us13.74ms236.25ms11.40ms12.99ms19.87ms22.16ms93.24ms2.76s200000020000000100001000010240.00695.931194.34360.41M361.41M362.41M
nbio_blocking763517840.9215.91us13.02ms125.83ms10.96ms13.41ms19.41ms20.61ms49.08ms2.62s20000002000000010000100001024693.08907.961122.83213.23M213.23M213.23M
nbio_mixed789053917.1514.92us12.60ms148.03ms10.54ms12.94ms19.24ms20.27ms55.67ms2.53s20000002000000010000100001024603.90860.331127.10272.71M272.71M272.71M
nbio_nonblocking7174961044.3429.75us13.90ms168.11ms12.07ms13.85ms20.14ms21.29ms35.10ms2.79s200000020000000100001000010240.00687.041142.5686.80M95.38M103.96M
nbio_std753412821.5711.66us13.23ms223.49ms10.92ms13.05ms19.54ms21.57ms77.76ms2.65s20000002000000010000100001024719.26917.041114.81202.95M202.95M202.95M
nettyws778445892.5914.18us12.79ms142.58ms10.86ms13.31ms19.36ms20.35ms27.50ms2.57s20000002000000010000100001024636.37872.121127.89189.11M189.11M189.11M
nhooyr659804651.8919.06us15.10ms181.33ms11.14ms14.08ms24.10ms37.20ms107.87ms3.03s2000000200000001000010000102424.981012.141515.70386.97M386.97M386.97M
quickws782685944.6115.31us12.71ms139.09ms10.78ms12.24ms19.28ms20.40ms41.09ms2.56s20000002000000010000100001024578.30828.581086.75150.31M150.31M150.31M
greatws648302983.0430.80us15.35ms302.55ms13.35ms16.50ms21.74ms24.18ms62.52ms3.08s2000000200000001000010000102468.93659.49973.74154.16M154.71M155.25M
greatws_event6573851158.5928.88us15.17ms190.30ms13.45ms16.33ms21.33ms22.78ms31.36ms3.04s2000000200000001000010000102411.99567.40845.77161.71M163.85M165.98M


20240403 16:31.05.064 [BenchRate] Report

FrameworkDurationEchoEERPacket SentBytes SentPacket RecvBytes RecvConnsSendRatePayloadCPU MinCPU AvgCPU MaxMEM MinMEM AvgMEM Max
fasthttp10.00s1867.331990000018.98G1986854618.95G1000020010241043.721064.011092.89368.16M402.69M461.00M
gobwas10.00s650.821100172010.49G1067569210.18G1000020010241528.811640.331744.65423.34M431.77M442.66M
gorilla10.00s2079.851990000018.98G1990000018.98G1000020010240.00956.801078.91328.34M397.06M464.05M
gws10.00s1866.561985087018.93G1985087018.93G1000020010240.001063.501207.03245.38M251.12M259.20M
gws_std10.00s2069.831988796018.97G1988796018.97G1000020010240.00960.851075.37251.84M257.60M266.69M
hertz10.00s1471.931569103014.96G1552180914.80G1000020010241028.861054.521098.86756.00M786.49M841.21M
hertz_std10.00s1752.331987950018.96G1982103518.90G1000020010241117.021131.131148.89396.29M460.64M504.64M
nbio_blocking10.00s2004.791988453018.96G1988453018.96G1000020010240.00991.851116.45238.64M252.28M270.88M
nbio_mixed10.00s1854.411989992018.98G1988130418.96G1000020010241046.511072.111092.85427.79M451.41M464.98M
nbio_nonblocking10.00s1548.991964920018.74G1955925518.65G1000020010241217.771262.711285.73136.00M158.42M181.10M
nbio_std10.00s1968.851984975018.93G1984975018.93G1000020010240.001008.191140.91222.25M242.36M265.38M
nettyws10.00s1924.261990000018.98G1990000018.98G100002001024979.881034.161061.80205.34M206.97M207.56M
nhooyr10.00s1150.491865968017.80G1853425217.68G1000020010241575.611610.991645.84388.97M391.11M391.66M
quickws10.00s2238.761990000018.98G1990000018.98G1000020010240.00888.891010.88154.31M155.87M156.31M
greatws10.00s1626.121964332018.73G1958145818.67G1000020010241151.571204.181240.71154.30M162.51M170.98M
greatws_event10.00s1914.011988919018.97G1985830718.94G100002001024984.681037.521058.69154.58M163.28M177.87M

1m connections, 1k payload, benchmark for nbio/greatws

run:

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

result:


20240403 16:35.28.724 [Connections] Report

FrameworkTPSMinAvgMaxTP50TP75TP90TP95TP99UsedTotalSuccessFailedConcurrency
nbio_nonblocking6405810ns30.94ms15.61s20ns20ns21ns30ns31ns15.61s1000000100000002000
greatws6388210ns31.04ms15.65s20ns21ns30ns40ns121ns15.65s1000000100000002000
greatws_event6932410ns28.61ms14.42s20ns20ns30ns31ns51ns14.43s1000000100000002000

20240403 16:35.28.732 [BenchEcho] Report

FrameworkTPSEERMinAvgMaxTP50TP75TP90TP95TP99UsedTotalSuccessFailedConnsConcurrencyPayloadCPU MinCPU AvgCPU MaxMEM MinMEM AvgMEM Max
nbio_nonblocking152342440.1227.08us65.54ms1.08s34.59ms37.14ms133.20ms367.50ms453.01ms13.13s2000000200000001000000100001024189.15346.13496.95967.02M967.58M968.51M
greatws141385412.6625.55us70.62ms1.05s37.50ms42.03ms143.13ms373.50ms463.37ms14.15s2000000200000001000000100001024112.40342.62399.85575.97M576.48M576.86M
greatws_event145457514.7924.77us68.66ms1.00s35.80ms38.67ms140.22ms373.21ms453.04ms13.75s200000020000000100000010000102448.71282.56340.90447.33M448.25M448.86M