W3wp hih cpu usage and non-existent web pages - cpu-usage

When I try to display a non-existent page on our web site the w3wp.exe process uses 13% cpu and stays at that level. For each additional non-existent page request an additional 13% of the cpu is used. Of course, after several requests the total cpu usage is up to 95-100% and the site becomes unusable.
I kill off the w3wp.exe process and everything goes back to normal. After awhile several random users go to non-existent pages and the cpu goes up to 100% again.
Researching the problem I stumbled across the idea that the web.config httperrors section was locked and potentially causing problems. I and my hosting firm technical staff tried the suggestions in this post: http://forums.iis.net/p/1159721/1912266.aspx. None of these suggestions solved the problem.
I looked at Worker Processe in IIS and that told me nothing.
I looked at Failed Request Tracing and that did not help either.
Obviously, I'm looking for any other suggestions on how to diagnosis and solve this problem.
Thanks,
Ed

Have a look at this blog post. I've actually used Jose Reyes’ ASP.NET Perfecto tool to work out that a Page_Init on X page was being slow due to X. You can only really use this tool though, if you can get remote desktop access to the server - as you need to setup performance counters.
FREB / Failed Request Tracing (FRT) should also be able to tell you where it's all hanging, although I didn't find it as useful as the above. (Seems you also agree :p).
Also, may sound weird, but if it's a non existant page, I guess these are being handled using Custom Errors / Error Pages? So surely the page can't be that intensive! In any case, FREB/FRT should be able to you if that IS the case.
There's also the PerfView Tool, which I haven't personally used, but is apparently quite nifty.
HTH

Related

My site is taking a very long time to load, what can I do to investigate the issue?

my site is ASP.NET,C#, .net 4, using Umbraco 4, IIS 7.5 it has been working great for months but suddenly its taking ages just to load a single page and mostly not loading at all.
The DB looks fine,
I've restarted the site,
recycled the APP pool,
looked in the logs, it just looks like jibberish
Does anyone have any ideas as to how I can investigate further. No I am not asking you to fix my site or tell me why it is not working, I just want to know other methods for investigating the problem so I can get to the bottom of the issue.
IIS LOG:
http://pastebin.com/msjzty7m
Thanks
Use Google Pagespeed Insights to see where the problems might be.
I have a couple of suggestions:
Set up the ELMAH error log and take a look if some unhandled expcetions.
Set up mini profiler, maybe it is a bottle neck inside a new added script.
Use google PageSpeed Insights to analyze your pages.
My first guess would be it is infact a data issue. Not that it's taking a long time to grab the data but to process it. I've had a few times now where a page is around 138Kb but took over 3 seconds to wait for the page before rendering. Basically this was cause it was running a 3 tier repeater (repeater inside repeater inside repeater) to create the menu system. So even though the site wasn't big it was taking time processing this menu before sending it out.
Suggestions from me would be to comment out anything new that you've added before this date and bring stuff back in slowly till you find the problem part. After that you can look at caching. And if it's a module (.ascx) use # Output Caching and that could help.
This is not loading at all... the online tools can not help, you need to investigate whats happens on the server.
The tools for that is the process explorer from sysinternals to see what is running slow your server, then the autoruns to see what you loading with out your knowledge and also slow down your system, and the tcpView to see who is connected to your server.

ASP Page performance is poor and differs greatly across environments

