Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Constant SQL Server 80% CPU Utilization

We have a small (for now) Asp.Net MVC 5 website on a dedicated VPS. When I go to the server and fire-up task manager, I see that "SQL Server Windows NT - 64 bit" is using around 80% of CPU and 170MB of RAM and IIS is using 6% CPU and 400MB of RAM. Server Specs are:

  • CPU 1.90Ghz dual core
  • Memory 2GB
  • Windows Server 2012
  • SQL Server Express 2012
  • Disk Space: 25GB, 2.35 Free.

The database is not very big. Its backup is less than 10MB.

I have tried to optimize the website as much as I could. I added caching to a lot of controllers and implemented donut caching for quite a lot of controllers. But today, even though there were only 5 users online, our search wouldn't work. I restarted the Windows on the server and it started working but I got the high CPU usage the minute server started. Interestingly when I open the SQL Server Management Studio and try to get the report for top CPU-consuming queries it says that there are no queries currently consuming any CPU!!! But at the same time I can see that SQL server is consuming a lot of CPU. How can I examine what is taking all the CPU? Below is a picture from the server:

High CPU Usage

I was/am very careful with designing and implementing the website. All the database access is through latest version of Entity Framework. I just wonder if the server's specs are low. Any help would be very much appreciated.

Update:

Here's the result of the sp_who2 stored procedure.

sp_who2

like image 945
Alireza Noori Avatar asked Apr 08 '14 18:04

Alireza Noori


People also ask

Why is SQL Server CPU usage so high?

Although there are many possible causes of high CPU usage that occur in SQL Server, the following ones are the most common causes: High logical reads that are caused by table or index scans because of the following conditions: Out-of-date statistics. Missing indexes.

How do I reduce the CPU usage of a SQL Server query?

By processing data in batches, SQL Server uses less CPU than row by row processing. To take advantage of batch mode, a query had to reference a table that contained a column store index. If your query only involved tables that contain data in row stores, then your query would not use batch mode.

How do I find high CPU utilization queries in SQL Server?

Method 1: Task Manager You can RDP to the SQL server and launch the task manager. On the process tab of task manager, check the high CPU-consuming process. As shown below, the SQL Server Windows NT – 64 Bit consumes most of the CPU resources.

How can I tell which query is taking high CPU utilization?

You can use Performance Insights to identify the exact queries that are running on the instance and causing high CPU usage. First, activate Performance Insights for MySQL. Then, you can use Performance Insights to optimize your workload.


1 Answers

This could happen if the memory set to use is more than the available memory on the box. The default memory setting of 2147483647MB. In our case the AWS box had only 30.5 GB so we changed the setting to 26GB and the CPU usage fell to 40%. You generally want to leave 20% of memory for OS and its operations.

like image 89
Chand Avatar answered Oct 30 '22 14:10

Chand