473,382 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

More than one instance of HttpApplication present. Why?

Hi!

A while ago, I noticed that there are usually two instances of
HttpApplication created within IIS (observed on WinXPPro). Why is that?
Especially, since Application_Start handler is called on only one
instance (the one that was created first).

Anyone has an idea?

How to test:
I created my own class, which extended HttpApplication. In
Application_Start/End handlers I added some logging code and observed
the situation. The code is below (sorry for the messy code. Can one
format it somehow?).

Regards,
Miha

using System;
using System.Web;

[assembly:log4net.Config.XmlConfigurator()]
public class MyHttpApp : HttpApplication {
private static readonly log4net.ILog log =
log4net.LogManager.GetLogger(System.Reflection.Met hodBase.GetCurrentMethod().DeclaringType);

public MyHttpApp() {
log.InfoFormat("MyHttpApp constructor called! - Hashcode = {0}",
this.GetHashCode());
}
protected void Application_Start(Object sender, EventArgs e)
{
log.InfoFormat("MyHttpApp->Application_Start called! - Hashcode =
{0}", this.GetHashCode());
}

protected void Application_End(Object sender, EventArgs e)
{
log.Info("Application ending...");
}
}

Nov 19 '05 #1
5 1517
On 8 Nov 2005 03:33:05 -0800, mi***********@gmail.com wrote:
Hi!

A while ago, I noticed that there are usually two instances of
HttpApplication created within IIS (observed on WinXPPro). Why is that?
Especially, since Application_Start handler is called on only one
instance (the one that was created first).


I think the class name is misleading, personally.
http://odetocode.com/Articles/89.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 19 '05 #2
requests are handled by a HttpApplication instance. there is a pool of
these, so if you have simultaneous requests there will be more than one.
this is done so that there is a place to hold instance data during a
request.

the start/end handlers are only called once as that's the design. the
constructor/destructor is called on every instance create/destory.

-- bruce (sqlwork.com)

<mi***********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi!

A while ago, I noticed that there are usually two instances of
HttpApplication created within IIS (observed on WinXPPro). Why is that?
Especially, since Application_Start handler is called on only one
instance (the one that was created first).

Anyone has an idea?

How to test:
I created my own class, which extended HttpApplication. In
Application_Start/End handlers I added some logging code and observed
the situation. The code is below (sorry for the messy code. Can one
format it somehow?).

Regards,
Miha

using System;
using System.Web;

[assembly:log4net.Config.XmlConfigurator()]
public class MyHttpApp : HttpApplication {
private static readonly log4net.ILog log =
log4net.LogManager.GetLogger(System.Reflection.Met hodBase.GetCurrentMethod().DeclaringType);

public MyHttpApp() {
log.InfoFormat("MyHttpApp constructor called! - Hashcode = {0}",
this.GetHashCode());
}
protected void Application_Start(Object sender, EventArgs e)
{
log.InfoFormat("MyHttpApp->Application_Start called! - Hashcode =
{0}", this.GetHashCode());
}

protected void Application_End(Object sender, EventArgs e)
{
log.Info("Application ending...");
}
}

Nov 19 '05 #3
Scott,

thanks for the pointers. Very helpful for better understanding,
although not in-depth. What is missing still is how many objects there
are (how this object pooling works), (because there are not as many as
there are threads -- which are configured in macihne.config) but it is
not important. What is important is knowing that there is not just one.

I am basically storing some state in this App object and since it is
stored in the private static variable which is read only, it does not
matter if there are many instances of this object.

Thanks,
Miha.

Nov 19 '05 #4
There should be an application object for each request thread. An
application object is associated with each request thread as it works
it's way through the pipeline. Have you done any experiments that
indicate anything to the contrary?

Note that the objects may be lazily created, so it might not ramp up
to the number of threads configured in web.config unless it is
required.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 8 Nov 2005 12:30:58 -0800, mi***********@gmail.com wrote:
Scott,

thanks for the pointers. Very helpful for better understanding,
although not in-depth. What is missing still is how many objects there
are (how this object pooling works), (because there are not as many as
there are threads -- which are configured in macihne.config) but it is
not important. What is important is knowing that there is not just one.

I am basically storing some state in this App object and since it is
stored in the private static variable which is read only, it does not
matter if there are many instances of this object.

Thanks,
Miha.


Nov 19 '05 #5
I have observed the contrary. Not too radically, though. What I have
found through testing is, that, as you say, this pool gets lazily
created. Meaning, that it has some sort of algorithm and it starts with
fewer threads in the begining and if the contention happens, the
threadpool grows. In my case, there were 9 HttpApplication instances,
although the threads configured were at 10. Even though I got more than
half 403.9 ERRORs back from the application (too many requests). I
wonder why, since there is supposed to be a default value of 500 for
the queue size.

But, from experience (and web resources) WinXP/2000 is limited in that
way to max 10 connections, but obviously 0 length queue. :( But this is
another discussion...

rgds,
Miha.

Nov 19 '05 #6

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

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
0
by: Joe Kraft | last post by:
I'm hoping someone can help me out. We're running a website that uses XML/XSLT transformations, VB.Net and an Oracle database. Currently the site cannot support more than 6-7 users at a time...
3
by: Stanley Alex | last post by:
I connect to myDataStore from different places but I really only need to connect once when the application loads. 'Connect to database. Dim myDataStore As IDataStore = New...
4
by: sikander khan via .NET 247 | last post by:
hello all ! i know that there exists one to one relationship between HttpApplication instance and a request. My doubt is that instance associated with that request until session times out. i mean...
161
by: KraftDiner | last post by:
I was under the assumption that everything in python was a refrence... so if I code this: lst = for i in lst: if i==2: i = 4 print lst I though the contents of lst would be modified.....
4
by: Urs | last post by:
Two questions: 1) What possibly causes HttpApplication from being unloaded or recycled? 2) How can I prevent HttpApplication from being unloaded or recycled (to prevent loss of session state...)...
1
by: Assimalyst | last post by:
Hi, I am trying to publish a website, but i can't get the aspx file to load instead i get the above error and the following stack trace: ...
2
by: Nitinkcv | last post by:
Hi all, Very strange problem. Everything was working just fine and then suddenly whatever page i access the following error message: Object reference not set to an instance of an object. ...
2
by: snester | last post by:
Hi, I am using visual studio 2005 and recently created a new web service project. I seem to have edited the global config file (inadvertently) somewhere along the line. All new projects I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.