views:

257

answers:

7

I work in an asp.net shop, and I heard today that the bottleneck on our servers is CPU. I had always thought that webapps tended to be I/O and network bound before CPU. Is this an ASP.net/IIS thing? Is it our code? Or am I just completely wrong about the whole thing?

Also, we do public facing social/commerce sites using webforms. It is not that the CPU load is a problem or anything, our servers can currently handle the load. I just found it suprising, since from what I understand about web applications, most of the time CPU is not the issue when it comes to scaling, especially on a compiled language with a fast runtime like .NET.

+1  A: 

While at first blush, I'd say "I/O intensive, of course", the truth is that it depends on what your application is serving.

At one extreme, a multimedia server would, of course, be I/O bound.

At the other, a calculation intensive site that serves up rather plain text-only HTML pages would be CPU bound.

In my experience, I've found that most sites are I/O bound. That is, when additional servers are purchased, it's to increase I/O rather than CPU throughput. I'd go so far as to say that even the most elaborate site I've worked on, which had about thirty servers, would have been well served by a single processor. It was network bandwidth that directed our purchases.

Bob Kaufman
We are not doing encoding or anything like that, it is a mixture of static resources and HTML generation. I have had the same experience with CPU not being the issue on most webapps, which is why I asked the question.
Matt Briggs
+3  A: 

It's most likely your code. You can't categorically state anything about ASP.Net here, it's just like any other computer program - it is totally dependent on what your application is actually doing.

There is nothing inherently CPU intensive about serving up web pages. I've seen a laptop running IIS serving 1200 page requests per second. Although it is true that ASP.Net is more configured for "ease of use" out of the gate rather than optimal performance, it's not too hard to tweak it for great performance.

You can use a profiler such as Dottrace or RedGate Ants to see where your code is slowing everything down.

womp
Was that IIS laptop serving up webforms pages? I have this suspicion that the high cpu usage comes from the webforms "page lifecycle" way of doing things, building up and tearing down controls, and then rendering them out to html on each request.
Matt Briggs
Yes, it was. Have you ever benchmarked a webforms page? It's extremely fast.
womp
+1  A: 

I would look at the code to see if there are performance issues. This site serves almost 1 million pages a day and seems to be doing fine. Asp.net is pretty optimized for scalability when written to do so.

Kevin
+6  A: 

It is your code. There is nothing inherently CPU intensive about ASP.NET, and I would actually call in to question the research that was done for saying the CPU was the bottleneck, because unless you are calculating Pi out to the billionth decimal point on your web application, I see no reason what could be eating up all that CPU time.

Nick Berardi
I'd also ask him if he's running his database back-end (like SQL Server) on the same server his doing his hosting on. Is he running additional services? Do you have enough RAM? RAM RAM RAM, MORE IS GOOD! :)
Mr. Smith
That was my thought too. SQL server is on another machine. Ram usage comes in second after CPU (we are probably over using the cache if anything)
Matt Briggs
Is this a shared hosting environment or a VPS where you share the server with other apps? If so you might just be on a heavily loaded server, and should ask to be moved.
Nick Berardi
Its dedicated servers on freakin rackspace.
Matt Briggs
"It is your code." cannot be expressed enough.
mxmissile
@Nick: The approach used was using the VS Load Testing tools and looking at the machine performance. It is also something we have observed during peak periods. We are not doing inherently CPU intensive activities (ecommerce/forums/db driven content), but it is CPU that is driving when we need to add a server, not RAM, IO or Network which (to my understanding) tend to come before cpu in regards to scaling most webapps.
Matt Briggs
A: 

If you are talking about CPU intensive, its quite relative term, however .NET is not but ASP.NET is very much. Web Apps doing thousands of postbacks and recreating/destroying controls on every request is quite expensive.

Think of it this way, in pure ASP.NET (non ajax ones, the old ones) calculate visibility/color.. all attributes of every element of html page for 1000s of users only on server and distribute them to clients. Not only that badly written ASP.NET Server Controls eat up more CPU as they do too much calculations.

To improve ASP.NET performance, more AJAX should be used or RIA like Flex/Silverlight will drastically reduce CPU overhead because you can use client's CPU to do your Data Visualization.

RIA Client (Flex/Silverlight) + ASP.NET Web Services is the future, I dont have detailed statistics to share but we moved away from ASP.NET almost a year back and our CPU usage has been reduced to 18% average from 99% before RIA based web sites.

Akash Kava
A: 

If you have slow hardware, yes. For most modern servers, no. The database will tax your CPU much more in most cases.

mcjabberz
A: 

Run a profiler to see if there are areas in your application that use too much cpu, or ridiculous amounts of memory. Use task manager on the server and see if it is IIS (inetinfo and w3wp) that is running away and not some other process. If it is IIS find out if it's your application pool that is running away. use iisapp command to find which app pool is assigned to which worker process.

gjutras