Running PHP in CGI vs. FastCGI


The design differences between the two approaches are quite small, so you can try your very application with both.

In general, unless poor programming techniques get involved, FastCGI yields to better performance results than CGI at least because:

1. process start up fee is paid only once (scheduler allocates resources);
2. application initialisation and finalisation fees are paid only once (system resources, such as DB connections and file descriptors, get acquired but not released for every request)

I should warn however, that:

3. Even small memory leaks can lead to disasters in FastCGI;
4. The 'resource clean-up' among requests should be designed and implemented very carefully, otherwise it will cost more than a process cost to start up.

Therefore, to summarise, if you are certain that you have coded your site(s) to handle resources efficiently, closing sockets and cleaning up after execution, then FastCGI may produce better performance. However, if this is not the case, or you have any memory leaks in your code, then CGI will be safer.

Last update:
2011-07-18 14:55
Author:
Nick Fawbert
Revision:
1.0
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category

Tags

top