473,396 Members | 1,799 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,396 software developers and data experts.

Application & Session Cache Performance Problem

Hi,

Our website has recently been experiencing some problems under load. We have
pinpointed a particular function which slows dramatically when we have these
problems. Normally it should execute in under a second but it rises to about
one minute under duress.

The code is fairly straight forward with no calls to databases or any other
servers. The only dubious thing I can see is that it retrieves several arrays
from the Application cache and a few variables from Session Cache. From
reading around I get the impression that storing arrays in Application cache
can cause thread queuing problems that are only noticeable under heavy loads.
However, some of the documents I have read apply to different versions of
IIS, etc., so I am not sure if the info I have read applies to our
configuration. We are using classic ASP running on IIS6 running on Win2K
Server SP4.

Please can someone confirm whether we may be expeiencing thread queuing on
the Application cache or offer any other explanations.

Thanks,
roadrunner
May 15 '06 #1
22 3185

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Hi,

Our website has recently been experiencing some problems under load. We have pinpointed a particular function which slows dramatically when we have these problems. Normally it should execute in under a second but it rises to about one minute under duress.

The code is fairly straight forward with no calls to databases or any other servers. The only dubious thing I can see is that it retrieves several arrays from the Application cache and a few variables from Session Cache. From
reading around I get the impression that storing arrays in Application cache can cause thread queuing problems that are only noticeable under heavy loads. However, some of the documents I have read apply to different versions of
IIS, etc., so I am not sure if the info I have read applies to our
configuration. We are using classic ASP running on IIS6 running on Win2K
Server SP4.

Please can someone confirm whether we may be expeiencing thread queuing on
the Application cache or offer any other explanations.

