IIS Memory Worker Process Memory W3WP.EXE
Is your little IIS server eating all your memory?
Update: 1-16-2015: This is now a two (2) part posting regarding memory and covering cache for your IIS server. Second part is here. IIS 7.x Caache GZip Web.Config.
Update: 1-5-2017: For those that feel Recyle is the answer to your ASP Classic code memory issues I say, "Damn you!" I'm not sure you know the suffering of adding things to a form, shopping cart, etc while you are logged in and in a simple page change you have lost it all. I want to make sure do everything else before you set your Recyling schedule to 10 minutes or to 300MB. I want to know you're doing this so I never do anything on your site!!!!!
For IIS 7.5 read over everything below and look at my update near the end of the page.
I've seen Small Business Servers running classic ASP code that would just eat up memory to the last 5% of what was available on the server. Hosting internal and external websites can be more of a memory issue than you think.
I'm not going to talk SBS here but only IIS and in this article all about memory and what you can do.
I've had the issue in the past and still do today on some sites.
You built the perfect website and it handled things just fine, that's until you really started seeing traffic and your memory started to decrease causing your site to slowly fade away.
Our first choice is to "Recycle" the applications pool. It seems most point to the applications pool as the issue. If you actually look, the apps pool isn't the memory hog for most sites.
It's your cached pages!
Ok, maybe not in your case but it sure was in mine.
I've had to work for hours adjusting the server to match what I needed it to do. I need pages to load as designed, SQL services to run smooth and allow memory for other applications to run when needed.
Before I adjusted the out of the box IIS 7 server it was all about giving memory to the older websites and choking everything else.
I'll review the issue first to make sure you're not wasting your time.
I had 2 websites that would consume memory and grow based on the number of visits. Page Cache was eating memory to the tune of 1Gb per site in the IIS server. The SQL server was auto adjusting down and that slowed other components.
The first test was to disable the cached pages and see if that would show any differences. It didn't really show anything in my case. I run 0 HTML direct processes and all IIS ASP .Net which shouldn't have made any differences but it did.
It was almost like the IIS server was broken when you set no cached pages. But that might be related to something else.
Open your IIS Server manager and from the base IIS server open the "Worker Processes"
This is what I started with, I needed 1Gb per site but I wanted to use more hard drive than physical memory so I created a balance and the balance can be shown here.
Ok, close the worker process.
From the Output caching feature click on Edit Feature Settings.
If you are like most of us you've been here 10 times and have made changes repeatedly and still aren't getting the results you need.
I found in my case the following settings to work very well. I have 6 ASP Classic websites, 5 .Net and 1 PHP on the same server. PHP and .Net handle memory and caching better so the focus is going to be on the IIS ASP Classic sites. But this doesn't mean you might not have an issue with your .Net memory.
- Enable cache (checked)
- Enable kernel cache (checked)
- Maximum cached response size (in bytes) (default 262144)
- Cache size limit (in MB) Checked = 10MB
Next I created a rule for all .asp pages. You might need to adjust this based on how your hard drives are and your actual memory. I'm running a 32bit system so memory is one issue.
Cache Rule (Named .asp)
- User-mode caching (checked)
File Cache Monitoring
- Using file change notifications
Kernel-mode caching (checked)
- Using file change notifications
Nothing in the advanced but if you need to set a query string cache rule that would be the place.
From what I just did I now have controlled memory cache to my memory hog IIS ASP Classic pages.
They run at less than 280Mb each site which when I compared it to the old configuration at 980Mb allows more memory.
I have actually seen a balanced speed increase based on the sites response and users haven't had anything to report or complain about. (Yes, like you I get those site reviews from other site owners that seem to never tell me about their speed sites and it's code. But you know, your site took xyz seconds to load reports.)
Test this setting in your IIS server, check your file folders listed below to be sure the disk caching is picking up for the memory cache you took away.
I've configured the files to save at 20,000 from the default 2,000 for testing.
You can adjust your core default settings for your ASP Classic pages from the server page not the site page properties. Look for the cache controls in ASP features.
%SystemDrive%\inetpub\temp\ASP Compiled Templates
From the Server: ASP Feature
- Enable Buffering (True)
- Enable Chucked Encoding (True)
- Enable HTML Fallback (True)
- Enable Parent Paths (False)
- Client connection test (00:00:03)
- Maximum requesting entity.. (200,000)
- Queue Length (3000)
- Request queue time-out: (00:00:00)
- Response Buffering Limit (4194304) default
- Script time-out (00:01:30)
- Threads per processor limit (25)
- Locale ID
- Restart on Config Change (True)
- Cache Directory Path (Default)
- SystemDrive%\inetpub\temp\ASP Compiled Temp
- Enable Type Library Caching (True)
- Maximum Disk Cached Files (20,000)
- Maximum Memory Cached Files (0) (Custom setting)
- Maximum Script Engines Cached (20) custom setting
Basically what the above configuration does is limit your ASP pages to less than 300Mb of physical memory. Actually, it's not caching pages but it's using other features that need to run.
Run your Debug Diag 1.2 from your IIS resource kit. It really does show clearly what is taking your memory. My issue was directly to the number of pages cached into memory. (Sites have 100,000+) so it was clear that disk cache was going to save the day. It did, now the SQL servers can do their job without limits which is another day and another article.
Ok, that's about it, I'll update this if I find anything that really doesn't work.
For those that have had similar issues of massive memory usage feel free to send a note listing what you have done or if this article helped you can always tell me so I know to keep it online.
I'll be working with the newer servers and older code soon but if you're finding that same issue offer tips of what you're doing now so I don't have to waste time testing configs.
UPDATE 1-5-2017: Above you see the Caching Properties that I used on one of my servers during testing. It's actually not my live version and it most likely will not match yours because you are turning your system to match your ASP Classic code.
I let my ASP Classic sites eat as much memory as they wanted which was between 300MB and 2.5Gb. I had my pages cache to memory because ... I have memory ... because I host my own servers ... Because I can!!!
Now I'm intertaining the idea of managing a few more ASP Classic sites for some old schoolers that think like me and will not drop the stuff. Now I have to manage a big chuck of my memory so I have limited the cached pages to memory to 5 to 10 depending on size. I want you to read this article by Eric Lippert posted September 18, 2003, title "How does Active Server Pages use the script engines?" before you make any changes and before you start your recycling processes.
Look at this image:
Here's some numbers: By changing my Cached Pages to Memory from the default 200 on my big code page site I dropped from 2.5Gb to 350MB.
I'm still disk caching and until I notice anything I'll stick with the 5 pages maybe jump to 10 if it will provide a better end user experience. But for now, we all see little change.
So there is my 2017 update to this age old question of "Out Of Memory, What do I do?"
By the way, I am now hosting ASP Classic sites under a full developers and management environment. If you don't have time to manage things I'll do it on my servers for you.