开发者

Java - High cpu usage

开发者 https://www.devze.com 2023-01-22 09:29 出处:网络
I have a production web application running in Tomcat. The web application uses struts 2 as MVC layer.

I have a production web application running in Tomcat. The web application uses struts 2 as MVC layer.

We had an issue wherein one of the web servers spiked to 100% cpu usage. This issue lasted for over several hours. I took the thread dump and saw over several hundred threads in runnable state and the dumps show the same stack trace for most of the threads.

TP-Processor2" daemon prio=10 tid=0x00002aab80880c00 nid=0x5b4f runnable [0x0000000043bff000..0x0000000043c05d90]
   java.lang.Thread.State: RUNNABLE
        at java.util.HashMap.get(HashMap.java:303)
        at com.opensymphony.xwork2.util.LocalizedTextUtil.buildMessageFormat(LocalizedTextUtil.java:620)
        at com.opensymphony.xwork2.util.LocalizedTextUtil.getDefaultMessage(LocalizedTextUtil.java:588)
        at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:461)
        at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:224)
        at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:99)
        at org.apa开发者_C百科che.struts2.components.Text.end(Text.java:158)
        at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)
        at org.apache.jsp.parts.myjsp_jsp._jspx_meth_s_005ftext_005f2(myjsp_jsp.java:296)
        at org.apache.jsp.parts.myjsp_jsp._jspService(myjsp_jsp.java:94)

Now the code in question uses struts s:text tag and just fetches the value from a property file. I am not sure why so many threads should get stuck over there (threads are in runnable state).

Can i get some help in resolving what could have gone wrong.


A guess right out of left-field: you're not synchronizing multithreaded access properly.

java.util.HashMap is not threadsafe, and if accessed concurrently by multiple threads, one particular mode of failure is an infinite loop within a particular bucket.

Take a look at the map in question (indicated by the stacktrace), and see whether multiple threads are in fact able to access it without adequate synchronization.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号