V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
aruisi
V2EX  ›  Linux

TIME_WAIT 过高如何优化?

  •  
  •   aruisi · 2017-06-20 11:28:02 +08:00 · 2692 次点击
    这是一个创建于 2495 天前的主题,其中的信息可能已经有所发展或是发生改变。
    TIME_WAIT 1979
    FIN_WAIT1 3
    FIN_WAIT2 24
    ESTABLISHED 741
    SYN_RECV 6
    LAST_ACK 4

    单跑 nginx,nginx 配置
    worker_rlimit_nofile 200000;
    worker_connections 102400;
    multi_accept on;
    use epoll;
    keepalive_timeout 10;
    client_header_timeout 10;
    client_body_timeout 5;
    reset_timedout_connection on;
    send_timeout 10;
    open_file_cache max=100000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
    gzip on;


    当前 sysctl.conf
    net.ipv4.tcp_syncookies = 1
    net.ipv4.tcp_tw_reuse = 1
    net.ipv4.tcp_tw_recycle = 1
    net.ipv4.tcp_fin_timeout = 6
    net.ipv4.tcp_keepalive_probes = 3
    net.ipv4.tcp_orphan_retries = 1
    net.ipv4.tcp_max_tw_buckets = 6000
    net.ipv4.ip_local_port_range = 1024 65000
    net.core.somaxconn =262144
    net.core.netdev_max_backlog = 262144
    net.ipv4.tcp_max_orphans = 262144
    net.ipv4.tcp_timestamps = 0
    net.ipv4.tcp_synack_retries = 1
    net.ipv4.tcp_syn_retries = 1
    net.ipv4.tcp_fin_timeout = 1

    找了好多资料都不见效,有没什么猛药?
    3 条回复    2017-06-20 15:04:35 +08:00
    ToughGuy
        1
    ToughGuy  
       2017-06-20 14:23:13 +08:00   ❤️ 1
    才 2000 个不到而已, 完全不用理会, 这个对系统性能影响甚微, 不用太想着去优化这一块儿。

    下面是我们的一个 web 服务.

    ss -nat | awk '{a[$1]++}END{for (i in a) printf("%-10s %s\n",a[i],i)}' | sort -rnk 1

    29405 TIME-WAIT
    2168 ESTAB
    31 FIN-WAIT-2
    15 SYN-SENT
    12 LISTEN
    10 SYN-RECV
    3 FIN-WAIT-1
    1 State
    1 CLOSING
    aruisi
        2
    aruisi  
    OP
       2017-06-20 14:42:01 +08:00
    @ToughGuy 原来如此啊,那就不管了。谢谢~
    denghongcai
        3
    denghongcai  
       2017-06-20 15:04:35 +08:00 via Android   ❤️ 1
    time_wait 是正常状态,适当限制下数量就好了
    不要去搜索什么 tw 解决方法,你看你就配了个 tw_recycle 害自己
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1514 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:05 · PVG 01:05 · LAX 10:05 · JFK 13:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.