JMeter、Jetty 性能测试和 Keep-Alive 问题
好的,我创建了一个非常简单的 WAR,它提供一个简单的 Hello World .jsp。所有 HTML 大约有 200 字节。
将其部署在运行 Jetty 7.5.x jdk 6u27 的服务器上 在我的客户端计算机上创建简单的 JMeter 测试计划,其中包含:线程组、HTTP 请求、响应断言、摘要报告客户端也运行 jdk6u27
我将线程组设置为 5 个线程,运行 60 秒,每秒收到 5800 个请求 然后我设置了 10 个线程,
当我在 HTTP 请求采样器上的 JMeter 中禁用 Keep-Alive 时,每秒收到 6800 个请求。我想我在客户端似乎有很多大的停顿,服务器似乎没有收到任何东西。我在 5 个线程时得到的暂停较少,或者几乎没有,但在 10 个线程时它几乎一直挂起。
这究竟意味着什么?
请记住,我在技术上创建了一个 REST 服务,并且遇到了同样的问题,所以我想也许我在服务中做了一些奇怪的事情,直到我发现这是一个 Keep-Alive 问题,因为它几乎是在一个静态网络应用程序。所以实际上我会有 1 个客户端请求 1 个服务器响应。客户端不会保持连接打开。
Ok, so I created a very simple WAR which serves a simple Hello World .jsp. With all the HTML it's about 200bytes.
Deployed it on my server running Jetty 7.5.x jdk 6u27
On my client computer create simple JMeter test plan with: Thread Group, HTTP Request, Response Assertion, Summary Report Client also running jdk6u27
I set up the thread group to 5 threads running for 60secs and I got 5800 requests/sec
Then I setup 10 threads and got 6800 requests/sec
The moment I disable Keep-Alive in JMeter on the HTTP Request sampler. I seem to get lots of big pauses on the client side I suppose, it doesn't seem the server is receiving anything. I get less pauses at 5 threads or barely none but at 10 threads it hangs pretty much all the time.
What does this mean exactly?
Keep in mind I'm technically creating a REST service and I was getting the same issue, so I though maybe I was doing something funky in my service, till I figured out it's a Keep-Alive issue as it's doing it pretty much on a staic web app. So in reality I will have 1 client request 1 server response. The client will not be keeping the connection open.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,由于 Keep-Alive 允许 HTTP 连接(从而允许套接字)重用,因此您将耗尽可用的临时端口号 - 只有 64k 端口号,并且因为连接必须具有唯一的客户端/服务器端口组合(并且服务器端口是固定的),您可以快速浏览这些。现在,如果一侧关闭连接后端口就可以重用,那就没关系:但是,根据 TCP 规范,双方必须等待可配置的时间(默认值:2 分钟),直到认为重用是安全的。
有关更多详细信息,您可以阅读 TCP 书籍(例如“Stevens book”);上面是一个简化。
My guess is that since Keep-Alive is what allows HTTP Connection (and thereby, socket) reuse, you are running out of available ephemeral port numbers -- there are only 64k port numbers, and since connections must have unique client/server port combos (and server port is fixed), you can quickly go through those. Now, if ports were reusable as soon as connection was closed by one side, it would not matter: however, as per TCP spec, both sides MUST wait for configurable amount of time (default: 2 minutes) until reuse is considered safe.
For more details you can read a TCP book (like "Stevens book"); above is a simplification.