?
Solved

App Pool Recycling.... affect on current Users??

Posted on 2010-04-08
17
Medium Priority
?
1,800 Views
Last Modified: 2013-12-14
Hi,

I need to schedule an "App Pool" recycle for about 5pm due to memory leak which I am sorting, but obviously will take a little time.

Now my understanding is that the recyling of Application Pools is intelligent and does not disturb current users. Is this correct?  In the past I have resaved the "Web.config" which resets the ASP.NET Worker Process for the website which obviously does kick people out. I hasten to add I have done this late at night !! However it releases lost memory that my website has taken up, but obviously not memory lost by other websites on the same server.

So can I use App Pool Recylcing during the day without effect to the end users. If so then would there be any initial ASP.NET page delay after a recycle?

Thanks,

Sam
0
Comment
Question by:SamJolly
  • 8
  • 6
  • 3
17 Comments
 
LVL 21

Expert Comment

by:Alfred A.
ID: 30105212
Hi,

What kind of session management do you use?  Are you using the default InProc process?

You can try using either State Server or SQL Server session management to separate the ASP.NET worker process from the Sessions.  This means that if an App Pool recycles, session would be intact because it is in a separate thread.
0
 

Author Comment

by:SamJolly
ID: 30105485
Hi Alfred.... I am using standard session management. So are you saying that I will destroy all the current sessions with app recycling?

Sam
0
 
LVL 21

Accepted Solution

by:
Alfred A. earned 2000 total points
ID: 30106261
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:SamJolly
ID: 30108666
Alfred,

I think this says it all !!

Thanks,

Sam
0
 

Author Comment

by:SamJolly
ID: 30109036
Out of interest... do you have views on any how many CMS sites should be a W2K3 server which also has SQL Server on it. There is 4GB of RAM on this 32bit Server. Just wondering whether the Server is being overworked....???

My available memory can start at 350MB in the morning and go down to about 1MB at midnight? Other sites eat into this as well.However if I do a web.config reset then I can get back from 1MB to about 190MB. So there is obviously a leak of sorts somewhere which I am checking with a profiler, but am wondering whether it is reasonable to be operating with these numbers in a live system. The test server is at around 900MB !!

Cheers,

Sam
0
 
LVL 21

Expert Comment

by:Alfred A.
ID: 30109057
Hi Sam,

No problem.  Happy to help. :-)

0
 
LVL 21

Expert Comment

by:Alfred A.
ID: 30109504
Hi Sam,

OK.  It really depends on concurrency.  How many users hit your servers at the same time?  Every user uses resources.  The higher the number of users, the higher the memory consumption.

Also, the w3wp.exe I believe has a limit of 1GB in W2K3, you might end up getting an out-of-memory error because of this.

Also, one thing that can lower down memory leaks is to handle all exception thrown.  Unhandled Errors waste resources and they stay in memory for quite sometime before being cleaned up.

Also, try to dispose your objects as soon as you don't need them.  Don't just let the GCC finalizer do this for you.

I hope this helps.

0
 

Author Comment

by:SamJolly
ID: 30112223
Alfred,

Thanks for this.

Interesting comment about Unhandled Exceptions. Basically I have taken on a webapp and it uses the OnError event in Global.asax to handle Unhandled Exceptions, write them to a DB Error Log and then clears them using "Server.ClearError()". Now I have to admit that I am getting quite a few errors although they are not affecting the User Experience... well that is until there is an out of memory error!! Of particular note are quite a few "invalid viewstate" errors.

I had always thought that the GC goes around pretty quickly clearing up. At least after 15 mins one should expect a clean down of junk....????

For info my profiler tells me that my memory usage on my current session is 61MB (dev server) . Now how much of this is overhead that would not be repeated by a 2nd user I am unsure since the profiler can only map to one user session.

I know we are getting a little off track, but I value your thoughts.....

Thanks again,

Sam
0
 
LVL 21

Expert Comment

by:Alfred A.
ID: 30114813
Hi,

-> Now I have to admit that I am getting quite a few errors although they are not affecting the User Experience...

Your comment above is the tricky part.  I got burned in the past because of that.  A simple try-catch would do you a lot of good. :-)

