NYCPHP Meetup

NYPHP.org

[nycphp-talk] FW: [PHP] Re: APC and PHP 5.1.2

michael lists at genoverly.net
Sun Apr 2 13:17:49 EDT 2006


On Fri, 3 Mar 2006 23:55:10 -0500
"Hans Zaunere" <lists at zaunere.com> wrote:
 
> Some tips from Rasmus on PHP General on performance...
 
> Rasmus Lerdorf wrote on Friday, March 03, 2006 11:51 PM:
> > 4. Make use of APC's apc_store/apc_fetch mechanism.  If you have any
> >     sort of large array of data you need often, stick it in shared
> >     memory with an apc_store() call.  For example, a typical thing
> >     you see in PHP applications is some sort of config.php file.  It
> >     might look like this:
> > 
> >      <?php
> >         $config['db_type'] = 'mysql';
> >         $config['db_user'] = 'bob';
> >         $config['db_pswd'] = 'foobar';
> >         $config['data_dir'] = '/var/www/app_data';
> >         ...
> > 
> > 
> >     And then on every page you have:  include './config.php';
> > 
> >     This is very inefficient even though the actual file will be
> >     cached in the opcode cache, it still has to execute and create
> >     the array. You can cache the created array like this:
> > 
> >      if(!$config = apc_fetch('config')) {
> >         include './config.php';
> >         apc_store('config',$config);
> >      }
> > 
> >     Here we only include the config file and thus create the $config
> >     array if it isn't in the cache.  So this will only happen on the
> >     very first request.  From then on it will get pulled from the
> >     shared memory cache.
> > 
> >     If you look around there are usually a couple of candidates for
> >     this sort of caching in every application and it can make quite
> >     a difference for large arrays.  Try to avoid caching objects
> >     because they need to be serialized and unserialized in and out
> >     of the cache and you can only cache the properties anyway, so
> >     pull the data you want to cache into an array and cache that.
> > 
> > -Rasmus

I was looking over these slides, http://talks.php.net/show/yul/ and
found (among other great things) http_load.  I've installed and run it
and I am now looking for ways to 'bring up my numbers'.  

I know many, many, many things influence performance.. but.. the above
example seems like good advice.  I haven't seen much talk about The
Alternative PHP Cache (APC) opcode cache on this list.  Is anyone
making use of it? 

I also found xdebug (xdebug.org), but have not installed it.  Can
anyone thumbs up/down on that one? 


-- 

Michael



More information about the talk mailing list