When I was looking for ways to replicate the contents of memcached for high-availability performance, I found this memcached-repcached application. that has the ability to replicate the contents of one memcached to another.
Repcached key features
- Multi master replication.
- Asynchronous data repliacation.
- Support all memcached command (set, add, delete, incr/decr, flush_all, cas)
People probably already know about memcached . It’s a robust, high performance key-value based memory object cache interface. but unfortunately, lack the ability to create redundancy and replication in memcached server clusters. although replication could be done at the application level. However, it all depends on each individual’s taste.
This is a quick and dirty experiment I have tried using memcached-repcached application on 2 servers.
On the first server and second server extract memcached-1.2.8-repcached-2.2.tar.gz, compile with –enable-replication option when configure.
$ tar xvzf memcached-1.2.8-repcached-2.2.tar.gz $ cd memcached-1.2.8-repcached-2.2 $ ./configure --enable-replication $ make
On the first server, while still being in the directory when doing the compilation, run this command
[first server]$ ./memcached -u nobody -l 192.168.1.1 -p 22122 -m 64 -x 192.168.1.2 -v replication: connect (peer=192.168.1.2:11212) replication: marugoto copying replication: close replication: listen
On the second server, also run this command
[second server]$ ./memcached -u nobody -l 192.168.1.2 -p 22122 -m 64 -x 192.168.1.1 -v replication: connect (peer=192.168.1.1:11212) replication: marugoto copying replication: start
Now, let’s try to simulate the process of replication on both memcached server.
[third server]$ telnet 192.168.1.1 22122 Trying 192.168.1.1... Connected to 192.168.1.1. Escape character is '^]'. set hey 0 0 4 dude STORED get hey VALUE hey 0 4 dude END quit Connection closed by foreign host.
We stored a value “dude” with the key “hey” and verified with “get hey” command.
Now connecting to the second memcached server.
[third server]$ telnet 192.168.1.2 22122 Trying 192.168.1.2... Connected to 192.168.1.2. Escape character is '^]'. get hey VALUE hello 0 4 dude END quit Connection closed by foreign host.
We got the same result on a second memcached server. recent memcached-repcached only capable for 2 node replication setup only. but it was pretty good. 🙂