Hi,

I wanted to know what the difference would be between installing this drupal module vs just installing APC via apache?

Also the documentation for the module doesn't load.

Comments

pounard’s picture

Just installing the pecl APC extension will allow you to use the cache what is called "OPcode cache". The OPcode is the result of PHP script compilation phase, which is then stored into local memory to avoid PHP file parsing and compiling phase the next hit thus providing a raw performance boost that can vary between x2 to x5 depending on the environment and code.

But you have to be aware that using APC as an OPcode cache will only make the PHP runtime faster, it doesn't involve any other caching mecanism that this, just makes the raw execution faster, that is all.

This module allows Drupal to use the second caching level of APC, which is a high level feature: it is called the "user cache". The user cache is an in-memory storage space that allows high level software to put arbitrary binary business data in order to fetch it back later.

Drupal core splits its cache storage space logically into what it is called "bins", each bin is named ("cache_page", "cache_filter", "cache_field", etc...). A bin is a specific storage space. Drupal per default uses the database for these bins, one table per logical bin.

When using this module, you can redirect some or all of the bins to the APC user cache, which will makes them a lot faster (since it doesn't have to use a SQL storage via a TCP connection).

But you have to be aware that the more data you will put into the APC user cache, the more you will bloat your box memory, thus removing precious memory that the HTTPd itself could use in order to accept more clients. For example, you definitely cannot put "cache_page" or "cache_field" into APC (except for very small sites) because they are bins that can potentially contains thousands of entries, you would bloat your memory quite quickly this way.

In order to use it in a clever way, you have to identify which bins are small and the most oftenly use. I'd recommend for a safe use to put "cache" and "cache_bootstrap" into APC and let the rest live into database as a start, then proceed to size measures on other bins, because their usage will vary depending on the site integration and business.

Does this answer your question?

dreadlocks1221’s picture

yes it does very well thank you

pounard’s picture

Status: Active » Fixed

You're welcome!

Peter Bowey’s picture

The APC - Alternative PHP Cache makes a great addition to Drupal 7 - or Drupal 6 (thanks to the cache_backport module)!
I have set APC up to offer these bins under Pressflow 6.22: (showing part of my settings.php here)

      $conf += array(
        'cache_inc'        => './sites/all/modules/cache_backport/cache.inc',
        'cache_backends'   => array('./sites/all/modules/apc/drupal_apc_cache.inc',),
        'apc_show_debug'   => FALSE,
        'page_cache_without_database' => TRUE,
        'page_cache_invoke_hooks'     => FALSE,
        'page_cache_maximum_age'      => 3600,
        'cache_lifetime'              => 0,
        'session_inc'      => './sites/all/modules/cacherouter/session.inc',
            'cache_default_class'               => 'DrupalAPCCache',
            'cache_class_cache'                 => 'DrupalAPCCache',
            'cache_class_cache_block'           => 'DrupalAPCCache',
            'cache_class_cache_bootstrap'       => 'DrupalAPCCache',
            'cache_class_cache_content'         => 'DrupalAPCCache',
            'cache_class_cache_filter'          => 'DrupalAPCCache',
            'cache_class_cache_form'            => 'DrupalAPCCache',
            'cache_class_cache_menu'            => 'DrupalAPCCache',
            'cache_class_cache_page'            => 'DrupalAPCCache',
            'cache_class_cache_pathdst'         => 'DrupalAPCCache',
            'cache_class_cache_pathsrc'         => 'DrupalAPCCache',
            'cache_class_cache_session'         => 'DrupalAPCCache',
            'cache_class_cache_session_user'    => 'DrupalAPCCache',
            'cache_class_cache_update'          => 'DrupalAPCCache',
            'cache_class_cache_users'           => 'DrupalAPCCache',
            'cache_class_cache_views'           => 'DrupalAPCCache',
            'cache_class_cache_views_data'      => 'DrupalAPCCache',
      );

Notes: I have additionaly re-written the memcache-session.inc to handle session and user caching via APC.
[edit spelling = oops!]
The bench-marked results are very pleasing!
[edit = addition - stats]
APC show a hit ratio of 94%,
Cached Files 361 ( 33.7 MBytes)
Cached Variables 388 ( 2.5 MBytes)

Many thanks to pounard for supporting this combo!

The Drupal 'Module parts' of both 1) APC - Alternative PHP Cache, and 2) cache_backport are not at all essential,
and only add some very light monitor features to Drupal: = 'very non-essential - really'.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.