Welcome! Log In Create A New Profile

Advanced

How does PHP-FPM use APC ?

Posted by Ben 
Ben
How does PHP-FPM use APC ?
November 26, 2010 03:14AM
Hi...I've googled for a while about how PHP-FPM using APC, but got few
information, so I give a trial here.

In a test server, I got the following data.

After start up PHP-FPM ( with APC ), I start up only one PHP child
process use around 5080K RES memory.

And then I visit a general wordpress site stored in the test server,
the PHP child processes increased to 2 , and their RES memory usage
are 21532K and 24532K respectively. If I send more visits to the site,
I can see the php-fpm child processes increase to 3 or 4, all of them
are using around 21 - 28 MB memory.

Currently, I am using APC's default settings, except apc.stat = 0 to
disable it to check file each request.
I've checked wordpress, it is totally around 9MB.

My question is where is the difference 5MB -> 21M coming from? I know
it is affected by APC, but I don't know how APC affect it. It seems if
I install APC, PHP-FPM will use a lot of Memory ( before APC,
generally speaking it's about 5-10MB), or how can I use APC
correctly?

Thank in advance for any help / Ben
陈智宏
Re: How does PHP-FPM use APC ?
November 26, 2010 04:14AM
APC use shm to share memory across the processes.

On Fri, Nov 26, 2010 at 4:13 PM, Ben <benpptung@gmail.com> wrote:

> Hi...I've googled for a while about how PHP-FPM using APC, but got few
> information, so I give a trial here.
>
> In a test server, I got the following data.
>
> After start up PHP-FPM ( with APC ), I start up only one PHP child
> process use around 5080K RES memory.
>
> And then I visit a general wordpress site stored in the test server,
> the PHP child processes increased to 2 , and their RES memory usage
> are 21532K and 24532K respectively. If I send more visits to the site,
> I can see the php-fpm child processes increase to 3 or 4, all of them
> are using around 21 - 28 MB memory.
>
> Currently, I am using APC's default settings, except apc.stat = 0 to
> disable it to check file each request.
> I've checked wordpress, it is totally around 9MB.
>
> My question is where is the difference 5MB -> 21M coming from? I know
> it is affected by APC, but I don't know how APC affect it. It seems if
> I install APC, PHP-FPM will use a lot of Memory ( before APC,
> generally speaking it's about 5-10MB), or how can I use APC
> correctly?
>
> Thank in advance for any help / Ben
Ben
Re: How does PHP-FPM use APC ?
November 26, 2010 05:02AM
Hi..thank you,

Please let me clarify my question as following,

Since the APC default apc.shm_size is 32 MB, I assume the increased
Memory will be less than 32MB.

However, in the test, I've found PHP-FPM will demand much more Memory
than 32MB.
e.g. if 4 instances, each of the PHP-FPM Child Process will eat around
24MB, almost additional 80MB RAM is required.

Because if without apc.so loaded, generally the php-fpm child process
eat around 5-10 MB RAM (in the test server).
The increased 10-15 MB RAM by each child, is used by PHP-FPM or APC ?

# top

I use this command to check system status in FreeBSD 8.1, and check
RES of
each php-fpm child process, following is the log:

PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU
COMMAND
10880 php-default 1 47 0 46236K 24684K accept 1 0:03 0.00%
php-fpm
10883 php-default 1 48 0 45212K 24540K accept 1 0:02 0.00%
php-fpm
10882 php-default 1 48 0 45212K 23852K accept 1 0:00 0.00%
php-fpm
10881 php-default 1 47 0 45212K 24372K accept 1 0:01 0.00%
php-fpm
10879 root 1 44 0 9172K 4848K kqread 1 0:00 0.00%
php-fpm




On Nov 26, 5:12 pm, 陈智宏 <zhihong.chen...@gmail..com> wrote:
> APC use shm to share memory across the processes.
>
> On Fri, Nov 26, 2010 at 4:13 PM, Ben <benppt...@gmail.com> wrote:
> > Hi...I've googled for a while about how PHP-FPM using APC, but got few
> > information, so I give a trial here.
>
> > In a test server, I got the following data.
>
> > After start up PHP-FPM ( with APC ), I start up only one PHP child
> > process use around 5080K RES memory.
>
> > And then I visit a general wordpress site stored in the test server,
> > the PHP child processes increased to 2 , and their RES memory usage
> > are 21532K and 24532K respectively. If I send more visits to the site,
> > I can see the php-fpm child processes increase to 3 or 4, all of them
> > are using around 21 - 28 MB memory.
>
> > Currently, I am using APC's default settings, except apc.stat = 0 to
> > disable it to check file each request.
> > I've checked wordpress, it is totally around 9MB.
>
> > My question is where is the difference 5MB -> 21M coming from? I know
> > it is affected by APC, but I don't know how APC affect it. It seems if
> > I install APC, PHP-FPM will use a lot of Memory ( before APC,
> > generally speaking it's about 5-10MB),  or how can I use APC
> > correctly?
>
> > Thank in advance for any help / Ben
>
>
Antony Dovgal
Re: How does PHP-FPM use APC ?
November 26, 2010 05:10AM
On 11/26/2010 12:59 PM, Ben wrote:
> Hi..thank you,
>
> Please let me clarify my question as following,
>
> Since the APC default apc.shm_size is 32 MB, I assume the increased
> Memory will be less than 32MB.
>
> However, in the test, I've found PHP-FPM will demand much more Memory
> than 32MB.
> e.g. if 4 instances, each of the PHP-FPM Child Process will eat around
> 24MB, almost additional 80MB RAM is required.

http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html

--
Wbr,
Antony Dovgal
---
http://pinba.org - realtime statistics for PHP
Ben
Re: How does PHP-FPM use APC ?
November 26, 2010 06:30AM
Thank you very much for the sharing!! This article explains very well.
And thank you for the great PHP-FPM solution!! ^_^


On Nov 26, 6:09 pm, Antony Dovgal <t...@daylessday.org> wrote:
> On 11/26/2010 12:59 PM, Ben wrote:
>
> > Hi..thank you,
>
> > Please let me clarify my question as following,
>
> > Since the APC default apc.shm_size is 32 MB, I assume the increased
> > Memory will be less than 32MB.
>
> > However, in the test, I've found PHP-FPM will demand much more Memory
> > than 32MB.
> > e.g. if 4 instances, each of the PHP-FPM Child Process will eat around
> > 24MB, almost additional 80MB RAM is required.
>
> http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage...
>
> --
> Wbr,
> Antony Dovgal
> ---http://pinba.org- realtime statistics for PHP
Antony Dovgal
Re: How does PHP-FPM use APC ?
November 26, 2010 07:10AM
On 11/26/2010 02:29 PM, Ben wrote:
> Thank you very much for the sharing!! This article explains very well.
> And thank you for the great PHP-FPM solution!! ^_^

You're welcome!

--
Wbr,
Antony Dovgal
---
http://pinba.org - realtime statistics for PHP
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 211
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready