470,645 Members | 1,203 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,645 developers. It's quick & easy.

Timer question


I need some help on timers. My app is asp.net 1.1 website running in a
shared hosting environment with a third-party service provider. I currently
request and cache 20 - 40 remote RSS feeds. When a user requests the page,
the app first tries to retrieve a feed from cache, if the feed has expired,
it goes off and request the file from the web.

If create a CacheItemRemovedCallback for each item to automatically
re-request an expired cached page, will I clog up the ThreadPool?

Would I be better off using Threading.Timer or
ThreadPool.RegisterWaitForSingleObject?(although I far as I can tell both
methods create wait operations on threadpool threads)

Richard

Sep 19 '05 #1
5 1949
Hi Richard,

Welcome to MSDN newsgroup.
AS for the Timer question you mentionded, here are some of my understanding
and suggestions:

For the ASP.NET's Cache entry's RemoveCallback function, generally they're
called when the underlying background polling thread found an certain cache
item expired, and this background thread is not necessarily a thread pool
thread, of course we don't worry that removecallback function will consume
many thread pool thread. However, since the background polling thread(for
checking cache expireation) is important, we'd recommend that we don't put
two many tasks (long run ) in removecallback handler.

Also, I don't suggest that we use ThreadPool's RegisterWaitForSingleObject
or other methods to do the work since they'll occupy threadpool threads
which is important for serving asp.net requests. In fact, my suggestion
is just let the items expire and rerequest them on the next request from
page, and retrieve them from remote url and cache in the memory cache.
Just like:

//////////
If (Cache[key] == null)
{
//retrieve from remote place and insert into cache
}

return Cache[key];
/////////

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Richard P" <or**@community.nospam>
| Subject: Timer question
| Date: Mon, 19 Sep 2005 19:42:00 +0100
| Lines: 18
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <OC**************@TK2MSFTNGP15.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralplus.com
86.129.136.61
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50240
| X-Tomcat-NG: microsoft.public.dotnet.general
|
|
| I need some help on timers. My app is asp.net 1.1 website running in a
| shared hosting environment with a third-party service provider. I
currently
| request and cache 20 - 40 remote RSS feeds. When a user requests the
page,
| the app first tries to retrieve a feed from cache, if the feed has
expired,
| it goes off and request the file from the web.
|
| If create a CacheItemRemovedCallback for each item to automatically
| re-request an expired cached page, will I clog up the ThreadPool?
|
| Would I be better off using Threading.Timer or
| ThreadPool.RegisterWaitForSingleObject?(although I far as I can tell both
| methods create wait operations on threadpool threads)
|
| Richard
|
|
|
|

Sep 20 '05 #2
Hi Steven,

Thanks for your reply. So from what you say CacheItemRemovedCallback is the
most efficient of the three timer options because wait operations create no
additional load. The CLR automatically polls the cache for expired items and
only starts a threadpool thread when its time to execute the callback.
Threading.Timer and RegisterWaitForSingleObject will each spawn an extra
thread on the thread pool to perform a wait operation and then spawn another
thread to run the callback.

The request triggered method you recommend is what I am currently doing. The
problem is that when throughput is low, the response times can be quite
slow - even though I fire the RSS requests in parallel.

It seems to me therefore that it is ok to create any number (within reason)
of short term or long term CacheItemRemovedCallbacks, because no additional
load is created for the wait operations. The key issue is to avoid
congesting the threadpool with loads of callback operations, particularly if
each operation is long-running and non-CPU intensive, such as when
requesting a remote RSS feed.

Please let me know if I've got this wrong.

thanks

Richard

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:PT**************@TK2MSFTNGXA01.phx.gbl...
Hi Richard,

Welcome to MSDN newsgroup.
AS for the Timer question you mentionded, here are some of my
understanding
and suggestions:

For the ASP.NET's Cache entry's RemoveCallback function, generally they're
called when the underlying background polling thread found an certain
cache
item expired, and this background thread is not necessarily a thread pool
thread, of course we don't worry that removecallback function will consume
many thread pool thread. However, since the background polling thread(for
checking cache expireation) is important, we'd recommend that we don't put
two many tasks (long run ) in removecallback handler.

Also, I don't suggest that we use ThreadPool's RegisterWaitForSingleObject
or other methods to do the work since they'll occupy threadpool threads
which is important for serving asp.net requests. In fact, my suggestion
is just let the items expire and rerequest them on the next request from
page, and retrieve them from remote url and cache in the memory cache.
Just like:

