Which programming language does Facebook use to store, query, and update user data?


The Programming Languages Running The Massive Social Network of Facebook

You may have visited Facebook at some point in time in your life. There are  2 billion inhabitants of planet Earth who use Facebook in some form. Out of these 2 billion users, nearly 900 million are active users. Have you ever asked yourself, how does Facebook run such a gigantic social media cogwheel? Which programming languages does it use to store user data, answer your queries, and update your requests?

In this article, we look at the programming languages that power the vast social networking engine of Facebook.

Understanding Facebook’s social network

Before we enter into the programming details, we take a look at the massive thing called Facebook. To understand the semantics, Facebook’s user base is larger than the world’s most populated country, China by a mile.

  • Facebook had 2.50 billion users out of which 970 million are actively using at any point in time.
  • Facebook offers its services is available in over 100 languages
  • Every 60 seconds 317 thousand Facebookers update their status
  • Every 60 seconds 147 thousand new images are uploaded on Facebook
  • Every minute, nearly 54 thousand links are shared on Facebook
  • Facebook users generate 8 billion video views per day on average, 20% of which are live-streamed
  • Facebook has 20 million square feet of data center space which host millions of servers

How does a site as large as the Facebook store, query, and update user data?

Facebook is one of the original LAMP users. It uses Linux, Apache, MySQL, and PHP, 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. Its basic functions are still done using

To start with, Facebook is the largest user of the MySQL database distributed across data centers in the U.S, Asia, and Europe. 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 also uses Linux but has optimized it for its own purposes (especially in terms of network throughput).


Facebook has the world’s largest Memcached installation. Memcached is a distributed memory caching system that Facebook uses as a caching layer between the web servers and MySQL servers. Over the years, Facebook has made a ton of optimizations to Memcached and the surrounding software. Facebook runs thousands of Memcached servers with tens of terabytes of cached data at any one point in time.

PHP and HipHop Virtual Machine (HHVM)

PHP that powers the Internet is used by Facebook extensively though it is converted in C++. HipHop 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. A small team of engineers from Facebook spent 18 months developing HipHop, and it was used for a few years. The project was discontinued back in 2013 and then replaced by HHVM (HipHop Virtual Machine).


Facebook uses a system called Haystack for photo storage/photo retrieval system. Haystack is an object store and has been modified by Facebook to share/store and retrieve more than 20 billion uploaded photos. Remember, each photo is saved in four different resolutions, resulting in the storage of more than 80 billion photos for instantaneous retrieval. Remember, Facebookers upload around 147,000 photos every minute which makes it 2,450 photos per second.


BigPipe is a dynamic web page serving system that Facebook has developed. Facebook has divided its page into small pagelets or web sections which can be easily served to the end-user. If you click on your friend’s Facebook update, it will open as an independent webpage due to BigPipe. Similarly, you can use the chat window within Facebook or independently.


Thrift is the in-house programming framework developed by Facebook. It is basically a cross-language framework that ties PHP, Erlang, Java, and C+++. Independently, Facebook uses PHP for the front-end, Erlang is used for Chat, Java, and C++ are also used in several places. The Thrift framework makes these multiple languages operate together error-free.

Facebook also uses traces of Varnish-the HTTP accelerator and React. React is an open-source JavaScript library created in 2011 by Jordan Walke.

Now you know what Facebook is made of. It’s like Facebook engineers are scaling Mount Everest of data every time they work. Using different programming languages to power the world’s largest social media network can be very tiring.


About Author

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." Eric Schmidt

Notify of
Inline Feedbacks
View all comments