473,396 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CGI PHP vs. FastCGI vs. mod_php vs. application server?

Hello

I'm interested in hearing reflections by seasoned web app
developpers about the different ways to write PHP apps, and especially
how they compare in terms of performance, whether it's the PHP part or
connections to MySQL.

As far as I know, there are different ways to write a PHP application:
- CGI, ie. the usual way : some PHP code in web pages, and the PHP
interpreter is loaded each time a PHP page is called
- FastCGI : apparently, the interpreter is loaded at boot time; the
application itself might also be compiled and loaded once
- mod_php : same as FastCGI?
- application server : the application is compiled and loaded once;
the application can either have its own web server, or use a web
server as front end, and only handle its own part

Any tips much appreciated, thank you.
Jan 3 '07 #1
7 25696
NC
Vincent Delporte wrote:
>
I'm interested in hearing reflections by seasoned web app
developpers about the different ways to write PHP apps,
and especially how they compare in terms of performance,
whether it's the PHP part or connections to MySQL.
On which HTTP server?
As far as I know, there are different ways to write a PHP application:
- CGI, ie. the usual way : some PHP code in web pages, and the
PHP interpreter is loaded each time a PHP page is called
Yes, but it has not been the usual way for years; most hosting
companies these days do either FastCGI or mod_php.
- FastCGI : apparently, the interpreter is loaded at boot time; the
application itself might also be compiled and loaded once
Also, the preferred way of running PHP under Zeus.
- mod_php : same as FastCGI?
Nope. Different executables. mod_php is a library which Apache
uses to process PHP scripts (there is a similar library for IIS as
well). FastCGI is a standalone executable.
Any tips much appreciated, thank you.
Check the documentation for your HTTP server. It will likely have
some information about performance improvement with PHP.
Generally speaking, CGI is the worst performer. The choice
between FastCGI and server modules will depend on the HTTP
server you are using.

Cheers,
NC

Jan 3 '07 #2
On 3 Jan 2007 11:32:19 -0800, "NC" <nc@iname.comwrote:
>Check the documentation for your HTTP server. It will likely have
some information about performance improvement with PHP.
Generally speaking, CGI is the worst performer. The choice
between FastCGI and server modules will depend on the HTTP
server you are using.
I'm free to use any server that I want since it'll be hosted on our
premises. Apart from loading the PHP interpreter at boot time, what
else do FastCGI and Apache's mod_php do to increase performance? Do
they compile PHP scripts into bytecode once, do they leave connections
to MySQL open, other things?

Thank you.
Jan 3 '07 #3
On what operating system are you running? I have been very pleased with
Apache 2.0.xx on Win XP pro (although I would prefer to run it on win
2k). The downside is that certain libraries and features aren't ported
to win32 just yet. In a *nix environment, Apache is a very good choice.

I've only used FastCGI with ruby on rails, while I always use mod_php
for PHP. I couldn't provide a fair comparison. Have you googled around?
People have probably performed various tests on performance issues
related to yours.

On Jan 3, 11:45 am, Vincent Delporte <just...@acme.comwrote:
On 3 Jan 2007 11:32:19 -0800, "NC" <n...@iname.comwrote:
Check the documentation for your HTTP server. It will likely have
some information about performance improvement with PHP.
Generally speaking, CGI is the worst performer. The choice
between FastCGI and server modules will depend on the HTTP
server you are using.I'm free to use any server that I want since it'll be hosted on our
premises. Apart from loading the PHP interpreter at boot time, what
else do FastCGI and Apache's mod_php do to increase performance? Do
they compile PHP scripts into bytecode once, do they leave connections
to MySQL open, other things?

Thank you.
Jan 4 '07 #4
Vincent Delporte wrote:
On 3 Jan 2007 11:32:19 -0800, "NC" <nc@iname.comwrote:
>>Check the documentation for your HTTP server. It will likely have
some information about performance improvement with PHP.
Generally speaking, CGI is the worst performer. The choice
between FastCGI and server modules will depend on the HTTP
server you are using.


I'm free to use any server that I want since it'll be hosted on our
premises. Apart from loading the PHP interpreter at boot time, what
else do FastCGI and Apache's mod_php do to increase performance? Do
they compile PHP scripts into bytecode once, do they leave connections
to MySQL open, other things?

Thank you.
No, they don't compile PHP into bytecode. The best you're going to do
is to get a package to cache the compiled PHP.

And MySQL connections are generally best NOT being left open. Open
connection still require system resources, even when they are not being
used. And you would need the maximum possible number of connections you
would ever need open all the time.

But I really think you're worrying about performance problems that don't
exist. Just get yourself a decent server, load a good Linux distro and
Apache server on it and go.

Once you've got your site up, see if you have performance problems. If
so, figure out where those problems are and fix them.

Hint: If you do have problems, they won't be in the PHP compiler or
MySQL connection code.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jan 4 '07 #5
On Thu, 04 Jan 2007 09:06:56 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>But I really think you're worrying about performance problems that don't
exist. Just get yourself a decent server, load a good Linux distro and
Apache server on it and go.
OK, but I'd rather know up-front what's available to raise performance
should I have the problem, especially if that involves writing code in
a certain way to use eg. FastCGI, or even using totally different
tools such as writing this as an application server instead of *CGI
like PHP.

So there's no good real-life comparison available to compare those
four solutions to write web applications? For instance, I'd be
intested in hearing about business apps written in PHP in (CGI |
FastCGI | mod_php) vs. Java as an application server. Does it make a
difference? If not, did all those companies choose Java because of the
libraries?

What I'm driving at, is that I'd like to choose a technology based on
real-life data, not just because it's well know (whether it's PHP,
Ruby, Java, etc.)