//////////
If (Cache[key] == null)
{
//retrieve from remote place and insert into cache
}

return Cache[key];
/////////

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Richard P" <or**@community.nospam>
| Subject: Timer question
| Date: Mon, 19 Sep 2005 19:42:00 +0100
| Lines: 18
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <OC**************@TK2MSFTNGP15.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralplus.com
86.129.136.61
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50240
| X-Tomcat-NG: microsoft.public.dotnet.general
|
|
| I need some help on timers. My app is asp.net 1.1 website running in a
| shared hosting environment with a third-party service provider. I
currently
| request and cache 20 - 40 remote RSS feeds. When a user requests the
page,
| the app first tries to retrieve a feed from cache, if the feed has
expired,
| it goes off and request the file from the web.
|
| If create a CacheItemRemovedCallback for each item to automatically
| re-request an expired cached page, will I clog up the ThreadPool?
|
| Would I be better off using Threading.Timer or
| ThreadPool.RegisterWaitForSingleObject?(although I far as I can tell
both
| methods create wait operations on threadpool threads)
|
| Richard
|
|
|
|

Sep 20 '05 #3
Hi Richard,

Thanks for your prompt response.
Yes, using RemoveCallBack is ok , however since you're put many longrun
operations in it, I'm not sure whether this has kill your app's throughput.
Also, it seems that the reason you use RemoveCallBack now is just need to
rerequest the in memory RSS(or can I use refresh? I think it's rather
exactly what you do, yes?)

If so, I think you can consider use a separate background thread to do the
work. when adding RSS content retrieved from remote url into application
Cache, you can event not specify a expiration timeout. And create a
background thread in Application_Start time which will refresh the cached
RSSs in the cache once every certain time period. To create such as
background thread, you can just using the System.Threading.Thread to
construct a thread and a global ThreadProc , after start, store the
thread's reference in the applicationStates or be held in a global
variable(static vartiable). Thus, all the RSS retrieving operations is
done in the background thread, totally nothing related to threadpool
thread.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Richard P" <or**@community.nospam>
| References: <OC**************@TK2MSFTNGP15.phx.gbl>
<PT**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Timer question
| Date: Tue, 20 Sep 2005 07:53:24 +0100
| Lines: 115
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <#D**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: host86-129-127-92.range86-129.btcentralplus.com
86.129.127.92
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50273
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Hi Steven,
|
| Thanks for your reply. So from what you say CacheItemRemovedCallback is
the
| most efficient of the three timer options because wait operations create
no
| additional load. The CLR automatically polls the cache for expired items
and
| only starts a threadpool thread when its time to execute the callback.
| Threading.Timer and RegisterWaitForSingleObject will each spawn an extra
| thread on the thread pool to perform a wait operation and then spawn
another
| thread to run the callback.
|
| The request triggered method you recommend is what I am currently doing.
The
| problem is that when throughput is low, the response times can be quite
| slow - even though I fire the RSS requests in parallel.
|
| It seems to me therefore that it is ok to create any number (within
reason)
| of short term or long term CacheItemRemovedCallbacks, because no
additional
| load is created for the wait operations. The key issue is to avoid
| congesting the threadpool with loads of callback operations, particularly
if
| each operation is long-running and non-CPU intensive, such as when
| requesting a remote RSS feed.
|
| Please let me know if I've got this wrong.
|
| thanks
|
| Richard
|
|
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:PT**************@TK2MSFTNGXA01.phx.gbl...
| > Hi Richard,
| >
| > Welcome to MSDN newsgroup.
| > AS for the Timer question you mentionded, here are some of my
| > understanding
| > and suggestions:
| >
| > For the ASP.NET's Cache entry's RemoveCallback function, generally
they're
| > called when the underlying background polling thread found an certain
| > cache
| > item expired, and this background thread is not necessarily a thread
pool
| > thread, of course we don't worry that removecallback function will
consume
| > many thread pool thread. However, since the background polling
thread(for
| > checking cache expireation) is important, we'd recommend that we don't
put
| > two many tasks (long run ) in removecallback handler.
| >
| > Also, I don't suggest that we use ThreadPool's
RegisterWaitForSingleObject
| > or other methods to do the work since they'll occupy threadpool threads
| > which is important for serving asp.net requests. In fact, my
suggestion
| > is just let the items expire and rerequest them on the next request from
| > page, and retrieve them from remote url and cache in the memory cache.
| > Just like:
| >
| > //////////
| > If (Cache[key] == null)
| > {
| > //retrieve from remote place and insert into cache
| > }
| >
| > return Cache[key];
| > /////////
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | From: "Richard P" <or**@community.nospam>
| > | Subject: Timer question
| > | Date: Mon, 19 Sep 2005 19:42:00 +0100
| > | Lines: 18
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <OC**************@TK2MSFTNGP15.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.general
| > | NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralplus.com
| > 86.129.136.61
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50240
| > | X-Tomcat-NG: microsoft.public.dotnet.general
| > |
| > |
| > | I need some help on timers. My app is asp.net 1.1 website running in a
| > | shared hosting environment with a third-party service provider. I
| > currently
| > | request and cache 20 - 40 remote RSS feeds. When a user requests the
| > page,
| > | the app first tries to retrieve a feed from cache, if the feed has
| > expired,
| > | it goes off and request the file from the web.
| > |
| > | If create a CacheItemRemovedCallback for each item to automatically
| > | re-request an expired cached page, will I clog up the ThreadPool?
| > |
| > | Would I be better off using Threading.Timer or
| > | ThreadPool.RegisterWaitForSingleObject?(although I far as I can tell
| > both
| > | methods create wait operations on threadpool threads)
| > |
| > | Richard
| > |
| > |
| > |
| > |
| >
|
|
|

