App Pool Explosion

Are you absolutely, positively sure that your question does not fit anywhere else?
kendallbeaman
Posts: 10
Joined: Wed Jan 16, 2013 9:18 am

App Pool Explosion

Postby kendallbeaman » Wed Jan 16, 2013 9:33 am

Hey all,

We just started using WURFL. We are currently tracking down an issue that causes our site to crash. The crash occurred after I added code to exclude Tablets from our mobile web app. When this code is commented out the problem goes away. So I have re-factored it a bit. Added a check to make sure the manager object is in the cache like it should be. We're going to put this new version up but I'd like to submit what I was doing in case I'm doing something horribly wrong.

In the Global.asax under Application_Start I placed the following:

Code: Select all

	var configurer = new ApplicationConfigurer();
	var manager   = WURFLManagerBuilder.Build(configurer);
	HttpContext.Current.Cache[WurflManagerCacheKey] = manager;
Then in a parent controller I override the OnActionExecuting method and in there I place the following code:

Code: Select all

			var manager    = System.Web.HttpContext.Current.Cache[MvcApplication.WurflManagerCacheKey] as IWURFLManager;

			if ( manager == null )
			{
				var configurer = new ApplicationConfigurer();
				manager        = WURFLManagerBuilder.Build(configurer);

				System.Web.HttpContext.Current.Cache[MvcApplication.WurflManagerCacheKey] = manager;
			}

			var device = manager.GetDeviceForRequest(request);

			if ( device.GetCapability("is_tablet") == "true")
			{
				Session["isMobile"] = _isMobile = false;
			}
We will be testing the above code this weekend to see if the new check for null makes any difference though I don't see how it could. Its like something is being allocated too much but since I'm using the Cache it should only be the one object right?

Should I be checking the value coming back from WURFLManagerBuilder.Build? The code functions fine and properly excludes the tablet devices that we've tested. Its just the resource issue and the App Pool explosion that happened after we restarted the server but doesn't seem to happen all the time.

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: App Pool Explosion

Postby kamermans » Wed Jan 16, 2013 11:36 am

Hi,

We're looking into the issue now. Is the problem specifically that the resources are being starved and the application dies? Is the WURFL application being completely rebuilt on every request, because this would certainly cause resources to explode.
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

kendallbeaman
Posts: 10
Joined: Wed Jan 16, 2013 9:18 am

Re: App Pool Explosion

Postby kendallbeaman » Wed Jan 16, 2013 12:07 pm

Unknown at this time. When this occurred it was on a live server and so not many debugging details were gathered. They were frantically prepping the backup server and getting it running and since the only place where this happened was on the live server (dev, staging, local all ran fine) we're going to wait until Sat night to update the live again and see if it's still doing it and our boss will be closely monitoring it and getting more info for us to try and track down what is going on.

The code to detect mobile worked just fine without trouble. It was only when I added the configurer / manager / device objects that things went nuts.I couldn't see how anything in the code to indicate I was allocating too much or too often and whether or not the app was being rebuilt on each request. Hopefully know more after the weekend.

sm_support2
Posts: 294
Joined: Mon Jun 20, 2011 5:04 pm

Re: App Pool Explosion

Postby sm_support2 » Thu Jan 17, 2013 10:52 am

WURFL should be initialized only once in global.asax. Latest demos we built don’t use the Cache for a couple of reasons – though using the Cache is not necessarily.

1) If you use WURFL, you need WURFL data available at any time your site is up. So WURFL is probably not a piece of data you can remove from memory and load on demand repeatedly. More, if the Cache object is emptied—ASP.NET can do that—that it’s likely because the system is running short of memory. Re-adding 50MB of WURFL can easily collapse the system. Latest demo use a static object that is up and running all the time.

2) ASP.NET Cache is not distributed which moves to the dev the burden of making the cache distributed in a farm—not sure this is really related to the problem raised.

In light of this, if WURFL data is stored to the Cache a test again NULL makes a lot of sense; there’s the risk that “manager” is null when read in a request. However, another reason having a GLOBAL WURFL manager object is that you store the manager instance in the cache and that instance is disconnected from the cache. The memory it holds is subject to GC policies for removal; so it may be that you end up with several managers in memory at a given time which may implode the system.

I suggest to have a static member on the global.asax class initialized to the WURFL manager object—this is never nulled—and invoked directly from every controller method.

Thanks

kendallbeaman
Posts: 10
Joined: Wed Jan 16, 2013 9:18 am

Re: App Pool Explosion

Postby kendallbeaman » Thu Jan 17, 2013 11:25 am

That makes sense. So perhaps what was happening before was that the Cache was being cleared while the instance itself was not? Just trying to guess what may have been going on. I do see that what you mention is a new potential problem because I just added the code to create a new instance if the Cache had a null there.

Do you have a link to the latest demos? All the examples I have seen use the Cache. Although if not I'll just do what you suggest and use a global static object for the manager.

sm_support2
Posts: 294
Joined: Mon Jun 20, 2011 5:04 pm

Re: App Pool Explosion

Postby sm_support2 » Fri Jan 18, 2013 7:57 am

We discussed this internally. We will publish the demo as part of a new blog post sooner rather than later

Thanks

kendallbeaman
Posts: 10
Joined: Wed Jan 16, 2013 9:18 am

Re: App Pool Explosion

Postby kendallbeaman » Wed Jan 23, 2013 8:35 am

Hey there,

Just wanted to follow up on this. It worked. I followed your suggested and instead of using the Cache I used a static member on the global object and initialized it to an instance of the manager. This has solved the issues we were seeing on our large scaled site. I've added this to our internal documentation as this will be the recommended way going forward as I don't see any downsides to it.

I do still look forward to seeing your demos and seeing if there is something I am missing. Is there ever a chance that the manager would become null? Do I need to account for that in some way? Currently I'm not.

Anyway, thank you for all your help on this.

sm_support2
Posts: 294
Joined: Mon Jun 20, 2011 5:04 pm

Re: App Pool Explosion

Postby sm_support2 » Wed Jan 23, 2013 7:04 pm

Please find the Blog Post we promised here. Thanks

http://www.scientiamobile.com/blog/post ... in-ASP.NET

kendallbeaman
Posts: 10
Joined: Wed Jan 16, 2013 9:18 am

Re: App Pool Explosion

Postby kendallbeaman » Wed Jan 23, 2013 9:01 pm

Sweet thanks! This was well written. I am going to include a link to it in our internal documentation.


Who is online

Users browsing this forum: No registered users and 2 guests