Tomcat performance bottleneck
michael.yuan Jul 24, 2006 7:52 PMHi guys,
This is not really a jboss/tomcat integration issue. But I cannot find a better forum to discuss it ... So, here it goes:
In my performance tests at Dell, I identified a likely performance contention point in Tomcat. The symptom is that we cannot drive the server CPU utilization beyond 90 percent. A quick thread dump shows that most threads are waiting to execute a synchronized HashMap access block in line 175 of the org.apache.catalina.core.ApplicationContext class:
public class ApplicationContext implements ServletContext { ... ... public Object getAttribute(String name) { synchronized (attributes) { return (attributes.get(name)); } } }
Since the server has multiple CPUs, they must wait in turn to run this block of code and hence results in lower CPU utilization. The best solution is to use a concurrent hashmap to get rid of the synchronized block. Can we get this fixed? Thanks. I attach a more detailed stack trace from the thread dump below.
"http-0.0.0.0-8080-17" daemon prio=1 tid=0x0000002c918799d0 nid=0x107b waiting for monitor entry [0x0000000044c9a000..0x0000000044c9bc90] at org.apache.catalina.core.ApplicationContext.getAttribute(ApplicationContext.java:175) - waiting to lock <0x0000002ae2a4f980> (a java.util.HashMap) at org.apache.catalina.core.ApplicationContextFacade.getAttribute(ApplicationContextFacade.java:315) at org.apache.myfaces.context.servlet.ApplicationMap.getAttribute(ApplicationMap.java:41) at org.apache.myfaces.context.servlet.AbstractAttributeMap.get(AbstractAttributeMap.java:87) at org.jboss.seam.contexts.FacesApplicationContext.get(FacesApplicationContext.java:46) at org.jboss.seam.Component.forName(Component.java:1138) at org.jboss.seam.ejb.SeamInterceptor.getSeamComponent(SeamInterceptor.java:93) at org.jboss.seam.ejb.SeamInterceptor.aroundInvokeInContexts(SeamInterceptor.java:66) at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:45) at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118) at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:180) at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98) at $Proxy72.getCart(Unknown Source)