When it comes to keeping its thousands of servers running smoothly, Facebook relies on the open source Chef configuration manager, modified slightly to handle the size of the social networking giant's huge infrastructure.
"Chef's biggest advantage for us is its flexibility," said Phil Dibowitz, a Facebook systems engineer.
Chef is one of a number of open source configuration management tools that have grown in popularity over the last few years.A As data centers grow ever larger, companies look to automate routine operations around deploying and upgrading servers, switches, OSes, databases and other components. Facebook's experience in managing its infrastructure may hold lessons for other organizations as well.A Facebook wanted "a new way to manage its systems," Dibowitz said. A Although Facebook does not reveal the total number of servers it runs, industry observers estimate it could be in the tens of thousands, at least. Surprisingly, the company only has a handful of employees -- four on latest count -- on the core infrastructure team, of which Dibowitz is a member. Prior to using Chef, Facebook had been using another open source configuration management package, called CFEngine. The deployment was growing increasingly unwieldy, however.A Using CFEngine version 2, Facebook was experiencing a rapid and unchecked proliferation of system control files.A With CFEngine, users could not edit a configuration management file directly. Instead, each time operations engineers needed to make a change to a system, they would copy a similar system file, make the necessary changes, and then submit the file back to CFEngine. "In doing so, they added a couple hundred lines of stale configuration," Dibowitz said. As a result, the infrastructure team did not know all the various configuration permutations it had on hand, or even which of the configuration settings were outdated. "It became really unsupportable," Dibowitz said. To look for a new open source configuration management system, the team ran a number of tests comparing Chef, Puppet, and Spine, which was developed by Ticketmaster.A
Chef best fit the bill for a number of reasons, Dibowitz explained.A
Chef offers great flexibility on how to write configuration changes, thanks in part to how it is based on Ruby, a full-fledged programming language that can be easy to learn for administrators and engineers.
"There's no limiting factor. You don't have to be in the Domain Specific Language [DSL] that CFEngine or Puppet gives you," Dibowitz said. "From there, we had a lot of power to do what we wanted."A
Chef offered a number of other advantages as well. It could manage settings at a A much more granular level. It also offered more flexibility in how to manage the configuration files themselves, Dibowitz said.A
Specifically, Chef provides the ability to modify a configuration file for a specific user.A
"The database administrators, the Web foundation guys, the cache guys -- all these people can write just a little bit of code for just the settings they care about, and not have to worry about anything else," Dibowitz said.A
For instance, if MySQL administrators need more memory for a database, they can just enter that single requirement into Chef. Any change made to a configuration file is then propagated across all of Facebook within minutes.
"If you make a change, it goes across the world in 30 minutes or less," Dibowitz said.A
Giving line-of-business engineers this control, in turn, helps the core infrastructure team. "This allows us to do way more work with way fewer people," Dibowitz said.A
Facebook, however, had to modify the way Chef handles out-of-date configuration changes. The software offers no easy way of automatically deleting changes when they are no longer needed. "This is not a comfortable thing to do when you are at the scale of hundreds of thousands of systems," Dibowitz said.
Typically, organizations use Chef by building their own "cookbooks," or list of configuration changes that Chef then applies to a system.A
Facebook, however, took the process a step further. The company's engineers developed a set of templates for defining the defaults in each configuration file, calculating a numerical hash to match the original template.A
Each time Chef runs a configuration file it can then use the hash value to delete all entries that have been designated as no longer needed.A
It is an uncommon way of using Chef, Dibowitz admitted. This way of working with Chef does not require any additional tooling, though. "This is all stuff built into Chef, we're just using it differently," he said.
The company has rolled out Chef to manage all of its servers and is in the process to migrating other software and hardware onto Chef as well.
Facebook has also fed some of the code modifications it has made back to the company shepherding the Chef code base, also now called Chef, after changing its name from Opscode in December.A
The engineers also wrote some additional open source utilities for Chef, some of which have been posted on GitHub. One such tool is called Grocery Delivery, which allows multiple Chef clusters to keep their cookbooks in sync. As a result of the code being on GitHub, others have contributed additional changes back to Facebook.
Perhaps most importantly for Facebook though, Chef allows system managers to have greater control of their own configurations, an approach that Dibowitz admitted has attracted some criticism, which he doesn't mind
"Our job at Facebook is to get out of the way of our engineers and let them do their jobs," Dibowitz said. "Our job is not only to make these systems reliable but also to give everyone the access they need to get their jobs done."