Tomcat性能问题

发布于 2024-08-09 18:08:14 字数 1127 浏览 4 评论 0原文

我有一个 Web 应用程序运行速度非常慢并且偶尔会挂起。它是一个与学校相关的 Wicket 应用程序,具有报告和编辑功能,也是一个 servlet,自动化客户端使用它通过 HTTPS 获取/发布数据。

在进行大量编辑/上传/下载的繁忙时间,应用程序会变得缓慢且无响应。我收到 Wicket“PageMap 仍处于锁定状态”错误。雄猫似乎还在继续前进。内存占用可控,50M左右。

我设置了 YourKit 来获取一些分析信息,在繁忙期间发现 81% 的 Tomcat CPU 时间都花在了这里:

org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run()
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(Object[])
org.apache.jk.common.ChannelSocket.processConnection(MsgContext)
org.apache.jk.common.ChannelSocket.receive(Msg, MsgContext)
org.apache.jk.common.ChannelSocket.read(MsgContext, byte[], int, int)
java.io.BufferedInputStream.read(byte[], int, int)
java.io.BufferedInputStream.read1(byte[], int, int)
java.io.BufferedInputStream.fill()
java.net.SocketInputStream.read(byte[], int, int)
[Wall Time]  java.net.SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int)

在这个应用程序中,大约有 250 个客户端通过 SSL 轮询服务器,要求每 30 秒更新一次。大多数时候,这很快就会返回空响​​应。有时,会出现一系列数据库活动,并且可能会将大量数据(几 MB)发送回客户端。

那么这 81% 的活动来自哪里?一些连接速度非常慢的客户端是否会导致 Tomcat 线程等待传入的请求主体而陷入困境?

有人见过这样的事情,或者对如何测试/故障排除/修复这个问题有什么建议吗?

I've got a web application that's running really slowly and occasionally hanging. It's a school-related Wicket app with reporting and editing, and also a servlet which is used by automated clients to get/post data via HTTPS.

During busy times where a lot of editing/uploading/downloading is going on, the app becomes sluggish and unresponsive. I get Wicket "PageMap still locked" errors. Tomcat seems to keep chugging along. Memory usage is managable, about 50M.

I set up YourKit to get some profiling info, and during a busy period found that 81% of the Tomcat CPU time is spent here:

org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run()
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(Object[])
org.apache.jk.common.ChannelSocket.processConnection(MsgContext)
org.apache.jk.common.ChannelSocket.receive(Msg, MsgContext)
org.apache.jk.common.ChannelSocket.read(MsgContext, byte[], int, int)
java.io.BufferedInputStream.read(byte[], int, int)
java.io.BufferedInputStream.read1(byte[], int, int)
java.io.BufferedInputStream.fill()
java.net.SocketInputStream.read(byte[], int, int)
[Wall Time]  java.net.SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int)

In this app I've got about 250 clients polling the server over SSL asking for updates every 30 seconds. Most of the time, this quickly returns an empty response. Occasionally, there's a flurry of DB activity, and a whole slew of data (a few MB) may be sent back to the client.

So what's this 81% activity from? Could a few clients with really slow connections bog down tomcat threads by causing it to wait for incoming request bodies?

Anyone seen anything like this, or have any advice on how to test/troubleshoot/fix this?

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

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

发布评论

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

评论(2

樱娆 2024-08-16 18:08:14

您应该设置一个测试环境并尝试通过负载测试重现此情况。
这样您就可以找出原因。否则因素太多。
此外,通过这种方式,您可以尝试修复,而不会危及您的产品环境。

You should set up a test environment and try to reproduce this with a load test.
That way you can isolate the cause. Otherwise there are too many factors.
Also, this way you can try fixes without jeopardizing your prod env.

绻影浮沉 2024-08-16 18:08:14

内存使用可能是原因。

您应该检查 java 进程的内存使用情况,看看它获得了多少内存。
如果还不够,您必须在为 tomcat 设置的位置设置 Xmx jvm 参数。

The memory use is probably the cause.
You should check the memory use for the java process to see how much it's getting.
If it's not getting enough you have to set the Xmx jvm parameter wherever these are set for tomcat.

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