go websocket rps, cpu, latency 全面测评

查看 18|回复 0
作者:Nazz   
本来想测试四款websocket package的, 但是gobwas/ws数据太异常还是不放了. 今天测试的三个库分别是
  • gorilla/websocket
  • nhooyr/websocket
  • lxzan/gws

    测试代码地址: github
    Env

    WebSocket Protocol
    正确性高于性能, 首先测试一下WebSocket协议. 每个包基本都是用的默认配置,为了节省时间,本项测试关闭了压缩.
    可以看到,尽管 gorilla/websocket 和 nhooyr/websocket 宣称通过了所有 autobahn-testsuite 测试,但可能还需要开发者额外写一些代码.
  • 命令

    docker run -it --rm \
      -v ${PWD}/config:/config \
      -v ${PWD}/reports:/reports \
      crossbario/autobahn-testsuite \
      wstest -m fuzzingclient -s /config/fuzzingclient.json
  • 结果

    [td]package[/td]
    [td]Pass[/td]
    [td]Info[/td]
    [td]Non-Strict[/td]
    [td]Unclean[/td]
    [td]Failed[/td]
    lxzan/gws
    294
    3
    4
    0
    0
    gorilla/websocket
    223
    3
    0
    85
    75
    nhooyr/websocket
    173
    3
    0
    0
    125

    RPS
    // 1000 connections, 500 messages/second, 1000 Byte Payload
    tcpkali -c 1000 --connect-rate 500 -r 500 -T 30s -f assets/1K.txt --ws 127.0.0.1:${port}/connect
  • gws

    Destination: [127.0.0.1]:8000
    Interface lo address [127.0.0.1]:0
    Using interface lo to connect to [127.0.0.1]:8000
    Ramped up to 1000 connections.
    Total data sent:     12919.8 MiB (13547411965 bytes)
    Total data received: 12854.5 MiB (13478908970 bytes)
    Bandwidth per channel: 7.178⇅ Mbps (897.2 kBps)
    Aggregate bandwidth: 3594.175↓, 3612.441↑ Mbps
    Packet rate estimate: 316194.9↓, 581166.7↑ (3↓, 2↑ TCP MSS/op)
    Test duration: 30.0017 s.
  • gorilla

    Destination: [127.0.0.1]:8001
    Interface lo address [127.0.0.1]:0
    Using interface lo to connect to [127.0.0.1]:8001
    Ramped up to 1000 connections.
    Total data sent:     7077.0 MiB (7420776528 bytes)
    Total data received: 7089.8 MiB (7434174595 bytes)
    Bandwidth per channel: 3.961⇅ Mbps (495.1 kBps)
    Aggregate bandwidth: 1982.319↓, 1978.746↑ Mbps
    Packet rate estimate: 272613.9↓, 173441.2↑ (2↓, 12↑ TCP MSS/op)
    Test duration: 30.0019 s.
  • nhooyr

    Destination: [127.0.0.1]:8002
    Interface lo address [127.0.0.1]:0
    Using interface lo to connect to [127.0.0.1]:8002
    Ramped up to 1000 connections.
    Total data sent:     5103.5 MiB (5351431830 bytes)
    Total data received: 5140.6 MiB (5390317539 bytes)
    Bandwidth per channel: 2.856⇅ Mbps (357.0 kBps)
    Aggregate bandwidth: 1437.359↓, 1426.990↑ Mbps
    Packet rate estimate: 135048.1↓, 124004.1↑ (1↓, 14↑ TCP MSS/op)
    Test duration: 30.0012 s.
    Latency
  • 1000 connections, 100 messages/second, 1000 Byte Payload




      PID   USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
      18305 caster    20   0  720780  38116   7332 S 248.8   1.0  24:29.55 gorilla-linux-amd64
      18325 caster    20   0  720952  52544   7180 S 161.1   1.3  15:57.80 gws-linux-amd64
      18346 caster    20   0  721460  50064   7364 R 311.3   1.3  20:49.94 nhooyr-linux-amd64
  • 10000 connections, 10 messages/second, 1000 Byte Payload




      PID   USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
      19430 caster    20   0 1070196 395408   6924 S 294.0   9.9   3:44.56 gws-linux-amd64
      19618 caster    20   0  930480 267108   7268 S 313.0   6.7   9:01.10 gorilla-linux-amd64
      20939 caster    20   0 1067980 372916   7236 R 455.8   9.3  12:12.72 nhooyr-linux-amd64
    Final Result
    可以看到, 除了内存, 每一项都是
    gws > gorilla >> nhooyr
  • 您需要登录后才可以回帖 登录 | 立即注册

    返回顶部