What technology stack does Facebook use?

What is Facebook's architecture?

Michaël Figuière at Quora Visit the source

Was this solution helpful to you?

Other answers

Facebook uses Linux, Apache, PHP, Memcache, Haystack, and BigPipe. This tech stack seems straight forward, but a lot of optimization is being done under the hood to make it work with the load such a popular site receives, and also the mass amounts of data people upload to and request from. Read the details here: http://en.wikipedia.org/wiki/Facebook http://www.slideshare.net/meet.hak/facebook-technology-stack

Alex Freska

I have written http://blog-bhaskaruni.blogspot.in/2012/12/facebook-architecture.html based on Quora and web-posts  Please comment and suggest. Your comments help me, to write more of this kind :)

Ravi Bhaskaruni

Here's a very interesting presentation by a Facebook engineer about how their architecture has evolved. http://www.infoq.com/presentations/Evolution-of-Code-Design-at-Facebook

Simon Gardner

The backend is PHP but it is precompiled using a system they developed called HipHop The database is a highly customized MySQL database.  Here are some details about the system they use: http://www.z-car.com/blog/mysql/what-database-does-facebook-use

Bart Loews

Facebook recently shared on its blog a detailed overview of its next-gen networking architecture, which it piloted at its new Altoona data center. it's quite an innovative approach for coping with their massive traffic volumes, which goes beyond traditional approaches and protocols. fascinating stuff. https://horovits.wordpress.com/2014/12/04/facebook-next-gen-networking-datacenter-fabric/ Another interesting bit is the recently-announced enhanced Facebook Search, which is supported by big data analytics and data management foundations, some of which were discussed a few months ago on a data faculty summit hosted by Facebook, in which Facebook shared its top open data problems. https://horovits.wordpress.com/2014/12/11/facebooks-big-data-analytics-boost-search-capabilities/

Dotan Horovits

