Newsletter Subscription | Glossary | Contact Us
Sample data
Home > All Categories > MySQL > Announcements > Keeping Up - Facebook scaling and replication with MySQL
Question Title Keeping Up - Facebook scaling and replication with MySQL
Authored by: Thomas Darwin
Viewed: 692 times so far
Almost two million new users from around the world sign up for Facebook each week—and we couldn't be happier. It's tremendously rewarding to see so many people find what we work on useful and fun. As we continue to add new users and features, however, the load on our thousands of servers continues to increase at a pretty astounding rate. A few weeks ago we reached full capacity in our California datacenters. In the past we handled this problem by purchasing a few dozen servers, hooking them up, and getting on with our lives, but this time we didn't have it so easy. We'd actually run out of space in our datacenters for new machines.

Fortunately we saw this problem coming a long time ago and started work on a new datacenter in Virginia. Now, we identify whether a user would be better off talking to the east coast datacenter or a west coast data center. For people in Europe and the eastern half of the US, it's noticeably faster to talk to a server in Virginia than in California. For these users we direct them to Virginia whenever they're browsing the site and not making any changes.

Whenever that person goes to change some data—uploading a photo album, or changing profile info for example—we send them off to California so that all our modifying operations happen in the same location. This decision was made to prevent two or more modifications from conflicting with each other and messing up our data. It might sound like we're forcing our users to go to California a lot but only about 10% of our traffic causes a modifying operation. MySQL has a great replication feature that allows us to, in real time, stream all the modifications happening on a California MySQL server to another one in Virginia. Replication happens so fast, even across the country, that the Virginia servers are almost never more than one or two seconds behind the California servers.

Even though all of the modification happens in California and streams instantly to Virginia, we were faced with another problem. Although Facebook's data is stored in MySQL database servers, we use a large number of memcached servers to store copies of the data. Memcached is much faster and able to keep up with requests quicker than the databases themselves can keep up. We had to figure out a way for memcached servers to replicate data concurrently with the MySQL databases. Because of various technical limitations of our architecture there was no easy way to do so.

Fortunately MySQL is open source software, meaning we can actually change the way it works by modifying the code. We did just that—embedding extra information in to the MySQL replication stream that allows us to properly update memcached in Virginia. This ensures that the cache and the database are always in sync. Over the last seven months a great team of Facebook employees has been building new software and setting up new servers like I described above. Over Thanksgiving we finally flipped the switch and since then almost 30% of our traffic has been served from Virginia.

The east coast datacenter is a great first step towards keeping Facebook fast and reliable as the site grows. Going forward we have lots of exciting plans to expand our infrastructure and improve performance so no user ever has to sit around waiting for a page to load.

Jason, a Facebook engineer, is all about the east coast.

Author : Jason Sobel
Source : http://blog.facebook.com/blog.php?post=7899307130
Click Here to View all the questions in Announcements category.
File Attachments File Attachments
User Comments User Comments
There are no user comments for this question. Be the first to post a comment. Click Here
Post Comment Add a Comment
Email Address:
Comment/Message
Verify Code

Post Comment How helpful was this article to you?
Related Questions Related Article
  1. Sun acquires MySQL
  2. What's New in MySQL 5.1
  3. MySQL Forge 2.0 released
  4. db4free.net now offers MySQL 6.0
  5. Open Source Groups Upbeat, Cautious on Sun-MySQL
  6. MySQL Enterprise Server 5.0.54a
  7. MySQL 5.1 Downloads
  8. Sun Microsystems Announces Agreement to Acquire MySQL, Developer of the World's Most Popular Open Source Database
  9. MySQL Magazine Scoop
  10. The 2008 MySQL Conference & Expo
  11. Virgin Mobile Implements MySQL Enterprise
  12. MySQL AB & Carahsoft to Host a Federal DBA Day on January 24
  13. Enabling Converged Services with MySQL Cluster
  14. Live Webinar: MySQL Performance Tuning Best Practices
  15. MySQL and Sun: A Letter from Mårten Mickos
  16. Sun Microsystems Announces MySQL 5.1
  17. Open-source community sees promise in MySQL deal
  18. A New MySQL Forge is Born
  19. Sun Completes Acquisition of MySQL
  20. Interview with Nokia's Olli Toivanen
  21. 25 years of Open Source
  22. MySQL Jobs
  23. Pursing new ventures with MySQL
  24. Testing the new MySQL Forge
  25. Comsys Selects the MySQL Embedded Server for its Voice Over IP Solutions
  26. New Forge: Missing the bug!
  27. Falcon Storage Engine Beta Now Available
  28. MySQL Server is Open Source, even Backup extensions
  29. Why is MySQL more popular than PostgreSQL?
  30. New Release of MySQL 5.1.25 Release Candidate
  31. Win a Free Ticket to the MySQL Users Conference!
  32. MySQL 5.1 Storage Engine Architecture
  33. New MySQL forums
  34. Try and Buy MySQL on Sun Systems
  35. New Release of MySQL 5.1.24 (Release Candidate)
  36. Materialized Views in MySQL
  37. Web Developer Needed
  38. MySQL Enterprise Server 5.1 is ready
  39. It's official: The future of Sun/MySQL is open...and closed
  40. db4free.net again offers latest MySQL 6.0
  41. MySQL 5 1 Use Case Competition
  42. Donate to help Andrii Nikitin's son Ivan
  43. MySQL Live Webinar Introducing MySQL Products
  44. Ivan Nikitin: Contributions and Medical Status
  45. Live Webinar: MySQL Query Analyzer - Finding and Fixing Problem Queries
  46. Ivan Nikitin has arrived in Germany
  47. New Community release - MySQL 5.0.67
  48. New Release of MySQL 6.0.5
  49. New Release of MySQL 5.1.26
  50. MySQL Jobs
Article Information Additional Information
Article Number: 59
Created: 2008-01-23 11:42 AM
Rating No Rating
 
Article Options Article Options
Print Question Print this Question/Article
Email Question Email this Question/Article to Friend
Export to MS Word Export to MS Word
Bookmark Article
del.icio.us Bookmark del.icio.us Bookmark
Digg It Digg It
Furl It Furl It
Subscribe to Article Subscribe to Article
 
Language Translation Language Translation
 
Search Knowledge Base Search Knowledge Base