FB Documentation
FB Documentation
FB Documentation
TABLE OF CONTENTS
Page No.
Certificate ii Abstract iii
CHAPTER 1: INTRODUCTION
------------------------------------------------------------------
05
1.02. History
----------------------------------------------------------------
06
1.03. FACEBOOK
----------------------------------------------------------------
07
10
12
14
16
CHAPTER 3: CONTENTS
3.01. DATA BASE
----------------------------------------------------------------
3.02. MySql
---------------------------------------------------------------
19
3.03. HBASE
---------------------------------------------------------------
22
4 | Page
18
23
24
5 | Page
6 | Page
7 | Page
8 | Page
Chapter 2
PROGRAMMING LANGUAGES
9 | Page
imperative
and functional programming styles. It has an API for working with, arrays, dates and regular
expressions, but does not include any I/O, such as networking, storage, or graphics facilities,
relying for these upon the host environment in which it is embedded.
JavaScript and Java are otherwise unrelated and have very different semantics. The syntax of
JavaScript is actually derived from C, while the semantics and design
are influenced by the Self and Scheme programming languages.
JavaScript is also used in environments that are not Web-based, such
as PDF documents, site-specific browsers, and desktop widgets.
On the client side, JavaScript has been traditionally implemented as
an interpreted language, but more recent browsers perform just-intime compilation. It is also used in game development, the creation
of desktop and mobile applications, and server-side network
programming with runtime environments such as Node.js.
JavaScript in Facebook :
/*This Script allows people to enter by using a form that asks for aUserID and Password*/
function pasuser(form)
10 | P a g e
11 | P a g e
12 | P a g e
HACK IN FACEBOOK:
Hack as a new version of PHP. It too runs on the Hip Hop Virtual Machine, but it lets coders use
both dynamic typing and static typing. This is whats calledgradual typing, and until now, it has
mostly been an academic exercise. Facebook, OSullivan says, is the first to bring gradual typing
to a real, industrial strength language.
What this means is that Facebook was able to gradually replace its existing PHP code with Hack
move from the old dynamically typed system to a statically typed arrangement. It allows you
to slide the dial yourself on the continuum between dynamic types and statics so you can start
out with dynamically typed code and then gradually add more statically typed code, benefiting
from each little bit of work you do as you go along,
system. It stays strong while building concurrency programs. Erlang provides language-level
features for creating and managing processes with the aim of simplifying concurrent
programming. It has large application in many chat service well known now such as Whatsapp
and initial version of Facebook chat.
Previously we have written an article. Use of Erlang in WhatsApp . In this post, we will talk
about the story about use of Erlang in Facebook chat. The initial version of Facebook chat is
developed by Adam D'Angelo , an early Facebook employee.
While Adam was in college he made a prototype of a chat website with Erlang because it
seemed like the ideal language for the task and also it was a chance to have fun learning a new
language according to him. Later Rebekah Cox , Ari Steinberg and Adam worked on the initial
Facebook chat prototype as part of a hackathon project in early 2007. Some of the Erlang code
were pulled from his personal project while in college. When they decided to make it an official
project and productionalize the server code, the team decided to stick with Erlang and took over
the code from there.
Example:
An Erlang function that uses recursion to count to ten
-module(count_to_ten).
-export([count_to_ten/0]).
count_to_ten() -> do_count(0).
do_count(10) -> 10;
do_count(Value) -> do_count(Value + 1).
Erlang in Facebook Chat:Erlang is designed by Ericsson to be able to handle massive loads
under very demanding circumstances required of high criticality telecommunication network
operations. As a result of which, language is bottom up designed to have no shared states and
locks .There are additional features such as ability to live patch and "self-healing" networks.
WhatsApp and Facebook chat as well as all popular RabbitMQ all used and except Facebook
14 | P a g e
Channel (Erlang): message queuing and delivery. Queue messages in each users channel
Deliver messages as responses to long-polling HTTP requests Presence (C++): aggregates online
info in memory (pull-based presence).Chat logger (C++): stores conversations between page
loads
Web tier (PHP): serves our vanilla web requests.
2.04. Haskell (SERVER SIDE):
Haskell is a general-purpose purely functional language with non-strict semantics and strong
static typing language. The latest standard of Haskell is Haskell 2010; however, there is a group
working on the next version, Haskell 2014 as of February 2016.
15 | P a g e
= 1 otherwise = n * factorial (n - 1)
Haskell in facebook:
Fighting spam with Haskell:
Sigma: One of the weapons in the fight against spam, malware, and other abuse on
Facebook is a system called Sigma. Its job is to proactively identify malicious actions on
16 | P a g e
Chapter 3
DATABASE
3.01. DATA BASE:
A database is an organized collection of data. It is the collection of schemas, tables, queries,
reports, views and other objects. The data are typically organized to model aspects of reality in a
way that supports processes requiring information, such as modeling the availability of rooms in
hotels in a way that supports finding a hotel with vacancies.
17 | P a g e
management
system (DBMS)
is
creation,
querying,
update,
and
MySql
HBase
Cassandra
3.02. MySql:
MySQL is an open-source relational database management system (RDBMS) in July 2013,
it was the world's second most widely used RDBMS, and the most widely used open-source
18 | P a g e
19 | P a g e
Facebook uses MySql in Timeline. Storing every transaction for 800 million users and handling
more than 60 million queries per second, your database environment had better be something
special. Many readers might see these numbers and think NoSQL, but Facebook held a Tech
Talk on Monday night explaining how it built a MySQL (s orcl) environment capable of handling
everything the company needs in terms of scale, performance, and availability.
The importance of its mysql user database:
MySQL handles pretty much every user interaction: likes, shares, status updates, alerts,
requests, etc.
Facebook has 800 million users; 500 million of them visit the site daily.
350 million mobile users are constantly pushing and pulling status updates
7 million applications and web sites are integrated into the Facebook platform
User data sets are made even larger by taking into account both scope and time
Timeline is more concerned about organizing data neatly than shooting out updates in real
time; MySQL is well suited for the app. Although the data is aggregated in the same location
20 | P a g e
21 | P a g e
3.03. HBASE:
Hbase is an open source, non-relational, distributed database modeled written in Java. It
is developed as part of Apache Software Foundation's Apache Hadoop project Runs on top
of HDFS (Hadoop Distributed File system), providing BigTable-like capabilities for
Hadoop.Hbase is now serving several data-driven websites, including Facebook's Messaging
Platform.
HBase features compression, in-memory operation, and Bloom filters on a per-column
basis as outlined in the original BigTable paper. Tables in HBase can serve as the input and
output for MapReduce jobs run in Hadoop, and may be accessed through theJava API but also
through REST, Avro or Thrift gateway APIs. Hbase is a column-oriented key-value data store
and has idolized widely because of its lineage with Hadoop and HDFS. HBase runs on top of
HDFS and well-suited for faster read and write operations on large datasets with high throughput
and low input/output latency
Hbase Architecture:
22 | P a g e
In HBase, tables are split into regions and are served by the region servers. Regions are
vertically divided by column families into Stores. Stores are saved as files in HDFS.
The Master Server Assigns regions to the region servers and takes the help of Apache ZooKeeper for
this task. Handles load balancing of the regions across region servers. It unloads the busy servers
and shifts the regions to less occupied servers. It is responsible for operations such as creation of
tables and column families.
Regions-Regions are nothing but tables that are split up and spread across the region servers.
Zookeeper-Zookeeper is an open-source project that provides services like maintaining
configuration information, naming, providing distributed synchronization, etc. Clients
communicate with region servers via zookeeper.
Messaging Data: Small/Medium sized dataHbase Search index Small message bodies
Attachments and Large messages Haystack Used for our existing photo/video store
23 | P a g e
References:
1. http://www.makeuseof.com/tag/facebook-work-nuts-bolts-technologyexplained/
2. https://gigaom.com/2011/12/06/facebook-shares-some-secrets-on-makingmysql-scale/
3. https://en.wikipedia.org/wiki/Programming_languages_used_in_most_popul
ar_websites
4. https://www.facebook.com/CCodingTips/posts/441715235849774
5. https://www.facebook.com/notes/facebook-engineering/mysql-and-databaseengineering-mark-callaghan/10150599729938920/
6. http://www.theregister.co.uk/2013/06/27/facebook_tao/
7. https://gigaom.com/2011/12/06/facebook-shares-some-secrets-on-makingmysql-scale/
24 | P a g e