Firstly apologies I cannot be more specific as if I could then I might know where to look. I have an ASP.net web app with a bunch of pages using AjaxControlToolKit. The speed the pages render differs greatly between my two environments. On one it is super slow taking a ~5 seconds to render a relatively simple page which has two grids and a bunch of controls. Everywhere i look articles say "check your SQL" but that cannot be it as SQL perf should be common across all environments. I have also narrowed it down to where the page is just doing a basic post back, no sql, and still the issue is repro. A user clicks Select All and we check a bunch of items in a list. I timed the code behind for this and it is fast 00:00:00.0002178.
The two environments are sitting side by side, same location, both have IE9, except one is running on W2K8 and one is W7. That is the only real difference. On W7 the pages are relatively fast to render.
Any pointers greatly appreciated.
EDIT:
Changing the debug to false did have a positive impact.
Debug Page Time
True 0.143363802770544
False 0.0377570798614921
So what I will do next is systematically look at each component of the application to see why I am making mistakes, SQL, ViewState, etc. I'll update the post with my final findings for those interested.
Thanks All for the help!
I would check the following
Check the CPU usage on the server through task manager (web app and database). Is it maxed out
Are the servers out of physical memory - again task manager
Are the returned pages massive. This is obvious but sometimes it's not. Sheer quantity of HTML can kill a page dead. This could be hidden (ViewState, elements with display:'none') or actually on the page but you are so used to looking that you can't see
Get fiddler onto it. Are you calling any external resources you shouldn't be. maybe there is a web service you are relying on that is suddenly inaccessible from a particular box. We had a twitter feed that was timing out that totally killed a site.
Do profile the database. You think it can't be but are you sure. Are you sure you're sure. You might not be comparing like with like and bring back huge amounts of data on one test without realising.
Certain processes are very sensitive to page/data length. For instance I had a regex that utterly failed and timed the page out once the page reached a certain size. The performance hardly tailed off - it stopped dead (badly written - who did that - erm me!!)
Is the physical box just dying. Are they any other processes/sites on there that are killing it. Who are you sharing the box with? Is the hard disc on it's way out?
Firewalls can be naughty. We have seen massive increases in performance by rebooting a physical firewall. Can you trace those packets?
Any there will be more - performance debugging can be a bit of an art. But hey - we're all artists aren't we.
I probably first check to see whether I have 'debug' mode switched on in my web.config

Speed up web application compilation

I have tried looking at "related" questions for answers to this but they don't seem to actually be related...
Basically I have a VB.Net application with a catalogue, administration section (which can alter the catalogue, monitor page views etc etc) and other basic pages on the customer front end.
When I compile and run the app on my local machine it seems to compile fairly quickly and run very fast. However when deployed on the server it seems to take forever and a day on the very first page load (no matter what page it is, how many stylesheets / JS files there are, how many images there are, how big the page markup is and so on). After this ALL the pages load really fast. My guess is this is due to having to load the code from scratch; after that, until it is recycled, the application runs perfectly fast. Does anyone have any idea how I could speed this part of the application up? I am afraid that some customers (on slow connections such as my own at less than dial-up speed) may be leaving the site never to return as a result of it not loading fast enough. Any help would be greatly appreciated.
Thanks in advance.
Regards,
Richard
PS If you refer to some of my other questions you will find out a bit more about the system, such as the fact that most of the data is loaded into objects on the first page load - I am slowly sorting this out but it does not appear to be making all that much of a difference. I have considered using Linq-to-SQL instead but that, as far as I know, does not give me too much flexibility. I would rather define my own system architecture and make it specific to the company, rather than working within the restrictions of Linq-to-SQL.
If you can, the quickest easiest solution is simply to configure the AppDomain not to recycle after a period of inactivity. How this is accomplished differs between IIS 6 & IIS 7.
Another option is to write a small utility program that requests a page from your site every 4 minutes and set it up as a scheduled task on another PC that is on all the time. That at least will prevent the timeout and consequent AppDomain recycle from happening. It is a hack, to be sure, but sometimes any solution is better than none.
The proper solution, however, is to precompile your views. How exactly to accomplish and deploy that will depend on the exact type of Visual Studio project your web site is.

How do I track down sporadic ASP.NET performance problems in a production environment?

