Facebook is releasing mcrouter, its software for turning many cache servers around the world into one distributed system, as open source.
The company announced the release on Monday at its @Scale conference in San Francisco, where it also launched a new open-source project called TODO (Talk Openly, Develop Openly) to make it easier for organizations to use open-source software.
By offering mcrouter as open source, under a BSD (Berkeley Source Distribution) license, Facebook is making the tool available to more users. Facebook is already using it to handle traffic involving thousands of cache servers at the company's data centers around the world, and recent Facebook acquisition Instagram used it on AWS (Amazon Web Services) before switching over to its new parent company's infrastructure, Facebook engineer Rajesh Nishtala said at the conference.
Facebook claims mcrouter can handle almost 5 billion requests per second. The company does more than 4 billion operations per second through its cache tier, while Instagram does about 100 million, Nishtala said.
Cache servers keep the data most used for an application available in RAM for quick delivery, saving applications from having to dig those bits out of storage, Nishtala said. But what was once a nice-to-have performance booster is now relied on for some services, so how it's implemented is critical.
"Sites could become dependent on cache, and the loss of cache could have adverse effects for any site that leverages cache," Nishtala said.
To take full advantage of all the caches in a distributed infrastructure, Facebook developed mcrouter.
Specifically, mcrouter handles traffic for cache infrastructures that use Memcached, a popular distributed memory caching system. It uses the standard ASCII Memcached protocol as an API (application programming interface), because all clients capable of talking to Memcached servers understand that protocol, Facebook said. To clients, mcrouter looks like a Memcached server, and to servers, it looks like a client.
All the features of mcrouter were developed to solve real-world challenges at Facebook and Instagram, so they're all production quality, he said. All of the companies' cache operations go through mcrouter.
Mcrouter handles a wide range of tasks required to keep a cache infrastructure running and efficient, including monitoring, automatic failover detection and cold cache warmup, Nishtala said. Facebook used to implement those functions in its PHP stack. "As you can imagine, this stack got pretty loaded, pretty quickly," Nishtala said. Inconsistent implementations can lead to corrupted data, so Facebook wanted to rein in its caching infrastructure.
Among other things, mcrouter can act as a front end to many Memcached servers, allowing companies to distribute a growing data set across multiple servers when it no longer fits on one. It can also divide memory space into separate pools for different workloads, saving those workloads from having to share space.
Another common cache problem is the lag that can come when new or recently reset servers have to be repopulated with data in demand. When the local memory pool for a given client is empty and an application can't quickly get the data it needs, mcrouter can look in a neighboring "warm" pool that's already up-to-date with the bits that are in demand. After coming through in a pinch, mcrouter can then automatically start populating the new pool with data from the warm one.
This type of "reheating" problem has been a big one for Reddit, which is now testing mcrouter, said Ricky Ramirez, an operations engineer at the social media site. Reddit runs entirely on AWS and consumes up to 300 servers at a time, backed by 73 back-end cache nodes with 1TB of memory, he said in a presentation at the conference.
When memory pools have to be taken down for modification, reheating the cache can take days, during which some users get slow page loads and "random error messages," Ramirez said. Mcrouter gives Reddit automatic failover, pooling of connections and other benefits, he said.