Building Timeline: Scaling up to hold your life story

Visit the post for more.

Ryan Mack
6 min readintermediate
--
View Original

Overview

The article discusses the engineering efforts behind Facebook's Timeline feature, emphasizing the need for a system that can handle years of user activity. It outlines the technologies used, the challenges faced during data denormalization, and the development process that allowed for rapid prototyping and implementation.

What You'll Learn

1

How to denormalize data for improved database performance

2

Why using well-understood technologies reduces technical risk

3

How to implement a caching strategy with memcached

4

When to apply parallel processing in database queries

Prerequisites & Requirements

  • Understanding of database normalization and denormalization concepts
  • Familiarity with MySQL and memcached(optional)

Key Questions Answered

What technologies were used to build Facebook's Timeline?
Facebook's Timeline was built using MySQL/InnoDB for storage, Multifeed for ranking, Thrift for communications, and memcached for caching. These technologies were chosen for their reliability and familiarity, allowing better capacity predictions and operational efficiency.
How did Facebook handle the challenges of denormalizing data?
Facebook faced several challenges during the denormalization process, including legacy data formats and slow network storage. They developed a custom language for data format conversion, deployed hundreds of servers to expedite data retrieval, and consolidated join tables into flash-only databases to improve performance.
What role does caching play in the Timeline feature?
Caching is crucial for the Timeline feature as it allows results from large queries to be stored for extended periods without frequent invalidation. The use of memcached helps in efficiently managing the cache for both recent and historical activity data, significantly enhancing performance.
How did the development process for Timeline facilitate rapid prototyping?
The development of Timeline involved staged and layered prototyping, allowing different teams to work in parallel on UI design, frontend code, and backend infrastructure. This approach minimized dependencies and enabled the team to achieve significant progress in a short timeframe.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Database
Mysql/Innodb
Used for storage and replication of user data.
Backend
Multifeed
Powers the ranking of posts and activities in the Timeline.
Communication
Thrift
Facilitates communication between different components of the system.
Caching
Memcached
Used for caching query results to improve performance.

Key Actionable Insights

1
Implementing a denormalization strategy can significantly enhance database performance, especially for read-heavy applications like social media platforms.
By reducing the number of database queries needed to fetch related data, applications can respond faster to user requests, improving overall user experience.
2
Leveraging caching solutions like memcached can optimize performance for frequently accessed data.
Caching allows applications to serve data quickly without hitting the database for every request, which is particularly beneficial for static or infrequently changing data.
3
Parallel processing in database queries can drastically reduce response times for complex data retrieval tasks.
By allowing multiple queries to run simultaneously, applications can handle larger datasets more efficiently, which is essential for scaling up services.

Common Pitfalls

1
Relying too heavily on a normalized database structure can lead to performance bottlenecks, especially in read-heavy applications.
When data is highly normalized, it often requires multiple queries to retrieve related information, which can slow down response times. Denormalization can mitigate this issue by reducing the number of queries needed.