Storing anything in the application object requires the application to lock
while it's being accessed. If another page attempts to anything with the
application it will block. Heavy use of the application object will result
in threads queing up for access (I'm not sure the queue will be orderly).

Do any of your pages use the .Lock and .Unlock methods. Is it possible that
a few of them are holding on the application object for longer than
necessary?

Are there many different arrays that have different uses?

Thanks,
roadrunner

May 15 '06 #2
Hi Anthony,

We are not using Application.Lock & Unlock on the section of code that is
misbehaving as we are only reading data. The main array we are accessing has
dimensions of 200*20. It stores small (<256 chars) string values.

Thanks,
roadrunner


"Anthony Jones" wrote:

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Hi,

Our website has recently been experiencing some problems under load. We

have
pinpointed a particular function which slows dramatically when we have

these
problems. Normally it should execute in under a second but it rises to

about
one minute under duress.

The code is fairly straight forward with no calls to databases or any

other
servers. The only dubious thing I can see is that it retrieves several

arrays
from the Application cache and a few variables from Session Cache. From
reading around I get the impression that storing arrays in Application

cache
can cause thread queuing problems that are only noticeable under heavy

loads.
However, some of the documents I have read apply to different versions of
IIS, etc., so I am not sure if the info I have read applies to our
configuration. We are using classic ASP running on IIS6 running on Win2K
Server SP4.

Please can someone confirm whether we may be expeiencing thread queuing on
the Application cache or offer any other explanations.


Storing anything in the application object requires the application to lock
while it's being accessed. If another page attempts to anything with the
application it will block. Heavy use of the application object will result
in threads queing up for access (I'm not sure the queue will be orderly).

Do any of your pages use the .Lock and .Unlock methods. Is it possible that
a few of them are holding on the application object for longer than
necessary?

Are there many different arrays that have different uses?

Thanks,
roadrunner


May 15 '06 #3

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
Hi Anthony,

We are not using Application.Lock & Unlock on the section of code that is
misbehaving as we are only reading data. The main array we are accessing has dimensions of 200*20. It stores small (<256 chars) string values.

An empty array of those dimensions will be 64K to start with. If we
estimate a conservative 20 characters per entry you can add 160K to that.

Each time you access this array it needs to be serialised into the local
memory used by the thread and each time you write it back to the application
object it needs to be serialised.

If you are doing this a lot it is going to impact performance. Whilst this
array is being moved into or out of the application object no other thread
can access the application object.

How are you managing the concurrency of multiple requests trying to modify
this array at the same time?

Without a lock the state of this array is going to get into a real mess
isn't it?
Thanks,
roadrunner


"Anthony Jones" wrote:

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Hi,

Our website has recently been experiencing some problems under load. We
have
pinpointed a particular function which slows dramatically when we have

these
problems. Normally it should execute in under a second but it rises to

about
one minute under duress.

The code is fairly straight forward with no calls to databases or any

other
servers. The only dubious thing I can see is that it retrieves several

arrays
from the Application cache and a few variables from Session Cache.
From reading around I get the impression that storing arrays in Application

cache
can cause thread queuing problems that are only noticeable under heavy

loads.
However, some of the documents I have read apply to different versions of IIS, etc., so I am not sure if the info I have read applies to our
configuration. We are using classic ASP running on IIS6 running on Win2K Server SP4.

Please can someone confirm whether we may be expeiencing thread queuing on the Application cache or offer any other explanations.


Storing anything in the application object requires the application to

lock while it's being accessed. If another page attempts to anything with the application it will block. Heavy use of the application object will result in threads queing up for access (I'm not sure the queue will be orderly).
Do any of your pages use the .Lock and .Unlock methods. Is it possible that a few of them are holding on the application object for longer than
necessary?

Are there many different arrays that have different uses?

Thanks,
roadrunner


May 15 '06 #4
Anthony Jones wrote on 15 mei 2006 in
microsoft.public.inetserver.asp.general:
An empty array of those dimensions will be 64K to start with. If we
estimate a conservative 20 characters per entry you can add 160K to
that.

Each time you access this array it needs to be serialised into the
local memory used by the thread and each time you write it back to the
application object it needs to be serialised.

If you are doing this a lot it is going to impact performance. Whilst
this array is being moved into or out of the application object no
other thread can access the application object.

How are you managing the concurrency of multiple requests trying to
modify this array at the same time?

Without a lock the state of this array is going to get into a real
mess isn't it?


You should not do an unlocked write.

If the applicatin variable is read once every page access, and say 500
users get one page every quarter minute, this will give 33 reads per
second. Would that amount to your "real mess"?

I think the question is if the problem is worse than withother methods.

Worse than Jet engine access of a database containing the same?

Worse than the same with SQL-server?

=================

I read once and somewhere that:

<%
application("mine")=application("mine")+1
%>

has an imlpied lock mechanism in ASP. Is this true?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 15 '06 #5
To repeat, no writes are being made in the problematic function, nor in any
others that are being executed at the same time. The 'large' array is loaded
when the application first starts and not modified after that. Also, we are
not experiencing high memory usage or cpu on the servers.

Anthony you say "whilst this array is being moved into or out of the
application object no other thread can access the application object". If
there are no application.locks and we are not updating the array anywhere why
is there this restriction?
May 15 '06 #6

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
To repeat, no writes are being made in the problematic function, nor in any others that are being executed at the same time. The 'large' array is loaded when the application first starts and not modified after that. Also, we are not experiencing high memory usage or cpu on the servers.

Anthony you say "whilst this array is being moved into or out of the
application object no other thread can access the application object". If
there are no application.locks and we are not updating the array anywhere why is there this restriction?


Yes it still needs to be serialised into the threads local memory before
vbscript can access it's contents. Hence every page that uses it represents
at least one movement of 160K+ of memory. That's quite a lot of memory to
be allocating and deallocating frequently. This is a bad enough situation
as it is.

One would hope that the application object understands the difference
between mutliple read attempts and a write attempt thus allowing multiple
concurrent reads of the array but I wouldn't count on it. If it doesn't
then threads would queue up to read the array.

An alternative perhaps would be to use a FreeThreaded XML DOM. Accessing
this doesn't require the entire set of data to be moved into the thread's
local memory. It depends on usage but it may be worth a try.
Anthony.


May 15 '06 #7
roadrunner wrote:
Hi,

Our website has recently been experiencing some problems under load.
We have pinpointed a particular function which slows dramatically
when we have these problems. Normally it should execute in under a
second but it rises to about one minute under duress.

The code is fairly straight forward with no calls to databases or any
other servers. The only dubious thing I can see is that it retrieves
several arrays from the Application cache and a few variables from
Session Cache. From reading around I get the impression that storing
arrays in Application cache can cause thread queuing problems that
are only noticeable under heavy loads. However, some of the documents
I have read apply to different versions of IIS, etc., so I am not
sure if the info I have read applies to our configuration. We are
using classic ASP running on IIS6 running on Win2K Server SP4.

Please can someone confirm whether we may be expeiencing thread
queuing on the Application cache or offer any other explanations.

Does your page pull the data from Application once, storing it in a local
variable? Or did the author make the mistake of repeatedly reading the data
from Application in the same page?

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
May 15 '06 #8

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.242...
Anthony Jones wrote on 15 mei 2006 in
microsoft.public.inetserver.asp.general:
An empty array of those dimensions will be 64K to start with. If we
estimate a conservative 20 characters per entry you can add 160K to
that.

Each time you access this array it needs to be serialised into the
local memory used by the thread and each time you write it back to the
application object it needs to be serialised.

If you are doing this a lot it is going to impact performance. Whilst
this array is being moved into or out of the application object no
other thread can access the application object.

How are you managing the concurrency of multiple requests trying to
modify this array at the same time?

Without a lock the state of this array is going to get into a real
mess isn't it?
You should not do an unlocked write.

If the applicatin variable is read once every page access, and say 500
users get one page every quarter minute, this will give 33 reads per
second. Would that amount to your "real mess"?


No. At the time of asking I was concerned that without the benefit of
lock/unlock the array would become corrupt due to concurrent
read-modify-write cycles on the array.
I think the question is if the problem is worse than withother methods.

Worse than Jet engine access of a database containing the same?

Depends on how much of the array content is needed per request.
Worse than the same with SQL-server?
Ditto

=================

I read once and somewhere that:

<%
application("mine")=application("mine")+1
%>

has an imlpied lock mechanism in ASP. Is this true?

At the end of the day it's just COM copying the content of a variant from
one apartment to another. Certainly you can't have two requests writing the
same application value at the same time so some locking has to be inplace.
I doubt the locking is as granular as per named item. It's probably a
single lock on the application object after all it isn't designed to store
rapidly changing data.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

May 15 '06 #9
Rather than asking us to speculate based on your (possibly incorrect)
description and diagnosis of the problem, please post the code. Include
the entire section of code that you are _certain_ contains the problem.
I'm assuming that you know roughly where the problem is but are
unfamiliar with the exact nature of the problem.
May 16 '06 #10
Thanks Anthony, You mean store the array in an xml file instead of the
application object? I guess this would slow down a single request? For
multiple requests, wouldn't there be contention to access it by the threads
still?

"Anthony Jones" wrote:

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
To repeat, no writes are being made in the problematic function, nor in

any
others that are being executed at the same time. The 'large' array is

loaded
when the application first starts and not modified after that. Also, we

are
not experiencing high memory usage or cpu on the servers.

Anthony you say "whilst this array is being moved into or out of the
application object no other thread can access the application object". If
there are no application.locks and we are not updating the array anywhere

why
is there this restriction?


Yes it still needs to be serialised into the threads local memory before
vbscript can access it's contents. Hence every page that uses it represents
at least one movement of 160K+ of memory. That's quite a lot of memory to
be allocating and deallocating frequently. This is a bad enough situation
as it is.

One would hope that the application object understands the difference
between mutliple read attempts and a write attempt thus allowing multiple
concurrent reads of the array but I wouldn't count on it. If it doesn't
then threads would queue up to read the array.

An alternative perhaps would be to use a FreeThreaded XML DOM. Accessing
this doesn't require the entire set of data to be moved into the thread's
local memory. It depends on usage but it may be worth a try.
Anthony.


May 16 '06 #11
Hi Bob, The application object is referenced each time a different element of
the array is required. I know this is a bit bad from a speed point of view
due to object references but from what Anthony says it sounds like the
Application object should be avoided for arrays completely. I am posting a
simplfied version of the sub under Michael Kersey's post to give a better
idea of what it does.

"Bob Barrows [MVP]" wrote:
roadrunner wrote:
Hi,

Our website has recently been experiencing some problems under load.
We have pinpointed a particular function which slows dramatically
when we have these problems. Normally it should execute in under a
second but it rises to about one minute under duress.

The code is fairly straight forward with no calls to databases or any
other servers. The only dubious thing I can see is that it retrieves
several arrays from the Application cache and a few variables from
Session Cache. From reading around I get the impression that storing
arrays in Application cache can cause thread queuing problems that
are only noticeable under heavy loads. However, some of the documents
I have read apply to different versions of IIS, etc., so I am not
sure if the info I have read applies to our configuration. We are
using classic ASP running on IIS6 running on Win2K Server SP4.

Please can someone confirm whether we may be expeiencing thread
queuing on the Application cache or offer any other explanations.

Does your page pull the data from Application once, storing it in a local
variable? Or did the author make the mistake of repeatedly reading the data
from Application in the same page?

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

May 16 '06 #12
Hi Michael,

Here is a simplifed (for readability/legal reasons) version of the code.

Sub WithContentionProblems (byref intNumItems)

Dim intItemIndex, intSubItemIndex

intNumItems = 0

For intItemIndex = 1 To UBound(Application("Items"),2)
For intSubItemIndex = 2 To 0 Step -1
If InStr(1, "," & Request.ServerVariables("HTTP_TYPES") & ",",
",""WIDGETS"",", vbTextCompare) > 0 ) Then
parrItemData(0, intNumItems) = intItemIndex
parrItemData(1, intNumItems) = 1
parrItemData(2, intNumItems) = Application("Items")(2, intItemIndex)
parrItemData(3, intNumItems) = Application("Items")(3, intItemIndex)
parrItemData(4, intNumItems) = Application("Items")(4, intItemIndex)
parrItemData(5, intNumItems) = Application("Items")(5, intItemIndex)
parrItemData(6, intNumItems) = intSubItemIndex
parrItemData(7, intNumItems) = Application("Items")(7, intItemIndex)
parrItemData(8, intNumItems) = Application("Items")(8, intItemIndex)
parrItemData(9, intNumItems) = Application("Items")(9, intItemIndex)
intNumItems = intNumItems + 1
Exit For
End If
Next
Next

