ASP performance issues

W

Woody

I have a page that is linked into by other pages that pass it query
strings, it then reads a config file, displays 1 of several forms, gets
posted to itself, depending upon users response may display a different
form etc etc.

I want to take the config data and have that read by a globals.asa and
then use application("VariableName") to reference it.

i also want to take the initial query strings and load them into session
variables.

Problem is, whats does a globals.asa file look like? how do i build one?
how do i make it referenced in my page?

Thanx
Woody
any sugestion or comment made by me should be examined first for
validity and appropriateness before assuming i have any idea at all
what the heck i am talking about. I am not responsible for anything you
may see with my name attached to it, i think.

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
A

Atrax

ummm... what does this have to do with global.asa? as far as I can see
your objective has nothing to do with it. but maybe if you were more
clear about your explanation it'd help...





________________________________________
Atrax. MVP, IIS
http://rtfm.atrax.co.uk/

newsflash : Atrax.Richedit 1.1 in beta with Mozilla-compatibility.
http://rtfm.atrax.co.uk/infinitemonkeys/components/Atrax.RichEdit/

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
B

Bob Barrows [MVP]

Woody said:
I have a page that is linked into by other pages that pass it query
strings, it then reads a config file, displays 1 of several forms,
gets posted to itself, depending upon users response may display a
different form etc etc.

I want to take the config data and have that read by a globals.asa and
then use application("VariableName") to reference it.

i also want to take the initial query strings and load them into
session variables.

Problem is, whats does a globals.asa file look like? how do i build
one? how do i make it referenced in my page?

Here is the default global.asa page created by Interdev:

******************************************************************
<SCRIPT LANGUAGE=VBScript RUNAT=Server>

'You can add special event handlers in this file that will get run
automatically when
'special Active Server Pages events occur. To create these handlers, just
create a
'subroutine with a name from the list below that corresponds to the event
you want to
'use. For example, to create an event handler for Session_OnStart, you would
put the
'following code into this file (without the comments):

'Sub Session_OnStart
'**Put your code here **
'End Sub

'EventName Description
'Session_OnStart Runs the first time a user runs any page in your
application
'Session_OnEnd Runs when a user's session times out or quits your
application
'Application_OnStart Runs once when the first page of your application is
run for the first time by any user
'Application_OnEnd Runs once when the web server shuts down

</SCRIPT>

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
End Sub
</SCRIPT>
***********************************************************

The global.asa page is run whenever one of the 4 events mentioned in the
comments section above occurs. You do NOT refer to global.asa in any of your
other pages. You simply use the application and session variables that may
have been created in global.asa.

HTH,
Bob Barrows
 
L

Lord Merlin

Doesn't this impose a performace issue? doesn't global.asa get read
everytime, by every script? What happens if you have a lot of arb stuff in
global.asa, which is only used in one script, each one of those items as
needed? Won't this have performance implications on the whole site?

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
Woody said:
I have a page that is linked into by other pages that pass it query
strings, it then reads a config file, displays 1 of several forms,
gets posted to itself, depending upon users response may display a
different form etc etc.

I want to take the config data and have that read by a globals.asa and
then use application("VariableName") to reference it.

i also want to take the initial query strings and load them into
session variables.

Problem is, whats does a globals.asa file look like? how do i build
one? how do i make it referenced in my page?

Here is the default global.asa page created by Interdev:

******************************************************************
<SCRIPT LANGUAGE=VBScript RUNAT=Server>

'You can add special event handlers in this file that will get run
automatically when
'special Active Server Pages events occur. To create these handlers, just
create a
'subroutine with a name from the list below that corresponds to the event
you want to
'use. For example, to create an event handler for Session_OnStart, you would
put the
'following code into this file (without the comments):

'Sub Session_OnStart
'**Put your code here **
'End Sub

'EventName Description
'Session_OnStart Runs the first time a user runs any page in your
application
'Session_OnEnd Runs when a user's session times out or quits your
application
'Application_OnStart Runs once when the first page of your application is
run for the first time by any user
'Application_OnEnd Runs once when the web server shuts down

</SCRIPT>

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
End Sub
</SCRIPT>
***********************************************************

The global.asa page is run whenever one of the 4 events mentioned in the
comments section above occurs. You do NOT refer to global.asa in any of your
other pages. You simply use the application and session variables that may
have been created in global.asa.

HTH,
Bob Barrows
 
B

Bob Lehmann

global.asa is run once upon accessing the first *.asp page in an
application.

Bob Lehmann
 
B

Bob Barrows [MVP]

Lord said:
Doesn't this impose a performace issue? doesn't global.asa get read
everytime, by every script?

No. Global.asa is run only during the events shown in the sample page
comments section. Pages access session variables and application variables.
Your pages do NOT run the code in the global.asa file. The code in the
global.asa file is run by your web server:

a) when the application starts
b) when a session starts
c) when a session ends
d) when the application ends

I don't know how to say it any clearer than that. I suspect you need to do
some reading of the ASP documentation at msdn.microsoft.com. Here's a link:
http://msdn.microsoft.com/library/en-us/iissdk/iis/asp.asp

and

http://msdn.microsoft.com/library/en-us/iissdk/iis/iis_web_pages.asp

Bob Barrows
 
L

Lord Merlin

