memcached - a distributed memory object caching system

Introduction: Memcached Proxy - Dormando (March 27, 2024)

What is this and why?

A generic cache pool management proxy, built into the memcached daemon. It supports all of the text protocol. It is designed to abstract clients away from pools of memcached servers, for ease of management, scale-out, and portability. It uses Lua to create a highly flexible configuration system, allowing a company to fully customize how requests are routed to fit their specific needs. It also comes with standard libraries for common use cases.

The proxy can manage pools of servers locally, across availability zones, replicate set and delete traffic, and send keys to different pools based on flexible rules. It is fast (hundreds of thousands of rps at least) with frequent improvements to the performance.

The proxy is built into memcached to simplify deployment and enable code re-use; all of memcached’s client handling code is reused for the proxy, including TLS management. The proxy adds no new external dependencies so it is easy and fast to compile and deploy. Being embedded in the cache daemon allows flexible topology designs, which we will talk about in future posts.

Why make this when other proxies exist? There are a couple popular memcached specific proxies, but they are either abandoned or hard to build. This proxy is fully supported by the community. Existing proxies are designed for the company they were built at; with our flexible configuration system we can avoid restricting people to designs and compromises taken at these larger companies.

We are early in the process of getting this proxy to end users. If you feel something is missing or undocumented, please reach out and let us know!

Common deployment architectures are discussed in the wiki

More can be answered by the full documentation

Quickstart Guide

This guide needs version 1.6.26 or newer. Enabling the proxy is as easy as adding an extra configure argument:

./configure --enable-proxy
make
make test # optional

You can also use Docker to try out the proxy with our standard routing library:

# this image expects a "config.lua" to be in the directory
# you will need to start backend memcached's on your own!
docker run -v /path/to/config/directory:/config:ro --publish 11211:11211 \
    dormando/memcached:next-proxy

This docker image is based off of the memcached “next” branch. All code in the “next” branch is intended to be production ready, and then we cut a release tag and tarball off of this every month or two. We will also have Docker images for the release tarballs, however using the “next” branch for now will let us more quickly respond to user needs.

The best place to get started with simple configurations is looking at the routelib library

The library is under active development: if there are routes or features you would like to see please let us know. It is very quick to add or extend logic to routelib.

What's next?

This blog post demonstrates the basic capability of the new proxy, and future posts will go deeper into more examples and how to build your own route library.