nginx环境

  • 基准环境

    # gcc编译器:编译安装
    yum install -y gcc gcc-c++
    # pcre库:perk兼容正则表达式
    yum install -y pcre pcre-devel
    # zlib: nginx处理http响应,支持gzip先压缩后传输,加少网络传输量
    yum install -y zlib zlib-devel
    # openssl库: http+ssl安全传输协议
    yum install -y openssl openssl-devel
    
  • 内核优化

    fs.file-max = 100000
    net.ipv4.tcp_tw_reuse = 1
    net.ipv4.tcp_keepalive_time = 600
    net.ipv4.tcp_fin_timeout = 30
    net.ipv4.tcp_max_tw_buckets = 5000
    net.ipv4.ip_local_port_range = 1024 61000
    
    • fs.file-max: 进程可以同时打开的最大句柄数。直接限制做大并发连接数
    • tcp_tw_reuse:允许将处于TIME_WAIT状态的socket重新用户新TCP连接
    • tcp_keepalive_time:TCP发送keepalive消息的频度,默认2个小时。有利于清理无效的链接
    • tcp_fin_timeout:socket连接由本段关闭时,保持在FIN-WAIT-2状态的时间
    • tcp_max_tw_buckets:TIME_WAIT状态的最大连接数,超过被立刻清除并警告
    • ip_local_port_range:TCP/UDP链接的端口范围。把值改大是为了防止高并发时可能无法建立连接的情况
posted @ 2021-02-28 21:04  那就这样吧~  阅读(59)  评论(0编辑  收藏  举报