HingyGuy
11-20-2002, 05:57 AM
Hi all,
I have a question ...
Out of CGI/PHP/Perl what is the most expensive on the server resources, ie: CPU/memory ....
I know things like JavaScript run on client so it's not a problem and normal Java does not come into the equation. C++ code is also a diffrent story and not under discussion.
From what I have heard/seen CGI is a bit of a resource monster and PHP is quite light ....
Are there any others major scripting languages that I have missed?
Thanks all ...
akashik
11-20-2002, 07:12 AM
A lot of it will depend on the script, and the coding, but all things being equal, perl is considered the 'heavier' of the two.
Greg Moore
HingyGuy
11-20-2002, 07:22 AM
The two ??
ok so: 'cgi' then 'perl' then 'php' in order from greediest to lightest ?
txs
akashik
11-20-2002, 07:26 AM
perl is cgi - or rather perl is a cgi.
CGI: 1. Abbreviation for common gateway interface. A means for allowing programs or scripts (usually written in C++ or Perl) to add functionality to the World Wide Web. Note: Examples are search engines, feedback forms, and guestbooks. [Bahorsky] 2. Abbreviation for computer graphics interface.
Greg Moore
HingyGuy
11-20-2002, 07:45 AM
Aha .. Ok .. so to be on the safe side I'll try and keep all my stuff to PHP ..
Txs for the info
Alex042
11-20-2002, 08:35 AM
You missed ASP as a major script and there's also JSP which isn't quite as common.
chrisb
11-20-2002, 01:57 PM
Just to clarify...
Perl is NOT CGI. CGI is a gateway; perl is a programming language used for CGI as well as non-CGI. Many languages can be used for CGI.
2host.com
11-21-2002, 12:40 AM
The question isn't correct.
PHP can run as a web server module or as CGI.
Perl can run as a web server module or as CGI.
The question should be: "Which is more efficient, CGI or a web server module?"
The answer would depend on what you are trying to do, how you go about doing it and how well that web server module is coded and implemented.
Then you can look at the actual code that someone wrote to use in the web server module interface as opposed to a CGI interface.
Python, Perl, C, C++, PHP and others, all can run in a web server module environment or as CGI. Then it comes down to the language itself. For example, Perl in a web server module environment will be faster than PHP, if implemented properly. C or C++ run in a web server module will run faster than Perl, if implemented properly. Then it comes down to the code, the skills of the programmer, how well the web server is set up, what it's best suited for.
Then you have the module itself, how it's built it. What language the actual web server module itself is coded in. A web server module can be coded in C, C++, Perl (but not PHP). A web server module written in C will be faster than one written in Perl, for example. It's all relative, and shouldn't be confused as a few posts above seem to indicate.
If your question is a web server module faster than CGI. Probably, but not always. It depends on the module and how well that was written to be able to run the code people write for it. In usual cases, a well written, well implemented web server module will run code more efficiently than CGI (not necessarily significantly faster or more efficient), as CGI produces overhead for each request. But a less than great module will probably not make a huge difference, if any, and could make things worse.
The PHP module is not one of those in the 'worse' category though, so it will often be more efficient than CGI. The problems come in now though, that few PHP scripts are coded well enough to take advantage of the efficiency increase. Therefore it doesn't help much or at all in a lot of cases. The downside to modules in that case, is that they do not allow you to limit the user's individually like you can with CGI and a CGI wrapper.
When all is said and done, I'd recommend learning everything you need to know to write your own web server modules. Create them for specific needs and create a wrapper function that will allow you to limit the usage in the module form. Otherwise I'd recommend that you just run CGI, which will offer you better control over processing and allow users to have better security over their files in a shared server environment. If nothing else, to hack the PHP module code to offer the ability to limit processes per user and allow users to set more secure file permissions. As you can see, there are pros and cons or a lot of work involved with either option to say what one is better.