Newbie APC Question

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
SimpleQuestions's picture

I suspect this is a general Apache question, rather than a Drupal question, but since I may be wrong and you guys will know the answer I'll just run this question by you:

I am just competent enough to get myself in trouble so I want to make sure I understand this correctly --

I can install APC as an opcode cache and this will apply to ALL my php code without having to make any changes to Drupal (or any other CMSes I'm using) correct? This would seem like a no-brainer first step for me to improve performance. I run quite a few sites off of this one box, does this lead to any particular risks?

Most of my sites are fairly static and Boost has worked very well for them, however I'm looking at putting up a fairly heavy use forum and I fear it will be a performance hog. I'd like to start with the lowest hanging fruit. Am I right in thinking putting an APC opcode cache on there would be an obvious first step?

Thanks in advance for your help.

Comments

I haven't heard of any

Garrett Albright's picture

I haven't heard of any complaints of incompatibilities between APC and Drupal; in fact, I've heard quite well. And, yes, installing an opcode cache is definitely low-hanging fruit. Go for it.

Yes you've got it. Here's a

dalin's picture

Yes you've got it.

Here's a good set of instructions on how to install APC, depending on what distro you are using:
http://www.debian-administration.org/articles/574

After you install be sure to follow those last few paragraphs about minimizing the number of cache clears. If you have several sites on this one machine the default 30MB may not be big enough for you.

--


Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his

With APC op-code cache you

Jamie Holly's picture

With APC op-code cache you generally see performance boosts of 20+%. The only "gotcha" is the apc.stat setting. A lot of people recommend setting it to 0, but you can have problems on Drupal with that. See this thread for details:

http://groups.drupal.org/node/23636

With APC you can also gain significant performance increases by using it with the Cacherouter module and using the APC user-cache for Drupal's caching.


HollyIT - Grab the Netbeans Drupal Development Tool at GitHub.

APC Config

ThetaJoin's picture

One aspect of configuring APC is shared memory. Most distros come with shmmax size of 32MB, which is fine for Drupal and a few additional modules. If you're running Ubercart, you'll need at least 48MB, possibly more depending upon how many modules you've installed.

What happens when shmmax size is too small is that APC will start to fragment your shared memory, causing your site to run slower than without APC. I ran into this problem on a client site a few weeks ago. Very subtle as the site would take a few days before the fragmented memory became an issue.

I blogged about it here: http://blog.thetajoin.com/content/alternative-php-cache-apc-and-drupal-p...

Yes, you are correct that APC will cache all the Drupal PHP code, but you can filter files from being cached using the apc.filters setting. The other setting that may help with your site is apc.include_once_override. This setting improves all the requires/includes calls in the cache.

HTH

Mark Schoonover
http://www.thetajoin.com
High Performance Drupal Hosting & IT Services

Good info in that post. One

Jamie Holly's picture

Good info in that post. One little thing I noticed though. On your APC page it shows your shm_size at 32. Did you change it back or did some setting not stick?


HollyIT - Grab the Netbeans Drupal Development Tool at GitHub.

Thanks for all the great

SimpleQuestions's picture

Thanks for all the great responses. Very supportive group.

I'm planning on putting cacherouter on the forum, but I figured I'd do APC first just as an opcode cache and get that stable. As far as memory settings, I run about 15 drupal sites as well as several wordpress sites on that box. Presumably it will be caching a version of the code for each site. Should I start out with a relatively high shmmax setting because of this, or should I start at 32 and work it up as I notice fragmentation problems?

Also several of the drupal sites are relatively static and I would say the vast majority of pages served are already done so by boost. Should I consider excluding these sites from the opcode caching to save shared memory?

Thanks again everyone.