473,721 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 25717
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.comwr ote:
>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.c omwrote:
On 3 Jan 2007 11:32:19 -0800, "NC" <n...@iname.com wrote:
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.comwr ote:
>>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*******@attgl obal.net
=============== ===
Jan 4 '07 #5
On Thu, 04 Jan 2007 09:06:56 -0500, Jerry Stuckle
<js*******@attg lobal.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
"interestin g" 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.comwr ote:
>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
2431
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 found one at the java site, but there it was attached to an application server. And that's my second question, what is a application server and what can u do with it?? Thnx someone.....
3
1649
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 background and helpful colleagues... The query goes... In a DOTNET based desktop application environment, does it make sense to have each copy of the installed application from the different
4
2228
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 server must support the following: - 600+ users using various ASP.Net based applications, only 2 currently but growing over time as old legacy apps are converted; - Some applications are mission critical, others not so much; - DB back-end is a...
3
1270
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 database is located on IBM SHARK Storage. There is a need to consolidate the above server and bring the database on the application server. The approach is to unistall db2 client on the application server and
0
1093
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. Then I have a DTS package that runs which points to the file in c:/mydirectory and sends it out. Problem is I think it is looking in its own C: drive for the file. I tried mapping a drive from the database server to the application server...
10
4948
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 mod_python vs. building an application server using Python-based tools like CherryPy, Quixote, Draco, etc.? Thanks.
3
2391
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 do you use for application server? COM+ server is for COM interface which is not ideal for .NET applications. Web service and .NET Remoting is for communicating with other applications which is not ideal for a layer of application structure. Can...
1
2758
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 different applications running on the application server. For example: (Two websites - www.app1.com and www.app2.com) If the user browsing the www.app1.com, then the IIS will forward the request to the application called 'app1' deployed on the...
0
4641
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 this server. formsweb.cfg contents...... baseHTML=/u01/app/oracle/OraHome_1/forms/server/base.htm
0
8736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8025
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6677
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2145
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.