473,795 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mod_php and Fast CGI

How many of you are running Fast CGI instead of the popular mod_php?

I planning to change to fast cgi since my applications need around
15MB memory to handle a single request, so consider if Apache running
in multi-process mode, serving 300 clients, then it nearly used up all
my memory in my server.

Any experience can share how to handle large concurrent clients for
PHP?
Thanks
Jun 27 '08 #1
4 4357
On Jun 14, 7:31 am, setesting...@gm ail.com wrote:
How many of you are running Fast CGI instead of the popular mod_php?

I planning to change to fast cgi since my applications need around
15MB memory to handle a single request, so consider if Apache running
in multi-process mode, serving 300 clients, then it nearly used up all
my memory in my server.

Any experience can share how to handle large concurrent clients for
PHP?
300 is not a lot of clients. Unless you mean that you normally have
300 active connections to the webserver.

Why do you think it will need less memory with fast CGI?

Even if I could see that such a change was valid, it would be well
down my list of things to change. While changing a lot of legacy code
can be tricky, I'd start by looking to optimize memory usage within
PHP, consider using autoloader, check queries (which are typically
buffered oustide of PHP's memory limit) and look at front and back end
caching. Making the code go faster and get off the server more quickly
will relieve memory pressures too - so the usual process of
performance optimization. You do have compression enabled in your
webserver and a PHP aaccelerator running?

But sometimes the only solution is to just throw more hardware at it.
But do make sure you've exhausted the other approaches first.

C.
Jun 27 '08 #2
se**********@gm ail.com wrote:
How many of you are running Fast CGI instead of the popular mod_php?

I planning to change to fast cgi since my applications need around
15MB memory to handle a single request, so consider if Apache running
in multi-process mode, serving 300 clients, then it nearly used up all
my memory in my server.

Any experience can share how to handle large concurrent clients for
PHP?
Thanks
First of all, Fast CGI will not use any less memory the mod_php. In
fact, it may use slightly more.

Are you saying you will be handling 300 requests concurrently? That
would be a very busy web server - with typical processing, you're
talking several million hits a day. If that's the case, memory isn't
going to be your only problem. In fact, it probably won't be your main
problem.

Also, if you are regularly using that much memory, chances are you're
code is quite inefficient. It's not unusual to require that much
occasionally. But not on a regular basis.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Jun 27 '08 #3
On 6$B7n(B14$BF |(B, $B2<8a(B6$B; ~(B15$BJ,(B, "C. (http://symcbean.blogsp ot.com/)"
<colin.mckin... @gmail.comwrote :
On Jun 14, 7:31 am, setesting...@gm ail.com wrote:
300 is not a lot of clients. Unless you mean that you normally have
300 active connections to the webserver.

ps ax | grep httpd | wc -l
>286
and an example of running httpd process:
>31594 web 15 0 142m 16m 8472 S 0 0.3 12:02.94 httpd
I believe it is currently using 16M of memory per httpd process (I am
running Apache 1.3, multi process mode)
I am thinking about using fastcgi as not all these 286 httpd process
need to use php at every instance? (E.g. create a pool of fast cgi
php , say 100 process, and let them share)

Then it may save me some memory becoz I don't have 300 CPU to server
all these php at anytime?
Thanks.





Why do you think it will need less memory with fast CGI?

Even if I could see that such a change was valid, it would be well
down my list of things to change. While changing a lot of legacy code
can be tricky, I'd start by looking to optimize memory usage within
PHP, consider using autoloader, check queries (which are typically
buffered oustide of PHP's memory limit) and look at front and back end
caching. Making the code go faster and get off the server more quickly
will relieve memory pressures too - so the usual process of
performance optimization. You do have compression enabled in your
webserver and a PHP aaccelerator running?

But sometimes the only solution is to just throw more hardware at it.
But do make sure you've exhausted the other approaches first.

C.
Jun 27 '08 #4
On Jun 14, 2:40 pm, setesting...@gm ail.com wrote:
On 6$B7n(B14$BF |(B, $B2<8a(B6$B; ~(B15$BJ,(B, "C. (http://symcbean.blogsp ot.com/)"

<colin.mckin... @gmail.comwrote :
On Jun 14, 7:31 am, setesting...@gm ail.com wrote:
300 is not a lot of clients. Unless you mean that you normally have
300 active connections to the webserver.

ps ax | grep httpd | wc -l
286
You have about 300 httpd servers running at any one - time - this is
FAR from the same thing as 300 users OR 300 concurrent requests. Since
you think that's an answer to the question, I'm guessing you haven't
even done any basic tuning of your apache.
>
and an example of running httpd process:
31594 web 15 0 142m 16m 8472 S 0 0.3 12:02.94 httpd
Without seeing the headers or knowing which ps was run with what
options, it's hard to tell what I'm looking at here, I would expect
the %CPU and %mem to be listed in most formats, so I suspect that this
is using 0.3% of the available memory - which suggests that your
system could cope (memory wise) with a lot more then 300 concurrent
connections. What OS are you running on? Do you see any signs of
swapping or even paging?
I believe it is currently using 16M of memory per httpd process (I am
running Apache 1.3, multi process mode)

I am thinking about using fastcgi as not all these 286 httpd process
need to use php at every instance? (E.g. create a pool of fast cgi
php , say 100 process, and let them share)
mod_php will (and most likely IS) happily live in COW TXT segment -
i.e. there will be only one copy in memory, referenced mulitple times.
The usage reported in ps is how much memory would be used if one AND
ONLY ONE instance of apache was running.

Forget about using FastCGI - you're just going to end up using more
memory and running slower.

Start by tuning your apache config (there are lots of good books
available) and add a compressed output handler (like mod_gzip) then
install a PHP cache, then think about optimizing any database and file
I/O by PHP.

C.
Jun 27 '08 #5

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

Similar topics

5
1858
by: zaphod | last post by:
I've recently considered switching from mod_perl to mod_php because mod_perl, unless configured with multiple servers/ports/IP addresses, serves static HTML from mod_perl processes, which is grossly inefficient. Since I do not think you should have to tamper so much with server configs to do web development efficiently I'm considering mod_php instead. I need to know if PHP handles this differently: - Are static HTML requests handled...
6
2241
by: yarmfelder | last post by:
Hi all, I noticed that with Slackware they don't include mod_php in the latest distro. I also noticed some talk on the web that there was an insecurity issue with mod_php in a previous version of Slackware. So is this just a Slackware mishap or is there a good reason to no longer permit PHP from
40
1296
by: Shufen | last post by:
Hi all, Can someone who has use PHP before and know quite well about the language, tell me what are the stuffs that Python offers and PHP doesn't. A few examples will be nice. I know about the date format problem which PHP is having but I need more examples. Thank you for any help. Shufen
3
1399
by: emilper | last post by:
Hi, while using mod_php in apache: If I am including one .inc file in one page, does it get compiled and kept in memory so when I include the same file in another page on the same server, the server won't have to search for it and recompile it ? does mod_php provide other advantages besides preloading the php interpretor/compiler in memory ?
5
3557
by: howachen | last post by:
hi, which package you perfer? mod_php on apache is okay but some people said fastcgi version of php is faster, is it true? thanks...
7
25723
by: Vincent Delporte | last post by:
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
0
3182
by: R.A.M. | last post by:
Hello, I am using Fedora 7 Moonshine Linux with Apache installed. I have installed PHP5 using command: yum install php. Then I configured httpd adding module mod_php.so to httpd.conf (and other necessary operations). The problem is that when I am trying to start Apache using command: httpd -k start, I receive error of missing mod_php.so. To solve the problem, I downloaded mod_php.2.0.1.-9.s390.rpm and executed command: rpm -i...
2
1713
by: Evil Son | last post by:
Hello group, If I switched from mod_php to fast-cgi, would I need to make any changes to my php source? Also, will something like APC still be useful? Will my database connections suddenly become persistent? If I had static data in my script, will it persist when that same
7
3622
by: yawnmoth | last post by:
Correct me if I'm wrong, but isn't running PHP via mod_php faster than running it via CGI? If so, why would a web hosting company be running PHP via CGI and not mod_php? I asked that very question to one web hosting company and given the following response: "We run our php based on what is secure, not what could be a few seconds faster"
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10436
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
10000
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
9040
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
7538
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
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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
2920
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.