Memcache is a system used by Dreamwidth to lessen the amount of database access needed, by temporarily storing frequently-accessed information in memory for quick access. It was developed by Brad Fitzpatrick and is used in many high-profile websites, including Slashdot, Wikipedia, and, of course, LiveJournal (for which it was developed). Dreamwidth Studios also uses this system.
Using Memcache on a Dreamhack
To use memcache on a Dreamhack, do the following:
- Contact the owner of the Dreamhack box you're using for a port to use with the
memcachedprogram; this will usually be Mark.
screento run this command:
memcached -m 8 -l 127.0.0.1 -p <port>
- ...replacing <port> with the port number assigned to you in the previous step. If you need help with
screen, feel free to contact Mark. (A wiki page on this should be available in the future.)
- Edit your
ext/local/etc/config-local.plfile (copy it first from
ext/dw-nonfree/etc/config-local.plif it doesn't exist) and look for the line:
#@MEMCACHE_SERVERS = ('hostname:port');
- Change this to:
@MEMCACHE_SERVERS = ('127.0.0.1:<port>');
- again replacing <port> with the appropriate port number. (Make sure also that the line is uncommented by removing the # at the front.)
- If your Apache server is currently running, restart it:
Your Dreamhack should now be set up for memcache.
Using Memcache on your own setup
First, install the daemon:
sudo apt-get install memcached
You can run it in kind of a debug mode like this:
memcached -vv -m 25 -l 127.0.0.1 -p 8080
Or in the background like this:
memcached -d -m 25 -l 127.0.0.1 -p 8080
For more help on the options,
You'll also have to set up your installation to use it. First, copy ext/dw-nonfree/etc/config-local.pl to ext/local/etc/config-local.pl if the latter doesn't exist. Then edit the file using your favorite editor (the example uses vi):
And edit the appropriate information:
# MemCache information, if you have MemCache servers running @MEMCACHE_SERVERS = ('127.0.0.1:8080'); $MEMCACHE_COMPRESS_THRESHOLD = 1_000; # bytes
You will need to restart your web server in order for these changes to take effect.
Note that the memcache server doesn't have to be on your web server; you can set it up and configure it with the IP of a different server.