Performance of ASP pages calling COM object methods 
Author Message
 Performance of ASP pages calling COM object methods

The website I am working on is written mostly in ASP (VBScript), and also
COM objects written in VB.
The site has some components running under MTS.

I have noticed that  when you request a page in your browser that also uses
a COM object method,
it is often slower to load than one of the ASP pages which just uses basic
ASP and stored procedures with ADO.
You get "Web site found, waiting for reply" in th browser as it crawls
slowly to open the page.

I thought that COM was supposed to speed things up?

What could be wrong with my COM objects or their implementation?

Sometimes if I stop and start MTS, the speed of the whole site improves, but
this does not really help the difference in speed between the slow
COM-object  pages and the faster basic ASP pages.

Any help ideas for improvements gratefully appreciated



Mon, 27 Jan 2003 03:00:00 GMT  
 Performance of ASP pages calling COM object methods
COM components can speed things up, but usually you will only gain in
performance when there is a lot of intense processing happening on/in the
page.

If your ASP pages are pretty straight forward, then leaving everything in
script and foregoing COM Might provide superior performance.

I don't think anyone is going to be able to provide you with a cut and dried
answer. The only way to know for sure is to benchmark individual pages.

--
Cheers,

Greg Jackson MCSD, MCT
Sr. Software Engineer
STEP Technology
PDX, OR
http://www.steptech.com



Mon, 27 Jan 2003 03:00:00 GMT  
 Performance of ASP pages calling COM object methods

If the site is very lightly loaded, then you will
suffer occasional delays that are significant.
This is due to the package being instantiated
after having been torn down due to inactivity.

This behavior can be eliminated with pooled
objects, but you would have to implement in
VC++, as VB object cannot be pooled. To fully
understand the issue you will need to set up
a test environment that closely mimics the
production system and run scalability tests.

Other issues can adversely impact performance,
such as heavy simultaneous demand for resources
that are expensive to create - such as connections
to a database. Under heavy load I have observed
that connections to Oracle can take longer than
60 seconds. When this condition occurs, some of
these connections are left in an INACTIVE state
*indefinitely* due to not being properly closed,
which in turn worsens the problem.

Performance analysis requires experience with the
technology, an understanding of the application
usage patterns, and a very methodical approach
to the test, analyze, change and retest cycle.

Performance tuning an application should start with
a thorough design/code review. Often a developer
with a "fresh set of eyes" can spot problems that
the original author overlooks.

Good luck,

--
Michael D. Long
http://extremedna.homestead.com



Quote:
> The website I am working on is written mostly in ASP (VBScript), and also
> COM objects written in VB.
> The site has some components running under MTS.

> I have noticed that  when you request a page in your browser that also
uses
> a COM object method,
> it is often slower to load than one of the ASP pages which just uses basic
> ASP and stored procedures with ADO.
> You get "Web site found, waiting for reply" in th browser as it crawls
> slowly to open the page.

> I thought that COM was supposed to speed things up?

> What could be wrong with my COM objects or their implementation?

> Sometimes if I stop and start MTS, the speed of the whole site improves,
but
> this does not really help the difference in speed between the slow
> COM-object  pages and the faster basic ASP pages.

> Any help ideas for improvements gratefully appreciated



Mon, 27 Jan 2003 03:00:00 GMT  
 Performance of ASP pages calling COM object methods

Quote:

> The website I am working on is written mostly in ASP (VBScript), and also COM objects written in VB. The site has some components running under MTS. I have noticed that  when you request a page in your browser that also uses a COM object method, it is often slower to load than one of the ASP pages which just uses basic ASP and stored procedures with ADO. You get "Web site found, waiting for reply" in th browser as it crawls slowly to open the page.
> I thought that COM was supposed to speed things up? What could be wrong with my COM objects or their implementation?
> Sometimes if I stop and start MTS, the speed of the whole site improves, but this does not really help the difference in speed between the slow COM-object  pages and the faster basic ASP pages. Any help ideas for improvements gratefully appreciated

