Internet Technology Explained

How Does Facebook Work? The Nuts and Bolts [Technology Explained]

Steve Campbell 27-02-2010

<firstimage=”//” />How Does Facebook Work? The Nuts and Bolts [Technology Explained] 0 intro facebookSocial networking is the art of connecting with those who share common interests. Your “˜network’ is a community that helps keep you united with others and offers many benefits. Networking via social media sites has revolutionized how we use the Internet and is at the forefront of what we now call Web 2.0.


Facebook is social networking. People have been “facebooking” each other for about 6 years now, making Facebook the most used social network with over 350 million users worldwide. But how does Facebook work?

In this article, I will discuss Facebook’s inner workings, covering its architecture and frontend/backend infrastructure””the nuts and bolts that hold Facebook together.

How Does Facebook Work?””The Front End

Facebook uses a variety of services, tools, and programming languages to make up its core infrastructure. At the front end, their servers run a LAMP (Linux, Apache, MySQL, and PHP) stack with Memcache. Not a computer science expert? Let’s take a look at exactly what that means.

Linux & Apache

how does facebook work


This part is pretty self-explanatory. Linux is a Unix-like computer operating system kernel. It’s open source, very customizable, and good for security. Facebook runs the Linux operating system on Apache HTTP Servers. Apache is also free and is the most popular open source web server in use.


how does facebook work

For the database, Facebook utilizes MySQL because of its speed and reliability. MySQL is used primarily as a key-value store as data is randomly distributed amongst 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.

As far as customizations are concerned, Facebook has developed a custom partitioning scheme in which a global ID is assigned to all 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.



how does facebook work

Facebook uses PHP because it is a good web programming language with extensive support and an active developer community and it is good for rapid iteration. PHP is a dynamically typed/interpreted scripting language.


how facebook works

Memcache is a memory caching system that is used to speed up dynamic database-driven websites (like Facebook) by caching data and objects in RAM to reduce reading time. Memcache is Facebook’s primary form of caching and helps alleviate 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.

Downsides to Using LAMP

Facebook has realized that there are downsides to using the LAMP stack. Notably, PHP is not necessarily optimized for large websites and therefore hard to scale. Also, it is not the fastest executing language and the extension framework is difficult to use.

how facebook works

Mike Schroepfer, Facebook’s Vice President of Engineering, recently did an interview at EmTech@MIT concerning this. “Scaling any website is a challenge,” Schroepfer said, “but scaling a social network has unique challenges.”


He went on to say that unlike other websites, you can’t just add more servers to solve the problem because of Facebook’s “huge interconnected dataset.” New connections are created all the time due to user activity.

Facebook has grown so quickly that they are often faced with issues regarding database queries, caching, and storage of data. Their database is huge and largely complex. To account for this, Facebook has started a lot of open source projects and backend services.

How Does Facebook Work?””The Back End

Facebook’s backend services are written in a variety of different programming languages including C++, Java, Python, and Erlang. Their philosophy for the creation of services is as follows:

1. Create a service if needed

2. Create a framework/toolset for easier creation of services

3. Use the right programming language for the task

A list of all of Facebook’s open source developments can be found here. I will discuss a few of the essential tools that Facebook has developed.

Thrift (protocol)

How Does Facebook Work? The Nuts and Bolts [Technology Explained] 7 fb thriftThrift is a lightweight remote procedure call framework for scalable cross-language services development. Thrift supports C++, PHP, Python, Perl, Java, Ruby, Erlang, and others. It’s quick, saves development time, and provides a division of labor of work on high-performance servers and applications.

Scribe (log server)

Scribe is a server for aggregating log data streamed in real-time from many other servers. It is a scalable framework useful for logging a wide array of data. It is built on top of Thrift.

Cassandra (database)

how facebook works

Cassandra is a database management system designed to handle large amounts of data spread out across many servers. It powers Facebook’s Inbox Search feature and provides a structured key-value store with eventual consistency.

HipHop for PHP

HipHop for PHP is a source code transformer for PHP script code and was created to save server resources. HipHop transforms PHP source code into optimized C++. After doing this, it uses g++ to compile it to machine code.


In a nutshell, that’s Facebook. This article could easily be 37 pages longer if I were to go into more detail, but to answer the question “How does Facebook work?” I think this will suffice. If you look past all of the features and innovations the main idea behind Facebook is really very basic””keeping people connected. Facebook realizes the power of social networking and is constantly innovating to keep their service the best in the business.

