Find memory leak in ASP.NET Web App - asp.net

I'm hosting 7 websites on a single production server (virtual) at 2.53 Ghz (2 CPU) and 8GB of RAM on WIN SERVER 2008 R2 Enterprise 64 Bit.
Web server is IIS 7 and all of the websites are with .NET Framework 4.0 application pool.
My current memory usage is about 4.16 GB out of 8GB and w3wp.exe is the most process which consuming most of the memory usage (about 1.6 GB at this time) followed by sqlservr.exe with (1.5 GB) usage.
What I would like to do is to know which website out of 7 is consuming the most memory so that I could have a look.
I've tried Process Explorer and Resource monitor but it could only show how much rem taken by w3wp.exe but not individual website's usage.
Is there a way where I could pin point the memory hogger?

You could do a memory dump using Microsoft's Debug Diag tool.
Basic process is:
Launch DebugDiag
Cancel Wizard
Click "Processes" tab
Select w3wp
Right-click and select "Create full dump"
Snigger quietly to yourself because you said "dump"
Once dump is complete (snigger again), click "Advanced Analysis" tab
Use the 2 Memory Pressure Analyser scripts to see if you can see what objects are using a lot of memory.
I would advise doing this in combination with Uri May's answer, as otherwise you will likely waste a lot of time.

You can configure each web site to use different app pool, that way you'll have a w3wp.exe process for every web site of the 7 websites you host. After that you can use the tool in the following this link to find out which of the websites is causing the leak by tracing the PID of the w3wp.exe with biggest memory consumption.

In windows task manager you can see which app pool is running each w3wp.exe simply by showing the "user" column. This is because each app pool typically runs with its own user. They made it a bit harder to see this in Windows 2012 server - you need to click on "details" tab first.

Related

Trouble Shooting IIS 8.5 Classic ASP Loading Time

So I am migrating a server and can't find out why the new machine / environment is slower than the old one. Here are the facts.
Old Machine
2008 R2 - 3.1ghz quad core Xeon w/ 12gb
SQL2k \ SQL 2008
IIS 7
New Machine
2012 R2 - 2.5ghz 8 core Opteron w/ 16gb
SQL2k \ SQL 2008 \ SQL 2016
IIS 8.5
So here is what I have done. I migrated the codebase onto the new machine. I loaded up SQL2k which I know is not supported and I plan to upgrade. The same page on both machines loads fine. Old machine loads in 10 seconds new machine takes 124 seconds.
Next step was to convert database from 2k to 2016 via 2008. Done with that same load speed 124 seconds. Next changed connections strings from OLEDB to Native 11. That dropped the load time from 124 down to 30 seconds.
Next I went into query manager and ran the SP on both machines. Old machine takes 4 seconds to complete the query. New machine takes less than 2 seconds to run the same query on sql2k but on sql2016 the same query runs in under a second. I then wrote a much more intensive query and ran it on both machines. The old machine took 120 seconds to execute the new machine took 12 seconds in 2016 and about 25 seconds in SQL2k.
So at this point I am assuming it is IIS settings. Next I went to the old machine installed SQL 2016 and loaded it up to test speeds with the new database running on the old server with IIS 7. Zero difference.
I have tried connection string changes with IP vs NAME no difference.
Is there some change in IIS 8.5 that affects classic ASP performance or a setting in 2012R2 that I am missing somewhere? All app pools and sites are exactly the same on both machines.
Any help would be great, thanks
** Added all sql settings are the same also for both sql2k and sql2016 along with IIS settings. Firewall settings also the same. .NET environments all the same too.
** Changed New Machine is 8 Core not 4
Too many cores man.
Some questions - it's this all one site? All one app pool?
Classic asp wasn't written for 8 core machines. In IIS 8.5 there are settings you can set for processor affinity and numa node (memory) affinity. But really only useful if you have separate sites or app pools to run. But before looking at any of that I'd ask you to try an experiment. Make a vm version of your site, set to use 4 cores and 8 gb ram. Deploy two copies to your machine. Test hitting the page in one of them. You may get better performance. You could also try this without vms by setting the site to run in two worker processes (web garden configuration) and bind each process to half the cores.
Just try adding a host file entry IP pointing to the machine name. I understand you are running SQL server in the same machine but still it will make a big difference from my experience.
As #Brain suggested, Web gardens will help a little on high load but I think your issue is just related to the connection speed.

IIS 7 app pool optimization

