Skip to the content.

TAO: Facebook’s Distributed Data Store for the Social Graph

What is TAO

Paper

Why does Facebook need TAO

Facebook was originally built by storing the social graph in MySQL(Data model uses node and edge to represent the social graph), querying it from PHP, and caching results in memecache as look-aside cache.

There are several reasons Facebook wants to use TAO:

Instead of rewriting existing memecache based solution, it might be a good idea to invent TAO for social graph usage.

Data models and APIs

data-model

assoc_add(id1, atype, id2, time, (k→v)*)
Adds or overwrites the association (id1, atype,id2), and its inverse (id1, inv(atype), id2) if defined.

assoc_delete(id1, atype, id2)
Deletes the association (id1, atype, id2) and the inverse if it exists.

assoc_change_type(id1, atype, id2, newtype)
Changes the association (id1, atype, id2) to (id1, newtype, id2), if (id1, atype, id2) exists.

assoc_get(id1, atype, id2set, high?, low?)
Returns all of the associations (id1, atype, id2) and their time and data, where id2 ∈ id2set and high ≥ time ≥ low (if specified).
The optional time bounds are to improve cacheability for large association lists (see § 5).

assoc_count(id1, atype)
Returns the size of the association list for (id1, atype), which is the number of edges of type atype that originate at id1.

assoc_range(id1, atype, pos, limit)
Returns elements of the (id1, atype) association list with index i ∈ [pos,pos+limit).

assoc_time_range(id1, atype, high, low, limit)
Returns elements from the (id1, atype) association list, starting with the first association where time ≤ high, returning
only edges where time ≥ low.

Architecture

architecture

Two tiers of caching

Why does TAO have two tiers

How does two tiers work

Single region

single-region

Single region read
Single region write

Multi region

multi-region

Multi region read

Same as single region, read miss will eventually be redirected into local region DB.

Multi region write

How does TAO handle large volume data

How does TAO handle consistency

There is one case that data is inconsistent between slave DB and slave region cache:

How does TAO handle failures

DB failure

Leader cache failure

Follower cache failure

Refill and invalidation failure