I've had sporadic performance problems with my website for awhile now. 90% of the time the site is very fast. But occasionally it is just really, really slow. I mean like 5-10 seconds load time kind of slow. I thought I had narrowed it down to the server I was on so I migrated everything to a new dedicated server from a completely different web hosting company. But the problems continue.
I guess what I'm looking for is a good tool that'll help me track down the problem, because it's clearly not the hardware. I'd like to be able to log certain events in my ASP.NET code and have that same logger also track server performance/resources at the time. If I can then look back at the logs then I can see what exactly my website was doing at the time of extreme slowness.
Is there a .NET logging system that'll allow me to make calls into it with code while simultaneously tracking performance? What would you recommend?
Every intermittent performance problem I ever had turn out to be caused by something in the database.
You need to check out my blog post Unexplained-SQL-Server-Timeouts-and-Intermittent-Blocking. No, it's not caused by a heavy INSERT or UPDATE process like you would expect.
I would run a database trace for 1/2 a day. Yes, the trace has to be done on production because the problem doesn't usually happen in a low use environment.
Your trace log rows will have a "Duration" column showing how long an event took. You are looking at the long running ones, and the ones before them that might be holding up the long running ones. Once you find the pattern you need to figure out how things are working.
IIS 7.0 has built-in ETW tracing capability. ETW is the fastest and least overhead logging. It is built into Kernel. With respect to IIS it can log every call. The best part of ETW you can include everything in the system and get a holistic picture of the application and the sever. For example you can include , registry, file system, context switching and get call-stacks along with duration.
Here is the basic overview of ETW and specific to IIS and I also have few posts on ETW
I would start by monitoring ASP.NET related performance counters. You could even add your own counters to your application, if you wanted. Also, look to the number of w3wp.exe processes running at the time of the slow down vs normal. Look at their memory usage. Sounds to me like a memory leak that eventually results in a termination of the worker process, which of course fixes the problem, temporarily.
You don't provide specifics of what your application is doing in terms of the resources (database, networking, files) that it is using. In addition to the steps from the other posters, I would take a look at anything that is happening at "out-of-process" such as:
Databases connections
Files opened
Network shares accessed
...basically anything that is not happening in the ASP.NET process.
I would start off with the following list of items:
Turn on ASP.Net Health Monitoring to start getting some metrics & numbers.
Check the memory utilization on the server. Does re-cycling the IIS periodically remove this issue (memory leak??).
ELMAH is a good tool to start looking at the exceptions. Also, go though the logs your application might be generating.
Then, I would look for anti-virus software running at a particular time or some long running processes which might be slowing down the machine etc., a database backup schedule...
HTH.
Of course ultimately I just want to solve the intermittent slowness issues (and I'm not yet sure if I have). But in my initial question I was asking for a rather specific logger.
I never did find an answer for that so I wrote my own stopwatch threshold logging. It's not quite as detailed as my initial idea but it has the benefit of being very easy to apply globally to a web application.
From my experience performance related issues are almost always IO related and is rarely the CPU.
In order to get a gauge on where things are at without writing instrumentation code or installing software is to use Performance Monitor in Windows to see where the time is being spent.
Another quick way to get a sense of where problems might be is to run a small load test locally on your machine while a code profiler (like the one built into VS) is attached to the process to tell you where all the time is going. I usually find a few "quick wins" with that approach.

Debugging an already-running ASP.NET site in IIS7

We currently have a Live ASP.NET application (Basically a CMS) running on our IIS7 web-server.
Every once and a while (Talking every few months) it's app pool will go to 100% CPU-usage and stay there until the page times out. We've tried increasing the timeout for the page to 30 minutes in the web.config but it still just stayed at full CPU so I'm presuming it's some form of infinite loop.
It is a massive application, one of the biggest we have, and far too large to blindly search for an issue. The prevailing opinion is that since it's so rare we can just restart the app-pool whenever it happens, but I'd much prefer to fix it.
I have access to the code and full administrator access to the hosting server, and the monitoring software we're running gives me plenty of time to be on the server while the issue is taking place but I can't find any way to get useful data about what's going on at the time without adding a massive constant overhead to the site (Which given it'll take months to happen isn't really viable).
I'm wondering if anyone has some advice as to how I could narrow down our search? A stack trace of the currently running threads would be spectacular, but even just a list of the pages that are actively being served would make a huge difference. I can add code to the project to make it more traceable, but logging everything in the hopes of catching it would be unrealistic (It gets a lot of traffic and we don't want to add significant overhead to page loads).
Tess's blog is an excellent resource on debugging production asp.net applications.
I think this blog post from her blog will be really helpful in getting started in debugging this problem: Hang debugging walkthrough.
Hope this helps
I recommend you to use ASP.Net performance counter, (like the requests queue and number of requests)

Resources