Confluence Uses >=40% CPU (possible caching issue?)
Asked by Axel Irriger:

I installed Confluence 4.2.7 w/ MySQL support on a virtual machine (vmware) with SuSE Linux. MySQL DB and Confluence are on the same VM installation.

Startup of Confluence is awfully slow (\>400.000msec the logs state), but the system continously uses 40% CPU at least. After startup, using confluence is possible (no NPE or other exceptions) but it's slow (not unusable slow, but slow).

Various memory settings (-Xms -Xmx) tried, but to no effect. Garbage collection is not an issue here, it seems. Getting various thread dumps, it looks like the system is essentially idle, but one thread, invoked by Quartz, performing some DB operation.

The relevant portion of thread dump output is:

scheduler_Worker-9 daemon prio=10 tid=0x00000000407a2000 nid=0x1cac runnable 0x00007f8bb0447000

java.lang.Thread.State: RUNNABLE

at java.net.SocketInputStream.socketRead0(Native Method)

at java.net.SocketInputStream.read(Unknown Source)

at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)

at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)

at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)

- locked \<0x00000000dca645d0\> (a com.mysql.jdbc.util.ReadAheadInputStream)

at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2499)

at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2954)

at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2943)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3486)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2687)

- locked \<0x00000000dc4dac80\> (a java.lang.Object)

at com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.java:1651)

- locked \<0x00000000dc4dac80\> (a java.lang.Object)

at com.mchange.v2.c3p0.impl.NewProxyConnection.commit(NewProxyConnection.java:803)

- locked \<0x00000000dcabf330\> (a com.mchange.v2.c3p0.impl.NewProxyConnection)

at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:63)

at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:510)

at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:732)

at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:701)

at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

at $Proxy89.jobToBeExecuted(Unknown Source)

at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1906)

at org.quartz.core.JobRunShell.notifyListenersBeginning(JobRunShell.java:335)

at org.quartz.core.JobRunShell.run(JobRunShell.java:173)

at com.atlassian.confluence.schedule.quartz.ConfluenceQuartzThreadPool$1.run(ConfluenceQuartzThreadPool.java:20)

at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)

Any ideas?

<br />


Answers:
author: Axel Irriger
body: My issue could be resolved by not running Confluence as a normal linux user, but as root. That solved the issue and may be related to the virtualization environment, the server runs in.


author: Bruna Griebeler
body: Seems like an expected behavior since Confluence will take some minutes to start. The amount of time to start the application will depend on the environment used, the memory given to the JDK vs the memory given to the VM and also the plugins that your Confluence has (third-party plugins).

So as a good practice, since you choose to run Confluence and the database on the same server, is important to increase the memory for the VM, so the JDK will not "starv "the operating system.


author: Rodrigo Girardi Adami
body: Hi Axel,  

As for the 40% of CPU use, I think there is something environmental going on since is not common for confluence to do this.  

Maybe you can perform a quick test and try to run confluence outside the VM to verify if the problem is in the environment or not. This is a good way to narrow down the issue.  

If Confluence runs smoothly outside the VM, then I recommend verifying the VM settings.

I've also had one case before in which the Tomcat was using 100% of CPU and rising the memory helped to solve the issue. Maybe you need to rise more the memory and verify how the cpu handles it.


author: Jack-Benny Persson
body: During startup my Confluence uses 100% CPU and takes around 2-3 minutes, this is normal behavior. But using 40% CPU continously doesn't seems right though...? After startup mine rarely dosen't use any CPU time, execpt when being used.


author: Matthew J. Horn
body: My Confluence instance (running on Tomcat) regularly takes 3 to 4 minutes to completely start up.


Tags: mysql

performance

quartz