Maximum concurrent Socket.IO connections

前端 未结 5 1858
旧时难觅i
旧时难觅i 2020-11-29 15:23

This question has been asked previously but not recently and not with a clear answer.

Using Socket.io, is there a maximum number of concurrent connections that one c

相关标签:
5条回答
  • 2020-11-29 15:36

    I tried to use socket.io on AWS, I can at most keep around 600 connections stable.

    And I found out it is because socket.io used long polling first and upgraded to websocket later.

    after I set the config to use websocket only, I can keep around 9000 connections.

    Set this config at client side:

    const socket = require('socket.io-client')
    const conn = socket(host, { upgrade: false, transports: ['websocket'] })
    
    0 讨论(0)
  • 2020-11-29 15:38

    For +300k concurrent connection:

    Set these variables in /etc/sysctl.conf:

    fs.file-max = 10000000 
    fs.nr_open = 10000000
    

    Also, change these variables in /etc/security/limits.conf:

    * soft nofile 10000000
    * hard nofile 10000000
    root soft nofile 10000000
    root hard nofile 10000000
    

    And finally, increase TCP buffers in /etc/sysctl.conf, too:

    net.ipv4.tcp_mem = 786432 1697152 1945728
    net.ipv4.tcp_rmem = 4096 4096 16777216
    net.ipv4.tcp_wmem = 4096 4096 16777216
    

    for more information please refer to https://www.linangran.com/?p=547

    0 讨论(0)
  • 2020-11-29 15:47

    This article may help you along the way: http://drewww.github.io/socket.io-benchmarking/

    I wondered the same question, so I ended up writing a small test (using XHR-polling) to see when the connections started to fail (or fall behind). I found (in my case) that the sockets started acting up at around 1400-1800 concurrent connections.

    This is a short gist I made, similar to the test I used: https://gist.github.com/jmyrland/5535279

    0 讨论(0)
  • 2020-11-29 15:56

    After making configurations, you can check by writing this command on terminal

    sysctl -a | grep file
    
    0 讨论(0)
  • 2020-11-29 15:57

    This guy appears to have succeeded in having over 1 million concurrent connections on a single Node.js server.

    http://blog.caustik.com/2012/08/19/node-js-w1m-concurrent-connections/

    It's not clear to me exactly how many ports he was using though.

    0 讨论(0)
提交回复
热议问题