SQL Server process priority - windows

I made a CLR plugin for SQL Server 2008 R2 Developer edition that runs a lot of float computing on multiple threads. To test it, I used my laptop (core 2 duo 6670), and those calculations ran on 2 threads. This caused the CPU to be at 100% usage.
The question is this: When SQL process occupied 100% of CPU (for 2-3 minutes), my computer stops responding (cursor doesn't move, the clock is not updated, the entire UI is dead). It never happend with other programs, so the question is : "Does SQL Server run with a higher priority than the other services?"
Thanks

Taken from http://msdn.microsoft.com/en-us/library/ms188709%28v=sql.100%29.aspx
Use the priority boost option to specify whether Microsoft SQL Server
should run at a higher Microsoft Windows 2000 or Windows 2003
scheduling priority than other processes on the same computer. If you
set this option to 1, SQL Server runs at a priority base of 13 in the
Windows 2000 or Windows Server 2003 scheduler. The default is 0, which
is a priority base of 7.

Related

Good idea? MS SQL Limit CPU Affinity to prevent system lock down?

recently I had to run few heavy one-time queries on our MSSQL 2008 R2 64-bit server and faced a problem: executing them made SQL server consume 100% CPU which eventually (in about 20 seconds) made server absolutely unresponsive.
Thus I was forced to reboot it or wait until execution completes which took a lot of time depending on a query.
What I noticed is that setting CPU Affinity for SQL server to 7 cores instead of 8 available in task manager would keep server responsive so I could cancel my query if it took too long (and proceed with query optimizations without having too reboot).
But is it a good idea to limit CPU Affinity of SQL server?
Please share your thoughts. Server is being used for web-applications.
It turns out to be a Bad Idea.
After few days with CPU affinity 7/8 I noticed that SQL server would continuously load 1-2 cores up to 100% while other cores were available.
It is probably true that SQL Scheduler cannot distribute workload correctly when CPU affinity is limited.
Its years later but in case anyone finds this in search, your assumption is correct that work schedulers become locked to a core. However there is a trace flag to turn on in order to put this back: 8002.

High CPU Usage by Resource Monitor in SQL Server 2012

Has anyone encountered this before? I have a two node cluster with SQL Server 2012 SP1, Enterprise enterprise installed on Windows 2012. These are VMs running on VMWare 5.1. I have noticed that occasionally the CPU would spike all the way up to 100% and be sustained for a while. When I checked to see what was utilizing that much CPU it turned out to be the Resource Monitor. I know there was an issue with SQL Server 2008 with high CPU usage when virtual memory is low (KB 968722) but it was fixed in a service pack.
Is anyone seeing the same thing with SQL Server 2012 SP1? It's the exact same situation as mentioned in KB 968722 but instead of SQL Server 2008, it's happening on SQL Server 2012.
I just face a similar issue. Our windows team reported to me (SQL DBA) that we have one server with high CPU on only 2 cores (server has 10 cores). This server is part of a 2 node cluster and has 3 SQL Instances installed. One of those instances was causing the CPU issue, and it was very surprise that the instance causing the issue was the one doing nothing. This instance was installed but was not being used yet and it was causing CPU issues already on only 2 cores. Using Thread Object performance counters I identified the thread id that later I used to query sys.sysprocesses table to find those thread IDs (KPID).
SELECT * FROM sysprocesses
WHERE kpid IN (<Thread IDs>)
With that query I identified the Session IDs on SQL Server, they were background processes. Using sp_who one session ID cmd was: "RESOURCE MONITOR" and the other one was: "LAZY WRITER".
I verified memory, and since this instance was new, it was configured with min server memory as 1024 mb and max server memory as 1024 mb. I increased the max server memory setting to 2048 mb and the problem went away instantly.
I know this is not a universal solution, it was for my environment due to my context but hope it helps if somebody else is reading this question as well.
Quick answer (if > SQL Server 2008): then RESOURCE MONITOR is probably taking high CPU time because SQL server is lacking sufficient RAM.
Check your windows task manager / resource monitor for unnecessary ram-intensive processes. Clean it up.

SQL Server 2008 R2 Express limitations CPU, nr databases, max RAM?

This Thread is quite interesting:
Limitations of SQL Server Express
But I have further questions.
http://msdn.microsoft.com/en-us/library/cc645993.aspx
I have two questions:
What means number of CPUs? Is it the sockets inside a server - for e.g. the server has two sockets with 4 cores on every socket - total 8 cores.
Is SQL Server Express using one core or 4 cores?
If I have several instances of SQL Server 2008 R2 Express on one machine. Is the 10GB limit a sum of all data of all instances?
Best regards,
Thomas
According to the Microsoft references it is one socket express is limited to, not one core.
From http://msdn.microsoft.com/en-us/library/ms143760.aspx:
"SQL Server is licensed per processor socket, and not per logical CPU
basis."
The CPU limitation is one core, not one socket. So regardless of how many physical CPUs you have and how many cores per physical CPU, each SQL Express instance will be limited to a single CPU core.
The 10GB limit is per database, not the sum of all databases. I haven't tested this theory personally to be sure, but this size limit does not include the log file for each database; data file(s) only.
I was also searching along the net for this...
If based on dubbreak's link (link removed due to limitation)
The diagram actually shows a maximum of ONE core and TWO hyperthreaded processors (if supported).
I stand corrected after checking a little more.
Under this: http://msdn.microsoft.com/en-us/library/ms143760%28v=sql.105%29.aspx
It says "the following is considered a single processor for purposes of this table:
A single-core, hyper-threaded processor with 2 logical CPUs per socket.
A dual-core processor with 2 logical CPUs.
A quad-core processor with 4 logical CPUs."
While in here it elaborates (though its 2005 but I believe it is similar): http://support.microsoft.com/kb/914278
"
On a computer that has a multiple-core CPU, SQL Server 2005 Express Edition starts a separate scheduler for each core.
On a computer that has an HT Technology-enabled CPU, SQL Server 2005 Express Edition starts a separate scheduler for each logical processor."
So it references to a single CPU socket.
In theory it looks like that but in practice I can't get my core 2 processor to go over the 50% mark if I use SQL Server Express. The sqlservr.exe process is stuck at exactly 50%.

How can I force SQL Server to use more CPU

I have an data transformation query which takes a long time to run on my development machine (Core i7 920 running at 3.9GHz, and with 12GB of RAM under Windows Server 2003 x86 and with 2 Velociraptors 300GB iN RAID0).
When I look at the task manager, the CPU stays around 26%, with the third (out of 4) core being the most active.
As this is not a production environment, is there any way to tell SQL Server 2008 that I am alright with it using more of my CPU or is it because my query can not be parallelized for some reason?
If, shouldn't SQL Server be smart enough to cut the query in smaller chunks and run it across several threads so each core can get it?
Thanks.
Optimize your query. Chances are that the issue is with it and not SQL Server.
It already knows that it's okay unless you specifically limited it to use only a certain number of CPUs either through configuration or through setting the MAXDOP parameter.
It sounds like you may be constrained by your hard drives or memory more than anything.
Note that because you are running an x86 version of windows (and by extension sql server), you may be RAM limited to around 3GB. And even with the PAE (physical addressing extensions) turned on, it's going to be a world of difference slower than if you have an x64 OS and SQL Server to begin with.
In other words, you might consider reinstalling the machine from the ground up to take advantage of all the x64 goodness you have.

Significant Performance Decrease when moving from Windows Server 2003 to 2008 (IIS 6 to IIS 7)

Our ASP.Net 2.0 web app was running happily along on Windows Server 2003. We were starting to see some of the limits of the environment approaching, such as memory and CPU usage spikes, and as we're getting ready to scale we decided it was time for a larger server with higher availability.
We decided to move to Windows Server 2008 to take advantage of IIS 7's shared configuration. In our development and integration environments, we reproduced the OS and app in 2008/IIS 7 and everything seemed fine. But truth be told, don't have a good way of simulating production-like loads as of yet, nor can we reproduce our prod environment accurately (we're small with limited resources). So once we rolled out to production, we were surprised to find performance significantly worse on 2008 than it was on 2003.
We've also moved from a 32-bit environment to 64-bit in the process, and we've also incorporated ASP.Net 3.5 dll's into the project.
Memory usage is through the roof, but I'm not as worried about that. We believe in part this is because of the overhead with Server 2008's memory, so throwing more RAM at it may solve that issue. The troubling thing is we're seeing processor spikes to 99% CPU Utilization, which we've never seen before in the 2003/IIS 6 environment.
Has anyone encountered these issues before and are there any suggestions for a solution/places to look? Right now we're doing the following:
1) Buying time by adding memory.
2) Buying time by setting app pool limits: shut down w3wp.exe when CPU hits 99% load. Since you don't have the option to recycle the app pools, I have a scheduled task running that recycles any stopped app pools.
3) Profiling the app pools under Classic and Integrated modes to see which may perform better.
Any other ideas are completely welcome.
Our experiance is that code runs much faster on a 64bit windows 2008 than on a 32bit windows 2003 server.
I am wondering if something else is also running on the machine. For example is SQL Server installed with a maintainence plan that could cause the CPU spike.
I would check the following:
Which process is using the CPU?
Is there a change in the code? Try installing the new code on the old machine
Is it something to do with the compile options? Is the CPU usage a recompile?
Are there any errors in the event log?
In our cases, since we have 4 processors, we then increased the "number of worker process to 4" currently working well so far as compare before.
here a snapshot:
http://pic.gd/c3661a
You can use the application pool "Recycle" option in IIS7+ to configure physical and virtual memory limits for application pools. Once these are reached the process will recycle and the resources will be released. Unfortunately the option to recycle based on CUP usage has been removed from IIS7+ (some one correct me if I'm wrong). If you have other apps on the server and want to avoid them competing for resources when this condition happens you can implement Windows System Resources Manager and it's IIS policy (here is a good tutorial http://learn.iis.net/page.aspx/449/using-wsrm-to-manage-iis-70-apppool-cpu-utilization/)
Note SRWM is only available on Enterprise and Data Center editions.

Resources