Netflix is a high-profile consumer service. When things go wrong, people tend to notice. So it might seem strange that the company tries to make things go wrong with its service on a regular basis.
That's indeed the goal of "Chaos Monkey," the automated software Netflix developed to test its infrastructure's mettle. In layman's terms, Chaos Money tries to break stuff. The theory behind this is to build a stronger platform and avoid the types of major, unexpected problems that tend to make IT's phones ring at 2 a.m. (Netflix configures the tool to run only during normal business hours; that way IT staff handle any related issues during the day instead of on nights and weekends.)
Now everyone can embrace the chaos: Netflix just made the source code publicly available as a free download. You'll first need to ask yourself if you've got the guts for it. Or, as Netflix put it in a blog post: "Do you think your applications can handle a troop of mischievous monkeys loose in your infrastructure?"
[ Security researcher Dan Kaminsky wants to address security by changing the fundamental way code is written. Read more at Tired Of Security Problems? Change Rules Of Writing Code. ]
If you're picturing the band of winged monkeys from "The Wizard of Oz" running amok, you're not far off--they've just been reengineered for the cloud. Chaos Monkey deliberately shut downs virtual machines (VMs) within Amazon's Auto-Scaling Groups (ASGs). (Though the software was written with Amazon Web Services in mind, Netflix said Chaos Monkey is flexible enough to work with other cloud platforms.)
By causing intentional failures on individual instances--Netflix generated more than 65,000 failures in the last year, according to the company--you can learn from those errors and their resolutions. Basic example: Is your application hardy enough to weather a failed VM, or could that single instance bring the curtains down on the whole show?
That type of no-holds-barred testing can help unearth and resolve unknown issues before they become major outages. Better yet, it can lead to stronger applications as they're being built, rather than trying to retrofit them after the fact. "By having that constant idea that something's going to break, [Netflix has] within their dev ops and engineering departments the mindset that they have to make sure that no single point can take down the entire site," said Jim MacLeod, product manager at the networking firm WildPackets, in an interview.
In Netflix's case, it makes sense to try to rise to Chaos Monkey's challenge--their bottom line depends upon their site running smoothly. "If you look at Netflix's business model, what really differentiates them isn't just streaming media--it's the fact there's something immediate and easy for users to get to, but that means they have to be fairly reliable," MacLeod said. "Reliability and uptime are things that are difficult to put in afterwards if you don't design it in, just like security."
It's worth noting that Chaos Monkey is not a security tool, per se. It's not intended to unearth the types of flaws that might lead to a targeted hack or other security breach. MacLeod said it's better characterized as an automated QA tool, though it could help inspire a more serious approach to security in the process.
Chaos Monkey can conceivably help any organization that deploys applications via the cloud. So should you turn the monkey loose? Small and midsize businesses (SMBs) that beg off testing for budget reasons, for example, can't argue with Chaos Monkey's price tag. But MacLeod's not too sure many SMBs are prepared for what the software will do. If you lack the resources to quickly respond to downtime, Chaos Monkey is probably not for you. "There's not a 'reverse' of Chaos Monkey to bring things back up [automatically]," MacLeod said.
No matter your company's size, there are two prerequisites before running Chaos Monkey, according to MacLeod. First: "Know what you're getting into. This is something that is designed to cause problems," MacLeod warned. Chaos Monkey could very well knock you offline, something that's likely to inspire fear in some corners of the business. MacLeod also pointed out that it might be just as scary--and probably for good reason--if you turn on Chaos Monkey and nothing breaks.
The second prerequisite is to have the proper organizational philosophy. Given the tool's purpose--to break stuff--you'd better have buy-in from your bosses before turning it on. Imagine trying to explain yourself to non-technical management after the fact if Chaos Monkey runs rampant within your infrastructure. ("A chaos what?!") "It requires an adventurous spirit and confidence that you've got an architecture that's going to survive this, plus enough humility to know that you're willing to test your site to get better," MacLeod said. "One of the big problems out there is arrogance--'Oh, I know I don't have any problems.'
Even if you're unwilling or unable to invite Chaos Monkey inside your infrastructure, it can still offer a valuable lesson from safe distance. "The best thing about Chaos Monkey is that it's making people think about security and uptime and helping them realize that these aren't optional features in a service. They're something that needs to be designed in from the beginning," MacLeod said. Cutting corners on reliability will lead to unexpected failures--and a bunch of unhappy customers.
"It's like realizing, two-thirds of the way through building a car, that you kind of need an engine and a gas tank, and then trying to figure out where to shove those in," MacLeod added. "It's a lot easier if you start out with the reliability and the security in mind."
This Dr. Dobb's virtual event, Developer-Based Testing, will examine developer-based testing of code in its many forms: the tools, the techniques, the best practices. Sessions led by established experts explain the subtleties of different approaches and the best practices that have worked best in the field. If you want to know more about how to test your code with less effort and better results, one or all of the day's sessions are for you. It happens Aug. 2.