使用 jmeter 的 Apache 多个请求 [英] Apache multiple requests with jmeter

查看:21
本文介绍了使用 jmeter 的 Apache 多个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Jmeter 测试对我的 Web 应用程序的多个请求.
我在 Jmeter 中使用 NumberOfThread 作为 50.

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

我的流程如下:

  1. 登录页面.
  2. 使用用户名和密码登录.
  3. 显示菜单页面.
  4. 点击搜索页面.
  5. 转到搜索页面.
  6. 点击搜索按钮.
  7. 点击搜索结果链接进入更新页面.
  8. 更新数据并点击更新按钮.
  9. 显示更新后的结果页面.
  10. 返回搜索页面.
  11. 点击退出按钮.

在上面的过程中,我使用循环控制器处理5到10个进程,循环5次.
在这种情况下,如果我使用超过25个线程运行Jmeter测试,address already in use,发生socket绑定异常.

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.

推荐答案

看起来您的客户端用完了临时端口,或者您的客户端环境存在问题.
您使用的是 Windows 吗?

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:查看这篇文章 用于 Windows 系统作为 jmeter 主机的解决方案.
  2. 使用 Linux 系统作为主机来运行 Jmeter 负载方案.
  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.


您也可能会发现这篇文章对您的测试活动很有用(我已经在标签中看到了 Jboss).

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

更新:

再次来自上面链接的文章:

当发出一个 HTTP 请求时,一个临时端口被分配给TCP/IP 连接.临时端口范围是 32678 – 61000.客户端关闭连接,连接放置在TIME-WAIT 状态 60 秒.

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.

如果 JMeter (HttpClient) 每次发送数千个 HTTP 请求其次,创建新的 TCP/IP 连接,系统将耗尽用于分配的可用临时端口数.

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.

...

否则,JMeter JTL 文件中可能会出现以下消息:

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

非 HTTP 响应代码:java.net.BindException
非 HTTP 响应消息:地址已被使用

解决方案是启用快速回收 TIME_WAIT 套接字.

The solution is to enable fast recycling TIME_WAIT sockets.

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

其他选项包括 TCP_FIN_TIMEOUT 以减少连接时间置于 TIME_WAIT 状态和 TCP_TW_REUSE 以允许系统重用处于 TIME_WAIT 状态的连接.

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.

在服务器端:

  • 这样可以快速回收 TIME_WAIT 套接字

  • This enables fast recycling of TIME_WAIT sockets

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

这允许为新连接重用 TIME_WAIT 状态的套接字 - tcp_tw_recycle 的更安全替代方案

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

tcp_tw_reuse 设置在大量短连接打开并处于 TIME_WAIT 状态的环境中特别有用,例如网络服务器.重用套接字可以非常有效地减少服务器负载.

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

或相同但以另一种方式 - 将以下行添加到 /etc/sysctl.conf 文件,以便更改在重启后仍然有效:

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

同样在服务器端查看 ulimit -n 的结果.
max open files 的限制默认值为1024,可以解释1000个连接时出现BindExceptions.

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.

您还可以在测试运行期间使用例如监控服务器和 jmeter 之间的连接数

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.

这篇关于使用 jmeter 的 Apache 多个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