zoukankan      html  css  js  c++  java
  • 一次压力测试Loadrunner经验分享

    一次压力测试Loadrunner经验分享       

        

    Action.c(4): Error -27796: Failed to connect to server "stadig.ifeng.com:80": [10048] Address already in use

    Try changing the registry value

    HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/tcpip/Parameters/TcpTimedWaitDelay to 30

    and HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/tcpip/Parameters/MaxUserPort to 65534

    and rebooting the machine

    See the readme.doc file for more information

    压测目标是一个简单的js,服务器处理很快。LR压力测试遇到如上错误,跟据提示在注册表中已将TcpTimedWaitDelay  改为 1;MaxUserPort 改为 65534;并且重启电脑。运行后仍出现上面的错误。后来在 run-time setting/browser emulation中

    将simulate a new user on each iteration  选项去掉(默认是选中的)。重新运行一切正常,没有错误出现。

    猜测原因,客户端性能比较好,发出压力太快,所以把tcp/ip的连接或端口占满。在网上查了一下,xp好像默认开启15个tcp/ip

    去掉这个选项的意思是,始终使用一个tcp/ip链接,不断开,也就是开发人员所说的长链接或持久连接。    短连接:建立连接-----发送和接收报文1-------关闭连接 长连接:建立连接-----发送和接收报文1.。。。2.。。。3-----关闭连接

    有大量ESTABLISHED 状态的TCP6连接,并且有若干TIME_WAIT的状态。

    端口占用大概在5W6以上。 qatest@db-62:~$ netstat -an|wc -l 56179

    而测试机端口数为: qatest@db-62:~$ cat /proc/sys/net/ipv4/ip_local_port_range 8192 65535

    可见,端口基本被用尽。

    4. 问题解决

    1. 根据TCP/IP协议,连接断开之后,端口不会立刻被释放,而是处于TIME_WAIT状态,等待60s后(貌似/proc/sys/net/ipv4/tcp_fin_timeout配置),才会被释放掉,才能被新连接使用。 而性能测试并发了3W连接,每个连接关闭后,grinder又迅速创建新的连接,这时已关闭的连接所占用的端口实际是TIME_WIAT状态,未被释放,不能为新的连接所使用,当所有的端口号均被占用之后,新建连接因为无法分配到端口号而失败。
    2. 修改tpc/ip协议配置,通过配置TCP_TW_REUSE参数,来释放TIME_WAIT状态的端口号给新连接使用 /proc/sys/net/ipv4/tcp_tw_reuse (boolean, default: 0)

      Note: 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.

    3. 同时修改   /proc/sys/net/ipv4/tcp_tw_recycle (boolean, default: 0)

      TCP_TW_RECYCLE It enables fast recycling of TIME_WAIT sockets. The default value is 0 (disabled). The sysctl documentation incorrectly states the default as enabled. It can be changed to 1 (enabled) in many cases. Known to cause some issues with hoststated (load balancing and fail over) if enabled, should be used with caution.

      参考资料: http://www.speedguide.net/articles/linux-tweaking-121
    4. 设置参数后,重新测试,不再出现异常情况。
    5. 长连接服务器的性能测试中, 修改以上两个参数可以解决问题。但是在并发短连接情况下,还不足以解决问题。比如短连接10ms的情况下,仍然会出现端口号用尽的情况,这个需要修改TIME_WAIT时间,需要进一步调研。
     
    转自:http://blog.csdn.net/lxlmj/article/details/6570060
  • 相关阅读:
    题解报告:hdu1995汉诺塔V(递推dp)
    黑色CSS3立体动画菜单
    jQuery计算器插件
    CSS3动画库animate.css
    缩略图悬浮效果的jQuery焦点图
    CSS伪元素实现的3D按钮
    CSS3 3D旋转按钮对话框
    jQuery仿Android锁屏图案应用
    jQuery横向图片手风琴
    jQuery滑动杆打分插件
  • 原文地址:https://www.cnblogs.com/shouwu/p/2803278.html
Copyright © 2011-2022 走看看