Did you find this article useful? Leave your thoughts, comments, and ideas below!

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. isaac
    January 23, 2018 at 8:34 pm

    Great effort and can be developed to assist programmers

  2. Harshita
    January 2, 2018 at 1:16 pm

    Very crisp and concise. Please proivde link to a bit more detailed article for those interested.
    Thanks a lot for this one.

  3. Nellaiappan
    October 9, 2017 at 4:41 pm

    Very helpful...Update more

  4. Basil Consolation
    October 12, 2016 at 5:07 pm

    Wow I'm planning on working on my social net platform, but what are the main languages needed for a start.tnx as u reply

  5. James
    October 12, 2016 at 1:36 pm

    Why does face book follow people so closely is our key strokes being watched if so that is creepy at best alarming at worst is all this info shared with government agencies? Plus fb seems to involve itself in politics a mite too much and thwarts religious comments why?

  6. himanshu
    September 9, 2016 at 7:34 am

    very nice post.
    i like very much.

  7. Ath J
    July 22, 2016 at 6:04 pm

    Really interesting post.

  8. ariell
    March 4, 2016 at 7:30 pm

    which is the css processor they are using?

  9. shaksha
    December 16, 2015 at 3:26 am

    Good one

  10. anu
    April 26, 2015 at 5:07 am

    good post and really informative for students

    • resar
      June 18, 2016 at 8:04 am


  11. Rajani Karthik
    April 22, 2015 at 6:25 am

    Nice Post Steven! In distributed system how they handle with mysql. if it is regional wise data handling in mysql then if a personal travalling from one region to other region how it is handled. are they in cloud. can you provide your valuable info here thanks

  12. Rama
    April 20, 2015 at 2:42 pm

    I always heard facebook is done using PHP, in a Nut Shell this helps to understand how its been done.

  13. peter
    April 17, 2015 at 10:48 am

    Hello, Mr Steve i read your post about Facebook and I really appreciate your knowledge. I am new to website development n I your personal support to get some a website work. Please I hope to get a reply from you on how I start up

  14. Nitesh Pandey
    April 7, 2015 at 7:10 am

    I think best part of his post is not so big....
    Small but powerful:)

  15. Chandan Sinha
    March 19, 2015 at 12:05 pm

    That was quick glance through the working infrastructure of social networking giant. I really liked it but one thing that was missing , as pointed out in the other comment as well, as to what happens between Facebook account users and the Facebook programmers and coders, the complexity of connections, etc. It would surely help to comprehend the 'behind-the-curtains' networks. Hope to see some post addressing this in future & thanks a lot for this post :)

  16. R Nimai
    March 8, 2015 at 10:13 am

    It's very cool when i red this post. and how exactly does the facebook works.....

    Thanks for providing

  17. Pragathi
    February 28, 2015 at 4:29 am

    which is the toughest syntax in facebook programing?????

  18. Chintan
    January 24, 2015 at 11:40 am


    I am interested in knowing how the database is managed of facebook.

  19. tolustar
    December 17, 2014 at 1:28 pm

    informative, thank you so much

  20. gaga
    December 11, 2014 at 5:58 am


  21. Ted Thompson
    May 14, 2010 at 1:08 am

    Very interesting post. Learnt a few things I didn't know..! Thanks for sharing.

    • Steve Campbell
      May 14, 2010 at 1:38 am

      You're welcome Ted. Thanks!

  22. lisa
    March 30, 2010 at 7:00 pm

    why does object does not support this property or method reqs.php char 7893 line 10

  23. Milind Kale
    March 5, 2010 at 10:40 pm

    Really in a nutshell and very informative too goooood ...Good work !

    • Steven Campbell
      April 1, 2010 at 8:02 am

      Thanks! If you liked that I'm sure you'll like some of our other posts.

  24. idrees
    March 5, 2010 at 8:50 pm

    Duty paid

  25. Application Development Company
    March 2, 2010 at 5:18 am

    Thank you guy, you explore the Facebook coding languages very well. Python is used by Google for its products.

  26. zacharty
    March 1, 2010 at 11:26 am

    good one. its hard to find info rgdg the technologies used by these big sites. you did good.

  27. Babak
    March 1, 2010 at 3:00 am

    Thanks for the great post.
    What about the Tornado (python web server)? Isn't Facebook using that?

    • Steven Campbell
      March 1, 2010 at 8:36 am

      Tornado is one of the open source developments that Facebook has been working on. It's my understanding that they use it primarily to run FriendFeed at this point.

  28. plsburydoughboy
    February 28, 2010 at 9:32 pm

    I'm afraid it's still too esoteric for greenhorns like me. I can see that you went with the basic information, but rather than disclosing the programs and systems used, I was expecting a piece explaining what happens between Facebook account users and the Facebook programmers and coders. How the complex web of connections was established and maintained, and how new connections are added in while prior connections stay persistent.

    Well, don't want to get too down on you, but I suppose this is more of a request for what I'd want to see in an article explaining how FB works.

    • Steven Campbell
      March 1, 2010 at 8:34 am

      I agree. I would have loved to have been able to write an article like that, but the truth is that information is very difficult to find. I would have to interview someone at Facebook to understand the true inner workings, which I wouldn't mind doing some day.

  29. pthesis
    February 28, 2010 at 11:55 am

    Great topic for an article. The rest of us developers can learn a lot from seeing how big sites like Facebook and Amazon work.