Because script is compiled the first time an ASP page is referenced, and
the pcode interpreted after that, it does not suffer greatly speed-wise
w.r.t. Visual Basic components. In addition, the VB libraries have a
great deal of  internal code that is useless in the web environment,
because VB was designed for Windows client/server apps. So you always
have the additional overhead (and possible introduction of bugs) by
those unneeded code fragments.

The upshot is that while, with a component the server is busy handling a
CreateObject call and loading the component, the script would already be
executing and doing useful work. So script can actually make better use
of memory and CPU cycles, and can outrun the component-based approach.
See http://www.microsoft.com/isn/whitepapers/tuningiis.asp for an
explanation of how Server.CreateObject calls can heavily load a server.

"Rule of thumb: unless there are at least 100 lines of script and some
big loops in that script, it's probably not worth thinking about
translating that page into a component."  Alex Homer, Dave Sussman,
Brian Francis, page 1042, "Active Server Pages 3.0"

(Wrox Press Ltd., 1999)
The book goes on to describe in more detail the circumstances under
which one should use components. Note the implication that any
component-based architecture requires that you do some very heavy
compute-bound work. This is not a common requirement.

Components are useful mainly for

a) functions that are not available in script, e.g., binary file write.(
Although Microsoft ought to make this and other functions available as
either intrinsic functions or as part of the FileSystemObject.)

b) security of code (e.g., for a vendor selling a product).

Your use of components in MTS (which is the slowest way to use
components) ensures that you incur the maximum component overhead, both
in creating objects in a separate process and in marshalling recordset
data across process boundaries.



Mon, 27 Jan 2003 03:00:00 GMT  
 Performance of ASP pages calling COM object methods

Quote:

> The website I am working on is written mostly in ASP (VBScript), and also
> COM objects written in VB.
> The site has some components running under MTS.
> I have noticed that  when you request a page in your browser that also uses
> a COM object method,
> it is often slower to load than one of the ASP pages which just uses basic
> ASP and stored procedures with ADO.
> You get "Web site found, waiting for reply" in th browser as it crawls
> slowly to open the page.
> I thought that COM was supposed to speed things up?
> What could be wrong with my COM objects or their implementation?
> Sometimes if I stop and start MTS, the speed of the whole site improves, but
> this does not really help the difference in speed between the slow
> COM-object  pages and the faster basic ASP pages.
> Any help ideas for improvements gratefully appreciated

If all your component does is execute SQL queries, then script will
ALWAYS outrun a component that executes the same SQL queries. Reason is,
component (creation/deletion/marshalling of recordsets) overhead is
significant and gives no performance boost. The boost in a component
comes only if the procedure is sufficiently compute-bound so that the
component can catch up and then outrun script. Here's are two timelines
that demonstrate this behavior:

 Case 1: Script executes SQL procedure:
 ======================================

 ASP Script >------------------|          |----->
       SQL procedure           |----------|              

 Case 2: Script calls component that executes SQL procedure:
 ===========================================================

 ASP Script >------------------|                |----->
       Create component        |-----|          |    
               SQL procedure         |----------|              

As you can see, in this case the simple script runs faster. As soon as
the second script begins to create a component, it starts to fall
behind.

Note that these diagrams do not allow for the additional time/memory
required to marshal a dataset across process boundaries, as one might
incur by using MTS with IIS. So there is even more overhead in using
components than is demonstrated here.

So before components pay off performance-wise, you must have a *lot* of
compute-bound code.



Mon, 27 Jan 2003 03:00:00 GMT  
 Performance of ASP pages calling COM object methods
I've created COM components using VFP to do the data handling and got a 8
times performance boost under NT vs doing the exact same thing using
ADO...In sp3 MS made a new slimmed down runtime for VFP for use when Dll's
are built that have all the UI code removed for faster loads...it
helps...Since VFP has its own native dataengine, the hundreds of COM calls
that can be necessary under ADO are eliminated...this accounts for the
greatest speed increase...Also, a third party product from West-wind.com
allows for the pooling of VFP COM servers...VERY efficient approach. Using
the MS Stress tool, this has handled over 55,000 database hits/hour...Not
too shabby...

--
Harold Chattaway
Senior Software Engineer
ASP Division
www.usdatacenters.com
508-481-0050 x 4106



