Facebook's mcrouter is a cool project for anyone with the need to horizontally scale caching clusters in dynamic environments like Kubernetes, where specific workload instances cannot expect unchanging internal IP addresses.
Finally, to achieve a truly dynamic setup is annoyingly verbose due to needing to regenerate JSON configuration files and diff them on a timer after doing a bunch of DNS lookups per memcached cluster.
Write your mcrouter configuration as you usually do, using dnssrv:
prefix to get a dynamic list of servers in a pool
based on a headless Kubernetes service.
For example, for headless service foo-headless
in namespace memcache
:
{
"route": "PoolRoute|dynamic",
"pools": {
"dynamic": {
"servers": [
"dnssrv:_memcache._tcp.foo-headless.memcache.svc.cluster.local"
]
}
}
}
- You can have pools with static servers, but you cannot mix dynamic and static server entries in the same pool
- in-cluster IPv6 addressing is not supported
- These images are downstream of Wikipedia's images of mcrouter, as compiling mcrouter is currently exceedingly difficult, slow and resource-intensive ( see PR #449 and linked issues/PRs). Debated instead using a plain image, but the extra size of a full image for 2 shell scripts seemed a little silly, when one probably wants to use a readymade mcrouter image anyway de to how annoying it is to build.