End Sub

"Michael D. Kersey" wrote:
Rather than asking us to speculate based on your (possibly incorrect)
description and diagnosis of the problem, please post the code. Include
the entire section of code that you are _certain_ contains the problem.
I'm assuming that you know roughly where the problem is but are
unfamiliar with the exact nature of the problem.

May 16 '06 #13
It's more than a "bit" bad. It is probably what is exacerbating what
Anthony is talking about. Frankly, I've never had an issue with using an
array in Application, as long as I minimize references to it.

roadrunner wrote:
Hi Bob, The application object is referenced each time a different
element of the array is required. I know this is a bit bad from a
speed point of view due to object references but from what Anthony
says it sounds like the Application object should be avoided for
arrays completely. I am posting a simplfied version of the sub under
Michael Kersey's post to give a better idea of what it does.

"Bob Barrows [MVP]" wrote:
roadrunner wrote:
Hi,

Our website has recently been experiencing some problems under load.
We have pinpointed a particular function which slows dramatically
when we have these problems. Normally it should execute in under a
second but it rises to about one minute under duress.

The code is fairly straight forward with no calls to databases or
any other servers. The only dubious thing I can see is that it
retrieves several arrays from the Application cache and a few
variables from Session Cache. From reading around I get the
impression that storing arrays in Application cache can cause
thread queuing problems that are only noticeable under heavy loads.
However, some of the documents I have read apply to different
versions of IIS, etc., so I am not sure if the info I have read
applies to our configuration. We are using classic ASP running on
IIS6 running on Win2K Server SP4.