Quote:
> The website I am working on is written mostly in ASP (VBScript), and also
> COM objects written in VB.
> The site has some components running under MTS.

> I have noticed that  when you request a page in your browser that also
uses
> a COM object method,
> it is often slower to load than one of the ASP pages which just uses basic
> ASP and stored procedures with ADO.
> You get "Web site found, waiting for reply" in th browser as it crawls
> slowly to open the page.

> I thought that COM was supposed to speed things up?

> What could be wrong with my COM objects or their implementation?

> Sometimes if I stop and start MTS, the speed of the whole site improves,
but
> this does not really help the difference in speed between the slow
> COM-object  pages and the faster basic ASP pages.

> Any help ideas for improvements gratefully appreciated



Tue, 28 Jan 2003 03:00:00 GMT  
 Performance of ASP pages calling COM object methods

If you move all page generation code to a VB MTS
object then you will observe the following w/WAST:

1.) At one client thread (not very real world) the
     ASP only version runs faster than the VB DLL.

2.) At ten client threads or more, the VB DLL yields
     much lower response times and higher scalability.

Original ASP code ADO__01.ASP - see Wayne Plourde's
articles at ASPToday for full ASP source and his initial
results. Links are:
http://www.asptoday.com/articles/20000426.htm
http://www.asptoday.com/articles/20000113.htm

<% Option Explicit %>
<!-- #Include file="ADOVBS.INC" -->
<%
Dim objConn
Dim objRS

Response.Write( _
 "<HTML><HEAD>" & _
 "<TITLE>ADO Test</TITLE>" & _
 "</HEAD><BODY>" _
)

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open Application("Conn")

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.ActiveConnection = objConn
objRS.CursorType = adOpenForwardOnly
objRS.LockType = adLockReadOnly
objRS.Open Application("SQL")

If objRS.EOF Then
 Response.Write("No Records Found")
Else
 'write headings
 Response.Write( _
  "<TABLE BORDER=1>" & _
  "<TR>" & _
  "<TH>OrderID</TH>" & _
  "<TH>CustomerID</TH>" & _
  "<TH>EmployeeID</TH>" & _
  "<TH>OrderDate</TH>" & _
  "<TH>RequiredDate</TH>" & _
  "<TH>ShippedDate</TH>" & _
  "<TH>Freight</TH>" & _
  "</TR>" _
 )
 'write data
 Do While Not objRS.EOF
  Response.Write( _
   "<TR>" & _
   "<TD>" & objRS("OrderID") & "</TD>" & _
   "<TD>" & objRS("CustomerID") & "</TD>" & _
   "<TD>" & objRS("EmployeeID") & "</TD>" & _
   "<TD>" & objRS("OrderDate") & "</TD>" & _
   "<TD>" & objRS("RequiredDate") & "</TD>" & _
   "<TD>" & objRS("ShippedDate") & "</TD>" & _
   "<TD>" & objRS("Freight") & "</TD>" & _
   "</TR> " _
  )
  objRS.MoveNext
 Loop
 Response.Write("</TABLE>")
End If

objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing

Response.Write("</BODY></HTML>")
%>

Modified ASP and VB code, equivalent to ADO__01.ASP.

<% Option Explicit
Dim oMTS, sOut

Set oMTS = Server.CreateObject("ASPTests.IProcedures")

sOut = oMTS.ADO__01(Application("Conn"), Application("SQL"))

Response.Write(sOut)

Set oMTS = Nothing
%>

