美文网首页
linux并发服务器优化配置

linux并发服务器优化配置

作者: 搬砖中年人 | 来源:发表于2019-04-04 19:41 被阅读0次

    #五万连接优化方案

    系统限制最多只允许单个端口 61000-32758=28232个线程

    echo "10000 65535" > /proc/sys/net/ipv4/ip_local_port_range

    #加大打开文件数的限制

    vi /etc/security/limits.conf

    * soft nofile 65535

    * hard nofile 65535

    hive - nofile 65535

    hive - nproc 65535

    #用户进程限制 此步骤需要重启机器生效,可以设置完后再重启

    vi /etc/security/limits.d/20-nproc.conf

    * soft nproc 62459

    root soft nproc 62459

    #网络线程优化

    vi /etc/sysctl.conf

    # Disable IPv6

    net.ipv6.conf.all.disable_ipv6 = 1

    net.ipv6.conf.default.disable_ipv6 = 1

    # Determines how often to check for stale neighbor entries.

    net.ipv4.neigh.default.gc_stale_time=120

    # Using arp_announce/arp_ignore to solve the ARP Problem

    net.ipv4.conf.default.arp_announce = 2

    net.ipv4.conf.all.arp_announce=2

    vm.swappiness = 0

    net.ipv4.tcp_max_tw_buckets = 5000

    net.ipv4.tcp_max_syn_backlog = 1024

    net.ipv4.tcp_synack_retries = 2

    net.ipv4.conf.lo.arp_announce=2

    net.ipv4.tcp_keepalive_time = 1800

    net.ipv4.tcp_keepalive_probes = 3

    net.ipv4.tcp_keepalive_intvl = 15

    net.ipv4.tcp_syncookies = 1

    net.ipv4.tcp_tw_reuse = 1

    net.ipv4.tcp_tw_recycle = 1

    net.ipv4.tcp_fin_timeout = 30

    #本配置如果不配置 最大连接数会有限制

    kernel.pid_max=65535

    #保存退出

    #执行命令生效 /sbin/sysctl -p

    相关文章

      网友评论

          本文标题:linux并发服务器优化配置

          本文链接:https://www.haomeiwen.com/subject/ecvopqtx.html