Difference between revisions of "Memcached on 1and1 with MediaWiki"
From ThePlaz.com
(Inital draft (10 min)) |
(edit a bit more) |
||
Line 1: | Line 1: | ||
A few months ago I figured out by piecing together info form around the web how to install [http://www.danga.com/memcached/ Memcached] on to a server (in this case I am using a [http://www.1and1.com/?k_id=10309718 1and1] shared server) and configure [http://www.mediawiki.org/wiki/MediaWiki MediaWiki] to use it. (MediaWiki is the software which runs this site and Wikipedia) | A few months ago I figured out by piecing together info form around the web how to install [http://www.danga.com/memcached/ Memcached] on to a server (in this case I am using a [http://www.1and1.com/?k_id=10309718 1and1] shared server) and configure [http://www.mediawiki.org/wiki/MediaWiki MediaWiki] to use it. (MediaWiki is the software which runs this site and Wikipedia) | ||
− | Memcached will dramatically speed up MediaWiki. Some pages on my site, like the [[Main Page]] took 40 seconds to load before Memcached, but only 7 after installing Memcached. "Memcached is a high-performance, distributed memory object caching system". Memcached is essentially a database caching system which is object orientated, and works even if the database is updated. (MySQL caching discards | + | Memcached will dramatically speed up MediaWiki. Some pages on my site, like the [[Main Page]] took 40 seconds to load before Memcached, but only 7 after installing Memcached. "Memcached is a high-performance, distributed memory object caching system". Memcached is essentially a database caching system which is object orientated, and works even if the database is updated. (MySQL caching discards the entire cache when a table is changed) |
− | In MediaWiki, as with other common web apps | + | In MediaWiki, as with other common web apps, some items are called from the database for every page load, such as interface elements, commonly accessed text, and settings. Why should the database be hit each time you want to print the English version that means "edit"? Memcached keeps such commonly requested rows seperate from the database. The database still servers less commonly requested information when needed. |
==Installing Memcached and Libevent== | ==Installing Memcached and Libevent== | ||
− | I am going to demonstrate using my shared server on 1and1. This will work on any Linux server | + | I am going to demonstrate using my shared server on 1and1. This will work on any Linux server which you have shell access to (can be via SSH). |
{{Red Message|I will use '/kunden/homepages/13/d155370874/htdocs/' as my root directory, because that's the root of what I have access to on my shared server To find your working directory, use <pre>$ pwd</pre>}} | {{Red Message|I will use '/kunden/homepages/13/d155370874/htdocs/' as my root directory, because that's the root of what I have access to on my shared server To find your working directory, use <pre>$ pwd</pre>}} | ||
Line 22: | Line 22: | ||
</pre> | </pre> | ||
− | Then get [http://www.danga.com/memcached/ Memcached] and install giving it the directory where you installed libevent | + | Then get [http://www.danga.com/memcached/ Memcached] and install giving it the directory where you installed libevent. (Note: on 1and1 I could only get version 1.1.12 to work; not the latest version; I don't know why) |
<pre> | <pre> | ||
$ wget http://www.danga.com/memcached/dist/memcached-1.1.12.tar.gz | $ wget http://www.danga.com/memcached/dist/memcached-1.1.12.tar.gz | ||
Line 64: | Line 64: | ||
$ top | $ top | ||
</pre> | </pre> | ||
− | Output should be: | + | Output should be: |
+ | <pre> | ||
24190 u3988386 18 2 24056 22M 248 S N 0.0 0.0 0:00 memcached | 24190 u3988386 18 2 24056 22M 248 S N 0.0 0.0 0:00 memcached | ||
+ | </pre> | ||
==Configure MediaWiki== | ==Configure MediaWiki== | ||
Line 74: | Line 76: | ||
</pre> | </pre> | ||
− | + | For more information on using MediaWiki with Memcached see: http://meta.wikimedia.org/wiki/Memcached | |
[[Category:Tech]] | [[Category:Tech]] |
Revision as of 20:39, 13 August 2007
A few months ago I figured out by piecing together info form around the web how to install Memcached on to a server (in this case I am using a 1and1 shared server) and configure MediaWiki to use it. (MediaWiki is the software which runs this site and Wikipedia)
Memcached will dramatically speed up MediaWiki. Some pages on my site, like the Main Page took 40 seconds to load before Memcached, but only 7 after installing Memcached. "Memcached is a high-performance, distributed memory object caching system". Memcached is essentially a database caching system which is object orientated, and works even if the database is updated. (MySQL caching discards the entire cache when a table is changed)
In MediaWiki, as with other common web apps, some items are called from the database for every page load, such as interface elements, commonly accessed text, and settings. Why should the database be hit each time you want to print the English version that means "edit"? Memcached keeps such commonly requested rows seperate from the database. The database still servers less commonly requested information when needed.
Installing Memcached and Libevent
I am going to demonstrate using my shared server on 1and1. This will work on any Linux server which you have shell access to (can be via SSH).
$ pwd
First get via (wget) the latest version of libevent available. Then unzip it and install it. I use prefix to install it in my shared directory, because I don't have write access in the usual location for such stuff.
$ wget http://www.monkey.org/~provos/libevent-1.1a.tar.gz $ tar -zvxf libevent-1.1a.tar.gz $ cd libevent-1.1a $ ./configure --prefix=/kunden/homepages/13/d155370874/htdocs/libevent $ make $ make install $ cd
Then get Memcached and install giving it the directory where you installed libevent. (Note: on 1and1 I could only get version 1.1.12 to work; not the latest version; I don't know why)
$ wget http://www.danga.com/memcached/dist/memcached-1.1.12.tar.gz $ tar -zvxf memcached-1.1.12.tar.gz $ cd memcached-1.1.12 $ ./configure --prefix=/kunden/homepages/13/d155370874/htdocs/memcached --with-libevent=/kunden/homepages/13/d155370874/htdocs/libevent $ make $ make install
Start Memcached
If your server gets restarted, you might have to redo these steps.
$ cd memcached (the directory where you installed memcached) $ cd bin $ ldd memcached
That will output:
libevent-1.3b.so.1 => not found libc.so.6 => /lib/tls/libc.so.6 (0x00a55000) /lib/ld-linux.so.2 (0x00a3c000)
Now type (substuting where you installed libevent):
$ export LD_LIBRARY_PATH=/kunden/homepages/13/d155370874/htdocs/libevent/lib: $ ldd memcached
That will output: (Notice the path to libevent is now there)
libevent-1.3b.so.1 => /kunden/homepages/13/d155370874/htdocs/libevent-1.3b/lib/libevent-1.3b.so.1 (0x0061f000) libc.so.6 => /lib/libc.so.6 (0x00a55000) /lib/ld-linux.so.2 (0x00a3c000)
Start it up: This will start it up as a daemon (it will run in the background) on IP 127.0.0.1 on port 11000 using no more then 64 MB of RAM.
$ memcached -d -l 127.0.0.1 -p 11000 -m 64
Confirm that it it is working with
$ top
Output should be:
24190 u3988386 18 2 24056 22M 248 S N 0.0 0.0 0:00 memcached
Configure MediaWiki
Add this to your LocalSettings.php. For other web apps, check with there documentation to see how to enable Memcached. Notice how I set the IP and port where Memcached is running:
$wgMainCacheType = CACHE_MEMCACHED; $wgMemCachedServers = array( "127.0.0.1:11000" );
For more information on using MediaWiki with Memcached see: http://meta.wikimedia.org/wiki/Memcached