Public Function ADO__01(Optional ByVal sConnect As String = CONNECT_STRING,
Optional ByVal sSQL As String = SQL_STATEMENT) As String
  Dim cn As ADODB.Connection
  Dim rs As ADODB.Recordset
  Dim oFast As cFastString

  On Error GoTo ehProc

  ClearErrorInfo
  Set oFast = New cFastString

  Call oFast.Append("<HTML><HEAD><TITLE>ADO Test</TITLE></HEAD><BODY>")

  Set cn = New ADODB.Connection
  cn.Open sConnect

  Set rs = New ADODB.Recordset
  With rs
    Set .ActiveConnection = cn
    .CursorType = adOpenForwardOnly
    .LockType = adLockReadOnly
    .Open sSQL
  End With

  If rs.EOF Then
    Call oFast.Append("No Records Found")
  Else
    'write headings
    Call oFast.Append("<TABLE
BORDER=1><TR><TH>OrderID</TH><TH>CustomerID</TH><TH>EmployeeID</TH><TH>Order
Date</TH><TH>RequiredDate</TH><TH>ShippedDate</TH><TH>Freight</TH></TR>")
    'write data
    Do While Not rs.EOF
      Call oFast.Append("<TR><TD>" & rs("OrderID") & "</TD><TD>" &
rs("CustomerID") & "</TD><TD>" & rs("EmployeeID") & "</TD><TD>" &
rs("OrderDate") & "</TD><TD>" & rs("RequiredDate") & "</TD><TD>" &
rs("ShippedDate") & "</TD><TD>" & rs("Freight") & "</TD></TR>")
      rs.MoveNext
    Loop
    Call oFast.Append("</TABLE>")
  End If

  Call oFast.Append("</BODY></HTML>")

  ADO__01 = oFast.Data

exProc:
  On Error Resume Next
  Set oFast = Nothing
  Call ADORSCleanup(rs)
  Call ADOCNCleanup(cn)
  If m_lError = 0 Then
    If Not m_ctxObject Is Nothing Then m_ctxObject.SetComplete
  Else
    If Not m_ctxObject Is Nothing Then m_ctxObject.SetAbort
    On Error GoTo 0
    Err.Raise m_lError, "ADO__01", m_sError
  End If
  Exit Function

ehProc:
  SaveErrorInfo
  Resume exProc
End Function

I keep meaning to find the time to summarize and
publish my observations. I'm working on something
else at the moment, but... someday.

--
Michael D. Long
http://extremedna.homestead.com



Quote:

> > The website I am working on is written mostly in ASP (VBScript), and
also
> > COM objects written in VB.
> > The site has some components running under MTS.
> > I have noticed that  when you request a page in your browser that also
uses
> > a COM object method,
> > it is often slower to load than one of the ASP pages which just uses
basic
> > ASP and stored procedures with ADO.
> > You get "Web site found, waiting for reply" in th browser as it crawls
> > slowly to open the page.
> > I thought that COM was supposed to speed things up?
> > What could be wrong with my COM objects or their implementation?
> > Sometimes if I stop and start MTS, the speed of the whole site improves,
but
> > this does not really help the difference in speed between the slow
> > COM-object  pages and the faster basic ASP pages.
> > Any help ideas for improvements gratefully appreciated

> If all your component does is execute SQL queries, then script will
> ALWAYS outrun a component that executes the same SQL queries. Reason is,
> component (creation/deletion/marshalling of recordsets) overhead is
> significant and gives no performance boost. The boost in a component
> comes only if the procedure is sufficiently compute-bound so that the
> component can catch up and then outrun script. Here's are two timelines
> that demonstrate this behavior:

>  Case 1: Script executes SQL procedure:
>  ======================================

>  ASP Script >------------------|          |----->
>        SQL procedure           |----------|

>  Case 2: Script calls component that executes SQL procedure:
>  ===========================================================

>  ASP Script >------------------|                |----->
>        Create component        |-----|          |
>                SQL procedure         |----------|

> As you can see, in this case the simple script runs faster. As soon as
> the second script begins to create a component, it starts to fall
> behind.

> Note that these diagrams do not allow for the additional time/memory
> required to marshal a dataset across process boundaries, as one might
> incur by using MTS with IIS. So there is even more overhead in using
> components than is demonstrated here.

> So before components pay off performance-wise, you must have a *lot* of
> compute-bound code.



Wed, 29 Jan 2003 03:00:00 GMT  
 Performance of ASP pages calling COM object methods

Quote:

> If you move all page generation code to a VB MTS
> object then you will observe the following w/WAST:

> 1.) At one client thread (not very real world) the
>      ASP only version runs faster than the VB DLL.