Sep 20 '05 #4
Steven

I'll give that a go. Thanks a lot

Richard
"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:u$**************@TK2MSFTNGXA01.phx.gbl...
Hi Richard,

Thanks for your prompt response.
Yes, using RemoveCallBack is ok , however since you're put many longrun
operations in it, I'm not sure whether this has kill your app's
throughput.
Also, it seems that the reason you use RemoveCallBack now is just need to
rerequest the in memory RSS(or can I use refresh? I think it's rather
exactly what you do, yes?)

If so, I think you can consider use a separate background thread to do the
work. when adding RSS content retrieved from remote url into application
Cache, you can event not specify a expiration timeout. And create a
background thread in Application_Start time which will refresh the cached
RSSs in the cache once every certain time period. To create such as
background thread, you can just using the System.Threading.Thread to
construct a thread and a global ThreadProc , after start, store the
thread's reference in the applicationStates or be held in a global
variable(static vartiable). Thus, all the RSS retrieving operations is
done in the background thread, totally nothing related to threadpool
thread.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Richard P" <or**@community.nospam>
| References: <OC**************@TK2MSFTNGP15.phx.gbl>
<PT**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Timer question
| Date: Tue, 20 Sep 2005 07:53:24 +0100
| Lines: 115
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <#D**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: host86-129-127-92.range86-129.btcentralplus.com
86.129.127.92
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50273
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Hi Steven,
|
| Thanks for your reply. So from what you say CacheItemRemovedCallback is
the
| most efficient of the three timer options because wait operations create
no
| additional load. The CLR automatically polls the cache for expired items
and
| only starts a threadpool thread when its time to execute the callback.
| Threading.Timer and RegisterWaitForSingleObject will each spawn an extra
| thread on the thread pool to perform a wait operation and then spawn
another
| thread to run the callback.
|
| The request triggered method you recommend is what I am currently doing.
The
| problem is that when throughput is low, the response times can be quite
| slow - even though I fire the RSS requests in parallel.
|
| It seems to me therefore that it is ok to create any number (within
reason)
| of short term or long term CacheItemRemovedCallbacks, because no
additional
| load is created for the wait operations. The key issue is to avoid
| congesting the threadpool with loads of callback operations,
particularly
if
| each operation is long-running and non-CPU intensive, such as when
| requesting a remote RSS feed.
|
| Please let me know if I've got this wrong.
|
| thanks
|
| Richard
|
|
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:PT**************@TK2MSFTNGXA01.phx.gbl...
| > Hi Richard,
| >
| > Welcome to MSDN newsgroup.
| > AS for the Timer question you mentionded, here are some of my
| > understanding
| > and suggestions:
| >
| > For the ASP.NET's Cache entry's RemoveCallback function, generally
they're
| > called when the underlying background polling thread found an certain
| > cache
| > item expired, and this background thread is not necessarily a thread
pool
| > thread, of course we don't worry that removecallback function will
consume
| > many thread pool thread. However, since the background polling
thread(for
| > checking cache expireation) is important, we'd recommend that we don't
put
| > two many tasks (long run ) in removecallback handler.
| >
| > Also, I don't suggest that we use ThreadPool's
RegisterWaitForSingleObject
| > or other methods to do the work since they'll occupy threadpool
threads
| > which is important for serving asp.net requests. In fact, my
suggestion
| > is just let the items expire and rerequest them on the next request
from
| > page, and retrieve them from remote url and cache in the memory cache.
| > Just like:
| >
| > //////////
| > If (Cache[key] == null)
| > {
| > //retrieve from remote place and insert into cache
| > }
| >
| > return Cache[key];
| > /////////
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | From: "Richard P" <or**@community.nospam>
| > | Subject: Timer question
| > | Date: Mon, 19 Sep 2005 19:42:00 +0100
| > | Lines: 18
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <OC**************@TK2MSFTNGP15.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.general
| > | NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralplus.com
| > 86.129.136.61
| > | Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50240
| > | X-Tomcat-NG: microsoft.public.dotnet.general
| > |
| > |
| > | I need some help on timers. My app is asp.net 1.1 website running in
a
| > | shared hosting environment with a third-party service provider. I
| > currently
| > | request and cache 20 - 40 remote RSS feeds. When a user requests the
| > page,
| > | the app first tries to retrieve a feed from cache, if the feed has
| > expired,
| > | it goes off and request the file from the web.
| > |
| > | If create a CacheItemRemovedCallback for each item to automatically
| > | re-request an expired cached page, will I clog up the ThreadPool?
| > |
| > | Would I be better off using Threading.Timer or
| > | ThreadPool.RegisterWaitForSingleObject?(although I far as I can tell
| > both
| > | methods create wait operations on threadpool threads)
| > |
| > | Richard
| > |
| > |
| > |
| > |
| >
|
|
|