ok, why is it then a bad idea putting your DB connections strings into
global.asa, when not all of your scripts would access the DB? I have found
that if I remove the DB connection strings, and only include them into the
files that access the DB, my site seems to be quicker

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
Lord said:
Doesn't this impose a performace issue? doesn't global.asa get read
everytime, by every script?

No. Global.asa is run only during the events shown in the sample page
comments section. Pages access session variables and application variables.
Your pages do NOT run the code in the global.asa file. The code in the
global.asa file is run by your web server:

a) when the application starts
b) when a session starts
c) when a session ends
d) when the application ends

I don't know how to say it any clearer than that. I suspect you need to do
some reading of the ASP documentation at msdn.microsoft.com. Here's a link:
http://msdn.microsoft.com/library/en-us/iissdk/iis/asp.asp

and

http://msdn.microsoft.com/library/en-us/iissdk/iis/iis_web_pages.asp

Bob Barrows
 
B

Bob Barrows [MVP]

Lord said:
ok, why is it then a bad idea putting your DB connections strings into
global.asa, when not all of your scripts would access the DB?

It's not. Who told you this??? There is absolutely no performance issue with
storing ANY string, let alone connection strings, in Application or Session.


Maybe you are confusing the advice against storing COM objects in
Application and Session.
COM objects, such as ADO connections, by default, are apartment-threaded,
and should not be stored in Application or Session. They are not designed to
be used by the multiple threads involved in a web server application. Go
back to aspfaq and read about this again:
http://www.aspfaq.com/show.asp?id=2053

The advice is about COM objects, not strings and numeric data.

BTW, it is possible to modify a Registry key on your web server to make the
ADO objects free-threaded instead of apartment-threaded, allowing them to be
safely used in Application or Session. A batch file called makfre15.bat is
usually installed in C:\Program Files\Common Files\System\ADO to automate
making this change. A major caveat is to avoid doing this when using a Jet
database, because Jet is single-threaded. I reiterate: DO NOT DO THIS WHEN
USING ACCESS DATABASES IN YOUR WEB APPLICATIONS.

Bob Barrows
 
C

CJM

Bob Barrows said:
BTW, it is possible to modify a Registry key on your web server to make the
ADO objects free-threaded instead of apartment-threaded, allowing them to be
safely used in Application or Session. A batch file called makfre15.bat is
usually installed in C:\Program Files\Common Files\System\ADO to automate
making this change. A major caveat is to avoid doing this when using a Jet
database, because Jet is single-threaded. I reiterate: DO NOT DO THIS WHEN
USING ACCESS DATABASES IN YOUR WEB APPLICATIONS.

Bob Barrows

Bob,

This is news to me. Have you got any pointers to some background reading on
this?

How do this fit in with our existing Good Practice guides? Is it a Good
Thing (tm) or a Bad Thing (tm)?

Not sure if I could change my habits after all this time! lol

Chris
 
B

Bob Barrows [MVP]

CJM said:
Bob,

This is news to me. Have you got any pointers to some background
reading on this?

http://www.insightgraphics.com/reference/ASPStateMgmt.htm

See Tip 4 on this page:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnasp/html/asptips.asp

Interestingly enough, this guy:
http://www.vbxml.com/conference/wrox/2000_vegas/text/jimmy_cache.pdf
says he could not get a disconnected recordset into Application in IIS5 (it
worked as advertised in IIS4). He surmises that IIS5 is a little " ...
stricter about what counts as an agile object."
..
How do this fit in with our existing Good Practice guides? Is it a
Good Thing (tm) or a Bad Thing (tm)?

I'm not so sure about it being a Good Thing. Maybe for disconnected
recordsets. I can see the benefit of storing one of those in Session. It
does not seem to be a good thing for connections, since it would tend to
defeat connection pooling. Also, if you have any functionality that depends
on discrete database "sessions", then global connections should certainly be
avoided.
Not sure if I could change my habits after all this time! lol
Same here. But the main reason for me is that some of our web applications
are using Jet databases.

Bob Barrows
 
C

CJM

Bob Barrows said:
Interestingly enough, this guy:
http://www.vbxml.com/conference/wrox/2000_vegas/text/jimmy_cache.pdf
says he could not get a disconnected recordset into Application in IIS5 (it
worked as advertised in IIS4). He surmises that IIS5 is a little " ...
stricter about what counts as an agile object."

It does say that under IIS5, it must be free-threadind AND must aggregate
the free-threading marshaller. Still double-dutch to me(!) but nevertheless
it shows that IIS is a bit more fussy.
I'm not so sure about it being a Good Thing. Maybe for disconnected
recordsets. I can see the benefit of storing one of those in Session. It
does not seem to be a good thing for connections, since it would tend to
defeat connection pooling. Also, if you have any functionality that depends
on discrete database "sessions", then global connections should certainly be
avoided.

Connection Pooling: Agreed

Disconnected RS: It mentions that it is safe to cache disconnected rs's in
Item 5, so I suspect this isnt to do with Item 4.

Interesting: Scripting.Dictionary is non-agile, but there is a (free) 3rd
Party that is and therefore can be cached. Might be useful...
Same here. But the main reason for me is that some of our web applications
are using Jet databases.

Same here sometimes...


Anyway, thanks for this...

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

IIS and ASP 2
basic asp question 4
ASP 3 Overview 1
Tasks 1
Asp copy file from local to remote share drive disk 2
Generating HTML Reports with ASP 1
asp functions 2
ASP Questions 5

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top