Board index » delphi » What factors affect speed of a CGI app?

What factors affect speed of a CGI app?

Ok,

 I've written my stripped-down very-fast RPC server console-based CGI app.
It weighs in at only 100k and, locally on my laptop,  I can execute it
sequentially 1000 times in 15ms.

 However, when I upload it to my webserver I can only seem to get results
back every 1.5 seconds or so. And if I run several iterations of the
requesting RPC client the speed drops for all of them (even when run from
different locations).

 Now how does a CGI app which only requires .015ms to run bog down on the
webserver with a few requests a second?

 What are some of the factors that I need to look at for increasing
efficiency of such an application. My web pages from the same server come up
faster. ASP pages launch faster.

 Any thoughts? I'd be happy to share the source if anyone's interested.

TIA,
Chad Jones

 

Re:What factors affect speed of a CGI app?


In article <3c3b60b8_2@dnews>, "Chad Jones" <chad @ avatarsoft.com>
says...
Quote
> Ok,

>  I've written my stripped-down very-fast RPC server console-based CGI app.
> It weighs in at only 100k and, locally on my laptop,  I can execute it
> sequentially 1000 times in 15ms.

>  However, when I upload it to my webserver I can only seem to get results
> back every 1.5 seconds or so. And if I run several iterations of the
> requesting RPC client the speed drops for all of them (even when run from
> different locations).

>  Now how does a CGI app which only requires .015ms to run bog down on the
> webserver with a few requests a second?

I can think of several different things:

A) Capacity of the web-server.
B) Traffic on the server
C) A potential leak that might not be obvious on a samell scale (like
your local tests) but could be obvious on a larger scale
D) Operating system differences on the server or your system.
E) Differences in the web-server.
F) Distance between you and the server.

--
Support the anti-Spam amendment - Join at http://www.cauce.org/
J. Peter Mugaas     E-Mail:  oma00...@mail.wvnet.edu
http://wvnvm.wvnet.edu/~oma00215/  ICQ Number:  14297043
Finger for PGP Key

Re:What factors affect speed of a CGI app?


"Chad Jones" <chad @ avatarsoft.com> wrote in message
news:3c3b60b8_2@dnews...

Quote
>  I've written my stripped-down very-fast RPC server console-based CGI app.
> It weighs in at only 100k and, locally on my laptop,  I can execute it
> sequentially 1000 times in 15ms.

You executed the executable 1000 times in 15ms? That's certainly fast.

Did you also establish a pipe to capture the console output each time? (and
read the result back from the pipe?) There's probably some overhead with
pipes and stuff, but not so much to explain the discrepancy you're seeing?
Also check the event log on the webserver to make sure it's not something
completely different. The webserver runs in a different user context, so
another possibility is that your CGI depends on 'something' that takes a
while to time out...

How much CPU usage do you observe on the webserver before you invoke the CGI
(and during)?

(That said, this is a WinSock newsgroup -- CGI talk might be more
appropriate in the isapi-webbroker or webservices newsgroups and OS
performance related issues is probably best addressed in the winapi
newsgroup. If you don't get any good answers here, you migth want to give
the question a go elsewhere)

--
Rune

Re:What factors affect speed of a CGI app?


Here goes..... (puts hand over head and dives in)

"Chad Jones" <chad @ avatarsoft.com> wrote in message
news:3c3b60b8_2@dnews...

Quote
> Ok,

>  I've written my stripped-down very-fast RPC server console-based CGI app.
> It weighs in at only 100k and, locally on my laptop,  I can execute it
> sequentially 1000 times in 15ms.

This is when performing WinExecAndWait commands right?  you know
CreateProcess and WaitforSingleObject

Quote

>  However, when I upload it to my webserver I can only seem to get results
> back every 1.5 seconds or so. And if I run several iterations of the
> requesting RPC client the speed drops for all of them (even when run from
> different locations).

What webserver are you using?  CGI's can be very slow one some webservers
depending upon the implementation of the CGI execution routine.

Quote

>  Now how does a CGI app which only requires .015ms to run bog down on the
> webserver with a few requests a second?

This really depends on your web server, and the speed of your machine.  For
example you may have a slow machine, and things really do take 1000 times
longer (highly unlikely). The server Software may be stealing all the
machines CPU cycles, so you small program doesn't get much of a lookin. the
server may have a delay loop when waiting for a response, this will cause
your program to take an abnormal amount of time through no fault of it's
own.

What operating system are you using on your server.  I remember reading
somewhere that windows 95/98/me has a minumum timeslice of 55ms, whilst
NT/2000/XP is capable of 11ms.  I've also been told that 95/89/me can only
handle around 100 TCP connections, but that's not confirmed, and I'm sure
that somone here is capable of more.

How are you timing the program?  If you're testing be using a deplhi
launcher for you 1000 iterations and a web browser for the slow test, then
that's not really being fair.  Remember that the first test is designed
specifically to run your app, whilst the second test isn't.  In fact, if
you're using a web browser, then you need to take the following into
account:-

1. Time to make a connection to your web server. if it's on the same machine
it'll be fast, but it still takes time
2. Time to make the HTTP request. The browser has to ask for the url to be
downloaded.
3. Time for the server to decode the request and invoke your CGI program.
4. Time to read the result of the CGI program from the stdout of the CGI app
5. Time to send the info read from the stdout into the socket
6. Time for the information to be read by your browser
7. Time to render the HTML page for display
8. Time to paint the screen.

Your 1000 iterations will only be simulating the bit in between items 3 & 4.
As you can see there's alot of stuff that needs to happen here.

I apologise if I've just taught you to suck eggs.

Having said that 1.5 seconds does seem to be a bit long.  Is that for just
one attempt, or for several?

Can you send me a copy of the source, I'd like to try it on my web server,
to see if that's any quicker.  (My server is a Delphi based server using
Indy 9, but it's still in Alpha testing)

Regards

Colin Dawson
n...@cdawson.tele2.co.uk

Re:What factors affect speed of a CGI app?


You may want to see the following:

1) Grab a copy of cgiexpert.
2) Write a simple program to return a dynamic page.
3) Test invocation time.
4) Rewrite as persistent cgi program with cgiexpert (not sure if eval let's
you do this).
5) Test invocation time.

I think Rune, JP and Colin hit it on the head.  Find out where the
bottleneck is.  It may just be your web server and it's CGI invocation
logic.

What web server are you using?

Charles

"Chad Jones" <chad @ avatarsoft.com> wrote in message
news:3c3b60b8_2@dnews...

Quote
> Ok,

>  I've written my stripped-down very-fast RPC server console-based CGI app.
> It weighs in at only 100k and, locally on my laptop,  I can execute it
> sequentially 1000 times in 15ms.

>  However, when I upload it to my webserver I can only seem to get results
> back every 1.5 seconds or so. And if I run several iterations of the
> requesting RPC client the speed drops for all of them (even when run from
> different locations).

>  Now how does a CGI app which only requires .015ms to run bog down on the
> webserver with a few requests a second?

>  What are some of the factors that I need to look at for increasing
> efficiency of such an application. My web pages from the same server come
up
> faster. ASP pages launch faster.

>  Any thoughts? I'd be happy to share the source if anyone's interested.

> TIA,
> Chad Jones

Other Threads