By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,405 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,405 IT Pros & Developers. It's quick & easy.

How long is too long for a cgi script?

P: 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.

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
NC
el_roachmeis...@yahoo.com 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

Jul 17 '05 #2

P: n/a
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?

Jul 17 '05 #3

P: n/a
el*************@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.
Jul 17 '05 #4

P: n/a
el*************@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?


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.
Jul 17 '05 #5

P: n/a
Why only one script? You application isn't just one page, right?

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.