At the scale that http://facebook.com/ operates, a lot of traditional approaches to serving web content break down or simply aren’t practical. The challenge for Facebook’s engineers has been to keep the site up and running smoothly in spite of handling close to half a billion active users. This article takes a look at some of the software and techniques they use to accomplish that.Facebook’s scaling challengeBefore we get into the details, here are a few factoids to give you an idea of the scaling challenge that Facebook has to deal with: Facebook serves 570 billion page views per month (according to Google Ad Planner). There are more photos on Facebook than all other photo sites combined (including sites like Flickr). More than 3 billion photos are uploaded every month. Facebook’s systems serve 1.2 million photos per second. This doesn’t include the images served by Facebook’s CDN. More than 25 billion pieces of content (status updates, comments, etc) are shared every month. Facebook has more than 30,000 servers (and this number is from last year!) Software that helps Facebook scaleIn some ways Facebook is still a LAMP site (kind of), but it has had to change and extend its operation to incorporate a lot of other elements and services, and modify the approach to existing ones.For example: Facebook still uses PHP, but it has built a compiler for it so it can be turned into native code on its web servers, thus boosting performance. Facebook uses Linux, but has optimized it for its own purposes (especially in terms of network throughput). Facebook uses MySQL, but primarily as a key-value persistent storage, moving joins and logic onto the web servers since optimizations are easier to perform there (on the “other side” of the Memcached layer). Then there are the custom-written systems, like Haystack, a highly scalable object store used to serve Facebook’s immense amount of photos, or Scribe, a logging system that can operate at the scale of Facebook (which is far from trivial).But enough of that. Let’s present (some of) the software that Facebook uses to provide us all with the world’s largest social network site.MEMCACHEDhttp://memcached.org/ is by now one of the most famous pieces of software on the internet. It’s a distributed memory caching system which Facebook (and a ton of other sites) use as a caching layer between the web servers and MySQL servers (since database access is relatively slow). Through the years, Facebook has made a ton of optimizations to Memcached and the surrounding software (like optimizing the network stack).Facebook runs thousands of Memcached servers with tens of terabytes of cached data at any one point in time. It is likely the world’s largest Memcached installation.HIPHOP FOR PHPPHP, being a scripting language, is relatively slow when compared to code that runs natively on a server. http://wiki.github.com/facebook/hiphop-php/ converts PHP into C++ code which can then be compiled for better performance. This has allowed Facebook to get much more out of its web servers since Facebook relies heavily on PHP to serve content.A small team of engineers (initially just three of them) at Facebook spent 18 months developing HipHop, and it is now live in production.HAYSTACKhttp://www.facebook.com/note.php?note_id=76191543919 is Facebook’s high-performance photo storage/retrieval system (strictly speaking, Haystack is an object store, so it doesn’t necessarily have to store photos). It has a ton of work to do; there are more than 20 billion uploaded photos on Facebook, and each one is saved in four different resolutions, resulting in more than 80 billion photos.And it’s not just about being able to handle billions of photos, performance is critical. As we mentioned previously, Facebook serves around 1.2 million photos per second, a number which doesn’t include images served by Facebook’s CDN. That’s a staggering number.BIGPIPEhttp://www.facebook.com/notes/facebook-engineering/bigpipe-pipelining-web-pages-for-high-performance/389414033919 is a dynamic web page serving system that Facebook has developed. Facebook uses it to serve each web page in sections (called “pagelets”) for optimal performance.For example, the chat window is retrieved separately, the news feed is retrieved separately, and so on. These pagelets can be retrieved in parallel, which is where the performance gain comes in, and it also gives users a site that works even if some part of it would be deactivated or broken.CASSANDRAhttp://cassandra.apache.org/ is a distributed storage system with no single point of failure. It’s one of the poster children for the NoSQL movement and has been made open source (it’s even become an Apache project). Facebook uses it for its Inbox search.Other than Facebook, a number of other services use it, for example Digg. We’re even considering some uses for it here at Pingdom.SCRIBEhttp://github.com/facebook/scribe is a flexible logging system that Facebook uses for a multitude of purposes internally. It’s been built to be able to handle logging at the scale of Facebook, and automatically handles new logging categories as they show up (Facebook has hundreds).HADOOP AND HIVEhttp://hadoop.apache.org/ is an open source map-reduce implementation that makes it possible to perform calculations on massive amounts of data. Facebook uses this for data analysis (and as we all know, Facebook has massive amounts of data). http://hadoop.apache.org/hive/ originated from within Facebook, and makes it possible to use SQL queries against Hadoop, making it easier for non-programmers to use.Both Hadoop and Hive are open source (Apache projects) and are used by a number of big services, for example Yahoo and Twitter.THRIFTFacebook uses several different languages for its different services. PHP is used for the front-end, Erlang is used for Chat, Java and C++ are also used in several places (and perhaps other languages as well). http://incubator.apache.org/thrift/ is an internally developed cross-language framework that ties all of these different languages together, making it possible for them to talk to each other. This has made it much easier for Facebook to keep up its cross-language development.Facebook has made Thrift open source and support for even more languages has been added.VARNISHhttp://varnish-cache.org/ is an HTTP accelerator which can act as a load balancer and also cache content which can then be served lightning-fast.Facebook uses Varnish to serve photos and profile pictures, handling billions of requests every day. Like almost everything Facebook uses, Varnish is open source.Hope you got what you wanted !!!

Ashutosh Tripathi

In regards to Michaël Figuière's excellent response, the only thing I can see that is no longer true is their use of Cassandra.  It is no longer in use inside of Facebook.  This got flagged as needing to be a comment to another answer, but you can't comment on an answer as anonymous.   So until Quora changes that policy, this will have to stand alone as an answer.

Anonymous

Facebook Real Time Analytics system is based on Scribe to log all incomming links from like and comments request on a user page. Store them into HDFS than pull them out using Puma and store them on HBase in batches. I wrote a detailed post outlining the Facebook Real Time analytics architecture here: Real Time analytics for Big Data: Facebook's New Realtime Analytics System  - http://ht.ly/8OGHD This post include references to vidoe cast and other useful references on that regard.

Nati Shalom

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.