> 2.) At ten client threads or more, the VB DLL yields
>      much lower response times and higher scalability.

Master. "Sigh...Surely, Grasshopper, you must realize what this means?"
Grasshopper. "No, Master, enlighten me."

M. "The claim is:
'A single copy of program A (or similarly, a single thread) executes
faster than a single copy of program B, but 10 copies of program A
execute slower than 10 copies of program B.'"

G. "But how can this be, Master? What sort of magic spell has been cast
here?"

M. "Magic?  Indeed, if so, herein lies the solution to all computing
problems - the componentry Holy Grail- speed without limit! If a program
or component is too slow, we need only create more copies of it,
whereupon it will execute faster! Need more speed? Throw more copies of
the program at the problem! Ahhh, how long we have missed this simple
secret of performance! Once again computing nirvana is within our grasp:
we have the power to make any program execute at any speed by merely
creating more copies of it!"

G. "I think you are teasing me, My Lord. Perhaps it is a mystery not to
be known by us."

M. "A mystery? Then should we join the component Rosicrucians and take
up praying to the component gods for enlightenment?  Perhaps the magic
number 10 holds the secret? After all, 10 is divisible by 1, 2, 5, and
itself and is the only such positive integer. Perhaps we should build an
altar to the number 10: 'All praise to 10, the magic number whereat
components suddenly run faster than script!" And we should execute all
our code in units of 10, that magic number?'"

G. "Sometimes, Master, you demonstrate the qualities of a large bag of
hot air! Please, tease me no more, but enlighten me!"

M. "You are correct, Grasshopper, on both points. No, it is neither
magical nor a spiritual mystery: there is a rational explanation."

"These results mean only one thing: a particular resource needed by
program A becomes unavailable at some point between 1 and 10 copies,
whereas the same does not occur (or occurs to a lesser degree) for
program B. The copies of program A are not now executing more slowly
(i.e., using more CPU clock cycles) than the copies of program B - that
would be impossible; it is simply that some copies of program A are
waiting for a resource to become available."

"An example might be that ASP runs out of memory resources for the 8th,
9th, and 10th copy of an ASP page, or an IIS parameter is set so that
some resource is not available for more than 7 copies of program A."

"So what we are seeing is an illusion - an artifact of the system on
which the programs are running."

"The solution, Grasshopper, is not to switch to a component
architecture, but to increase that resource which is in short supply.
For example, one might change the web server settings appropriately or
even add more memory to the web server. This is two orders of magnitude
cheaper and much quicker and simpler than architecting or rewriting
everything to use components. What does 64 MB of memory cost today -
about an hour's time for a software monk?"

"Note that, if program A executes faster than program B, and each
program is an independent process or thread that does not rely upon the
execution of another copy of the same program(the usual case), it is
*always* possible to configure a system that will run N copies of
program A faster than N copies of program B."

"Most importantly, what applies to the single program/thread applies to
a collection of programs/threads."

Aside: FWIW Wayne Plourde's articles that were referenced don't examine
the use of components and do not support the contention stated.



Sat, 01 Feb 2003 03:00:00 GMT  
 Performance of ASP pages calling COM object methods
MTS and COM+ are used to scalibity not speed.  The first time you call
your object, it will take 1 to 2 seconds to kick in (depends on your
object), but the next time you hit it(before it shuts downs, usually 3
minutes), it should be instant.
In MTS or COM+ you can have your object run at all times.  It's under
properties of your package name.


Sat, 01 Feb 2003 03:00:00 GMT  
 Performance of ASP pages calling COM object methods

I only posted a single result, though I performed
several weeks of testing on various hardware. The
underlying issue is neither CPU nor memory, as
moving to a dual CPU machine with 1Gb RAM did
not change the characteristics.

Also, increasing the number of threads results in
a corresponding divergence in the latency.

WRT Wayne's articles, the very reason that I chose
to implement the same code as components (with
minor corrections) is because he did not explore the
use of objects in any scenario. Also, could you clarify
"do not support the contention stated" - I do not
understand your reference, and as I am traveling do
not have access to all normal resources.

I liked your Master Po. :-)

--
Michael D. Long
http://extremedna.homestead.com