Sep 21 '05 #5
You're welcome Richard,

Please feel free to post here if there're anything else we can help.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Richard P" <or**@community.nospam>
| References: <OC**************@TK2MSFTNGP15.phx.gbl>
<PT**************@TK2MSFTNGXA01.phx.gbl>
<#D**************@TK2MSFTNGP12.phx.gbl>
<u$**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Timer question
| Date: Wed, 21 Sep 2005 11:32:10 +0100
| Lines: 200
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <u7**************@TK2MSFTNGP15.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: host86-129-143-74.range86-129.btcentralplus.com
86.129.143.74
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50364
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Steven
|
| I'll give that a go. Thanks a lot
|
| Richard
|
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:u$**************@TK2MSFTNGXA01.phx.gbl...
| > Hi Richard,
| >
| > Thanks for your prompt response.
| > Yes, using RemoveCallBack is ok , however since you're put many longrun
| > operations in it, I'm not sure whether this has kill your app's
| > throughput.
| > Also, it seems that the reason you use RemoveCallBack now is just need
to
| > rerequest the in memory RSS(or can I use refresh? I think it's rather
| > exactly what you do, yes?)
| >
| > If so, I think you can consider use a separate background thread to do
the
| > work. when adding RSS content retrieved from remote url into application
| > Cache, you can event not specify a expiration timeout. And create a
| > background thread in Application_Start time which will refresh the
cached
| > RSSs in the cache once every certain time period. To create such as
| > background thread, you can just using the System.Threading.Thread to
| > construct a thread and a global ThreadProc , after start, store the
| > thread's reference in the applicationStates or be held in a global
| > variable(static vartiable). Thus, all the RSS retrieving operations is
| > done in the background thread, totally nothing related to threadpool
| > thread.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| > --------------------
| > | From: "Richard P" <or**@community.nospam>
| > | References: <OC**************@TK2MSFTNGP15.phx.gbl>
| > <PT**************@TK2MSFTNGXA01.phx.gbl>
| > | Subject: Re: Timer question
| > | Date: Tue, 20 Sep 2005 07:53:24 +0100
| > | Lines: 115
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | Message-ID: <#D**************@TK2MSFTNGP12.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.general
| > | NNTP-Posting-Host: host86-129-127-92.range86-129.btcentralplus.com
| > 86.129.127.92
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50273
| > | X-Tomcat-NG: microsoft.public.dotnet.general
| > |
| > | Hi Steven,
| > |
| > | Thanks for your reply. So from what you say CacheItemRemovedCallback
is
| > the
| > | most efficient of the three timer options because wait operations
create
| > no
| > | additional load. The CLR automatically polls the cache for expired
items
| > and
| > | only starts a threadpool thread when its time to execute the callback.
| > | Threading.Timer and RegisterWaitForSingleObject will each spawn an
extra
| > | thread on the thread pool to perform a wait operation and then spawn
| > another
| > | thread to run the callback.
| > |
| > | The request triggered method you recommend is what I am currently
doing.
| > The
| > | problem is that when throughput is low, the response times can be
quite
| > | slow - even though I fire the RSS requests in parallel.
| > |
| > | It seems to me therefore that it is ok to create any number (within
| > reason)
| > | of short term or long term CacheItemRemovedCallbacks, because no
| > additional
| > | load is created for the wait operations. The key issue is to avoid
| > | congesting the threadpool with loads of callback operations,
| > particularly
| > if
| > | each operation is long-running and non-CPU intensive, such as when
| > | requesting a remote RSS feed.
| > |
| > | Please let me know if I've got this wrong.
| > |
| > | thanks
| > |
| > | Richard
| > |
| > |
| > |
| > | "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| > | news:PT**************@TK2MSFTNGXA01.phx.gbl...
| > | > Hi Richard,
| > | >
| > | > Welcome to MSDN newsgroup.
| > | > AS for the Timer question you mentionded, here are some of my
| > | > understanding
| > | > and suggestions:
| > | >
| > | > For the ASP.NET's Cache entry's RemoveCallback function, generally
| > they're
| > | > called when the underlying background polling thread found an
certain
| > | > cache
| > | > item expired, and this background thread is not necessarily a thread
| > pool
| > | > thread, of course we don't worry that removecallback function will
| > consume
| > | > many thread pool thread. However, since the background polling
| > thread(for
| > | > checking cache expireation) is important, we'd recommend that we
don't
| > put
| > | > two many tasks (long run ) in removecallback handler.
| > | >
| > | > Also, I don't suggest that we use ThreadPool's
| > RegisterWaitForSingleObject
| > | > or other methods to do the work since they'll occupy threadpool
| > threads
| > | > which is important for serving asp.net requests. In fact, my
| > suggestion
| > | > is just let the items expire and rerequest them on the next request
| > from
| > | > page, and retrieve them from remote url and cache in the memory
cache.
| > | > Just like:
| > | >
| > | > //////////
| > | > If (Cache[key] == null)
| > | > {
| > | > //retrieve from remote place and insert into cache
| > | > }
| > | >
| > | > return Cache[key];
| > | > /////////
| > | >
| > | > Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure! www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | > --------------------
| > | > | From: "Richard P" <or**@community.nospam>
| > | > | Subject: Timer question
| > | > | Date: Mon, 19 Sep 2005 19:42:00 +0100
| > | > | Lines: 18
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | > | X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | > | X-RFC2646: Format=Flowed; Original
| > | > | Message-ID: <OC**************@TK2MSFTNGP15.phx.gbl>
| > | > | Newsgroups: microsoft.public.dotnet.general
| > | > | NNTP-Posting-Host: host86-129-136-61.range86-129.btcentralplus.com
| > | > 86.129.136.61
| > | > | Path:
| > TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| > | > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50240
| > | > | X-Tomcat-NG: microsoft.public.dotnet.general
| > | > |
| > | > |
| > | > | I need some help on timers. My app is asp.net 1.1 website running
in
| > a
| > | > | shared hosting environment with a third-party service provider. I
| > | > currently
| > | > | request and cache 20 - 40 remote RSS feeds. When a user requests
the
| > | > page,
| > | > | the app first tries to retrieve a feed from cache, if the feed
has
| > | > expired,
| > | > | it goes off and request the file from the web.
| > | > |
| > | > | If create a CacheItemRemovedCallback for each item to
automatically
| > | > | re-request an expired cached page, will I clog up the ThreadPool?
| > | > |
| > | > | Would I be better off using Threading.Timer or
| > | > | ThreadPool.RegisterWaitForSingleObject?(although I far as I can
tell
| > | > both
| > | > | methods create wait operations on threadpool threads)
| > | > |
| > | > | Richard
| > | > |
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|

Sep 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by brian | last post: by
4 posts views Thread by Richard P | last post: by
12 posts views Thread by Gina_Marano | last post: by
11 posts views Thread by Hotrod2000 | last post: by
11 posts views Thread by Anil Gupte/iCinema.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.