Re: Timer question



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" <orix@xxxxxxxxxxxxxxxx>
| References: <OCX1UnUvFHA.3932@xxxxxxxxxxxxxxxxxxxx>
<PTspkkZvFHA.3020@xxxxxxxxxxxxxxxxxxxxx>
| 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: <#DdcBAbvFHA.1028@xxxxxxxxxxxxxxxxxxxx>
| 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!TK2MSFTNGP12.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]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
| news:PTspkkZvFHA.3020@xxxxxxxxxxxxxxxxxxxxxxxx
| > 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" <orix@xxxxxxxxxxxxxxxx>
| > | 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: <OCX1UnUvFHA.3932@xxxxxxxxxxxxxxxxxxxx>
| > | 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!TK2MSFTNGP15.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
| > |
| > |
| > |
| > |
| >
|
|
|

.



Relevant Pages

  • Re: Timer question
    ... > Hi Richard, ... it seems that the reason you use RemoveCallBack now is just need to ... I think you can consider use a separate background thread to do the ... > Cache, you can event not specify a expiration timeout. ...
    (microsoft.public.dotnet.general)
  • Re: Access Cache from Another Thread?
    ... The cache isn't tied to a specific request or response so I don't see any ... problem accessing the cache from a background thread. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: [PATCH] speed up SATA
    ... The kicker when handling any request larger than the on-disk cache ... insufficient buffer for the entire host request), ...
    (Linux-Kernel)
  • Re: IIS 6.0 Not Caching Images
    ... There is a known bug where if a 204/304 is fulfilled from the kernel ... regardless if it is fulfilled from the kernel response cache or not. ... request is cached in kernel mode (in addition to using WFetch to make the ... server or not -- you need perfmon to determine. ...
    (microsoft.public.inetserver.iis)
  • Re: IIS 6.0 Not Caching Images
    ... which the client would reuse on subsequent requests to the ... IIS is not sending the ETag header on the request correctly. ... > coming out of the kernel mode cache or not. ... There is a known bug where if a 204/304 is fulfilled from the kernel ...
    (microsoft.public.inetserver.iis)

Quantcast