Difference between revisions of "Memcache"

From Dreamwidth Notes
Jump to: navigation, search
(Creating memcache page with instructions for using it on a Dreamhack.)
 
m (Ooops, thanks Sophie.)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
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.
 
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==
+
== Using Memcache on a Dreamhack ==
 +
 
 
To use memcache on a [[Dreamhacks|Dreamhack]], do the following:
 
To use memcache on a [[Dreamhacks|Dreamhack]], do the following:
  
* Contact the owner of the Dreamhack box you're using for a port to use with the <code>memcached</code> program; this will either be Sophie or Afuna.
+
* Contact the owner of the Dreamhack box you're using for a port to use with the <code>memcached</code> program; this will usually be Mark.
 
* Use <code>screen</code> to run this command:
 
* Use <code>screen</code> to run this command:
 
<source lang="bash">memcached -m 8 -l 127.0.0.1 -p <port></source>
 
<source lang="bash">memcached -m 8 -l 127.0.0.1 -p <port></source>
:...replacing ''&lt;port&gt;'' with the port number assigned to you in the previous step. If you need help with <code>screen</code>, feel free to contact Sophie. (A wiki page on this should be available in the future.)
+
:...replacing ''&lt;port&gt;'' with the port number assigned to you in the previous step. If you need help with <code>screen</code>, feel free to contact Mark. (A wiki page on this should be available in the future.)
* Edit your <code>etc/config-local.pl</code> file and look for the line:
+
* Edit your <code>ext/local/etc/config-local.pl</code> file (copy it first from <code>ext/dw-nonfree/etc/config-local.pl</code> if it doesn't exist)  and look for the line:
 
<source lang="perl">#@MEMCACHE_SERVERS = ('hostname:port');</source>
 
<source lang="perl">#@MEMCACHE_SERVERS = ('hostname:port');</source>
 
:Change this to:
 
:Change this to:
 
<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.
 +
 +
== 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. 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):
 +
 +
vi ext/local/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.
 +
 +
[[Category: Dreamwidth Installation]]

Latest revision as of 03:08, 11 December 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 usually be Mark.
  • 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 Mark. (A wiki page on this should be available in the future.)
  • Edit your ext/local/etc/config-local.pl file (copy it first from ext/dw-nonfree/etc/config-local.pl if 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:
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. 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):

vi ext/local/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.