100% CPU Usage


Lately we have been developing websites for clients who has heavy integration and large data (2M atleast) we notice that the CPU usage spikes to 100% for only 5 users accessing the website. What can we do to optimize this, and has anyone ever encountered this scenario?

Our server config are :  
Application server : 8gb RAM, 2core CPU. 500gb HDD
backend server : 16gb RAM, 2core CPU, 500gb HDD

Are you seeing the CPU spikes on the database or the front end servers?

We had a similar problem on our database server which was being caused due to the fact we use a large number of processes. Are your websites very process driven?

The solution in our case was to archive off old processes to clear up the internal process database tables. 

This forge component allows you/shows you how to do it: http://www.outsystems.com/forge/component/443/bpt-sample-archiver/

You need to find out the following:

1. What server are the CPU spikes happening on, database or application server?

2. Use Lifetime's performance page to determine what the slow pages are.

3. Use the "General" tab under "Monitoring" and filter by SLOWSQL and SLOWENTENSION in "Module" to determine if you have slow queries or extension code running.

4. Look at the code for the slow pages, and search for infinite loops, infinite recursion, etc.

5. Look at the Web Reference tab to see if any Web References are slow.

6. Monitor the CPU spikes, which processes are causing the issues? It may not even be the application at all! On our DB server, we get large CPU spikes, but they are coming from the backup software not our application.

7. If the problem is on the database, your DB tools (SQL Server Management Studio -> Activity Monitor, don't know what Oracle's would be under) will help you track down the bad queries. In addition, look for cross joins. If you are on 8.0.1.X, you will now see warnings in Service Studio about cross joins.

8. When did the problem start? Check what you deployed around that time.

9. How long do these CPU cpikes last for?

10. Check event log and database log on the appropriate machines and see if something else is happening, being logged, etc.