Re: How long is too long for a cgi script?



el_roachmeis...@xxxxxxxxx wrote:
>
> I have a 4000 line php cgi script that is not memory or cpu
> intensive. It runs in 1 second.

Memory and CPU are not the only resources you should watch
out for. I/O (Input/Output) can be a bottleneck, too.

> Now I am getting a lot of customer requests to add in new
> features. My question is if there is a point where my code
> will be too long and take too long to run (i.e > 5 seconds).

This is not a one-dimensional problem. Yes, increasing the
amount of code in the script will result in increasing time
to run, other things being equal. The problem is that other
things are NOT equal. Running time is NOT a linear function
of the script size. A lot depends on what kind of code you
add; calls to file systems (especially remote file systems)
and databases are particularly expensive.

Also, you mentioned your script was CGI... Are you using the
term "CGI" loosely or is your installation of PHP in fact a
CGI installation as opposed to, say, Apache module installation?
If so, what is the reason?

> I would really like to have my script rival the functionality
> of a desktop application but can php do it?
>
> My server is a dual processor with 2GB ram.

It's not a question of whether PHP can do it, but rather the
question of whether you can afford the hardware and bandwidth
to make it happen. A few hundred megabytes of RAM will be used
just to keep the server running (OS and daemons). Apache will
consume a few hundred kilobytes per connection (the exact number
depends on what modules are enabled), MySQL, another fifty or so.
Then there's a question of how much RAM your script requires.
If we assume that a single copy of the script requires a megabyte
of RAM (including memory allocated by Apache and MySQL) to run
and the system memory is 500 megabytes, you should be able to
serve up to (2000 - 500) / 1 = 1500 users. The problem is, if
you use a database server, it will probably be unable to serve
1500 simultaneous connections, unless you have some serious
enterprise-class hardware, meaning that I/O trumps memory and
CPU yet again...

Cheers,
NC

.



Relevant Pages

  • Re: Apache: limiting the execution place
    ... They want it so users can't use FTP, shell, or a CGI or PHP script to view, ... other users via shell, FTP, web server processes (such as PHP or CGI ...
    (Security-Basics)
  • Re: Upload files message
    ... the Perl upload works by using one script to save the ... Would be fairly simple to implement the same functionality with a PHP CGI. ... having the window there already, in a little iframe on the page. ...
    (comp.lang.php)
  • Re: Recommend PHP-Based Dashboard?
    ... and this is to illicite a response from php developers in a php usenet group trying to foster some kind of fear in us all that you may change your mind and go java or windows or mac? ... as i run true cgi scripts from the cgi exe *all the time* from the command-line, i assure you that you're wrong. ... the above explicitly states that i must use a feature of cgi in order to be considered a cgi script. ...
    (comp.lang.php)
  • Re: Recommend PHP-Based Dashboard?
    ... and this is to illicite a response from php developers in a php usenet group trying to foster some kind of fear in us all that you may change your mind and go java or windows or mac? ... as i run true cgi scripts from the cgi exe *all the time* from the command-line, i assure you that you're wrong. ... the above explicitly states that i must use a feature of cgi in order to be considered a cgi script. ...
    (comp.lang.php)
  • Re: Making a .php page a .cgi page
    ... I have written a PHP page which reports this abuse as per $_SERVER. ... My intentions were to replace the .cgi script with this .php script. ... And if I replace thescript.cgi with my PHP page, because it's not a Perl script yet ends in .cgi Apache is saying "Exec format error: ...
    (comp.lang.php)