Difference between revisions of "Memcache"

From Dreamwidth Notes
Jump to: navigation, search
(Restarting the web server is important, I believe!)
Line 14: Line 14:
 
<source lang="perl">@MEMCACHE_SERVERS = ('127.0.0.1:<port>');</source>
 
<source lang="perl">@MEMCACHE_SERVERS = ('127.0.0.1:<port>');</source>
 
:again replacing ''&lt;port&gt;'' with the appropriate port number. (Make sure also that the line is uncommented by removing the # at the front.)
 
:again replacing ''&lt;port&gt;'' 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:
 +
<source lang="bash">stop-apache
 +
start-apache</source>
  
 
Your Dreamhack should now be set up for memcache.
 
Your Dreamhack should now be set up for memcache.
Line 44: Line 47:
 
  @MEMCACHE_SERVERS = ('127.0.0.1:8080');
 
  @MEMCACHE_SERVERS = ('127.0.0.1:8080');
 
  $MEMCACHE_COMPRESS_THRESHOLD = 1_000; # bytes
 
  $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.
 
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.
  
 
[[Category: Dreamwidth Installation]]
 
[[Category: Dreamwidth Installation]]

Revision as of 20:46, 18 January 2018

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 memcached program; this will either be Sophie or Afuna.
  • Use screen to 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 Sophie. (A wiki page on this should be available in the future.)
  • Edit your etc/config-local.pl file 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:
stop-apache
start-apache

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,

memcached -h

You'll also have to set up your installation to use it:

vi etc/config-local.pl

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.