Celeritas
Celeritas

Reputation: 15033

Is CGI still slow when used with a compiled program that doesn't require a VM?

When I learned CGI I learned that any programing language can be used to hook it's output to the http response message and it's input is the http request message. Many articles I've red talk about CGI in the context of Perl, is this because Perl is the most common language used in conjunction with CGI?

What I'm wondering is if CGI connects to a program written in C/C++ would it still be slower than using PHP?

Upvotes: 2

Views: 1940

Answers (1)

stew
stew

Reputation: 491

CGI is a standard denoting how an application should interact, not a specific program itself.
The reason CGI is often too slow is because it requires a process to be started for the request and closed at the end of that request.

FastCGI differs from CGI in that it allows a process to serve multiple requests (it maintains a pool of request processors). This way the lengthy process startup/shutdown can be avoided for the majority of incoming requests.

For more information on CGI and its 'successors' take a look at http://en.wikipedia.org/wiki/Common_Gateway_Interface#Drawbacks

With this in mind, the performance characteristics depend not only on the language and its implementation, but also the interface used to process requests.

It is likely for a lot of simple requests the process startup time will far outweigh the processing time, making the language X vs Y argument moot.

Upvotes: 5

Related Questions