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.
Overall, this stuff's a pain and this repo aims to take care of it all for use-cases similar to ours.
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 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.