Quote:

> > If you move all page generation code to a VB MTS
> > object then you will observe the following w/WAST:

> > 1.) At one client thread (not very real world) the
> >      ASP only version runs faster than the VB DLL.

> > 2.) At ten client threads or more, the VB DLL yields
> >      much lower response times and higher scalability.

> Master. "Sigh...Surely, Grasshopper, you must realize what this means?"
> Grasshopper. "No, Master, enlighten me."

> M. "The claim is:
> 'A single copy of program A (or similarly, a single thread) executes
> faster than a single copy of program B, but 10 copies of program A
> execute slower than 10 copies of program B.'"

> G. "But how can this be, Master? What sort of magic spell has been cast
> here?"

> M. "Magic?  Indeed, if so, herein lies the solution to all computing
> problems - the componentry Holy Grail- speed without limit! If a program
> or component is too slow, we need only create more copies of it,
> whereupon it will execute faster! Need more speed? Throw more copies of
> the program at the problem! Ahhh, how long we have missed this simple
> secret of performance! Once again computing nirvana is within our grasp:
> we have the power to make any program execute at any speed by merely
> creating more copies of it!"

> G. "I think you are teasing me, My Lord. Perhaps it is a mystery not to
> be known by us."

> M. "A mystery? Then should we join the component Rosicrucians and take
> up praying to the component gods for enlightenment?  Perhaps the magic
> number 10 holds the secret? After all, 10 is divisible by 1, 2, 5, and
> itself and is the only such positive integer. Perhaps we should build an
> altar to the number 10: 'All praise to 10, the magic number whereat
> components suddenly run faster than script!" And we should execute all
> our code in units of 10, that magic number?'"

> G. "Sometimes, Master, you demonstrate the qualities of a large bag of
> hot air! Please, tease me no more, but enlighten me!"

> M. "You are correct, Grasshopper, on both points. No, it is neither
> magical nor a spiritual mystery: there is a rational explanation."

> "These results mean only one thing: a particular resource needed by
> program A becomes unavailable at some point between 1 and 10 copies,
> whereas the same does not occur (or occurs to a lesser degree) for
> program B. The copies of program A are not now executing more slowly
> (i.e., using more CPU clock cycles) than the copies of program B - that
> would be impossible; it is simply that some copies of program A are
> waiting for a resource to become available."

> "An example might be that ASP runs out of memory resources for the 8th,
> 9th, and 10th copy of an ASP page, or an IIS parameter is set so that
> some resource is not available for more than 7 copies of program A."

> "So what we are seeing is an illusion - an artifact of the system on
> which the programs are running."

> "The solution, Grasshopper, is not to switch to a component
> architecture, but to increase that resource which is in short supply.
> For example, one might change the web server settings appropriately or
> even add more memory to the web server. This is two orders of magnitude
> cheaper and much quicker and simpler than architecting or rewriting
> everything to use components. What does 64 MB of memory cost today -
> about an hour's time for a software monk?"

> "Note that, if program A executes faster than program B, and each
> program is an independent process or thread that does not rely upon the
> execution of another copy of the same program(the usual case), it is
> *always* possible to configure a system that will run N copies of
> program A faster than N copies of program B."

> "Most importantly, what applies to the single program/thread applies to
> a collection of programs/threads."

> Aside: FWIW Wayne Plourde's articles that were referenced don't examine
> the use of components and do not support the contention stated.



Tue, 04 Feb 2003 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Performance of ASP pages calling COM object methods

2. com object will not read registry when com object called from asp (vb works fine)

3. Calling a COM call back object's method fails if it is in Windows 98

4. Calling a COM Method with optional arguments from ASP

5. Calling a COM Method with optional arguments from ASP

6. COM-Object in ASP with COM-Object as parameter

7. calling asp page from another asp page

8. COM-Object in ASP with COM-Object as Parameter

9. COM hangs when called from vbscript in asp page

10. Calling an ASP page (http) using a COM component

11. Maybe a newbie question : Howto have a timeout on a COM Object method call

12. Problem calling a method of a COM object with VB

 

 
Powered by phpBB® Forum Software