ASP.NET 2.0 web cache insert fails

ASP.NET 2.0 web cache insert fails

am 23.12.2007 17:24:00 von CaT

As per Anthony's suggestion, I'm moving this discussion thread to this group.
The history:

We recently moved an older ASP.NET 1.1 code base on to ASP.NET 2.0, .NET 3.0
and Windows 2003 Server SP2. We started experiencing the following issue with
the web cache (the code is straightforward and worked flawlessy before the
upgrade):

Dim o As Object = Cache.Get(key)
If o Is Nothing Then
Cache.Insert(key, GetTheData())
o = Cache.Get(key)
End If

Randomly, Cache.Get(key) returns nothing, even after the application has
been up for a while. Then the Cache.Insert kicks in. Only that the call to
Insert fails with no error and no exception. The subsequent Cache.Get(key)
returns nothing. I've tried to set up the expiration to some remote date in
the future and the sliding expiration; still nothing. I tried something like
this;

Cache.Insert(key, GetTheData(), Nothing,
DateTime.Parse("1/1/9999"),Cache.NoSlidingExpiration)

and

Cache.Insert(key, GetTheData(), Nothing, Cache.NoAbsoluteExpiration,
TimeSpan.FromDays(365))

I even added after the first failed Insert a Thread.Sleep(20) the tried the
Insert again. Didn't work either.

I searched on the Internet and I found a few other posts describing a
similar issue. Yet no reply to any of them so it seems that there is not much
knowledge about this strange issue.

Any idea is highly appreciated.

Thanks,

cat


Could the problem be with the GetTheData method?
You might be better off asking in the

microsoft.public.dotnet.framework.aspnet

group.

--
Anthony Jones - MVP ASP/ASP.NET



Thank you Anthony for taking the time to reply. After my initial posting I
spent some time researching on the Internet and trying out some other things,
so I do have some more information.

1. To answer to your questions/suggestions:
1.a. I will move this discussion to microsoft.public.dotnet.framework.aspnet
1.b. GetTheData was just some very generic pseudocode. The real code
retrieves the information as a dataset based on some criteria, then saves
this dataset to the cache. I am storing a reference to the retrieved dataset
before putting it in the cache, so the code is more like this:

Dim dt As DataSet = GetTheData()
Cache.Insert(key, dt, Nothing,
DateTime.Parse("1/1/2999"),Cache.NoSlidingExpiration)


2. After several days of researching this issue and experimenting various
things, I kind of reached the conclusion that this must be something related
to the memory management. Everything is ok until w3wp (iis worker process)
exceends 400 MB. The computer I am running all those tests has 1 GB RAM.
Subtracting the OS and system cache memory allocations, the 400 MB threshold
means that the computer has under 100 MB of available physical RAM. After
passing that threshold, it seems that .NET runtime refuses to add items to
the cache while also not telling anything to the code (as in, raising some
sort of out of memory exception). Either ASP.NET 2.0 is a more memory hog or
whatever else changed, but this was not happening before upgrading the code
base/site to .NET 3.0 / ASP.NET 2.0 / w2k3 SP2. The site itself is complex
but not that big. It puzzles me why w3wp would grow beyond 400 MB of RAM.

3. I have downloaded, installed and run CLR profiler and ANTS profiler. I am
trying to figure out what's going on at the lower levels. To my surprise,
ANTS (non-Microsoft, not free tool) is worse than CLR profiler (Microsoft
free tool). To this point, it seems that the .net runtime is doing some
allocations (mostly strings) that sit there forever and eat up memory. At
some point I manage to induce a system failure; w3wp gets into a continuous
loop, and IIS fails to ping it therefore it recycles it. I can do that afther
hitting the site for about 10 minutes continuously. All very weird. Never had
those problems before upgrading the code to .NET 3.0 / ASP.NET 2.0 / Win2k3
SP2. A colleague of mine has a similar environment, just SP1 instead of SP2,
so I started wondering whether Microsoft created some weird bug in the heap
allocator in SP2.

RE: ASP.NET 2.0 web cache insert fails

am 23.12.2007 22:41:01 von CaT

After further testing, I've noticed that on a Windows Server 2003 R2 SP1
machine w3wp stays under 90 MB, on the SP2 machine that I'm doing development
on it goes to around 250 MB with the same code and same pages hit; if I
navigate for a while (like 15-30 minutes) between those pages at some point
the w3wp's memory consumption exceeds 350 MB and it starts going up by itself
with no navigation whatsoever. At that point the IIS ping fails (so w3wp
becomes unresponsive) and so IIS restarts the worker process. Not sure if
this has any relevance, but the pages are a mixture of old ASP with VB COM+
objects and ASP.NET pages with business layer components written in VB.NET
and C#.

RE: ASP.NET 2.0 web cache insert fails

am 24.12.2007 04:42:00 von pbromberg

