[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.caching

Everything removed from the cache at once

hcurrie

11/4/2008 4:14:00 PM

I am inserting some items into the cache with High priority, some with
Normal and some with AboveNormal. I am not setting an expiry time for any of
the items, but when I add a large number of items to the cache they start
getting removed with the reason: underused. This is as I would expect.
The normal priority items get removed first, which is also as I'd expect.
However, as soon as it decides it needs to start removing items, rather than
just removing enough items to reduce the memory used below the limit, it
seems to be removing all of my normal priority items in quick succession.
I found the following article which states that the expiration in dotnet 2.0
was too aggressive, but this was supposedly fixed in SP1, and I have SP2.
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedbac...
Is what I am seeing normal behaviour? It still seems too aggressive to me.
Is there any way around this other than setting explicit expiration times?
TIA
Phil.


7 Answers

hcurrie

11/5/2008 9:34:00 AM

0

>I am inserting some items into the cache with High priority, some with
>Normal and some with AboveNormal. I am not setting an expiry time for any
>of the items, but when I add a large number of items to the cache they
>start getting removed with the reason: underused. This is as I would
>expect.
> The normal priority items get removed first, which is also as I'd expect.
> However, as soon as it decides it needs to start removing items, rather
> than just removing enough items to reduce the memory used below the limit,
> it seems to be removing all of my normal priority items in quick
> succession.
> I found the following article which states that the expiration in dotnet
> 2.0 was too aggressive, but this was supposedly fixed in SP1, and I have
> SP2.
> http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedbac...
> Is what I am seeing normal behaviour? It still seems too aggressive to me.
> Is there any way around this other than setting explicit expiration times?

I've experimented with changing the priority of some of my cache items, and
I'm no longer seeing the whole of my lowest priority items all being removed
at the same time, so perhaps it was just to do with the timing of how the
items were being added. However, I am still seeing some slightly odd
behaviour. Now what I see is items being removed in several waves. It may be
that these correspond to the different parts of my system that are adding
the items to the cache, but what I don't understand is why these waves of
removal keep coming, even if my application is not adding any further items
to the cache. I would expect it to start removing items once the memory is
full, and stop removing items once the memory was no longer full. I don't
see why it would remove some items, and then remove some more a little bit
later, if nothing else has been added between times.


v-alchen

11/6/2008 2:14:00 AM

0

Hi Phil,

This is how the cache supposed to work. Currently the developers cannot
control how to remove the cache. It's by design. The cache items will be
removed if the server memory usage is high. I recommend that you not use
other priorities. Just use Normal.

If you need this feature you can submit a feedback via the connect:
http://connect.microsoft.com/VisualStudi...

We welcome your valuable feedback that can help to improve our products.

If you have further questions please feel free to ask.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#not....

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa9...
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| NNTP-Posting-Date: Wed, 05 Nov 2008 03:33:48 -0600
| From: "Phil" <N/A>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.caching
| References: <YeednXtQO7Ev6Y3UnZ2dnUVZ8sPinZ2d@posted.plusnet>
| Subject: Re: Everything removed from the cache at once
| Date: Wed, 5 Nov 2008 09:33:48 -0000
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
| X-RFC2646: Format=Flowed; Response
| Message-ID: <s-ednULCraDh9YzUnZ2dnUVZ8svinZ2d@posted.plusnet>
| Lines: 31
| X-Usenet-Provider: http://www.gi...
| X-Trace:
sv3-rsXB+fdMJZHHCtAFA+OoQjay1KMay/aCdLjdrvUqL43Uu72hIsBEYZVCTQGX59ADDhOLgrDl
VaPWJAO!WNjKQi4J+E+SHM7zOpLzxt7kuDako5J0jWuV6oy8Pg0+eI4oSTpjV5sy8qnBZTPeD9vm
XIfxTwAT!zK73EjZWXg==
| X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
| X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
| X-Postfilter: 1.3.39
| Bytes: 3110
| X-Original-Bytes: 3046
| Path:
TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTFEEDS01.phx.gbl!newsfeed0
0.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!border1.nntp.dca
..giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.posted.pl
usnet!news.posted.plusnet.POSTED!not-for-mail
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet.caching:546
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.caching
|
| >I am inserting some items into the cache with High priority, some with
| >Normal and some with AboveNormal. I am not setting an expiry time for
any
| >of the items, but when I add a large number of items to the cache they
| >start getting removed with the reason: underused. This is as I would
| >expect.
| > The normal priority items get removed first, which is also as I'd
expect.
| > However, as soon as it decides it needs to start removing items, rather
| > than just removing enough items to reduce the memory used below the
limit,
| > it seems to be removing all of my normal priority items in quick
| > succession.
| > I found the following article which states that the expiration in
dotnet
| > 2.0 was too aggressive, but this was supposedly fixed in SP1, and I
have
| > SP2.
| >
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.as...
kID=165191
| > Is what I am seeing normal behaviour? It still seems too aggressive to
me.
| > Is there any way around this other than setting explicit expiration
times?
|
| I've experimented with changing the priority of some of my cache items,
and
| I'm no longer seeing the whole of my lowest priority items all being
removed
| at the same time, so perhaps it was just to do with the timing of how the
| items were being added. However, I am still seeing some slightly odd
| behaviour. Now what I see is items being removed in several waves. It may
be
| that these correspond to the different parts of my system that are adding
| the items to the cache, but what I don't understand is why these waves of
| removal keep coming, even if my application is not adding any further
items
| to the cache. I would expect it to start removing items once the memory
is
| full, and stop removing items once the memory was no longer full. I don't
| see why it would remove some items, and then remove some more a little
bit
| later, if nothing else has been added between times.
|
|
|

hcurrie

11/6/2008 10:14:00 AM

0

> This is how the cache supposed to work. Currently the developers cannot
> control how to remove the cache. It's by design. The cache items will be
> removed if the server memory usage is high. I recommend that you not use
> other priorities. Just use Normal.

Thanks for the reply.
I don't understand why you say I should only use normal priority. This part
seems to work as expected - when it starts removing items due to low memory,
the lower priority items get removed first. In my particular application,
most of the cached items will be static data, that can stay in memory for
ever, so I am not setting any expiration times. I understand that in low
memory conditions, some items will need to be removed, it's just that when I
monitor which items are being removed, the timing, and choice of items to be
removed seems a little odd. In particular, it seems to be removing more
items than necessary, and once it starts removing items, it seems to
continue to periodically remove more and more items, even when I am not
adding anything further to the cache. Is there an explanation anywhere of
how this actually works?
I am thinking about adding a long sliding expiration time to some of the
items, which in normal operation will hopefully prevent the low memory
condition from occurring very often (at the moment I am deliberately
reducing the memory available to the cache in order to test this).


v-alchen

11/7/2008 5:00:00 AM

0

Hi Phil,

==================================================
I don't understand why you say I should only use normal priority.
==================================================

It seems is the only way to meet your requirement as you don't want to
remove all the items with the Normal priority. When the server is about to
exceed the memory limit it'll begin to drop cache items. Each time about
50% of the cache items will be dropped. If you have specified the priority,
the items with low priority will be dropped first. Say you have 100,000
items with AboveNormal priority and 100,000 items with Normal priority, all
the 100,000 items with Normal priority will be removed the first time the
server meets the memory limit. If then the memory pressure is still too
high, 50,000 items with the AboveNormal priority will be dropped. The
server continues doing this until the memory pressure is low.

Above is the basic policy how the cache items are dropped.

==================================================
I am thinking about adding a long sliding expiration time to some of the
items, which in normal operation will hopefully prevent the low memory
condition from occurring very ofte
==================================================

Setting the expiration time is a good idea and is recommended.

If you have further questions please feel free to ask.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#not....

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa9...
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| NNTP-Posting-Date: Thu, 06 Nov 2008 04:14:02 -0600
| From: "Phil" <N/A>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.caching
| References: <YeednXtQO7Ev6Y3UnZ2dnUVZ8sPinZ2d@posted.plusnet>
<s-ednULCraDh9YzUnZ2dnUVZ8svinZ2d@posted.plusnet>
<$ZqXaV7PJHA.356@TK2MSFTNGHUB02.phx.gbl>
| Subject: Re: Everything removed from the cache at once
| Date: Thu, 6 Nov 2008 10:14:01 -0000
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
| Message-ID: <AoqdnYB6UbH3Xo_UnZ2dnUVZ8v-dnZ2d@posted.plusnet>
| Lines: 24
| X-Usenet-Provider: http://www.gi...
| X-Trace:
sv3-vIKW374URLRw4rrNE8SuWeGpyoQrBY0lYiI2GfEErIDoZFjtbLGceUjf/27pbqWxm7UsakbQ
ZEY4Vcr!hV+JvB4nha/4xX5QkFrhD0HhiLgM33d+d8AXK/JoPj+KVMKh6nEMePJQxnz0a7wq2tm6
p7rv5EjR!UJF/6u57BA==
| X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
| X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
| X-Postfilter: 1.3.39
| Bytes: 2712
| X-Original-Bytes: 2648
| Path:
TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTFEEDS02.phx.gbl!newsfeed0
0.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!border1.nntp.dca
.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.posted.pl
usnet!news.posted.plusnet.POSTED!not-for-mail
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet.caching:549
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.caching
|
| > This is how the cache supposed to work. Currently the developers cannot
| > control how to remove the cache. It's by design. The cache items will be
| > removed if the server memory usage is high. I recommend that you not use
| > other priorities. Just use Normal.
|
| Thanks for the reply.
| I don't understand why you say I should only use normal priority. This
part
| seems to work as expected - when it starts removing items due to low
memory,
| the lower priority items get removed first. In my particular
application,
| most of the cached items will be static data, that can stay in memory for
| ever, so I am not setting any expiration times. I understand that in low
| memory conditions, some items will need to be removed, it's just that
when I
| monitor which items are being removed, the timing, and choice of items to
be
| removed seems a little odd. In particular, it seems to be removing more
| items than necessary, and once it starts removing items, it seems to
| continue to periodically remove more and more items, even when I am not
| adding anything further to the cache. Is there an explanation anywhere of
| how this actually works?
| I am thinking about adding a long sliding expiration time to some of the
| items, which in normal operation will hopefully prevent the low memory
| condition from occurring very often (at the moment I am deliberately
| reducing the memory available to the cache in order to test this).
|
|
|

hcurrie

11/7/2008 5:02:00 PM

0

>
> ==================================================
> I don't understand why you say I should only use normal priority.
> ==================================================
>
> It seems is the only way to meet your requirement as you don't want to
> remove all the items with the Normal priority. When the server is about to
> exceed the memory limit it'll begin to drop cache items. Each time about
> 50% of the cache items will be dropped. If you have specified the
> priority,
> the items with low priority will be dropped first. Say you have 100,000
> items with AboveNormal priority and 100,000 items with Normal priority,
> all
> the 100,000 items with Normal priority will be removed the first time the
> server meets the memory limit. If then the memory pressure is still too
> high, 50,000 items with the AboveNormal priority will be dropped. The
> server continues doing this until the memory pressure is low.

This just confirms to me that it is a good idea to use different priorities.
If I give everything the same priority, I basically have no control over the
order in which things are removed (although presumably the cache will give
preference to items that have not been used often/recently).
I have some items that are easier to regenerate (less processing intensive,
or smaller in size) than others, so I am giving these a lower priority. This
means that the more difficult items to regenerate are less likely to be
removed from the cache.
You are right that I don't want it to remove *all* of the normal priority
items, but I would like it to remove these before starting on the higher
priority ones, and this seems to work OK. From your explanation it seems
that it isn't removing them all, just half of them, but this is still
undesirable.
>
> Above is the basic policy how the cache items are dropped.

OK. Thanks for the explanation. It is a big help to my understanding. I
would never have dreamed that it would decide to immediately drop 50% of the
cache items when it starts to near the limit. I would have thought that it
would try to just drop enough to bring it below the limit. Do you happen to
know if this is just 50% of the number of items, or if it drops a number of
items that take up 50% of the memory used? Also do you know if it is
possible to tweak some of these parameters, it would seem much more sensible
to me to drop say 5% or 10% rather than throwing out half of the items in
one go.
>
> ==================================================
> I am thinking about adding a long sliding expiration time to some of the
> items, which in normal operation will hopefully prevent the low memory
> condition from occurring very ofte
> ==================================================
>
> Setting the expiration time is a good idea and is recommended.

Unfortunately, this will mean that after a certain period of inactivity, the
cache will start removing items unnecessarily that are still valid, and this
will have an affect on the performance later when those items are needed
again. I'll just have to weigh this against the performance problems that
I'll encounter if I allow the cache to fill up and it then suddenly drop
half of the items all in one go.

Thanks for your help.
It is very much appreciated.
Phil.


v-alchen

11/10/2008 2:13:00 AM

0

Hello Phil,

Quote from Phil==================================================
Do you happen to know if this is just 50% of the number of items, or if it
drops a number of
items that take up 50% of the memory used?
==================================================

Each time when the cache need to be dropped about 50% items will be
removed, not the items that take up 50% of the memory used.

Quote from Phil ==================================================
Also do you know if it is possible to tweak some of these parameters, it
would seem much more sensible
to me to drop say 5% or 10% rather than throwing out half of the items in
one go.
==================================================

I understand that you want more control over how and when to drop cache
items. However, as far as I know, currently the developers cannot control
it. What we can do now is to set the priority, dependency and the timeout
and let the internal mechanism to decide when and how to drop cache items.
It's by design.

You can submit a feedback via connect:
http://connect.microsoft.com/VisualStudi...

If lots of customers request this feature we may consider implementing it
in the future release.

If you have further questions please feel free to ask.

Regards,
Allen Chen
Microsoft Online Support


--------------------
| NNTP-Posting-Date: Fri, 07 Nov 2008 11:01:56 -0600
| From: "Phil" <N/A>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.caching
| References: <YeednXtQO7Ev6Y3UnZ2dnUVZ8sPinZ2d@posted.plusnet>
<s-ednULCraDh9YzUnZ2dnUVZ8svinZ2d@posted.plusnet>
<$ZqXaV7PJHA.356@TK2MSFTNGHUB02.phx.gbl>
<AoqdnYB6UbH3Xo_UnZ2dnUVZ8v-dnZ2d@posted.plusnet>
<TX#19rNQJHA.312@TK2MSFTNGHUB02.phx.gbl>
| Subject: Re: Everything removed from the cache at once
| Date: Fri, 7 Nov 2008 17:01:55 -0000
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
| Message-ID: <HaGdnZuw4oIY6YnUnZ2dnUVZ8oidnZ2d@posted.plusnet>
| Lines: 64
| X-Usenet-Provider: http://www.gi...
| X-Trace:
sv3-RnrGTIrtO/7+7M+v2rsU0cgpd3XZi3yO565ff8l/pRFb3t0BfBAYeGbympPd2GVC5ZtS/T/T
Ef+k3qG!lEpiNtozRyjOfaQTLyASbEEidveSq5dASlCtzUjJEPZbIGHrAcl8WBlN+G2C7jP68li5
7/UFrDsU!o3x6xD8GTA==
| X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
| X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
| X-Postfilter: 1.3.39
| Bytes: 4709
| X-Original-Bytes: 4645
| Path:
TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTFEEDS02.phx.gbl!TK2MSFTFE
EDS01.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.gigane
ws.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giga
news.com!nntp.posted.plusnet!news.posted.plusnet.POSTED!not-for-mail
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet.caching:552
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.caching
|
| >
| > ==================================================
| > I don't understand why you say I should only use normal priority.
| > ==================================================
| >
| > It seems is the only way to meet your requirement as you don't want to
| > remove all the items with the Normal priority. When the server is about
to
| > exceed the memory limit it'll begin to drop cache items. Each time about
| > 50% of the cache items will be dropped. If you have specified the
| > priority,
| > the items with low priority will be dropped first. Say you have 100,000
| > items with AboveNormal priority and 100,000 items with Normal priority,
| > all
| > the 100,000 items with Normal priority will be removed the first time
the
| > server meets the memory limit. If then the memory pressure is still too
| > high, 50,000 items with the AboveNormal priority will be dropped. The
| > server continues doing this until the memory pressure is low.
|
| This just confirms to me that it is a good idea to use different
priorities.
| If I give everything the same priority, I basically have no control over
the
| order in which things are removed (although presumably the cache will
give
| preference to items that have not been used often/recently).
| I have some items that are easier to regenerate (less processing
intensive,
| or smaller in size) than others, so I am giving these a lower priority.
This
| means that the more difficult items to regenerate are less likely to be
| removed from the cache.
| You are right that I don't want it to remove *all* of the normal priority
| items, but I would like it to remove these before starting on the higher
| priority ones, and this seems to work OK. From your explanation it seems
| that it isn't removing them all, just half of them, but this is still
| undesirable.
| >
| > Above is the basic policy how the cache items are dropped.
|
| OK. Thanks for the explanation. It is a big help to my understanding. I
| would never have dreamed that it would decide to immediately drop 50% of
the
| cache items when it starts to near the limit. I would have thought that
it
| would try to just drop enough to bring it below the limit. Do you happen
to
| know if this is just 50% of the number of items, or if it drops a number
of
| items that take up 50% of the memory used? Also do you know if it is
| possible to tweak some of these parameters, it would seem much more
sensible
| to me to drop say 5% or 10% rather than throwing out half of the items in
| one go.
| >
| > ==================================================
| > I am thinking about adding a long sliding expiration time to some of the
| > items, which in normal operation will hopefully prevent the low memory
| > condition from occurring very ofte
| > ==================================================
| >
| > Setting the expiration time is a good idea and is recommended.
|
| Unfortunately, this will mean that after a certain period of inactivity,
the
| cache will start removing items unnecessarily that are still valid, and
this
| will have an affect on the performance later when those items are needed
| again. I'll just have to weigh this against the performance problems that
| I'll encounter if I allow the cache to fill up and it then suddenly drop
| half of the items all in one go.
|
| Thanks for your help.
| It is very much appreciated.
| Phil.
|
|
|

hcurrie

11/10/2008 9:19:00 AM

0

> Each time when the cache need to be dropped about 50% items will be
> removed, not the items that take up 50% of the memory used.

OK. That's useful to know. This means that I can add the smaller items, as
lower priority. Then when it decides to begin dropping items, at least it
won't throw away half of the memory in one go.
>

> I understand that you want more control over how and when to drop cache
> items.

Actually I would prefer if it just worked in a more sensible way, without me
having to try to control it :-)

> However, as far as I know, currently the developers cannot control
> it. What we can do now is to set the priority, dependency and the timeout
> and let the internal mechanism to decide when and how to drop cache items.
> It's by design.

OK. It is useful to know how it works internally though, so that I can
predict the effect of changing these parameters. You have been very helpful
in aiding my understanding of this. Thank-you.
>