Apache用jmeter多次请求 [英] Apache multiple requests with jmeter

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

问题描述

我正在使用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. 使用用户ID和密码登录。

  3. 显示菜单页面。

  4. 点击搜索页面。

  5. 转到搜索页面。

  6. 点击搜索按钮。

  7. 点击搜索结果链接转到更新页面。

  8. 更新数据并单击更新按钮。

  9. 显示更新的结果页面。

  10. 返回搜索页面。

  11. 点击退出按钮。

  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.

在上面的过程中,我使用循环控制器进行5到10的进程,循环为5。

在这种情况下,如果我使用超过25个线程运行Jmeter测试,地址已经在使用,则发生套接字绑定异常

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响应code: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状态,例如web-servers。重新使用套接字可以非常有效地减少服务器负载。

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 <的结果/ code>。

默认值为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.

您还可以在测试运行期间使用例如

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.

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

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