Running Movable Type with memcached
Memcached (pronounced mem-cash-dee) is a caching framework that allieviates database load and makes applications that utilize it faster and more reliable. From memcached’s website:
memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
Danga Interactive developed memcached to enhance the speed of LiveJournal.com, a site which was already doing 20 million+ dynamic page views per day for 1 million users with a bunch of webservers and a bunch of database servers. memcached dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization, and faster access to the databases on a memcache miss.
How to Install Memcached in Unix
Using RPMs and Yum
Users of Red Hat Enterprise, Fedora and CentOS, depending upon the version you are using, may have success installing memcached via RPM. Do do so, execute the following command as root:
yum install memcached
Users of Debian can execute this command:
apt-get install memcached
Any missing dependencies will be resolved for you automatically.
Compiling from Source
While some RPMs and Debian packages exist for memcache, the most reliable way to get memcached up and running is to compile from source. This is typically very straight forward and quite reliable.
- Download libevent (version 1.3b).
- Untar libevent by executing
tar zxvf libevent-1.3b.tar.gz
- Execute
cd libevent-1.3b
- Execute
./configure
- Execute
make install as root
- Download memcached (version 1.2.2).
- Untar memcached by executing
tar zxvf memcached-1.2.2.tar.gz
- Execute
cd memcached-1.2.2
- Execute
./configure
- Execute
make install as root
Now you can start the memcached daemon by executing the following command:
./memcached -d -m 2048 -l 127.0.0.1 -p 11211 &
This will start memcached and bind it to port 11211 on the IP address of 127.0.0.1 with 2GB of memory.
How to Install Memcached in Windows
A version of memcached exists for windows as well. Download the latest Win32 Binary of memcached and follow the instructions found on its website.
How to Install Memcached on Mac OS X
To install memcached on a Mac OS X system, download and run the following script.
Setting Up Movable Type
Once memcache has been successfully installed on your machine, or on a server that is accessible by Movable Type, edit your mt-config.cgi file and add the following configuration parameter:
MemcachedServers 127.0.0.1:11211
Be sure to set the IP address (127.0.0.1 in the example above) and the port number (11211 in the example above) to the proper IP and Port that memcached is listening on.
To setup Movable Type to connect to a pool of memcache servers add multiple MemcachedServers directives like so:
MemcachedServers 127.0.0.1:11211 MemcachedServers 127.0.0.2:11211 MemcachedServers 127.0.0.3:11211
If you are running Movable Type under FastCGI you will need to restart your webserver.
That’s it. Movable Type will immediately begin caching data using memcached. If Movable Type experiences any problems accessing memcached then it will degrade gracefully and act as if it is not there.
Tips and Best Practices
- Consider launching memcached automatically when the server starts up so that you can rest assured that it will always be running.
- Monitor memcache using Nagios or other monitoring software to ensure that it is running
- Consider deploying memcache on a dedicated machine
- Do not deploy memcached and Movable Type on different networks - memcache operates most efficiently when network overhead and latency is completely minimized.
http://openid.hinn.cn/jackie on April 4, 2009, 6:59 a.m. Reply
What benefits will we get form installing memcached? Will memcached speeds up static html publishing?
Tomato Interactive on November 19, 2009, 9:25 a.m. Reply
What kind of data are cached by MT ?
Thanks
François Nonnenmacher on December 3, 2009, 2:10 p.m. Reply
These installation instructions miss an important point: you need to install the Perl module Cache::Memcached otherwise you’ll get the following error: Can’t locate object method “new” via package “Cache::Memcached” at lib/MT/Memcached.pm