Public | Automated Build

Last pushed: 3 years ago
Short Description
Docker image for running twemproxy both with embedded memcached instances and external backends
Full Description

Twemproxy Docker!

This docker image contains twemproxy configured to run standalone with
two bundled memcached instances or memcached instances dynamically
looked up via EC2 instance tags.

Running It

docker run -d -p 22121:22121 -p 22222:22222 zapier/twemproxy

Now you should be able to point any run of the mill memcached client at
it on port 22121 and start using it with two bundled memcache instances


You can also use this with other memcache containers via linking. For
example let's start up 3 memcache containers.

docker run --name a -d --expose 11211 tutum/memcached
docker run --name b -d --expose 11211 tutum/memcached
docker run --name c -d --expose 11211 tutum/memcached

Now let's link them so that they are proxied by twemproxy. The only
requirement here is that the link name MUST start with the name
"memcache" as we look for links that begin with this name and auto add

docker run \
  --link a:memcache1 \
  --link b:memcache2 \
  --link c:memcache3 \
  -d -p 22121:22121 twemproxy 

You can also specify consistent node names so you can ensure the same
routing algorith regardless of IP address changes.

docker run \
  --link a:memcache1 \
  --link b:memcache2 \
  --link c:memcache3 \
  -d -p 22121:22121 twemproxy 

This will generate a nutcracker configuration like the following.

  auto_eject_hosts: false
  distribution: ketama
  hash: fnv1a_64
  hash_tag: 'P:'
  - bumblebee
  - optimus
  - optimus
  timeout: 250

AWS Support

You can swap out the embedded backends for real backends on EC2 by
defining a series of environment variables to define what instances to
use as backends based on tags.

docker run -d \
  -p 22121:22121 -p 22222:22222 \
  -e AWS_TAG_NAME=role \
  -e AWS_TAG_VALUE=cache \
  -e AWS_PUBLIC_IP=false \

This will collect all EC2 instances tagged with role=cache and populate
the backend list with private IP addresses.

If you desire to use consistent node names for each memcache node, tag instances with a tag named "cache-node-name" with the name you want to give the node.

Docker Pull Command
Source Repository