I have several sites running on win 2008 64bit/ IIS 7 with each sites go with a separate application pool (default settings).
The problem is that many of them, very simple and low traffic site, consume lots of memory(100mb - over 1 gb). Most of them are written in c# asp.net 4.0 managed code (linq to sql and entity framework 4-5.0).
say one app pool is at 90000 kb, if i run the web on browser, it could go up to more than 200000 kb. Is it normal ?
So what would i do to keep them cool down without interrupting (much*) the performance ?
Should i lower the default recyling interval ?
Also, anyone know the best solution to monitor/trace memory leak that's easy to use.

W3WP is running slow

I have a very unusual problem with W3WP process (IIS Worker Process). It is not taking enough memory from my CPU to run faster. It is impacting my development work as it is taking way to long to pull up a local website. When I start the website from my localhost, W3WP start at roughly 50MB and takes nearly 10 min to spike upto 100MB.
Is there a way to make W3WP run fatser?
I am using a 64bit 3.4GHZ Quad Core i5 CPU with 8GB RAM. OS Windows 7 Enterprise Edition.
you can use .NET Profiler too see the slow methods.
Also you can change resource limits ( CPU , Memory , ... ) in advanced application pool settings.
I went to IIS settings and changed the 'Worker Process'/'Change .Net Framework Version' from 2.XX to 4.XX. Also I have a dedicated app pool for my application and stopped all other applications. These changes made things a lot better that what it was.

Asp.net application bottleneck identification: any suggestion?

We are struggling to find out what could be the ASP.NET application performance decrease when we pass from our staging server to our production server and we would like to hear from you to help us find the bottleneck.
Our staging server is a Intel Core 2 Quad CPU Q8200 (2.33 GHz) with 4GB of RAM, Windows Server 2003 R2 SP2 x64 Edition. Databases are hosted on Sql Server 2008 Express Edition. Everything seems to work smoothly. Page change is almost immediate ad page load time (for example switching pages in a grid) is ok.
Our production server is a VIRTUAL double Intel Xeon 3.00 GHz with 2GB of RAM, Windows Server 2008 Web Edition SP2 x86 Edition. Database are hosted on Sql Server 2008 Web Edition.
Our application is a .NET 3.5 (migrating to .NET 4 in these days) using classical best practices (masterpages, CSS, AJAX, paging for data, client cache for static resources, gzip compression on IIS for static and dynamic resources, server side cache for data that doesn't change frequently...).
I really can't understand what can cause the application to run so differently between the two scenarios. What could that be? The missing RAM? The load on the production server? The network limit?
What can I do to narrow bottlenecks' research?
You could briefly enable tracing on your production server (don't forget to turn it back off) and see what stages of your page loading are taking so long).
If you can easily add 2 GB more of RAM to the virtual server, try that, it's easy and might matter. Check your RAM usage in task manager and see how much you're using.
Are these servers hosted at the same place or might there be network latency differences?
On the server, run perfmon.msc and watch the counters, what's maxing out?

Why is intranet so slow on our machines?

we are using IIS 5 + Windows XP on our machines,
they have Celeron CPUs # 2.6 ghz, 2 GB RAM
These machines have control system for machinery, control system logs events to database and we want to show reports for machinery usage, operator logins, etc.
We use Windows XP and IIS 5, our applications are ASP.NET (3.5). We use Sql server 2005 express and Crystal Reports 10.5 for reporting.
The problem is, that whenever you open an intranet page after reboot or after longer period of webserver's inactivity, it takes a LOT of time for a page to react, 10-30 seconds. When I open up a page that shows a report, it lags for this amount of time too.
When pages are viewed after the first long load, they render quickly.
The pages are precompiled (helped a bit, but not much), disk is not fragmented, sql server reacts fast (tested with other applications) - I really don't know what's the cause, but I'd like to eliminate it, because this looks very bad with the customer - to wait for half a minute for a report page to display.
Why is this so slow? I have done some sample pages on php/mysql/iis and it was lightning fast... Is there something I can do to 'preload' all of the intranet applications on machine reboot? If nothing helps, I'll make a simple script that will periodically request all pages from the webserver, so it will be 'warmed up', but this is a dumb solution, I think. :(
I guess probably the application pool for the web site is not loaded until the first request - this time is for the out-of-process host process to start running and serve up requests.
IIS takes a few seconds to compile each ASPX page after a recycle. You need to create a warmup script that programatically loads a few of your pages after the recycle. The script will incur the delay so your users don't have to.
Here is an example. http://blogs.msdn.com/joelo/archive/2006/08/13/697044.aspx It's for SharePoint, but the concept is the same and you should be able to adapt it.

Resources