Please can someone confirm whether we may be expeiencing thread
queuing on the Application cache or offer any other explanations.

Does your page pull the data from Application once, storing it in a
local variable? Or did the author make the mistake of repeatedly
reading the data from Application in the same page?

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
May 16 '06 #14
This is horrible, but it looks real easy to fix. Do a search/replace,
replacing Application("Items") with "arItems" (no quotes of course). Then
add
dim arItems
arItems=Application("Items")
at the appropriate scope: put it outside the sub if used in multiple
procedures, inside the sub if used only within the sub.

roadrunner wrote:
Hi Michael,

Here is a simplifed (for readability/legal reasons) version of the
code.

Sub WithContentionProblems (byref intNumItems)

Dim intItemIndex, intSubItemIndex

intNumItems = 0

For intItemIndex = 1 To UBound(Application("Items"),2)
For intSubItemIndex = 2 To 0 Step -1
If InStr(1, "," & Request.ServerVariables("HTTP_TYPES") & ",",
",""WIDGETS"",", vbTextCompare) > 0 ) Then
parrItemData(0, intNumItems) = intItemIndex
parrItemData(1, intNumItems) = 1
parrItemData(2, intNumItems) = Application("Items")(2,
intItemIndex) parrItemData(3, intNumItems) =
Application("Items")(3, intItemIndex) parrItemData(4,
intNumItems) = Application("Items")(4, intItemIndex)
parrItemData(5, intNumItems) = Application("Items")(5,
intItemIndex) parrItemData(6, intNumItems) = intSubItemIndex
parrItemData(7, intNumItems) = Application("Items")(7,
intItemIndex) parrItemData(8, intNumItems) =
Application("Items")(8, intItemIndex) parrItemData(9,
intNumItems) = Application("Items")(9, intItemIndex) intNumItems
= intNumItems + 1 Exit For End If
Next
Next

