YouTube scales MySQL with Go code
YouTube's Vitess helps MySQL use less memory and run more efficiently
IDG News Service - YouTube engineers are developing a set of software, called Vitess, that will help open-source MySQL databases work more efficiently in very large-scale production environments. To write the code, they are using Google's programming language Go.
YouTube already uses one Vitess component, called Vtocc, to help serve videos to all of the service's 800 million monthly users. Google acquired YouTube in 2006.
Vtocc has "been very steady, and it has all the necessary tools for you to use in a production environment," said YouTube architect Sugu Sougoumarane, who, along with YouTube engineer Mike Solomon, discussed Vitess at the Usenix LISA (Large Installation System Administration) conference, held this week in San Diego.
That Vitess is written in Go could help validate the idea that this relatively new programming language could be used in large-scale production environments. Google introduced version 1 of Go in March.
YouTube serves more than 4 billion hours of video each month. About 72 hours of video are uploaded to the service every minute. While YouTube stores all its videos directly on a file system, it uses MySQL to store all the metadata needed to serve each video, such as user preferences, advertising information, country customizations and other needed bits of information.
YouTube likes using MySQL for its reliability, said Solomon, one of the engineers who originally built the service. It has quirks, but those quirks are well-known and can be mitigated fairly easily, he said. However, MySQL also has issues with scaling -- at least scaling to accommodate a service as large as YouTube's.
"The major problem with MySQL is that once you get to a certain point [of usage], you spend a lot of time managing hardware and how many instances you have," Solomon said. "We want to automate that chunk. We want to take every action that is complicated and error prone and make it heal itself."
MySQL also is not very efficient when used in a large deployment. Typically, each connection to MySQL requires its own thread on the server. This approach is not feasible at the scale of YouTube's operations, however. "Running tens of thousands of connections is not really viable," Solomon said.
The company's engineers, however, have been reluctant to try to change the core MySQL code itself, noting that making changes to the complex and somewhat difficult-to-understand code can often result in unanticipated effects. "It is not straightforward. Just when you think you know what you are doing, that's when you start getting in trouble," Solomon said.
So Vitess was created to run in conjunction with MySQL to offer additional management capabilities. The Vtocc component, for example, consolidates thousands of incoming SQL queries into a smaller number of batches so MySQL can take fewer resources fulfilling these requests. Vtocc also parses queries so they can be executed more efficiently, and reduces the work caused by duplicate queries by reusing the results from one query to satisfy the other identical requests.
Using Go has allowed YouTube developers to be more productive than they would have been using a more traditional language, Sougoumarane said.
Go code compiles quickly, he said. The 30,000 lines of code in Vitess can be compiled into binaries in about 30 seconds. And, thanks to a rich set of libraries, many tasks do not require that much programming. For instance, Sougoumarane wrote a 105-line routine that periodically trims log files, functionality that couldn't have been written in as few lines by using C or C++.
"That's how expressive Go is," Sougoumarane said. "The language features are well-thought-out. They help you compose things in a much more elegant way than traditional languages." Sougoumarane also praised Go's concurrency support, vital for use in multicore processors. "You don't have to worry about managing threads. Go manages them for you," he said.
The language also has some downsides, too, Sougoumarane admitted. Error handling could be improved, for instance. Scheduling and garbage collection could use some work as well.
Solomon said that, over time, Vitess will take on additional duties, such as database replication and automatic sharding, so a database can grow across multiple servers with no intervention from administrators.
- 15 Non-Certified IT Skills Growing in Demand
- How 19 Tech Titans Target Healthcare
- Twitter Suffering From Growing Pains (and Facebook Comparisons)
- Agile Comes to Data Integration
- Slideshow: 7 security mistakes people make with their mobile device
- iOS vs. Android: Which is more secure?
- 11 sure signs you've been hacked
- What Datapipe customers need to know about the new PCI DSS 3.0 compliance standard This handy quick reference outlines what PCI DSS 3.0 is, who needs to be compliant and how Alert Logic solutions address the new...
- The 12 PCI DSS 3.0 requirements addressed by Peer 1 Hosting This handy quick reference outlines the 12 PCI DSS 3.0 requirements, who needs to be compliant and how Alert Logic solutions address the...
- Defense Throughout the Vulnerability Life Cycle This whitepaper provides insight into how to leverage threat and log management technologies to protect your IT assets throughout their vulnerability life cycle.
- The Critical Role of Support in Your Enterprise Mobility Management Strategy Most business leaders underestimate the importance of tech support when they choose an EMM solution. Here's what to put on your checklist.
- Live Webcast Best Practices for the Hyperconverged Enterprise Network To the Age of Constant Connectivity and Information overload
- Live Webcast Unmasking the Differences between Consumer and Enterprise File Sync & Share The consumerization of IT combined with the rapid pace of the modern mobile workplace is forcing enterprise IT teams to evaluate file sync...
- Live Webcast Government Agency Webifies Outdated COBOL Applications Let this CTO tell you how his agency converted 1980s-era green screens into an e-filing portal for the 100,000 cases handled each year...
- The New Way to Work Knowledge Vault This Knowledge Vault focuses on how, in today's increasingly virtual world, it's more important than ever to engage deeply with employees, suppliers, partners,...
- Getting Ready for BlackBerry Enterprise Service 10.2 Find out how BlackBerry® Enterprise Service 10 helps organizations address the full spectrum of EMM challenges, while balancing the needs of both the... All Applications White Papers | Webcasts