Current time: 12-27-2024, 01:04 PM Hello There, Guest! (LoginRegister)


Post Reply 
memory consumption of php5+fastcgi
Author Message
ispcomm Offline
Junior Member
*

Posts: 93
Joined: Apr 2008
Reputation: 3
Post: #1
memory consumption of php5+fastcgi
I'm wondering what the memory requirements would be for a real server hosting domains with ispcp.

Using fastcgi+php5 (debian etch, default install) each php5 process is using 5900KB of memory (that is... almost 6megabytes).
Every site has 3 stand-by processes.

Allocating 100 domains (as a minimum requirement per physical server) would mean that 100x3x6 = 1800MB or RAM would be needed just to host the idle processes for all domains. This is on a 32bit machine (64 bit could be double this numbers).

If you add a few connections and the other daemons (primarily mysql) you'll end up with a minimum requirement of 4Gbytes that is too much IMHO.

My fear is that adding other stuff to php would get this number higher (currently my php5 has only the gd, idn, mcrypt, mhash and mysql extentions).

My question is: is there a way to reduce this number, other than reducing the number of idle processes that fastcgi spans ?
05-05-2008 07:31 PM
Find all posts by this user Quote this message in a reply
Cube Offline
Member
***

Posts: 740
Joined: Apr 2007
Reputation: 9
Post: #2
RE: memory consumption of php5+fastcgi
I go this way to reduce memory usage by FastCGI:
http://www.isp-control.net/documentation...em#fastcgi
This was the default in older ispCP version. The disadvantage is that it may take longer to load a website after the last process has disappeared.
(This post was last modified: 05-05-2008 11:11 PM by Cube.)
05-05-2008 11:11 PM
Find all posts by this user Quote this message in a reply
ispcomm Offline
Junior Member
*

Posts: 93
Joined: Apr 2008
Reputation: 3
Post: #3
RE: memory consumption of php5+fastcgi
Cube Wrote:I go this way to reduce memory usage by FastCGI:
http://www.isp-control.net/documentation...em#fastcgi
This was the default in older ispCP version. The disadvantage is that it may take longer to load a website after the last process has disappeared.
Thank you for the pointer. I think 1 process per idle website should be enough. I'll look at fastcgi and your pointer.

ispcomm.
05-06-2008 01:01 AM
Find all posts by this user Quote this message in a reply
Quemeros Offline
Junior Member
*

Posts: 86
Joined: Nov 2007
Reputation: 0
Post: #4
RE: memory consumption of php5+fastcgi
In 1st post... the estimation it's correct?... 6mb per site in idle?
Nobody have a server running with aprox. 50 sites in a 64bits OS, how ram are consuming?
(This post was last modified: 05-06-2008 05:19 AM by Quemeros.)
05-06-2008 05:17 AM
Find all posts by this user Quote this message in a reply
ispcomm Offline
Junior Member
*

Posts: 93
Joined: Apr 2008
Reputation: 3
Post: #5
RE: memory consumption of php5+fastcgi
Quemeros Wrote:In 1st post... the estimation it's correct?... 6mb per site in idle?
Nobody have a server running with aprox. 50 sites in a 64bits OS, how ram are consuming?
The numbers vary slightly (depending on dynamic allocation of php5) however they're correct (reported by top). Current figures (after 24hrs of real standby, which never occurs in real-world are:
Code:
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
vu2000    5717  0.0  2.2  19440  5956 ?        Ss   May04   0:00 /usr/bin/php5-cgi
vu2000    5778  0.0  2.3  19676  6180 ?        S    May04   0:15 /usr/bin/php5-cgi
vu2000    5779  0.0  2.3  19640  6052 ?        S    May04   0:14 /usr/bin/php5-cgi
vu2001   28731  0.0  2.2  19436  5948 ?        Ss   07:57   0:00 /usr/bin/php5-cgi
vu2001   28732  0.0  1.3  19436  3428 ?        S    07:57   0:00 /usr/bin/php5-cgi
vu2001   28733  0.0  0.8  19436  2252 ?        S    07:57   0:00 /usr/bin/php5-cgi
root     19599  0.0  0.1   1652   508 ttyp0    R+   21:10   0:00 grep php5
VSZ=virtual size in KB, RSS=physical non-swapped size in memory, in KB. That is 3x19MB per site virtual size of which 6-19MB in memory (not swapped to disk) in this particular case. There's a hit from the odd robot/spammer on the site every few minutes, so a site is never really "idle".

Good news is that part of the VSZ is shared between threads (text and other static stuff). But RSS is mainly thread-local (variables)... afaik.

For reference here's the memory footprint of the apache process on the same server:
Code:
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root     24296  0.0  1.3  10372  3572 ?        Ss   May04   0:00 /usr/sbin/apache2 -k start
www-data  5715  0.0  0.8  10372  2276 ?        S    May04   0:00 /usr/sbin/apache2 -k start
www-data  5718  0.0  1.7 232372  4508 ?        Sl   May04   0:00 /usr/sbin/apache2 -k start
www-data  5720  0.0  1.7 232384  4512 ?        Sl   May04   0:00 /usr/sbin/apache2 -k start
root     19615  0.0  0.1   1656   508 ttyp0    R+   21:14   0:00 grep apache

Multiply RSS by the number of connections you want to handle at the same time (150-500). Add MySQL (384-512MB at least), antivirus (minimum 15 istances), pop3 (100 concurrent connections at least... or 1 account per domain), smtp (another 100 as send/receive is done at the same time) ... hey where did my 4GB go?

Consider that these are worse-case figures. You can get by with 50% real memory and 50% swap file, but things slow down (and sum-up) when the server is busy swapping on the disks.

ispcomm.
(This post was last modified: 05-06-2008 07:33 AM by ispcomm.)
05-06-2008 07:31 AM
Find all posts by this user Quote this message in a reply
ergo Offline
Junior Member
*

Posts: 56
Joined: Apr 2008
Reputation: 0
Post: #6
RE: memory consumption of php5+fastcgi
i have 30 domains on my vps and memory usage is 350-400 mb - after the fastCGI change that cube mentioned. Its important to note that i have both mysql and postgresql there. and APC running, im not sure if apc stores the cache in memory ?
(This post was last modified: 05-07-2008 04:57 PM by ergo.)
05-07-2008 04:52 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)