How Has Facebook’s Software Architecture Changed Over Time?

From Dorm Room to Global Giant

Tech Truths
ILLUMINATION
4 min readMar 23, 2024

--

Photo by Alex Haney on Unsplash

Non-medium members can read the story for free here.

Facebook’s rise from a quirky college social network to a global giant with billions of users is a story of innovation and adaptation.

But behind the familiar interface lies a complex software infrastructure that has undergone a fascinating evolution.

Facebook’s Early Days with the LAMP Stack

Mark Zuckerberg’s initial vision for Facebook was a simple one: connect students within a single university. This allowed Facebook to leverage a familiar and cost-effective technology stack: the LAMP stack (Linux, Apache, MySQL, PHP) running on a single rented server.

The LAMP Stack

The LAMP stack was perfect for our initial needs,” says Michael Cheng, a software engineer who joined Facebook in its early days. “It was simple, easy to manage, and allowed us to iterate quickly.”

However, as Facebook expanded beyond Harvard and reached other universities, the LAMP stack began to show its limitations. The biggest challenge was scaling the ‘friends of friends’ algorithm, which is pivotal for displaying users’ mutual connections on Facebook.

Database Partitioning

To address this issue, Facebook’s engineers came up with a clever solution: database partitioning. They divided the user data into separate databases, one for each university.

This meant that to find mutual friends, the system only needed to search within the relevant university’s database, significantly improving efficiency.

Partitioning the database was a critical step in allowing us to scale,” says Cheng. “It meant we weren’t constantly bogging down the system searching through a massive pool of data.”

Photo by Geeks for Geeks

Separating Application and Database Tiers for Horizontal Scaling

Another challenge emerged with the varying usage patterns across different universities. A sudden influx of users from a large school could overload the server, bringing the entire system down.

To address this, Facebook adopted a crucial architectural shift: separating the application tier (web servers) from the database tier. This allowed them to horizontally scale the application layer.

By adding more web servers, Facebook could distribute user requests across multiple machines, handling increased traffic more effectively. This approach ensured that even if one server became overloaded, others could pick up the slack, keeping the platform running smoothly.

Introducing Memcached: The Cache that Saved the Day

Facebook’s relentless growth continued to put a strain on its architecture. Even the robust MySQL database began to struggle with the massive amount of data being processed. Every like, comment, and friend request added to the ever-growing data load.

Memcached

The solution came in the form of caching, a technique for storing frequently accessed data in memory. Facebook implemented Memcached, an open-source caching library, to store frequently accessed information like user profiles and friend lists.

“Memcached was a game-changer for us,” says Cheng. “By storing frequently accessed data in memory, we significantly reduced the load on the database servers. This improved performance and responsiveness for our users.”

With caching, Facebook doesn’t need to query the database every single time. If your friend’s profile has been accessed recently, the information is readily available in memory, allowing for a much faster response.

CI/CD Pipeline

A Continuously Evolving Architecture -A Journey That Never Ends

The points discussed about in this story are just a snapshot of Facebook’s early architectural evolution. As Facebook’s complexity increased, it likely transitioned to a microservices architecture. This approach breaks down the application into smaller, independent services that communicate with each other. This improves scalability, maintainability, and deployment flexibility.

The focus on efficiency remains constant throughout Facebook’s architectural evolution. Every step reflects a commitment to optimizing performance and handling massive data loads efficiently.

Hello, we write about the latest trends, updates, and innovations in the tech space. To stay on top of our latest articles, follow us on Tech Truths. And, to have stories sent directly to you, subscribe to the newsletter.👇

--

--

ILLUMINATION
ILLUMINATION

Published in ILLUMINATION

We curate and disseminate outstanding articles from diverse domains and disciplines to create fusion and synergy.

Tech Truths
Tech Truths