Normally, for the overhead, it really depends on the type of web site you are doing, if it is a web application that deals with heavy custom objects, a user will use more resources especially if you are using viewstate and sessions heavily.  As long as what the user uses (instantiates), returns later (dispose) after the process is over, the memory usage is usually really small.

In a web application that I did in the past, at peak, it reaches 950 MB for about approx 3000 users.  After handling the errors properly, it was peaking around 300 MB.  Big difference.
0
 
LVL 11

Expert Comment

by:b_levitt
ID: 30125026
Alfred answered your original recycling q so he deserves the points but I thought I'd jump in:

32 bit IIS has the same limits as other 32 bit processes - 2g or 3g with the /3g switch.

If your server shows free physical memory but you are still getting out of memory errors, then you might be bumping into a virtual memory problem or the memory fragmentation issue with 32 bit machines:
http://blogs.msdn.com/david.wang/archive/2006/02/14/More-on-Virtual-Memory-Memory-Fragmentation-and-Leaks-and-WOW64.aspx

I certainly agree that expected errors should be caught with a SPECIFIC catch, but I'm of the school that beleives catch(System.Exception) is generally a bad idea.  I don't think there is anything wrong with your global.asax routine.  Instead I would try to resolve the unhandled errors rather than change the way you're handling them.  

Ironically, invalid viewstate can be caused by a recycling app pool.  Your app pool might already be recycling if you have mem/virtual mem limits already set on the app pool.
0
 

Author Comment

by:SamJolly
ID: 30125292
Alfred,

How did you get those stats... ie using 950mb for 3000 users...??? Would be very interested in these stats for my site.

All I seem to be able to do is to find out what memory is available using a utility that I wrote using MemoryFailPoint.

I fear that going through the app and adding in Try Catch blocks etc will take a little while so I am thinking that there is wisdom in altering the session model to State or SQL Server so at Ieast I can app recycle. My current mod was to put in "MemoryFailPoint", but of course this just protects the server and does not recover memory. Then start altering code over a period of time.

Unfortunately there is little that can be done with the server without upgrading to 64bit, moving apps around etc....

Just hope State or SQL Server Session mgt does not throw up extra issues....

Sam
0
 
LVL 11

Expert Comment

by:b_levitt
ID: 30125552
As far as mem usage I've, seen sharepoint servers hover at 3g and higher on 64 bit machines.  900 isn't all that much but is pretty high.  Try browsing the site page by page and see where mem goes up.  There might be some places where objects are being dumped to session state and then not cleaned up.

Use of output caching (which actually will use memory) might reduce your overall usage beleive it or not.   Its very likely that the rendered page text takes less memory than the object did to create it.  You just have to be carefull about what you cache.

Good luck
0
 
LVL 21

Expert Comment

by:Alfred A.
ID: 30125834
@b_levitt,

Just to be clear, I use global.asax events such as Application_Error and Session_Error to catch errors but there were cases where specific errors considered unhandled and recorded in the Application Event Log of the production server I was working before and caused memory leaks within the application and I have plug the leaking pipe somehow.

I was just ask for my thoughts and all I can say is to each his own experience, mate!

I was not telling SamJolly to change his process.
 
0
 
LVL 21

Expert Comment

by:Alfred A.
ID: 30126353
Hi Sam,

The only issue I had with State Server is that it is slower than InProc due to out-of-process communication between the worker threads and session threads.

Anyway, goodluck with your projects/tasks.

0
 
LVL 11

Expert Comment

by:b_levitt
ID: 30126354
I understand alfred, I just didn't want him making huge try/catch(System.Exception) blocks - It's my #1 programming sin :).

Sam,
You can't use task manager to view the memory usage?

You could look at the "Sessions Active" counter in perfmon to get a rough idea of "user" count
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/2d7927e4-4416-4439-900f-5fb64ab2ee58.mspx?mfr=true
0
 
LVL 21

Expert Comment

by:Alfred A.
ID: 30127156
@b_levitt:

No worries.  I fully understand your position.   Anyway, I was just emphasizing to Sam the importance of handling errors whether it be global.asax routines or try-catch.

Cheers,
0
 

Author Closing Comment

by:SamJolly
ID: 31712236
Thanks to both of you for your great help.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
LinkedIn blogging is great for networking, building up an audience, and expanding your influence as well. However, if you want to achieve these results, you need to work really hard to make your post worth liking and sharing. Here are 4 tips that ca…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

598 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