jmeter多用户问题

发布于 2024-08-17 04:54:49 字数 373 浏览 4 评论 0原文

我们正在使用 Jmeter 来测试在 Apache 2 Web 服务器上运行的 Php 应用程序。我可以加载 Jmeter 以使用 25 或 50 个线程,并且服务器上的负载不会增加,但服务器的响应时间会增加。线程越多,响应时间越慢。 Jmeter 或 Apache 似乎正在对请求进行排队。我已经更改了 apache Web 服务器配置文件中的 maxclients 值,但这并没有改变问题。当 Jmeter 运行时,我可以使用该应用程序并获得可观的响应时间。什么给?我希望能够通过增加线程数将我的服务器空闲率降低到 0%。谁能帮我指出正确的方向?

更新:我发现,如果我从应用程序中删除会话,我就能够模拟服务器上的完整负载。我尝试重新启用会话并为每个线程使用 HTTP Cookie 管理器,但它似乎没有产生影响。

We are using Jmeter to test our Php application running on the Apache 2 web server. I can load up Jmeter to use 25 or 50 threads and the load on the server does not increase, however the response time from the server does. The more threads the slower the response time. It seems like Jmeter or Apache is queuing the requests. I have changed the maxclients value in apache web server configuration file, but this does not change the problem. While Jmeter is running I can use the application and get respectable response times. What gives? I would expect to be able to tax my server down to 0% idle by increase the number of threads. Can anyone help point me in the right direction?

Update: I found that if I remove sessions from my application I am able to simulate a full load on the server. I have tried to re-enable sessions and use an HTTP Cookie Manager for each thread, but it does not seem to make an impact.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

向地狱狂奔 2024-08-24 04:54:49

您需要确定瓶颈发生的位置,然后尝试修复问题。

  • JMeter 客户端应该在设备齐全的机器上运行。我更喜欢运行 JVM 的 Solaris/Unix 服务器,但对于 <200 个线程,现代 Windows 机器就可以了。 JMeter 可能成为瓶颈,一旦成为瓶颈,您将无法获得任何有意义的结果。此外,它应该在与您的测试不同的机器上运行,并且最好在同一网络上运行。如果您的测试设备和服务器相距较远,WAN 延迟可能会成为一个问题。
  • 第二件事要检查的是您的 Apache 工作人员。 Apache 有一个模块 - mod_status - 它将向您显示每个工作人员的状态。您的池大小可能设置得太低。从 mod_status 中,您将能够看到正在使用的工作人员数量。少数情况下,Apache 不会有任何工作人员来处理请求,并且请求将排队。太多,Apache 可能会耗尽运行它的机器上的内存。
  • 接下来,您应该检查您的数据库。如果它位于单独的计算机上,则数据库可能会出现 IO 或 CPU 短缺。
  • 如果遇到瓶颈,并且服务器和数据库位于同一台计算机上,则通常会遇到 CPU、RAM 或 IO 限制。我按照最容易识别的顺序列出了它们。如果您的应用程序受 CPU 限制,您可以轻松地看到 CPU 使用率达到 100%。如果你的内存不足,你的机器将开始交换。在 Windows 和 Unix 上,查看可用的空闲 RAM 相当容易。最后,您可能会受到 IO 限制。这也可以使用各种工具或统计数据进行监控,但不像 CPU 那样明显。

最后,特别针对您的问题,突出的一件事是可以将大量会话文件存储在单个目录中。 PHP 通常将会话信息存储在文件中。如果该目录变大,PHP 查找会话所需的时间就会越来越长。如果您运行测试时将 cookie 关闭,则 PHP 应用程序可能会为每个用户请求创建数千个会话文件。在 Windows 服务器上,速度会比在 UNIX 服务器上更快,这是由于两个操作系统上目录存储方式的差异造成的。

You need to identify where the bottleneck is occurring, and then attempt to remediate the problem.

  • The JMeter client should be running on a well equipted machine. I prefer a Solaris/Unix server running the JVM, but for <200 threads, a modern windows machine will do just fine. JMeter can become a bottleneck, and you won't get any meaningful results once it does. Additionally, it should run on a separate machine to what your testing, and preferable on the same network. The WAN latency can become a problem if your test rig and server are far apart.
  • The second thing to check is your Apache workers. Apache has a module - mod_status - which will show you the state of every worker. It's possible to have your pool size set too low. From the mod_status, you'll be able to see how many workers are in use. To few, and Apache won't have any workers to process requests, and the requests will queue up. Too many, and Apache may exhaust the memory on the box it's running on.
  • Next, you should check your database. If it's on a separate machine, the database could have an IO or CPU shortage.
  • If your hitting a bottleneck, and the server and db are on the same machine, you'll generally hit a CPU, RAM, or IO limit. I listed those in the order in which they are easiest to identify. If you get a CPU bound app, you can easily see you CPU usage go to 100%. If you run out of RAM, your machine will start swapping. On both Windows and unix it's fairly easy to see your available free RAM. Lastly, you may be IO bound. This too can be monitored using various tools or stats, but it's not as obvious as CPU.

Lastly, specifically to your question, the one thing that stands out is it's possible to have a huge number of session files stored in a single directory. Often PHP stores session information in files. If this directory gets large, it will take increasingly long amount of time for PHP to find the session. If you ran your test will cookies turned off, the PHP app may have created thousands of session files for each user request. On a Windows server, it will slow down faster than on a unix server, do to differences in the way directories are stored on the two operating systems.

神魇的王 2024-08-24 04:54:49

您是否使用恒定吞吐量计时器?如果 Jmeter 无法通过分配给它的线程来提供吞吐量,您将在响应时间中看到这种排队和井喷现象。要确定这是否是问题所在,请尝试添加更多线程。

我还发现了一份关于脚本内有 javascript 调用时发生这种情况的报告。在这种情况下,尝试将 javascript 调用移至脚本顶部的测试计划元素,或寻找预先计算该值的方法。

Are you using a constant throughput timer? If Jmeter can't service the throughput with the threads allocated to it, you'll see this queueing and blowouts in the response time. To figure out if this is the problem, try adding more threads.

I also found a report of this happening when there are javascript calls inside the script. In this instance, try to move javascript calls to the test plan element at the top of the script, or look for ways to pre-calculate the value.

风铃鹿 2024-08-24 04:54:49

尝试检查由 apache 而不是 PHP 提供的静态文件,看看问题是否出在 Apache 配置或 PHP 配置中。

另请检查您的网络连接和配置。我们的 JMeter 测试进展顺利,直到碰壁。最终意识到我们只有 100Mb 连接并且已经饱和,需要千兆位修复它。您的网卡或交换机的运行速度可能比您想象的要低,尤其是当它们的速度设置为“自动”时。

Try checking a static file served by apache and not by PHP to see if the problem is in the Apache config or the PHP config.

Also check your network connections and configuration. Our JMeter testing was progressing nicely until it hit a wall. Eventually realized we only had a 100Mb connection and it was saturated, going to gigabit fixed it. Your network cards or switch may be running at a lower speed than you think, especially if their speed setting is "auto".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文