End Sub

"Michael D. Kersey" wrote:
Rather than asking us to speculate based on your (possibly incorrect)
description and diagnosis of the problem, please post the code.
Include the entire section of code that you are _certain_ contains
the problem. I'm assuming that you know roughly where the problem is
but are unfamiliar with the exact nature of the problem.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
May 16 '06 #15
Thanks Bob, I am going to run this in loadrunner to simulate multi-user
conditions over the next few days and then try making the changes you suggest
and comparing the times. I will let you know how it goes but it may be a few
days before I can do this.

"Bob Barrows [MVP]" wrote:
This is horrible, but it looks real easy to fix. Do a search/replace,
replacing Application("Items") with "arItems" (no quotes of course). Then
add
dim arItems
arItems=Application("Items")
at the appropriate scope: put it outside the sub if used in multiple
procedures, inside the sub if used only within the sub.

roadrunner wrote:
Hi Michael,

Here is a simplifed (for readability/legal reasons) version of the
code.

Sub WithContentionProblems (byref intNumItems)

Dim intItemIndex, intSubItemIndex

intNumItems = 0

For intItemIndex = 1 To UBound(Application("Items"),2)
For intSubItemIndex = 2 To 0 Step -1
If InStr(1, "," & Request.ServerVariables("HTTP_TYPES") & ",",
",""WIDGETS"",", vbTextCompare) > 0 ) Then
parrItemData(0, intNumItems) = intItemIndex
parrItemData(1, intNumItems) = 1
parrItemData(2, intNumItems) = Application("Items")(2,
intItemIndex) parrItemData(3, intNumItems) =
Application("Items")(3, intItemIndex) parrItemData(4,
intNumItems) = Application("Items")(4, intItemIndex)
parrItemData(5, intNumItems) = Application("Items")(5,
intItemIndex) parrItemData(6, intNumItems) = intSubItemIndex
parrItemData(7, intNumItems) = Application("Items")(7,
intItemIndex) parrItemData(8, intNumItems) =
Application("Items")(8, intItemIndex) parrItemData(9,
intNumItems) = Application("Items")(9, intItemIndex) intNumItems
= intNumItems + 1 Exit For End If
Next
Next

End Sub

"Michael D. Kersey" wrote:
Rather than asking us to speculate based on your (possibly incorrect)
description and diagnosis of the problem, please post the code.
Include the entire section of code that you are _certain_ contains
the problem. I'm assuming that you know roughly where the problem is
but are unfamiliar with the exact nature of the problem.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

May 16 '06 #16

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
Thanks Anthony, You mean store the array in an xml file instead of the
application object?
I mean store your data in an XML file then on application start load that
file into a Free Threaded DOM :-

"MSXML2.FreeThreadedDOMDocument.3.0"

Store this DOM object in the application object.

If you store your array as a series of 200 elements each with a 20 child
elements then access it like:-

Dim oDOM : Set oDOM = Application("xmlDom")

x = oDOM.childNodes(123).childNodes(15).text

Not as fast as accessing an array but the only data that needs to marshalled
into the local thread is the string going into x not the entire array.
I guess this would slow down a single request? For
multiple requests, wouldn't there be contention to access it by the threads still?
Not when all those accesses are reads.

While your at it you might consider using an include to abstract this. If
this approach doesn't work out you can change the implementation behind the
abstract without changing lots of pages again.

IOW:-

'ArrayAccessor.asp
<%

Class ArrayAccessor

Private moDOM

Public Property Get Item(x,y)
Item = moDOM.childNodes(x).childNodes(y).Text
End Property