Do you have "ASPCOMPAT = true" in the @Page directives for your pages that
need to support classic COM components?
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


"cat" wrote:

> After further testing, I've noticed that on a Windows Server 2003 R2 SP1
> machine w3wp stays under 90 MB, on the SP2 machine that I'm doing development
> on it goes to around 250 MB with the same code and same pages hit; if I
> navigate for a while (like 15-30 minutes) between those pages at some point
> the w3wp's memory consumption exceeds 350 MB and it starts going up by itself
> with no navigation whatsoever. At that point the IIS ping fails (so w3wp
> becomes unresponsive) and so IIS restarts the worker process. Not sure if
> this has any relevance, but the pages are a mixture of old ASP with VB COM+
> objects and ASP.NET pages with business layer components written in VB.NET
> and C#.

RE: ASP.NET 2.0 web cache insert fails

am 24.12.2007 12:56:00 von CaT

We didn't use that as we deemed it's not needed. The .NET pages use .NET
application & business components. The classical ASP pages use COM+ VB
components. We are in the process of converting the current code base to .NET
and we converted all layers for the features that we managed to convert. The
code base is fairly big, so it will be another while until we are pure .NET
(we are at about 75% of the code base at this point).

From my initial tests, it seems that when hitting only the ASP.NET pages or
only the ASP pages, w3wp memory usage stays relatively constant (still over 2
times higher than on the SP1 machines). The issue seems to get triggered when
navigating between the 2 kinds of pages. I'll run further tests today to
validate this assumption.

"Peter Bromberg [C# MVP]" wrote:

> Do you have "ASPCOMPAT = true" in the @Page directives for your pages that
> need to support classic COM components?
> -- Peter
> Site: http://www.eggheadcafe.com
> UnBlog: http://petesbloggerama.blogspot.com
> MetaFinder: http://www.blogmetafinder.com
>
>
> "cat" wrote:
>
> > After further testing, I've noticed that on a Windows Server 2003 R2 SP1
> > machine w3wp stays under 90 MB, on the SP2 machine that I'm doing development
> > on it goes to around 250 MB with the same code and same pages hit; if I
> > navigate for a while (like 15-30 minutes) between those pages at some point
> > the w3wp's memory consumption exceeds 350 MB and it starts going up by itself
> > with no navigation whatsoever. At that point the IIS ping fails (so w3wp
> > becomes unresponsive) and so IIS restarts the worker process. Not sure if
> > this has any relevance, but the pages are a mixture of old ASP with VB COM+
> > objects and ASP.NET pages with business layer components written in VB.NET
> > and C#.

RE: ASP.NET 2.0 web cache insert fails

am 24.12.2007 13:04:01 von CaT

Just to be very clear on this aspect: we have no problem whatsoever with this
code base on the production servers, which are windows 2003 server R2 SP1.
This problem started happening about 2 months ago in development and qa.
During those 2 months we wrote some new features and we installed w2k3 SP2.
I've reviewed the code we changed and there seems to be no relevant change
in the application layer that could have caused any such problem. That would
leave SP2 as suspicious.

"cat" wrote:

> We didn't use that as we deemed it's not needed. The .NET pages use .NET
> application & business components. The classical ASP pages use COM+ VB
> components. We are in the process of converting the current code base to .NET
> and we converted all layers for the features that we managed to convert. The
> code base is fairly big, so it will be another while until we are pure .NET
> (we are at about 75% of the code base at this point).
>
> From my initial tests, it seems that when hitting only the ASP.NET pages or
> only the ASP pages, w3wp memory usage stays relatively constant (still over 2
> times higher than on the SP1 machines). The issue seems to get triggered when
> navigating between the 2 kinds of pages. I'll run further tests today to
> validate this assumption.
>
> "Peter Bromberg [C# MVP]" wrote:
>
> > Do you have "ASPCOMPAT = true" in the @Page directives for your pages that
> > need to support classic COM components?
> > -- Peter
> > Site: http://www.eggheadcafe.com
> > UnBlog: http://petesbloggerama.blogspot.com
> > MetaFinder: http://www.blogmetafinder.com
> >
> >
> > "cat" wrote:
> >
> > > After further testing, I've noticed that on a Windows Server 2003 R2 SP1
> > > machine w3wp stays under 90 MB, on the SP2 machine that I'm doing development
> > > on it goes to around 250 MB with the same code and same pages hit; if I
> > > navigate for a while (like 15-30 minutes) between those pages at some point
> > > the w3wp's memory consumption exceeds 350 MB and it starts going up by itself
> > > with no navigation whatsoever. At that point the IIS ping fails (so w3wp
> > > becomes unresponsive) and so IIS restarts the worker process. Not sure if
> > > this has any relevance, but the pages are a mixture of old ASP with VB COM+
> > > objects and ASP.NET pages with business layer components written in VB.NET
> > > and C#.