Solved

Multiple CPUs - SQL2005 - Windows 2003 - VB.net

Posted on 2007-03-30
6
220 Views
Last Modified: 2013-12-10
We are developing a VB.net application against the SQL2005 / Windows 2003 server (4 CPUs), when we run the application which has heavily sql queries, the CPU performance of the SQL server only see one CPU at a time being pegged at 100%, while others are pretty much quiet, but the 100% peak takes turns from one CPU to the other. My question is that:
1) how is it possible to have the CPU usage be evenly spread between the 4 CPUs?
2) why I see 8 CPU instants in Windows Performance task manager other than 4?
3) Is the OS, SQL or App. itself controlling the CPU ultilization?

Thanks,
fshguo.
0
Comment
Question by:fshguo
  • 3
  • 2
6 Comments
 
LVL 18

Assisted Solution

by:DarrenD
DarrenD earned 100 total points
Comment Utility
Hi,

You can tell SQL Server how many CPU's to use so it could be just set to one.

You have to buy a licence per processor though under certain licence agreements.

If you right click on the SQL Server in Microsoft SQL Server Management Server and choose properties you can then select processors and see how many are being used

Darren
0
 
LVL 21

Assisted Solution

by:mastoo
mastoo earned 400 total points
Comment Utility
After checking what DarrenD describes...

If you are running a single, single threaded app against Sql Server most activity will take place on a single processor.  In isolated cases, sql server might optimize a query by spreading it across more than one processor but that would be the exception rather than the general rule.  If your app is threaded or multiple instances run, they can be submitting multiple concurrent queries which will then cause more than one cpu to be used.

You'll see 8 if you have 4 processors that either are dual core or support hyperthreading.
0
 

Author Comment

by:fshguo
Comment Utility
I checked the SQL server can see 8 processors. and yes, it is dual core.

Now my question to Mastoo is that how can we make the change so that the App is multiple threaded?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 21

Accepted Solution

by:
mastoo earned 400 total points
Comment Utility
Multi-threaded programming is complicated and I can't do the subject justice here.  Can I suggest a couple other things before you go that route?  They all have potential for boosting performance enough that you might not feel the need to thread your app.

#1.  If you're going to have several people running your app at the same time, in effect this is the same as threading since it means your database server will be running several queries at the same time.  In this case, threading would help a single person but when several people run the performance would be unchanged.

#2. Use a code profiler on your app to be sure it spends most of its time waiting on the database.  If it only spends 20% of its time waiting on the db, and you thread it to cut that in half, you've only boosted your performance by 10%.

#3. If your app is waiting on the db for most of the time, use sql profiler to identify the queries that take the longest and then optimize those queries.  A simple index change can have a dramatic effect on performance.

#4. If none of those help, then look at the SqlCommand methods like BeginExecuteReader and BeginExecuteNonQuery.  Those are the easiest ways to thread things when db performance is the bottleneck.  They limit the scope of the threading.  They make coding a little more difficult because code needs to start several queries (loading up multiple cpus) and then react when they queries finish.  If you're using databound controls, threading isn't an option.
0
 

Author Comment

by:fshguo
Comment Utility
Thanks Wastoo, how code profiler knows how long it is spending waiting for database? simply a URL link will be helpful.  

0
 
LVL 21

Expert Comment

by:mastoo
Comment Utility
I use ants:

http://www.red-gate.com/products/ants_profiler/index.htm

Basically you run your program under the profiler.  When done, it will show you what percent of the total time was spent in what functions.  This lets you quickly identify where your code spends most of its time so you can focus on fixing the right chunk of code.  For example I might see that a button click takes 5 seconds, and of that time 25% is in a couple of database calls and the remaining time is spent populating a listview control.  In your case, if it leads to a couple stored procedure calls you'd know which procs you should try to optimize.

They let you download an eval copy for a trial period so you can give it a shot.

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

As you can read I recycle all my old hardware and the time has come that my power supply of 200 Watt cannot provide enough power for my backup server. I have lots of Compaq power supply's laying around, so I figured to use one of these PSU's. I t…
I have purchased two new systems and both are now Universal Extensible Firmware Interface (UEFI) based. UEFI is replacing BIOS for the desktop PC. It is a Linux based firmware with enough robustness it can communicate with a website without loading …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now