Private Sub Class_Initialize()
Set moDOM = Application("xmlDOM")
End Sub

End Class
%>

'YourPage.asp
<!-- #include virtual="/utils/ArrayAccessor.asp" -->
<%

Dim oArr: Set oArr = New ArrayAccessor

x = oArr.Item(123,15)

%>

If the FreeThreaded DOM stuff doesn't work out for you, you need only change
the ArrayAccessor.asp page.

"Anthony Jones" wrote:

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
To repeat, no writes are being made in the problematic function, nor in
any
others that are being executed at the same time. The 'large' array is

loaded
when the application first starts and not modified after that. Also,
we are
not experiencing high memory usage or cpu on the servers.

Anthony you say "whilst this array is being moved into or out of the
application object no other thread can access the application object".
If there are no application.locks and we are not updating the array

anywhere why
is there this restriction?


Yes it still needs to be serialised into the threads local memory before
vbscript can access it's contents. Hence every page that uses it represents at least one movement of 160K+ of memory. That's quite a lot of memory to be allocating and deallocating frequently. This is a bad enough situation as it is.

One would hope that the application object understands the difference
between mutliple read attempts and a write attempt thus allowing multiple concurrent reads of the array but I wouldn't count on it. If it doesn't
then threads would queue up to read the array.

An alternative perhaps would be to use a FreeThreaded XML DOM. Accessing this doesn't require the entire set of data to be moved into the thread's local memory. It depends on usage but it may be worth a try.
Anthony.


May 16 '06 #17

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi Michael,

Here is a simplifed (for readability/legal reasons) version of the code.

Sub WithContentionProblems (byref intNumItems)

Dim intItemIndex, intSubItemIndex

intNumItems = 0

For intItemIndex = 1 To UBound(Application("Items"),2)
For intSubItemIndex = 2 To 0 Step -1
If InStr(1, "," & Request.ServerVariables("HTTP_TYPES") & ",",
",""WIDGETS"",", vbTextCompare) > 0 ) Then
parrItemData(0, intNumItems) = intItemIndex
parrItemData(1, intNumItems) = 1
parrItemData(2, intNumItems) = Application("Items")(2, intItemIndex)
parrItemData(3, intNumItems) = Application("Items")(3, intItemIndex)
parrItemData(4, intNumItems) = Application("Items")(4, intItemIndex)
parrItemData(5, intNumItems) = Application("Items")(5, intItemIndex)
parrItemData(6, intNumItems) = intSubItemIndex
parrItemData(7, intNumItems) = Application("Items")(7, intItemIndex)
parrItemData(8, intNumItems) = Application("Items")(8, intItemIndex)
parrItemData(9, intNumItems) = Application("Items")(9, intItemIndex)
intNumItems = intNumItems + 1
Exit For
End If
Next
Next

End Sub

Yikes!!!

Having made my ealier post before reading this I would definitely say you
should try Bob's suggestion first before complicating things with DOMs etc.

"Michael D. Kersey" wrote:
Rather than asking us to speculate based on your (possibly incorrect)
description and diagnosis of the problem, please post the code. Include
the entire section of code that you are _certain_ contains the problem.
I'm assuming that you know roughly where the problem is but are
unfamiliar with the exact nature of the problem.

May 16 '06 #18
Ok, will do.

"Anthony Jones" wrote:

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi Michael,

Here is a simplifed (for readability/legal reasons) version of the code.

Sub WithContentionProblems (byref intNumItems)

Dim intItemIndex, intSubItemIndex

intNumItems = 0

For intItemIndex = 1 To UBound(Application("Items"),2)
For intSubItemIndex = 2 To 0 Step -1
If InStr(1, "," & Request.ServerVariables("HTTP_TYPES") & ",",
",""WIDGETS"",", vbTextCompare) > 0 ) Then
parrItemData(0, intNumItems) = intItemIndex
parrItemData(1, intNumItems) = 1
parrItemData(2, intNumItems) = Application("Items")(2, intItemIndex)
parrItemData(3, intNumItems) = Application("Items")(3, intItemIndex)
parrItemData(4, intNumItems) = Application("Items")(4, intItemIndex)
parrItemData(5, intNumItems) = Application("Items")(5, intItemIndex)
parrItemData(6, intNumItems) = intSubItemIndex
parrItemData(7, intNumItems) = Application("Items")(7, intItemIndex)
parrItemData(8, intNumItems) = Application("Items")(8, intItemIndex)
parrItemData(9, intNumItems) = Application("Items")(9, intItemIndex)
intNumItems = intNumItems + 1
Exit For
End If
Next
Next

