Connecting Tech Pros Worldwide Help | Site Map

How long is too long for a cgi script?

  #1  
Old July 17th, 2005, 01:53 PM
el_roachmeister@yahoo.com
Guest
 
Posts: n/a
I have a 4000 line php cgi script that is not memory or cpu intensive.
It runs in 1 second. 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). 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.

  #2  
Old July 17th, 2005, 01:53 PM
NC
Guest
 
Posts: n/a

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


el_roachmeis...@yahoo.com wrote:[color=blue]
>
> I have a 4000 line php cgi script that is not memory or cpu
> intensive. It runs in 1 second.[/color]

Memory and CPU are not the only resources you should watch
out for. I/O (Input/Output) can be a bottleneck, too.
[color=blue]
> 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).[/color]

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?
[color=blue]
> 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.[/color]

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

  #3  
Old July 17th, 2005, 01:54 PM
el_roachmeister@yahoo.com
Guest
 
Posts: n/a

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


I realize my question is a bit vague. How about comparing to other
commercial php scripts? How big are some of the better forum scripts?

  #4  
Old July 17th, 2005, 01:54 PM
Malcolm Dew-Jones
Guest
 
Posts: n/a

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


el_roachmeister@yahoo.com wrote:
: I realize my question is a bit vague. How about comparing to other
: commercial php scripts? How big are some of the better forum scripts?

It's an irrelevent comparison.

However, you might want to learn about things like "include_once" and
"require_once". They are very useful for larger projects.

--

This space not for rent.
  #5  
Old July 17th, 2005, 01:55 PM
Colin McKinnon
Guest
 
Posts: n/a

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


el_roachmeister@yahoo.com wrote:
[color=blue]
> I realize my question is a bit vague. How about comparing to other
> commercial php scripts? How big are some of the better forum scripts?[/color]

If you're not getting 100% code coverage of the 4000 lines it might be
better to split some of the code which is not always run off into
conditionally included files.

HTH

C.
  #6  
Old July 17th, 2005, 01:55 PM
Chung Leong
Guest
 
Posts: n/a

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


Why only one script? You application isn't just one page, right?

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Upload Files using the CGI.pm Module and Perl KevinADC insights 17 February 3rd, 2009 03:53 AM
how to check for all the fields in user registrations perl script happyse27 answers 82 November 3rd, 2008 02:39 AM
How to check in CGI if client disconnected Vishal answers 7 August 25th, 2008 12:35 PM
Apache Cgi (70007)The timeout specified has expired naima.mans@gmail.com answers 2 February 23rd, 2007 04:05 PM