Mcrouter is a Memcached protocol router for scaling Memcached deployments. It’s a core component of cache…
Mcrouter is a Memcached protocol router for scaling Memcached deployments. It’s a core component of cache infrastructure at Facebook and Instagram where mcrouter handles almost 5 billion requests per second at peak. See FB engineering blog post about mcrouter.
Mcrouter is developed and maintained by Facebook.
Because the routing and feature logic is abstracted from the client in mcrouter deployments, the client may simply communicate with destination hosts through mcrouter over a TCP connection using standard Memcached protocol. Typically, little or no client modification is needed to use mcrouter, which was designed to be a drop-in proxy between the client and Memcached hosts.
Mcrouter supports typical Memcache protocol commands like getting, set, delete, etc. and specific commands to access stats, version and so on.
Release v0.14.0. (November 25, 2015) Starting today, we will sync all mcrouter commits continuously to the master branch of our GitHub repo. In addition, we will be cutting a biweekly release branch that is intended to be stable and resilient to third-party incompatibilities. This week’s release appears as the release-14-0 branch in our GitHub repo.
Initial open source release (mcrouter 1.0) (September 15, 2014)
Immediately sends the same request to all child route handles. Does not wait for the response. Returns the default reply for the request right away as returned by NullRoute.
Immediately sends the same request to all child route handles. Returns the first non-error reply to come back. Other requests complete in the background and their replies are silently ignored.
Immediately sends the same request to all child route handles. Waits for the reply from first route handle in the children list and returns it. Other requests are completed asynchronously in the background.
Immediately sends the same request to all child route handles. Waits for replies until a non-error result appears (half + 1) times (or all replies if that never happens), and then returns the latest reply that it sees (the effect is that typically the reply with the most common result is returned).
Immediately sends the same request to all child route handles. Collects all replies and responds with the “worst” reply (i.e., the error reply, if any).
Same as NullRoute, but with mcrouter stats reporting.
Immediately returns the error reply for each request. You can specify the error value to return: “ErrorRoute|MyErrorValueHere”
Sends the request to the first child in the list and waits for the reply. If the reply is a non-error, returns it immediately. Otherwise, depending on the settings, sends the request to the second child, and so on. If all children respond with errors, returns the last error reply. Note: miss (key not found) doesn’t count for an error. See MissFailoverRoute to failover misses.
FailoverRoute with additional settings. Sends request to normal route handle. If it responds with an error, checks settings, and failovers to failover if necessary.
Routes to the destination based on the key hash.
Routes to one destination chosen based on client host ID.
Load balances to a destination from a list of children. The two supported load balancing algorithms are “weighted-hashing” and “two-random-choices”.
In weighted-hashing, requests are hashed between the children taking into account a cached server load for each child.
In two-random-choices, two children are chosen at random and the child with the lowest load is selected.
In both algorithms, the load for each child is cached from a previous response and has a configurable expiry time. On expiry, it will be reset to the configured default server load.
For get-like requests, sends the same request sequentially to each route handle in the list, in order, until the first hit reply. If all replies result in errors/misses, returns the reply from the last destination in the list.
Modifies exptime (TTL) for all requests.
Returns the default reply for each request right away. Default replies are:
Sends to different targets based on specified key prefixes.
Route handle that routes to a pool. With different settings, it provides the same functionality as HashRoute, but also allows rate limiting, shadowing, et cetera.
Sends to different targets based on specified operations.
Routes to one random destination from the list of children.
Allows for substantial changes to the number of boxes in a pool without increasing the miss rate and, consequently, to the load on the underlying storage or service.
All sets and deletes go to the target (“cold”) route handle. Gets are attempted on the “cold” route handle and, in case of a miss, data is fetched from the “warm” route handle (where the request is likely to result in a cache hit). If “warm” returns a hit, the response is forwarded to the client and an asynchronous request, with the configured expiration time, updates the value in the “cold” route handle.
Tell us about a new Kubernetes application
Never miss a thing! Sign up for our newsletter to stay updated.
Discover and learn about everything Kubernetes