如何找到服务器可以处理的最大并发连接数?
我想要一个java程序,它可以找到服务器可以处理的最大并发连接数?
您可以假设服务器是 http 服务器。
更明确地说:
有很多开源 NIO 框架。我想为我的项目选择一个。并想测试哪个实现支持最大并发连接数。其中一些框架声称它们支持这么多。但我想在选择之前先亲自验证一下。
我的意图是支持尽可能多的并发连接而不丢弃/拒绝客户端?
I want a java program, which can find the maximum number of concurrent connections that a server can handle ?
You can assume that the server is http server.
To be more clear:
There are lots of opensource NIO frameworks. I want to pick one for my project. And want to test which implemenation supports maximum number of concurrent connections. Some of these frameworks claim that they support these many. But I want to get it verified myself before chosing one.
My intentions is to support as many concurrent connections without dropping/rejecting clients?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用 Apache JMeter 等工具来执行 服务器负载测试。您需要在多台客户端计算机上运行 JMeter 工具:正如其他人提到的,各种操作系统对连接都有限制。它支持包括并发连接数等选项...
上次使用此工具对网站进行负载测试时,我们有 6 台客户端计算机在一台服务器上运行 JMeter。该死的,这给网络带来了沉重打击!
Use a tool like Apache JMeter to perform load testing of the server. You'll want to run the JMeter tool on multiple client machines: As others have mentioned, various operating systems have limits on connections. It supports options including number of concurrent connections, etc...
Last time used this tool to load test a website, we had 6 client machines running JMeter against the one server. Damn that gave the network a hammering!
我们不久前制作了一个 COMET 服务器,在测试它可以支持的最大连接数时遇到了巨大的麻烦。我们总是发现办公室网络设备在连接数量达到足以使设备崩溃的数量之前就发生了故障。生成请求的机器上的端口数量有限,并且需要一段时间才能清除它们才能重新使用。确实是一个棘手的问题。
We made a COMET server a while back and had enormous trouble testing the maximum number of connections it could support. Invariably we found that office networking equipment failed before we hit anywhere near the number of connections that makes it groan. There's a limited number of ports on a machine generating requests, and they take a while to clear down before they can be reused. A tricky problem indeed.
只需创建套接字,直到收到错误“连接被拒绝”,否则程序将在
new Socket()
中阻塞,或者您收到 HTTP 错误 在 5xx 范围内(通常是 503 服务不可用)。请注意,您应该只在内部测试时执行此操作,因为这是拒绝服务攻击。
Just create sockets until you get the error "connection refused" or the program will block in
new Socket()
or you get an HTTP error in the 5xx range (usually 503 Service Unavailable).Note that you should only do this for internal tests because it's a denial of service attack.
在 apache tomcat 中,最大连接数存储在“context.xml”文件中
In apache tomcat the max connections is stored in "context.xml" file
开始建立新的连接;当你拒绝新的人时,你已经达到了某种极限。
但是,无论如何,结果都不会准确:
此外,您的测试相当于 DoS 攻击,因此始终获得服务器所有者和其他相关方(例如您的 ISP、服务器托管的 ISP 等)的许可,并在开始此类测试之前通知他们。否则,您可能会发现自己成为诉讼的受害方。
Start opening new connections; when you are refused new ones, you have hit some sort of limit.
However, the result will not be accurate by any means:
Also, your testing amounts to DoS attack, so ALWAYS get permission from the server owners and other concerned parties (e.g. your ISP, server hosting's ISP etc.) AND notify them before you begin with such tests. Otherwise you may find yourself on the incoming side of a lawsuit.