memcached and Drupal

·

Drupal makes a lot of database calls for building every page, so anything that minimises those calls should dramatically increase the speed of a site. The node_load function pulls together all the parts of a node, from all the active modules, then returns this object to wherever it was called from. There's a static cache of nodes within this function, which means that each node only has to be compiled once, but this is only temporary and has to be rebuilt on each request*.

The ideal solution to this is memcached, which keeps an independent cache of objects in memory, so each node really only has to be compiled once, and only reset when it changes. Robert Douglass is working on a full memcached module, but for now here's a patch for node.module that connects to memcached running locally and uses it to store node objects.

*Drupal caches whole pages, but not for logged-in users. It also uses the database to store cached pages, but there's a contributed module for file-based page caching.