在 Windows 上遇到非常多 TIME_WAIT 連線時應如何處理

当流量大的网站或服务器出现大量TIME_WAIT状态的TCP连接时,可能会占用大量可用的连接端口。TIME_WAIT状态的默认超时时间是MSL的两倍,通常为4分钟。为了释放端口资源,可以通过调整Windows注册表中TcpTimedWaitDelay的值来缩短TIME_WAIT状态的持续时间,例如设置为30秒。这有助于避免WSAENOBUFS错误,确保服务器能够处理更多连接。

我們公司所代管的網站裡,有幾個流量是非常大的,在尖峰的時刻同時上線人數可能高達數千到數萬人,而在這個時候如果使用 netstat 或 TCPView 查看所有 TCP 連線時就會看到非常多處於 TIME_WAIT 狀態的連線,平時就會多達數千條 TIME_WAIT 連線之多,尖峰的時候還有一萬多條 TIME_WAIT 連線的狀況,雖然這些連線目前還不致於造成連線發生問題,但基於一股好奇心才決定研究到底查探個究竟,深入研究後才得知這問題現在不處理,等網站流量在大一些的時候那就會出亂子了!

以下是用 TCPView 查看連線狀況時的畫面,其中的 TIME_WAIT 狀態下的連線可能會很多:

TCPView - Sysinternals

熟悉 TCP/IP 的開發人員應該知道一台電腦可使用的 連接埠 (Ports) 是有限的,最多也只有 65536連接埠可以使用,且不管  

Console File version of D:/Xilinx/14.7/I5E_DS/ISE/data/xusb_xp2.hex = 2401. Firmware hex file version = 2401. PLD file version = 200Dh. pLD version = 200Dh. Type = 0x0005. ESNoption:00001D35501. DINFO:iMPACT - Failed to open file: --File ?--, replace with 'bypass'. D INFO:iMPACT:1777- Reading D:/Xi1inx/14.7/I5E DS/ISE/spartan6/data/xc6slxl6.bsd... À INEO:iMPACT:501-111: Added Device xc6slx16 successfully. Unprotect sectors: FALSE D INFO:iMPACT -A CFI file is not detected. To ensure correct and safe configuration, Please make sure a CFI file is present in the same directory as the PROM file, or, regenerate the PROM file with the latest software. Active mode is BS Project:'C:\Windows\system32\\auto_project.ipf' loaded. À INFO:iMPACT- Current time: 2025/8/14 16:15:06 PROGRESS START - Starting Operation. '1*: spr access core not detected. SPI access core will be downloaded to the device to enable operations. W INFO:iMPACT - Downloading core file D:/Xi1inx/14.7/I5E_DS/ISE/spartan6/data/xc6slxl6_spi.cor. *1*: Downloading core... LCK_cycle = NoWait. LCK cycle: NoWait done, *1*: Reading status register contents... L INEO:MPACT:2219 - Status register values: A INFO:MPACT- 0011 1100 1110 1100 ÀINFO:MPACT:2492-1': Completed downloading core to device. *1*: ID Check passed. *1*: ID Check passed *1*: Erasing Device. *1':Dsing Sector Erase. *1*;Programming Flash, *1': Reading device contents... done. *1': Verification completed, AINFO:1MPACT- File C:/Users/DZGD/Desktop/EB-CPU-64/20231019.cfi does not exist. *1*:Programming in Xl mode. *1*: Configuration data download to FPGA was not successful. DONE did not go high, please check your configuracion setup and mode settings. AINEO:iMPACT-'1'; Flash was not programmed succeasfully. FROGRESS END - End OperaLion, Elapsed Cime = 113 sec,
最新发布
08-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值