EMQ或EMQ X百万级并发调优(基于CentOS 7)

1、设置句柄数

    1)全局分配

            sysctl -w fs.file-max=2097152

            sysctl -w fs.nr_open=2097152

            echo 2097152 > /proc/sys/fs/nr_open

            echo "fs.nr_open = 2097152" >> /etc/sysctl.conf

            echo "fs.file-max = 2097152" >> /etc/sysctl.conf

            sysctl -p

    2)服务分配

            echo "DefaultLimitNOFILE=1048576" >> /etc/systemd/system.conf

    3)用户/进程分配

            ulimit -n 1048576

            echo "* soft nofile 1048576" >> /etc/security/limits.conf

            echo "* hard nofile 1048576" >> /etc/security/limits.conf

 

2、设置TCP协议栈网络参数

        echo "net.core.somaxconn = 32768" >> /etc/sysctl.conf

        echo "net.ipv4.ip_local_port_range = 1000    65535" >> /etc/sysctl.conf

        echo "net.ipv4.tcp_max_syn_backlog = 16384" >> /etc/sysctl.conf

        echo "net.core.netdev_max_backlog=16384" >> /etc/sysctl.conf

        echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf    

        echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf

        echo "net.core.rmem_max = 16777216" >> /etc/sysctl.conf

        echo "net.core.wmem_max = 16777216" >> /etc/sysctl.conf

        echo "net.core.optmem_max = 16777216" >> /etc/sysctl.conf

        echo "net.ipv4.tcp_rmem = 1024 4096 16777216" >> /etc/sysctl..conf

        echo "net.ipv4.tcp_wmem = 1024 4096 16777216" >> /etc/sysctl.conf

        echo "net.ipv4.tcp_fin_timeout = 15" >> /etc/sysctl.conf

        echo "net.ipv4.tcp_max_tw_buckets = 1048576" >> /etc/sysctl.conf

        sysctl -p

 

3、设置Erlang虚拟机参数

        sed -ri 's#node.process_limit = 256000#node.process_limit = 2097152#g' /etc/emqttd/emq.conf

        sed -ri 's#node.max_ports = 65536#node.max_ports = 1048576#g' /etc/emqttd/emq.conf

        sed -ri 's#listener.tcp.external.acceptors = 16#listener.tcp.external.acceptors = 64#g' /etc/emqttd/emq.conf

        sed -ri 's#listener.tcp.external.max_clients = 102400#listener.tcp.external.max_clients = 1000000#g' /etc/emqttd/emq.conf

 

4、修改EMQ消息服务器参数

        sed -ri 's#listener.tcp.external = 127.0.0.1:1883#listener.tcp.external = 0.0.0.0:1883#g' /etc/emqttd/emq.conf

        sed -ri 's#listener.tcp.external.acceptors = 16#listener.tcp.external.acceptors = 64#g' /etc/emqttd/emq.conf

        sed -ri 's#listener.tcp.external.max_clients = 102400#listener.tcp.external.max_clients = 1000000#g' /etc/emqttd/emq.conf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值