Windows Vista Forums

Custom Http Handler Factory and Possible Concurrency Issues on Application Start
  1. #1


    Jordan S. Guest

    Custom Http Handler Factory and Possible Concurrency Issues on Application Start

    Using .NET 3.5...

    1. Will ASP.NET guarantee that no more than ONE instance of a custom HTTP
    handler factory (class implementing IHttpHandlerFactory) is ever created in
    an ASP.NET application?

    2. Assuming the answer to #1 is "yes - never more than one instance" (I hope
    that's true), then does ASP.NET automatically take care of concurrency with
    respect to accessing that one instance?



    My situation is that I have written a custom handler factory. In it's
    constructor, I initialize a couple of class-scoped collections that are
    subsequently used by logic called by the factory's GetHandler() method.

    I am concerned that when the app is restarted (for whatever reason), and if
    the site is really busy, multiple requests could arrive simultaneously (or
    close enough to cause concurrency problems) while my custom factory is
    initializing itself. Is there anything I can or should do to avoid race
    conditions or other such concurrency problems - or will ASP.NET queue the
    requests until the factory is ready to serve all of the queued requests?

    I have observed that my custom factory is not instantiated until the first
    request arrives (after an IIS or application restart)... thus my concern -
    what if 100 requests arrive all at once and the factory isn't yet
    instantiated and initialized?

    Thanks.




      My System SpecsSystem Spec

  2. #2


    Juan T. Llibre Guest

    Re: Custom Http Handler Factory and Possible Concurrency Issues on Application Start

    re:
    !> what if 100 requests arrive all at once

    You mean if 100 requests arrive within the same 10,000th of one second ?
    I'd find it very difficult to see that happening.



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Jordan S." <A@xxxxxx> wrote in message news:etdJ7JMxIHA.3968@xxxxxx

    > Using .NET 3.5...
    >
    > 1. Will ASP.NET guarantee that no more than ONE instance of a custom HTTP handler factory (class implementing
    > IHttpHandlerFactory) is ever created in an ASP.NET application?
    >
    > 2. Assuming the answer to #1 is "yes - never more than one instance" (I hope that's true), then does ASP.NET
    > automatically take care of concurrency with respect to accessing that one instance?
    >
    > My situation is that I have written a custom handler factory. In it's constructor, I initialize a couple of
    > class-scoped collections that are subsequently used by logic called by the factory's GetHandler() method.
    >
    > I am concerned that when the app is restarted (for whatever reason), and if the site is really busy, multiple requests
    > could arrive simultaneously (or close enough to cause concurrency problems) while my custom factory is initializing
    > itself. Is there anything I can or should do to avoid race conditions or other such concurrency problems - or will
    > ASP.NET queue the requests until the factory is ready to serve all of the queued requests?
    >
    > I have observed that my custom factory is not instantiated until the first request arrives (after an IIS or
    > application restart)... thus my concern - what if 100 requests arrive all at once and the factory isn't yet
    > instantiated and initialized?
    >
    > Thanks.
    >
    >


      My System SpecsSystem Spec

  3. #3


    Jordan S. Guest

    Re: Custom Http Handler Factory and Possible Concurrency Issues on Application Start

    The factory, upon startup (it being instantiated) hits the database. That's
    a quick hit, but still it could be a full 1 second for the factory to fully
    initialize itself.
    It's reasonable to expect multiple requests to arrive within that one
    second. Will those requests queue up nicely and wait for the factory to
    initialize? Or would multiple instances of the factory be created?

    -Jordan


    "Juan T. Llibre" <nomailreplies@xxxxxx> wrote in message
    news:e5riLcMxIHA.5520@xxxxxx

    > re:
    > !> what if 100 requests arrive all at once
    >
    > You mean if 100 requests arrive within the same 10,000th of one second ?
    > I'd find it very difficult to see that happening.
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ======================================
    > "Jordan S." <A@xxxxxx> wrote in message
    > news:etdJ7JMxIHA.3968@xxxxxx

    >> Using .NET 3.5...
    >>
    >> 1. Will ASP.NET guarantee that no more than ONE instance of a custom HTTP
    >> handler factory (class implementing IHttpHandlerFactory) is ever created
    >> in an ASP.NET application?
    >>
    >> 2. Assuming the answer to #1 is "yes - never more than one instance" (I
    >> hope that's true), then does ASP.NET automatically take care of
    >> concurrency with respect to accessing that one instance?
    >>
    >> My situation is that I have written a custom handler factory. In it's
    >> constructor, I initialize a couple of class-scoped collections that are
    >> subsequently used by logic called by the factory's GetHandler() method.
    >>
    >> I am concerned that when the app is restarted (for whatever reason), and
    >> if the site is really busy, multiple requests could arrive simultaneously
    >> (or close enough to cause concurrency problems) while my custom factory
    >> is initializing itself. Is there anything I can or should do to avoid
    >> race conditions or other such concurrency problems - or will ASP.NET
    >> queue the requests until the factory is ready to serve all of the queued
    >> requests?
    >>
    >> I have observed that my custom factory is not instantiated until the
    >> first request arrives (after an IIS or application restart)... thus my
    >> concern - what if 100 requests arrive all at once and the factory isn't
    >> yet instantiated and initialized?
    >>
    >> Thanks.
    >>
    >>
    >
    >
    >



      My System SpecsSystem Spec

  4. #4


    bruce barker Guest

    RE: Custom Http Handler Factory and Possible Concurrency Issues on App

    1. no. there is one instance per httpapplication instance. the actually
    loading of the code is serialized. httpapplication are keep in pool

    -- bruce (sqlwork.com)


    "Jordan S." wrote:

    > Using .NET 3.5...
    >
    > 1. Will ASP.NET guarantee that no more than ONE instance of a custom HTTP
    > handler factory (class implementing IHttpHandlerFactory) is ever created in
    > an ASP.NET application?
    >
    > 2. Assuming the answer to #1 is "yes - never more than one instance" (I hope
    > that's true), then does ASP.NET automatically take care of concurrency with
    > respect to accessing that one instance?
    >
    > My situation is that I have written a custom handler factory. In it's
    > constructor, I initialize a couple of class-scoped collections that are
    > subsequently used by logic called by the factory's GetHandler() method.
    >
    > I am concerned that when the app is restarted (for whatever reason), and if
    > the site is really busy, multiple requests could arrive simultaneously (or
    > close enough to cause concurrency problems) while my custom factory is
    > initializing itself. Is there anything I can or should do to avoid race
    > conditions or other such concurrency problems - or will ASP.NET queue the
    > requests until the factory is ready to serve all of the queued requests?
    >
    > I have observed that my custom factory is not instantiated until the first
    > request arrives (after an IIS or application restart)... thus my concern -
    > what if 100 requests arrive all at once and the factory isn't yet
    > instantiated and initialized?
    >
    > Thanks.
    >
    >
    >
    >

      My System SpecsSystem Spec

  5. #5


    Juan T. Llibre Guest

    Re: Custom Http Handler Factory and Possible Concurrency Issues on Application Start

    re:
    !> It's reasonable to expect multiple requests to arrive within that one second.

    Sure, but the requests for code-loading are serialized.



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Jordan S." <A@xxxxxx> wrote in message news:e5UrlgMxIHA.6096@xxxxxx

    > The factory, upon startup (it being instantiated) hits the database. That's a quick hit, but still it could be a full
    > 1 second for the factory to fully initialize itself.
    > It's reasonable to expect multiple requests to arrive within that one second. Will those requests queue up nicely and
    > wait for the factory to initialize? Or would multiple instances of the factory be created?
    >
    > -Jordan
    >
    >
    > "Juan T. Llibre" <nomailreplies@xxxxxx> wrote in message news:e5riLcMxIHA.5520@xxxxxx

    >> re:
    >> !> what if 100 requests arrive all at once
    >>
    >> You mean if 100 requests arrive within the same 10,000th of one second ?
    >> I'd find it very difficult to see that happening.
    >>
    >>
    >>
    >> Juan T. Llibre, asp.net MVP
    >> asp.net faq : http://asp.net.do/faq/
    >> foros de asp.net, en español : http://asp.net.do/foros/
    >> ======================================
    >> "Jordan S." <A@xxxxxx> wrote in message news:etdJ7JMxIHA.3968@xxxxxx

    >>> Using .NET 3.5...
    >>>
    >>> 1. Will ASP.NET guarantee that no more than ONE instance of a custom HTTP handler factory (class implementing
    >>> IHttpHandlerFactory) is ever created in an ASP.NET application?
    >>>
    >>> 2. Assuming the answer to #1 is "yes - never more than one instance" (I hope that's true), then does ASP.NET
    >>> automatically take care of concurrency with respect to accessing that one instance?
    >>>
    >>> My situation is that I have written a custom handler factory. In it's constructor, I initialize a couple of
    >>> class-scoped collections that are subsequently used by logic called by the factory's GetHandler() method.
    >>>
    >>> I am concerned that when the app is restarted (for whatever reason), and if the site is really busy, multiple
    >>> requests could arrive simultaneously (or close enough to cause concurrency problems) while my custom factory is
    >>> initializing itself. Is there anything I can or should do to avoid race conditions or other such concurrency
    >>> problems - or will ASP.NET queue the requests until the factory is ready to serve all of the queued requests?
    >>>
    >>> I have observed that my custom factory is not instantiated until the first request arrives (after an IIS or
    >>> application restart)... thus my concern - what if 100 requests arrive all at once and the factory isn't yet
    >>> instantiated and initialized?
    >>>
    >>> Thanks.
    >>>
    >>>
    >>
    >>
    >>
    >
    >
    >


      My System SpecsSystem Spec

  6. #6


    Jordan S. Guest

    Re: Custom Http Handler Factory and Possible Concurrency Issues on Application Start

    Thanks Juan.


    "Juan T. Llibre" <nomailreplies@xxxxxx> wrote in message
    news:eXcST9MxIHA.5288@xxxxxx

    > re:
    > !> It's reasonable to expect multiple requests to arrive within that one
    > second.
    >
    > Sure, but the requests for code-loading are serialized.
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ======================================
    > "Jordan S." <A@xxxxxx> wrote in message
    > news:e5UrlgMxIHA.6096@xxxxxx

    >> The factory, upon startup (it being instantiated) hits the database.
    >> That's a quick hit, but still it could be a full 1 second for the factory
    >> to fully initialize itself.
    >> It's reasonable to expect multiple requests to arrive within that one
    >> second. Will those requests queue up nicely and wait for the factory to
    >> initialize? Or would multiple instances of the factory be created?
    >>
    >> -Jordan
    >>
    >>
    >> "Juan T. Llibre" <nomailreplies@xxxxxx> wrote in message
    >> news:e5riLcMxIHA.5520@xxxxxx

    >>> re:
    >>> !> what if 100 requests arrive all at once
    >>>
    >>> You mean if 100 requests arrive within the same 10,000th of one second ?
    >>> I'd find it very difficult to see that happening.
    >>>
    >>>
    >>>
    >>> Juan T. Llibre, asp.net MVP
    >>> asp.net faq : http://asp.net.do/faq/
    >>> foros de asp.net, en español : http://asp.net.do/foros/
    >>> ======================================
    >>> "Jordan S." <A@xxxxxx> wrote in message
    >>> news:etdJ7JMxIHA.3968@xxxxxx
    >>>> Using .NET 3.5...
    >>>>
    >>>> 1. Will ASP.NET guarantee that no more than ONE instance of a custom
    >>>> HTTP handler factory (class implementing IHttpHandlerFactory) is ever
    >>>> created in an ASP.NET application?
    >>>>
    >>>> 2. Assuming the answer to #1 is "yes - never more than one instance" (I
    >>>> hope that's true), then does ASP.NET automatically take care of
    >>>> concurrency with respect to accessing that one instance?
    >>>>
    >>>> My situation is that I have written a custom handler factory. In it's
    >>>> constructor, I initialize a couple of class-scoped collections that are
    >>>> subsequently used by logic called by the factory's GetHandler() method.
    >>>>
    >>>> I am concerned that when the app is restarted (for whatever reason),
    >>>> and if the site is really busy, multiple requests could arrive
    >>>> simultaneously (or close enough to cause concurrency problems) while my
    >>>> custom factory is initializing itself. Is there anything I can or
    >>>> should do to avoid race conditions or other such concurrency problems -
    >>>> or will ASP.NET queue the requests until the factory is ready to serve
    >>>> all of the queued requests?
    >>>>
    >>>> I have observed that my custom factory is not instantiated until the
    >>>> first request arrives (after an IIS or application restart)... thus my
    >>>> concern - what if 100 requests arrive all at once and the factory isn't
    >>>> yet instantiated and initialized?
    >>>>
    >>>> Thanks.
    >>>>
    >>>>
    >>>
    >>>
    >>>
    >>
    >>
    >>
    >
    >
    >



      My System SpecsSystem Spec

  7. #7


    Jordan S. Guest

    Re: Custom Http Handler Factory and Possible Concurrency Issues on App

    Thanks Bruce.


    "bruce barker" <brucebarker@xxxxxx> wrote in message
    news:2E899BBE-4751-4BD3-B8A8-ED86BDA8C240@xxxxxx

    > 1. no. there is one instance per httpapplication instance. the actually
    > loading of the code is serialized. httpapplication are keep in pool
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "Jordan S." wrote:
    >

    >> Using .NET 3.5...
    >>
    >> 1. Will ASP.NET guarantee that no more than ONE instance of a custom HTTP
    >> handler factory (class implementing IHttpHandlerFactory) is ever created
    >> in
    >> an ASP.NET application?
    >>
    >> 2. Assuming the answer to #1 is "yes - never more than one instance" (I
    >> hope
    >> that's true), then does ASP.NET automatically take care of concurrency
    >> with
    >> respect to accessing that one instance?
    >>
    >> My situation is that I have written a custom handler factory. In it's
    >> constructor, I initialize a couple of class-scoped collections that are
    >> subsequently used by logic called by the factory's GetHandler() method.
    >>
    >> I am concerned that when the app is restarted (for whatever reason), and
    >> if
    >> the site is really busy, multiple requests could arrive simultaneously
    >> (or
    >> close enough to cause concurrency problems) while my custom factory is
    >> initializing itself. Is there anything I can or should do to avoid race
    >> conditions or other such concurrency problems - or will ASP.NET queue the
    >> requests until the factory is ready to serve all of the queued requests?
    >>
    >> I have observed that my custom factory is not instantiated until the
    >> first
    >> request arrives (after an IIS or application restart)... thus my
    >> concern -
    >> what if 100 requests arrive all at once and the factory isn't yet
    >> instantiated and initialized?
    >>
    >> Thanks.
    >>
    >>
    >>
    >>
    >



      My System SpecsSystem Spec

Custom Http Handler Factory and Possible Concurrency Issues on Application Start problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [ANNOUNCE] Issues with http://blogs.msdn.com/powershell Thomas Lee PowerShell 0 02 Dec 2008
Handling param statement in custom host application paul PowerShell 4 07 Aug 2008
Setting Output Cacheability Programmatically is Not Working - In Custom Handler Jordan S. .NET General 0 22 May 2008
Handling Application.Start via Custom HTTP Module Cramer .NET General 0 23 Apr 2008
Unable to associate file types to custom application Steinar Haugen Vista file management 2 18 Apr 2007