End Sub


Yikes!!!

Having made my ealier post before reading this I would definitely say you
should try Bob's suggestion first before complicating things with DOMs etc.

"Michael D. Kersey" wrote:
Rather than asking us to speculate based on your (possibly incorrect)
description and diagnosis of the problem, please post the code. Include
the entire section of code that you are _certain_ contains the problem.
I'm assuming that you know roughly where the problem is but are
unfamiliar with the exact nature of the problem.


May 17 '06 #19
roadrunner wrote:
Hi Michael,
Here is a simplifed (for readability/legal reasons) version of the code.

Sub WithContentionProblems (byref intNumItems)
Dim intItemIndex, intSubItemIndex
intNumItems = 0

For intItemIndex = 1 To UBound(Application("Items"),2)
For intSubItemIndex = 2 To 0 Step -1
If InStr(1, "," & Request.ServerVariables("HTTP_TYPES") & ",",
",""WIDGETS"",", vbTextCompare) > 0 ) Then
parrItemData(0, intNumItems) = intItemIndex
parrItemData(1, intNumItems) = 1
parrItemData(2, intNumItems) = Application("Items")(2, intItemIndex)
parrItemData(3, intNumItems) = Application("Items")(3, intItemIndex)
parrItemData(4, intNumItems) = Application("Items")(4, intItemIndex)
parrItemData(5, intNumItems) = Application("Items")(5, intItemIndex)
parrItemData(6, intNumItems) = intSubItemIndex
parrItemData(7, intNumItems) = Application("Items")(7, intItemIndex)
parrItemData(8, intNumItems) = Application("Items")(8, intItemIndex)
parrItemData(9, intNumItems) = Application("Items")(9, intItemIndex)
intNumItems = intNumItems + 1
Exit For
End If
Next
Next

End Sub
The expression in the statement: If InStr(1, "," & Request.ServerVariables("HTTP_TYPES") & ",",
",""WIDGETS"",", vbTextCompare) > 0 ) Then


always has the same value (is a "loop invariant") - it's being
unnecessarily recomputed with each iteration. Another thing is that
Request.ServerVariables is rumoured to be a costly request and anyway it
is necessary to call it only once. Taking the entire invariant
expression out of the two loops yields something like (untested code):
strSearch = "," & Request.ServerVariables("HTTP_TYPES") & ","
strFind = ",""WIDGETS"","
IntWidget = InStr(1, strSearch, strFind , vbTextCompare)
For intItemIndex = 1 To UBound(Application("Items"),2)
For intSubItemIndex = 2 To 0 Step -1
If ( intWidget > 0 ) Then
...

May 17 '06 #20
Hi Guys,

After some initial tests using loadrunner it looks like just storing the
Application("Items") array into a local array and then accessing that gives a
significant improvement in performance. It seems to run in a tenth of the
time that the original code took no matter how many simultaneous requests
there are.

Plotting response time vs. Number simultaneous users gives a linear graph
for both versions of the code. This points to just poor performance rather
than a bottleneck being the main problem of the original code, surely? E.g.
It was running slow due to the cpu taken to copy the array rather than
threads blocking one another. If there was a bottleneck we would see a point
on the graph where response times suddenly escalate.

Thanks

"roadrunner" wrote:
Ok, will do.

"Anthony Jones" wrote:

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi Michael,

Here is a simplifed (for readability/legal reasons) version of the code.

Sub WithContentionProblems (byref intNumItems)

Dim intItemIndex, intSubItemIndex

intNumItems = 0

