9 Replies Latest reply on Mar 15, 2008 6:15 PM by George Daswani

    Maximum CPU Usage in Jboss4.0.4 GA

    jasmeen bajracharya Newbie

      Hi,
      Web Application with J2ee,EJB,Servlets,jsp,postgresql is taking maximum cpu usage resulting in degrading the performance. How to solve this problem?the result of top command in linux shows following cpu use.

      PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
      7316 root 25 0 334M 309M 3828 S 83.6 30.7 73:35 0 java
      8365 postgres 25 0 13236 12M 10904 R 14.4 1.2 13:01 0 postmaster

      looking forward for your quick response




        • 1. Re: Maximum CPU Usage in Jboss4.0.4 GA
          Peter Johnson Master

          The best thing to do is get a Java thread dump. I recommend doing three thread dumps at about 10 or 20 second intervals while the CPU usage is high. Examining the threads to see which ones are busy and what code they are executing should help pinpoint the problem.

          Also, what are your JVM command line options? Specifically the heap settings.

          • 2. Re: Maximum CPU Usage in Jboss4.0.4 GA
            jasmeen bajracharya Newbie

             

            "PeterJ" wrote:
            The best thing to do is get a Java thread dump. I recommend doing three thread dumps at about 10 or 20 second intervals while the CPU usage is high. Examining the threads to see which ones are busy and what code they are executing should help pinpoint the problem.

            Also, what are your JVM command line options? Specifically the heap settings.


            Thank you Peter, how to take java thread dump. Where so far as jvm option is concerned,its setting is as follows
            JAVA_OPTS="-server -Xms128m -Xmx1024m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"

            the server has 1 gb RAM.

            • 3. Re: Maximum CPU Usage in Jboss4.0.4 GA
              Peter Johnson Master

              Did you google "java thread dump"?

              The max heap size you specified is too large for the amount of ram you have, which will cause thrashing even if jbossas is the only thing running on that box. On top of that you have postgresql running on the same box, and the ram you have is barely enough for postgresql to run decently, if it was the only thing running on the box. Until you get more RAM and/or move postgresql to another box you will suffer lousy performance with a lot of paging.

              • 4. Re: Maximum CPU Usage in Jboss4.0.4 GA
                jasmeen bajracharya Newbie

                Hi Peter,

                The configurations are as follows:

                jdk version
                java version "1.5.0_08"
                Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
                Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)

                postgresql version
                PostgreSQL 8.1.4

                jboss version
                jboss 4.0.4 GA

                linux server specification
                RAM 1 GB
                CPU 3 GHz

                JVM shows::
                JAVA_OPTS="-server -Xms512m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"


                postgres-ds.xml shows::

                <local-tx-datasource>
                <jndi-name>PostgresDS</jndi-name>
                <connection-url>jdbc:postgresql://1.2.3.4:5432/db_testname</connection-url>
                <driver-class>org.postgresql.Driver</driver-class>
                <user-name>xyz</user-name>
                xyz

                <type-mapping>PostgreSQL 8.1.4</type-mapping>

                <min-pool-size>10</min-pool-size>
                <max-pool-size>64</max-pool-size>
                <blocking-timeout-millis>30000</blocking-timeout-millis>
                <idle-timeout-minutes>15</idle-timeout-minutes>
                <track-statement>true</track-statement>
                </local-tx-datasource>


                postgresql.conf shows::
                listen_addresses = '*'
                port = 5432
                max_connections = 100
                shared_buffers = 1000

                org.jboss.resource.connectionmanager.JBossManagedConnectionPool shows::
                BlockingTimeoutMillis int RW 30000 MBean Attribute.
                State int R 3 MBean Attribute.
                AvailableConnectionCount long R 64 MBean Attribute.
                ManagedConnectionFactoryName javax.management.ObjectName RW View MBean MBean Attribute.
                ConnectionCount int R 10 MBean Attribute.
                NoTxSeparatePools boolean RW True False MBean Attribute.
                MinSize int RW 10 MBean Attribute.
                MaxConnectionsInUseCount long R 14 MBean Attribute.
                MaxSize int RW 64 MBean Attribute.
                StateString java.lang.String R Started MBean Attribute.
                InUseConnectionCount long R 0 MBean Attribute.
                ConnectionCreatedCount int R 42 MBean Attribute.
                ConnectionDestroyedCount int R 32 MBean Attribute.
                IdleTimeoutMinutes long RW 15

                The applications gets very slow.Does increasing the RAM to 2gb solves it?

                • 5. Re: Maximum CPU Usage in Jboss4.0.4 GA
                  Peter Johnson Master

                  Increasing the RAM to 2GB will help. Right now, the OS is using about 1/2GB and the app server is using another 1/2GB, which leaves nothing for postgresql. So I imagine you are doing a lot of page swapping.

                  • 6. Re: Maximum CPU Usage in Jboss4.0.4 GA
                    jasmeen bajracharya Newbie

                    hi Peter,
                    Increasing RAM from 1 to 2 GB, now the postgres is taking maximim cpu usage and resulting in the same old problem of system getting hanged.

                    • 7. Re: Maximum CPU Usage in Jboss4.0.4 GA
                      Peter Johnson Master

                      Looks like you have some queries that are not well formed, or your might be missing some table indexes. You now need to use some postgresql tools (like ptop) to determine where the problem is and then fix it.

                      • 8. Re: Maximum CPU Usage in Jboss4.0.4 GA
                        George Daswani Newbie

                        The easiest way to get thread dumps is for one to use JDK 1.5 or above on the server. Make sure the JDK'x JMX MBean Server is turned on and that you've set the switches to allow for remote JMX connections..

                        enable jmx remote switch = "-Dcom.sun.management.jmxremote"
                        remote jmx port = "-Dcom.sun.management.jmxremote.port=SOMEPORTNUM"
                        disable remote auth = "-Dcom.sun.management.jmxremote.authenticate=false"

                        Install JCONSOLE on a workstation somewhere (preferably 1.6), download the JTA Plugin (Thread Dump Analyzer JCONSOLE Plugin) from https://tda.dev.java.net/ - then you should be able to perform thread dumps remotely.

                        • 9. Re: Maximum CPU Usage in Jboss4.0.4 GA
                          George Daswani Newbie

                          err, I meant, the TDA Plugin, not the JTA plugin.