Thank you.
Jan 4 '07 #6
NC
Vincent Delporte wrote:
>
I'd rather know up-front what's available to raise performance
should I have the problem,
The best thing you can do as a developer is come up with good
data architecture, write efficient SQL and, to borrow a phrase
from Yahoo's Michael Radwin, "use abstraction sparingly".
Most bottlenecks in Web applications come from the database
sever anyway... Beyond that, it's basic programming: efficient
memory use, fast algorithms, etc. Beyond that, it's pure system
administration: use a PHP accelerator, consider enabling
query cache, make sure you have adequate memory on your
system, fine-tune your database server, etc.

With application software already written and deployed, the
only way to "raise performance" (especially in response to
increasing loads) is to change the hardware architecture. First,
you split the front end and the back end (i.e., you have a
dedicated HTTP server and a dedicated database server, each
properly configured for the task). Eventualy, the load may
surpass the capacity of this architecture, and you will have to
further transition to a server cluster (a layer of HTTP servers
and a layer of database servers with load balancing all around).
So there's no good real-life comparison available to compare those
four solutions to write web applications? For instance, I'd be
intested in hearing about business apps written in PHP in (CGI |
FastCGI | mod_php) vs. Java as an application server.
CGI is patently inferior compared to both FastCGI and mod_php.
On Apache, both FastCGI and mod_php work well. Most ISPs
prefer mod_php, but Yahoo!, for one, likes FastCGI better
(perhaps it has something to do with the fact that most ISPs
run on Linux, whereas Yahoo! prefers FreeBSD). On Zeus,
developers recommend FastCGI.

As to Java, it is not an application server; you can use it with
different application servers (Tomcat, JBOSS, PowerTier,
WebLogic, WebSphere, etc.) Those may have vastly different
performance (and vastly different price tags).
Does it make a difference?
Here's what Joel Spolsky once had to say on the subject:

the bottom line is that there are three and a half platforms
(C#, Java, PHP, and a half Python) that are all equally
likely to make you successful, an infinity of platforms
where you're pretty much guaranteed to fail spectacularly
when it's too late to change anything (Lisp, ISAPI DLLs
written in C, Perl), and a handful of platforms where The
Jury Is Not In, So Why Take The Risk When Your Job Is On
The Line? (Ruby on Rails)... Python get a half because
it's on the border, about to cross the line from an
"interesting" choice to a "safe" choice.

http://www.joelonsoftware.com/items/2006/09/01.html
If not, did all those companies choose Java because of the
libraries?
No, because they had developers well-versed in Java and
a nice round budget for a big-ticket items such as WebLogic/
WebSphere and Oracle. Companies that tried developing
high-load Java applications on a low budget (as in Tomcat +
MySQL) didn't get very far; Friendster, for one, was plagued
with performance problems so pervasive that they had to
switch to PHP. There probably was an alternative, to switch
from MySQL to Oracle and from Tomcat to a commercial
application server, but they may have figured that the licenses
are going to cost more than a complete rewrite of the front
end...
What I'm driving at, is that I'd like to choose a technology
based on real-life data,
There is no real-life data. There is only anecdotal evidence.
And you almost never know whether a particular project failed
to meet the requirements because of the poor platform choice
or because developers were inept, or because the planets
were aligned unfavorably... Even people who worked on such
projects often disagree as to the cause of failure; what can
outsiders know for sure?

Cheers,
NC

Jan 4 '07 #7
On 4 Jan 2007 10:00:53 -0800, "NC" <nc@iname.comwrote:
>Most bottlenecks in Web applications come from the database
sever anyway... Beyond that, it's basic programming: efficient
memory use, fast algorithms, etc. Beyond that, it's pure system
administration: use a PHP accelerator, consider enabling
query cache, make sure you have adequate memory on your
system, fine-tune your database server, etc.
Thanks a lot for the feedback. I'll see if I can write a prototype in
PHP then run it in *CGI and mod_php, then rewrite it as a Python-based
application server, and compare performances.

Cheers,
Jan 4 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jean Paul | last post by:
Can someone explain to me what java enterprise edition is?? I've been looking into the web for some info, but can't really make sense of the info found. Is there also an tutorial avaible? I've...
3
by: Varkey | last post by:
Dear friends, I am new to .NET based app development and have a pretty elementary query, I suppose... I have caught up with the basics of .NET pretty well, thanks to some Microsoft VB/ASP...
4
by: Chris Gatto | last post by:
Hello, My organization is currently considering the purchase of a new intranet application server and we are looking for opinions from those who have been down this road before. In brief the...
3
by: DMina | last post by:
Hello there! I have the following configuration. Two AIX Servers: the first is server as an application server (SAP SEM) and the second as the database server (DB2 V7.2 with FIXPAK 12). The...
0
by: JustinRU | last post by:
I have an application that runs on one server with the database located on another database server. So when I run the application and upload a file through it, it gets saved to c:/mydirectory. ...
10
by: Vincent Delporte | last post by:
Hi I'm still a newbie when it comes to web applications, so would like some help in choosing a solution to write apps with Python: What's the difference between using running it through...
3
by: =?Utf-8?B?QkY=?= | last post by:
In Microsoft architecture diagrams, I always see 3 layers of application structure: web server, application server and database server. Web server is IIS. Database server is SQL server. What...
1
by: jchau | last post by:
Is anyone has any idea what i need to do if i would like to integrate the IIS with other application server, where the IIS will serves as a front end web server and forward the request to the...
0
by: sathyguy | last post by:
when i type the below in my RHEL AS 4's Firefox 1.5 http://appsworld.ncc.com:7777/forms/...&form=test.fmx iam getting the below error... The requested URL /forms/frmservlet was not found on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.