473,806 Members | 2,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 IHttpHandlerFac tory) 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.

Jun 27 '08 #1
6 1693
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@B.comwrote in message news:et******** ******@TK2MSFTN GP04.phx.gbl...
Using .NET 3.5...

1. Will ASP.NET guarantee that no more than ONE instance of a custom HTTP handler factory (class implementing
IHttpHandlerFac tory) 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.


Jun 27 '08 #2
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" <no***********@ nowhere.comwrot e in message
news:e5******** ******@TK2MSFTN GP06.phx.gbl...
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@B.comwrote in message
news:et******** ******@TK2MSFTN GP04.phx.gbl...
>Using .NET 3.5...

1. Will ASP.NET guarantee that no more than ONE instance of a custom HTTP
handler factory (class implementing IHttpHandlerFac tory) 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.





Jun 27 '08 #3
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 IHttpHandlerFac tory) 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.

Jun 27 '08 #4
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@B.comwrote in message news:e5******** ******@TK2MSFTN GP06.phx.gbl...
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" <no***********@ nowhere.comwrot e in message news:e5******** ******@TK2MSFTN GP06.phx.gbl...
>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@B.comwrote in message news:et******** ******@TK2MSFTN GP04.phx.gbl...
>>Using .NET 3.5...

1. Will ASP.NET guarantee that no more than ONE instance of a custom HTTP handler factory (class implementing
IHttpHandlerF actory) 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
automatical ly 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
initializin g 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
instantiate d and initialized?

Thanks.






Jun 27 '08 #5
Thanks Juan.
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:eX******** ******@TK2MSFTN GP06.phx.gbl...
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@B.comwrote in message
news:e5******** ******@TK2MSFTN GP06.phx.gbl...
>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" <no***********@ nowhere.comwrot e in message
news:e5******* *******@TK2MSFT NGP06.phx.gbl.. .
>>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@B.comwrote in message
news:et****** ********@TK2MSF TNGP04.phx.gbl. ..
Using .NET 3.5...

1. Will ASP.NET guarantee that no more than ONE instance of a custom
HTTP handler factory (class implementing IHttpHandlerFac tory) 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
concurrenc y with respect to accessing that one instance?

My situation is that I have written a custom handler factory. In it's
constructo r, I initialize a couple of class-scoped collections that are
subsequent ly 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
simultaneous ly (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.








Jun 27 '08 #6
Thanks Bruce.
"bruce barker" <br*********@di scussions.micro soft.comwrote in message
news:2E******** *************** ***********@mic rosoft.com...
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 IHttpHandlerFac tory) 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.



Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5046
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for my GridView/SqlDataSource combinations. I typically select from a view and update the corresponding...
10
3282
by: Jon | last post by:
I'm investiging multi-threaded GUI applications; specifically the technique used to ensure that controls are only modified under the correct thread. The standard technique is to use if(InvokeRequired == true) ... BeginInvoke(...) ... I have some code that ensures that an event fired from a worker (non-GUI) thread will use the appropriate BeginInvoke call for synchronisation. By offloading the synchronisation onto the worker thread the...
3
7171
by: weston | last post by:
I'm making a foray into trying to create custom vertical scrollbars and sliders, and thought I had a basic idea how to do it, but seem to be having some trouble with the implementation. My thinking was: (a) create a div for the slider / scroll nub to move within (b) attach event handlers which, onmousedown, specify the slider/nub is moveable, and onmouseup, specify it's not (c) attach an event handler to the contaning div which,...
7
10831
by: =?Utf-8?B?RG91Z2llIEJyb3du?= | last post by:
Hi I've written custom configuration section (inherits from System.Configuration.ConfigurationSection) to simplify the contents of the config file and to make life easier when accessing them in code. The configuration section is contained within the exe (it's a simple test case!) and everything works well debugging within the IDE or if the application is deployed on a drive or share that has been granted full trust. For the share the...
2
5117
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application = Windows Forms class B = a singleton hosted within A. B is responsible for dynamically loading classes X, Y, and Z.
5
1855
by: John | last post by:
Hi I have developed the following logic to handle db concurrency violations. I just wonder if someone can tell me if it is correct or if I need a different approach.Would love to know how pros handle it. Thanks Regards
0
1548
by: Cramer | last post by:
Using ASP.NET 3.5: Can a custom HTTP Module be used to register for the Application_Start event? Or _must_ I use Global.asax to work with Application.Start? I understand that I can use a custom HTTP Module to register for other pipeline events (like Application.BeginRequest), but I was told that the only place that I can set up an event handler for Application.Start is in Global.asax. My preference would be to register an HTTP Module...
0
1387
by: Jordan S. | last post by:
Using .NET 3.5... in a "plain old" .aspx page I have the following code in the Init event: this.Context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60)); this.Context.Response.Cache.SetCacheability(HttpCacheability.Public); this.Context.Response.Cache.SetValidUntilExpires(false); It works great. Testing shows that the page is cached for 60 seconds as expected. Specifically, I insert the current date/time into the Response...
6
1058
by: Jordan S. | last post by:
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?
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.