码迷,mamicode.com
首页 > Windows程序 > 详细

linux和windows下TIME_WAIT过多的解决办法

时间:2017-11-15 10:48:16      阅读:387      评论:0      收藏:0      [点我收藏+]

标签:ack   npos   effective   server   appear   sts   situation   .com   current   

http://www.51testing.com/html/48/202848-249774.html

linux和windows下TIME_WAIT过多的解决办法

 

http://m.sohu.com/a/122714498_412810

Windows time_wait过多解决办法

 

 

沐浴晨曦:
是配置的问题。。
除了用tcpwaitdelay之外 还需要配置maxuserport 除此之外 还需要加入动态端口的范围 netsh int ipv4 set dynamicport tcp start=1025 num=60000
沐浴晨曦:
tcpwaitdelay的值必须为微软官方推荐值 30 dword值是1e
我试过改成1 或者5 问题复现
沐浴晨曦:
改为30 问题消失 猜测如果值不是30到300就使用默认值240
沐浴晨曦:
也就是四分钟回收tcp链接

 

技术分享

百度来的答案 改成什么 1或者0。。。
是不对的

 

 

I am using Jmeter to test multiple requests to my web application.
I used NumberOfThread in Jmeter as 50.

My process is as follows:

  1. Login page.
  2. Login with userID and password.
  3. Show menu page.
  4. Click search page.
  5. Go to search page.
  6. Click search button.
  7. Click the searched result link to go to update page.
  8. Update data and click update button.
  9. Show the updated result page.
  10. Go back to search page.
  11. Log out button click.

In the above process, I used looping controller for process number 5 to 10 with 5 looping.
In that situation, if I used more than 25 thread to run Jmeter test, address already in use, the socket binding exception has occur.

I would like to know how to solve that problem.

shareimprove this question
 

Looks like your client ran out of ephemeral port or there‘s some problem with your client environment.
Are you using Windows?

You can possibly do at least the following:

  1. Windows: look into this article for solution for Windows system as host for jmeter.
  2. Use Linux system instead as host to run you Jmeter load-scenarios.

 

As well you possibly will find this article useful for your testing activities (I‘ve seen Jboss in tags).


UPDATE:

Once more from linked article above:

When an HTTP request is made, an ephemeral port is allocated for the TCP / IP connection. The ephemeral port range is 32678 – 61000. After the client closes the connection, the connection is placed in the TIME-WAIT state for 60 seconds.

If JMeter (HttpClient) is sending thousands of HTTP requests per second and creating new TCP / IP connections, the system will run out of available ephemeral ports for allocation.

. . .

Otherwise, the following messages may appear in the JMeter JTL files:

Non HTTP response code: java.net.BindException
Non HTTP response message: Address already in use

The solution is to enable fast recycling TIME_WAIT sockets.

echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle

Other options include TCP_FIN_TIMEOUT to reduce how long a connection is placed in the TIME_WAIT state and TCP_TW_REUSE to allow the system to reuse connections placed in the TIME_WAIT state.

On the server‘s side:

  • This enables fast recycling of TIME_WAIT sockets

    /sbin/sysctl -w net.ipv4.tcp_tw_recycle=1

  • This allows reusing sockets in TIME_WAIT state for new connections - a safer alternative to tcp_tw_recycle

    /sbin/sysctl -w net.ipv4.tcp_tw_reuse=1

    The tcp_tw_reuse setting is particularly useful in environments where numerous short connections are open and left in TIME_WAIT state, such as web-servers. Reusing the sockets can be very effective in reducing server load.

  • Maximum number of timewait sockets held by system simultaneously

    /sbin/sysctl -w net.ipv4.tcp_max_tw_buckets=30000

or the same but in another way - add the lines below to the /etc/sysctl.conf file so that the change survives reboot:

net.ipv4.tcp_max_tw_buckets = 30000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1

As well on the server‘s side look onto result of ulimit -n.
Default value is 1024 for the limit of max open files, which can explain appearance of BindExceptions at 1000 connections.

As well you can monitor number of connections between the server and jmeter during test-run using e.g.

netstat -an | grep SERVER_PORT | wc -l

to define limit of connections - if any.

shareimprove this answer
 
    
Thanks Belik, your answer very helpful for me. However, it still not solved by trying them. – PyiSoeMaw Jan 8 ‘13 at 11:44
    
So, any new details? If Windows OS: same behavior after applying all the instructions? – Aliaksandr Belik Jan 8 ‘13 at 12:39
    
I am using CentOS 5 for Apache Server and testing from Windows XP client PC. I have followed the detail procedure of the referenced link. However, it didn‘t work. But I found something that if I changed KeepAliveTimeout into 15 in httpd.conf file in CentOS server, it does solved the problem. Honestly, I don‘t clearly understand why it is solved by doing it. Do you have any idea about it? – PyiSoeMaw Jan 9 ‘13 at 3:37
    
Have you increased or decreased KeepAliveTimeout value? Please look into update in answer, I‘ve added several common issues for load-testing using linux boxes. Maybe something of these point will be helpful for you. – Aliaksandr Belik Jan 9 ‘13 at 13:03

linux和windows下TIME_WAIT过多的解决办法

标签:ack   npos   effective   server   appear   sts   situation   .com   current   

原文地址:http://www.cnblogs.com/rslai/p/7837531.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!