For intItemIndex = 1 To UBound(Application("Items"),2)
For intSubItemIndex = 2 To 0 Step -1
If InStr(1, "," & Request.ServerVariables("HTTP_TYPES") & ",",
",""WIDGETS"",", vbTextCompare) > 0 ) Then
parrItemData(0, intNumItems) = intItemIndex
parrItemData(1, intNumItems) = 1
parrItemData(2, intNumItems) = Application("Items")(2, intItemIndex)
parrItemData(3, intNumItems) = Application("Items")(3, intItemIndex)
parrItemData(4, intNumItems) = Application("Items")(4, intItemIndex)
parrItemData(5, intNumItems) = Application("Items")(5, intItemIndex)
parrItemData(6, intNumItems) = intSubItemIndex
parrItemData(7, intNumItems) = Application("Items")(7, intItemIndex)
parrItemData(8, intNumItems) = Application("Items")(8, intItemIndex)
parrItemData(9, intNumItems) = Application("Items")(9, intItemIndex)
intNumItems = intNumItems + 1
Exit For
End If
Next
Next

End Sub


Yikes!!!

Having made my ealier post before reading this I would definitely say you
should try Bob's suggestion first before complicating things with DOMs etc.

"Michael D. Kersey" wrote:

> Rather than asking us to speculate based on your (possibly incorrect)
> description and diagnosis of the problem, please post the code. Include
> the entire section of code that you are _certain_ contains the problem.
> I'm assuming that you know roughly where the problem is but are
> unfamiliar with the exact nature of the problem.
>


May 19 '06 #21

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
Hi Guys,

After some initial tests using loadrunner it looks like just storing the
Application("Items") array into a local array and then accessing that gives a significant improvement in performance. It seems to run in a tenth of the
time that the original code took no matter how many simultaneous requests
there are.

Plotting response time vs. Number simultaneous users gives a linear graph
for both versions of the code. This points to just poor performance rather
than a bottleneck being the main problem of the original code, surely? E.g. It was running slow due to the cpu taken to copy the array rather than
threads blocking one another. If there was a bottleneck we would see a point on the graph where response times suddenly escalate.


How many CPUs do you have :)

A runnable thread is still effectively blocked if it can't find a processor
to run on.

If you had more than one and all were busy in the original incarnation of
the site that would indicate that ASP was allowing multiple reads of the
array. That would be good know if not particularly helpful here.

Anthony.
May 19 '06 #22
Good point. In live we have multi cpu machines but the test machine I have
available is only a single cpu. Guess it's like comparing apples to pears..

It does seem to greatly improve performance, however, so I think we will
have to try this in live to really see how much of an improvement it makes.
Not ideal but c'est la vie..

"Anthony Jones" wrote:

"roadrunner" <ro********@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
Hi Guys,

After some initial tests using loadrunner it looks like just storing the
Application("Items") array into a local array and then accessing that

gives a
significant improvement in performance. It seems to run in a tenth of the
time that the original code took no matter how many simultaneous requests
there are.

Plotting response time vs. Number simultaneous users gives a linear graph
for both versions of the code. This points to just poor performance rather
than a bottleneck being the main problem of the original code, surely?

E.g.
It was running slow due to the cpu taken to copy the array rather than
threads blocking one another. If there was a bottleneck we would see a

point
on the graph where response times suddenly escalate.


How many CPUs do you have :)

A runnable thread is still effectively blocked if it can't find a processor
to run on.

If you had more than one and all were busy in the original incarnation of
the site that would indicate that ASP was allowing multiple reads of the
array. That would be good know if not particularly helpful here.

Anthony.

May 19 '06 #23

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

Similar topics

9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
8
by: Dave Wurtz | last post by:
All, I'm new to ASP development and I have a basic design question: Is it ok to store business objects to session variables or is there a better way to keep object information? For example,...
7
by: Greg Collins [MVP] | last post by:
Hi, I couldn't find what I was looking for by searching the newsgroup, but perhaps these have already been discussed somewhere. This is a bit long with a lot of interrelated questions. What I've...
2
by: Lars Netzel | last post by:
Hi We have an ASP.NET application running on a Live server and we have had some problems with the Application pool beeing recycled due to heavy load on the server. The load is really not that...
4
by: kanones | last post by:
I have some data that is been retrieved from a call to sql server stored procedure that I want to store for a period of time in a web farm architecture. I want to minimize the calls to sql server...
1
by: Sashko | last post by:
Hi, I made an ASP.NET (.NET 1.1) application that uses the Context.Cache object within Global.asax as a static member. It is set up in such a way that whenever the cache items expire, they...
2
by: =?Utf-8?B?Q2hhcmxpZQ==?= | last post by:
I have written an ASP.Net web application in C#. On Appplication_Start the code loads some data from the database into memory. It stores the data in Application State variables. The data is read...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.