Database yang Digunakan Facebook untuk Menyimpan Data User

Database yang Digunakan Facebook

Sore ini seperti biasanya saya sedang melihat-lihat newsfeed facebook saya, tiba-tiba muncul salah satu postingan (link share) ke salah satu website (dexterstuff.com) yang membahas Database yang Digunakan Facebook untuk Menyimpan Data Usernya (silahkan cek di sini).

Ketika membacanya, jujur saya cukup kaget ketika mengetahui bahwa facebook menyimpan datanya di database MySql, karena selama ini saya menganggap bahwa Oracle atau Ms SQL Server yang lebih optimal untuk aplikasi berskala besar atau enterprise. Sebelum saya membahas lebih jauh, silahkan simak penjelasan lengkap dari dexterstuff.com tersebut: 

What database does Facebook use is one of the most common questions asked when folks start taking about what database is the most scalable for large scale web applications. In fact, it is usually a person who is an open source proponent, and knows very well that Facebook uses MySQL as their core database engine. Because of this fact, this is often the single biggest reason that developers use to push to get MySQL used in their company. I would imagine that is why it is a very popular Google query.

While Facebook uses MySQL, they do not use it as-is out of the box. In fact, their team has submitted numerous high-performance enhancements to the MySQL core and Innodb plug-in. Their main focus has been on adding performance counters to Innodb. Other changes focused on the IO sub-system, including the following new features :

  • innodb_io_capacity – sets the IO capacity of the server to determine rate limits for background IO
  • innodb_read_io_threads, innodb_write_io_threads – set the number of background IO threads
  • innodb_max_merged_io – sets the maximum number of adjacent IO requests that may be merged into a large IO request

Facebook uses MySQL as a key-value store in which data is randomly distributed across a large set of logical instances. These logical instances are spread out across physical nodes and load balancing is done at the physical node level. Facebook has developed a partitioning scheme in which a global ID is assigned to all user data. They also have a custom archiving scheme that is based on how frequent and recent data is on a per-user basis. Most data is distributed randomly. Amazingly, it has been rumored that Facebook has 1800 MySQL servers, but only 3 full-time DBAs.

Facebook primarily uses MySQL for structured data storage such as wall posts, user information, etc. This data is replicated between their various data centers. For blob storage (photos, video, etc.), Facebook makes use of a custom solution that involves a CDN externally and NFS internally.

It is also important to note that Facebook makes heavy use of Memcache, a memory caching system that is used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce reading time. Memcache is Facebook’s primary form of caching and greatly reduces the database load. Having a caching system allows Facebook to be as fast as it is at recalling your data. If it doesn’t have to go to the database it will just fetch your data from the cache based on your user ID.

So, while “What database does Facebook use?” seems like a simple question, you can see that they have added a variety of other systems to make it truly web scalable. But, still feel free to use the argument, “MySQL is as good or better than Oracle or MS SQL Server, heck, even Facebook uses it, and they have 1200 Million users!”.

Dalam penjelasan tersebut dijelaskan bahwa Facebook menggunakan MySql dengan penuh optimasi mulai menggunakan engine Innodb dan plugin Innodb IO nya, berikutnya Facebook menggunakan Memcache yang merupakan sistem memory caching yang ternyata (lagi) sangat bisa membantu mempercepat pengambilan data dari Database.

Baca juga  Cara Install Webuzo di VPS dengan OS CentOS

Dari artikel ini saya mendapatkan pengetahuan bahwa belum tentu aplikasi opensource itu kalah dari yang berbayar (commercial), selama kita bisa melakukan optimasinya maka sangatlah mungkin aplikasi tersebut memberikan nilai lebih untuk kita dibandingkan kita pakai aplikasi berbayar tapi kita tidak bisa melakukan optimasi/tunning.

Jadi inget kata-kata saya sendiri untuk istri saya, tapi ini sih soal masakan. Saya suka bilang ma dia kalo saya mending makan tempe yang dikasih bumbu yang pas dan digoreng/diolah dengan enak daripada makan ayam goreng yang dikasih bumbu ngasal dan juga digoreng sekira-kiranya aja. :p