Facebook Server Architecture

Source: Internet
Author: User
Tags php server qcon

 

 

 

General hierarchy

 

Facebook's architecture can be divided from different perspectives.

 

One is:

One side is the classic LAMP stack of PHP; the other side is a variety of non-PHP services.



Facebook pages have been developed using PHP since the first time Zuckerberg wrote them. Backend services developed in various languages. They use cross-language thrift RPC communication (scribe is also built on thrift ).

 

Another angle is:

 


The front is the Server Load balancer (not hardware or software). It is responsible for allocating front-end web servers. The web servers use PHP to aggregate data. The last is
Services, memcached, and database.

What is interesting is the following three types of features:

Services-fast and complex;
You can develop your own business processes to implement complex business logic at a high speed.

Memchached-fast and simple; memchached performs simple key-value caching to serve fast read requests of applications.

Database-slow and persistent. The database performs persistent storage, and the disk Io is naturally slow, but it does not matter if memcached is used for caching.

 

 

 

 

NewsfeedArchitecture

 

Write:

Bob updates the status. The PHP program on the Web server not only sends the content to the MySQL database, but also sends the dynamic ID to a leaf through scribe.
Server (leaf server selected based on Bob's user ID ).

 

 

 

Read:

Another Alice opens Facebook, loads the home page, the PHP program queries the aggregator server (thrift call), aggregator from several leaf
The server reads the first 40 dynamic behaviors/actions of Alice's friends. aggregator performs aggregation and sorts them and returns them to the PHP program.

 


After the PHP program obtains these dynamic behavior IDs, it reads the content corresponding to these IDs from memcached. If memcached does not exist, it reads the content from the MySQL database. After aggregation, HTML is generated and returned to the browser.

 

 

 

 

ChatArchitecture

 

Page requests are still processed by the Web server (PHP). Of course, they also depend on various services after Web Tier. For example, viewing the message history, online user list, and sending chat messages.

 

When a chat message is received, the PHP server is not used. Instead, the channel server written in Erlang is used to process the chat message and long-polling is used to receive the chat message. The channel server is the core component of the chat service. The sent message is sent through the Web
Tier is sent to the channel server.

 

The chatlogger server written in C ++ is used to read and write historical records.

 

Similarly, C ++ is used to write the Presence Server to collect the online status from the channel server.

 

Shows the simplified structure of the system:

 

 

 

 

 

Web Tier, chatlogger, presence, Channel
Clusters composed of multiple servers.

The channel server partitions based on the user ID, and each partition is served by a highly available channel cluster.

Webtier, chatlogger, and presence, in public articles and PPT, do not explain how these clusters perform distribution and redundant backup.

 

 

 

 

Information on the Internet:

 

 

Http://www.infoq.com/presentations/Scale-at-Facebook

Aditya Agarwal, former Engineering director at qcon london2010
.

 

Http://www.infoq.com/presentations/Facebook-Software-Stack

Aditya Agarwal's speech at qcon sanfrancisco 2008 and qcon London 2010
There is no difference...

 

Http://www.infoq.com/presentations/Evolution-of-Code-Design-at-Facebook

Facebook engineer Nick Schrock introduced how they write code at qcon london2011.

 

Http://www.infoq.com/presentations/Infrastructure-at-Facebook

Jason Sobel, Team Manager of Facebook's basic platform (infrastructure), gave a speech at qcon San Francisco 2010.

 

Http://www.youtube.com/watch? V = T-Xr_PJdNmQ & feature = player_embedded

Velocity 2010: Tom Cook, "A Day In thelife of Facebook operations"

 

Http://www.erlang-factory.com/upload/presentations/31/EugeneLetuchy-ErlangatFacebook.pdf

 

Http://www.facebook.com/note.php? Note_id = 14218138919

 

 

Bytes -------------------------------------------------------------------------------------------------

For more blog posts, please subscribe to RSS. For more Weibo posts, please follow @ Qianli lone row nerd

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.