Skip to content

Article · 8 min read · Oct 31, 2026

How Meta handles billions of requests, and what your company should copy

Meta (formerly Facebook) serves its social graph through layers: load balancers, a very large cache, and a sharded MySQL tier behind it. A company of 20 to 200 people should copy the order of operations, which is to measure, index, cache, add read replicas, partition, and shard last, because most never need sharding. This guide explains each technique and when it starts paying off.

Farzan AnsariCofounder and CTO

Key takeaways

  • Sharding means splitting one database across several servers by a shard key, and it is the last technique to reach for, not the first.
  • Meta published figures of over a billion requests per second on its cache in 2013 and over a quadrillion queries a day on TAO in 2022, and those numbers describe a company with billions of users.
  • Meta chose a cache to take read load off MySQL, and described that choice as the best one given limited engineering resources and time.
  • Caching and read replicas address most read-heavy slowdowns, and managed services such as Amazon RDS offer read replicas as a standard feature.
  • Sharding makes cross-shard queries and transactions harder and resharding painful, so exhaust indexes, caching, replicas and partitioning first.

When engineers describe how Meta serves billions of people, the conversation can lead a 100-person company to ask whether it needs the same architecture. It does not. What a smaller company can borrow from Meta is the sequence in which large systems add complexity, because that sequence shows why each step exists and when it becomes worth the trouble.

How does Meta handle billions of requests?

Meta spreads the work across layers, so that no single machine sees everything. For its social graph, requests arrive at load balancers, a very large cache (Memcache and TAO) absorbs much of the read load, and a sharded MySQL tier holds the authoritative copy. Meta runs other storage systems for other workloads. A load balancer distributes incoming requests across many servers, and a cache keeps copies of frequently read data in fast memory so the database is asked less often.

The published figures come from different years, so read each one with its date:

FigureYearSource
Memcache "processing over a billion requests per second and storing trillions of items"2013Scaling Memcache at Facebook, NSDI 2013
TAO "can process a billion reads and millions of writes each second"2013TAO paper, USENIX ATC 2013
TAO data "partitioned into hundreds of thousands of shards"2013Engineering at Meta, June 25, 2013
TAO "serves more than one quadrillion queries a day"2022Cache made consistent, June 8, 2022
MyRocks needed 50 percent less storage than compressed InnoDB in one region's user database tier2016Engineering at Meta, August 31, 2016

These numbers describe a company with over a billion users already in 2013. They set the ceiling of what is possible, and they say little about what a business with 5,000 customers needs.

The network layer sits in front of all this. Meta's 2018 post on Katran describes a layer 4 load balancer that works on network packets rather than application requests, deployed on servers in Facebook's points of presence, which act as proxies for its data centers. Its Proxygen library is, per its README, the core set of C++ HTTP abstractions used at Facebook and the basis for many HTTP servers, proxies and clients.

What should your company copy, and when does each technique pay off?

Copy the order, not the end state. Each technique solves one problem, has a scale at which it starts to pay off, and has a cheaper step that comes first.

TechniqueProblem it solvesWhen it starts paying offWhat to do first instead
Measure and indexSlow queries from missing indexes or poor query shapeThe first time a page or report is slowNothing; this is step one
Bigger instanceA database server short of memory, CPU or disk speedWhen monitoring shows the server saturatedFix queries and indexes
Load balancingOne application server failing or overloadedAs soon as you run more than one application serverUse your cloud provider's managed load balancer
CachingThe same data read over and over from the databaseWhen reads dominate and the database is the bottleneckIndex and tune the slow queries
Read replicasRead load or reporting that slows the main databaseWhen reads exceed one instance after cachingCache, and run reports off hours
PartitioningOne giant table that is slow to query and maintainPostgreSQL docs suggest when a table exceeds the server's memoryIndex, and archive old rows
ShardingWrites or total data beyond the largest practical single serverAfter every step above, and a plan for cross-shard workEverything on this list

What is sharding, in plain English?

Sharding splits one database across several servers, with each server (a shard) holding a subset of the data. MongoDB's documentation defines it as a method for distributing data across multiple machines, used for very large data sets and high throughput. It calls the underlying idea horizontal scaling, which means adding servers instead of buying a bigger one, and states the price: increased complexity in infrastructure and maintenance.

The shard key is the field that decides which shard a record lives on. Pick it well and most requests touch one shard. Notion partitioned by workspace ID because, per its engineering post, each block belongs to exactly one workspace. Meta's TAO embeds a shard ID in each object ID, and stores each association on the shard of its source object, so an association query can be served from a single server.

There are two common ways to map keys to shards:

  • Range sharding assigns contiguous ranges of key values to each shard. MongoDB notes that nearby values sit together, so queries for a range can go to specific shards, but a poorly chosen key can produce uneven distribution and hot spots.
  • Hash sharding computes a hash of the key. MongoDB says this gives more even distribution, but range queries on the key are more likely to hit many shards.

What does sharding cost?

Sharding trades capacity for complexity, and three costs recur.

Cross-shard queries. When a query does not include the shard key, MongoDB's documentation says the router queries all shards in the cluster, and that these scatter/gather queries can be long running. Notion's post notes that distributed joins are expensive and that transaction guarantees are typically limited to a single host. It gave an example where a block deletion could succeed while a related comment update fails. TAO also has this issue: its paper says an association can involve two shards, because the forward edge sits on one shard and the inverse edge on another.

Resharding. Changing the shard key or rebalancing data later is slow. MongoDB says the balancer's chunk migration process is slow and resource intensive, and that you can reshard a collection from version 5.0 onward but should choose the key carefully to avoid problems. Notion's backfill of existing data took about three days on a large instance.

Operations. More servers mean more backups, upgrades, failure cases and monitoring. Every report that spans the whole company now has to combine results from every shard.

How do caching and read replicas help before sharding?

Caching and replicas address the most common pattern in business software: far more reads than writes. The memcache paper starts from the same pattern. It says users consume an order of magnitude more content than they create, and that of several ways to reduce read traffic on its MySQL databases it chose memcache because it was the best choice given limited engineering resources and time.

The design is a look-aside cache. The application asks the cache first. On a miss it reads the database and stores the result in the cache. On a write it updates the database and deletes the cached copy, since deletes are safe to repeat. The hard part is keeping the cache correct. Meta's 2022 post says a mishandled invalidation can leave inconsistent values in the cache indefinitely. The 2013 paper describes leases to prevent a rush of requests to the database when a heavily read key is repeatedly invalidated. For one set of keys, measured over a week, the peak database query rate fell from 17 thousand per second without leases to 1.3 thousand per second with them.

A read replica is a read-only copy of the database. AWS describes using one to scale beyond a single instance for read-heavy workloads and to run business reporting away from production. Updates arrive asynchronously, so a replica can show slightly old data, which matters for screens that must show a change immediately after it is made. TAO's design accepts the same trade: its paper describes eventual consistency, with reads served from a nearby region.

Partitioning comes after both. The PostgreSQL documentation describes splitting a logical table into smaller physical pieces, gives a rule of thumb that the table should exceed the server's physical memory to benefit, and notes that dropping an old partition is far faster than a bulk delete. A time-based partition on an events table is a common, low-risk use.

What order of operations should a 20 to 200 person company follow?

Follow the sequence below and stop at the first step that solves the problem.

  1. Measure. Find the slowest queries and the busiest hours, using database monitoring and application logs.
  2. Index and fix queries. Most slowdowns end here.
  3. Resize. A larger database instance is cheap compared with an engineering project, and relational databases typically scale up this way.
  4. Cache. Cache the data that is read most and changes least, such as price lists, reference data and rendered pages.
  5. Add read replicas. Send reports and search-heavy screens to replicas.
  6. Partition large tables. Start with time-based tables such as logs, events and history.
  7. Shard. Only when write volume or data size passes what the largest practical single server can hold, and when the shard key is clear.

Illustrative example: Consider a 150-person freight broker whose customer portal slows every month-end. The team measures first and finds that three queries account for most of the load, two of them scanning a shipments table without an index. They add the indexes, then cache the rate tables that rarely change, then point finance reports at a replica. The portal recovers. Sharding is never discussed, because the largest single database the company would realistically need is far from its limit. The expensive options were available on day one and unnecessary.

Most companies never reach step 7. Your company should copy the habit of measuring before each move and writing down what problem the move was meant to solve. Our guides to why Postgres became the default database and SQL vs NoSQL cover the database choices underneath this sequence.

How Kastling approaches scaling work

Performance and scaling work belongs to AI & Cloud Infrastructure: cloud architecture and deployment on AWS or Azure, and the data connections and pipelines behind applications. Kastling would begin by measuring how the current system behaves under real load and agreeing what success looks like, then change the least that solves the measured problem. A named person on the client side would sign off on anything consequential, such as a data move or a change to how records are stored, and AWS and Azure specialists would join where needed.

Questions

What is the difference between sharding and partitioning?

Partitioning splits one large table into smaller pieces that normally stay on one database server. Sharding spreads data across multiple servers, each holding its own subset. People sometimes use the words interchangeably, so ask which is meant in any proposal. Partitioning is far simpler to operate and is the step to try first.

Does sharding make a database faster?

It makes a database able to hold more data and take more writes by adding servers. It does not speed up an individual slow query, and it can slow down queries that must visit several shards. A poorly indexed query stays slow on every shard.

Can we shard later if we outgrow one database?

Yes, and most companies that shard do it later. Notion described a backfill of about three days on a large instance when it moved existing data into shards. The work is manageable when planned and painful in an emergency, so watch growth trends and plan the move before the largest server runs out of room.

Does a managed database service shard for us?

Some services handle part of it, but the choice of shard key and the effect on queries remain application decisions. Read the service documentation for what it automates and what your code must still handle. For a typical business application, a single managed relational instance with replicas goes a long way.

Sources

  1. USENIX NSDI 2013: Scaling Memcache at Facebook
  2. USENIX ATC 2013: TAO, Facebook's Distributed Data Store for the Social Graph
  3. Engineering at Meta: TAO, the power of the graph (2013)
  4. Engineering at Meta: Cache made consistent (2022)
  5. Engineering at Meta: MyRocks, a space- and write-optimized MySQL database (2016)
  6. Engineering at Meta: Open-sourcing Katran (2018)
  7. GitHub: facebook/proxygen
  8. MongoDB Manual: Sharding
  9. Notion: Herding elephants, sharding Postgres at Notion
  10. PostgreSQL 18 documentation: Table partitioning
  11. AWS RDS User Guide: Working with DB instance read replicas
  12. AWS: What is NoSQL?

Guide · 16 min read

Running AI in production on AWS and Azure: architecture, security, cost and operationsRunning AI in production on AWS or Azure means giving a model the same controls as any business system: identity, secrets, logging, cost limits, fallbacks and a named owner for every operating task. Managed services such as Amazon Bedrock and Azure OpenAI in Microsoft Foundry host the models, but the architecture, data boundaries and day-to-day operations remain your decisions to make and assign. This guide is for IT and operations leaders at companies of roughly 20 to 200 people.Read

Article · 10 min read

The encryption techniques that matter, and what the industry uses by defaultThe types of encryption that matter in practice are AES-256-GCM for stored data, TLS 1.3 for traffic, envelope encryption with a cloud key service for data at rest, Argon2id hashing for passwords, and hybrid post-quantum key exchange, which browsers already use. This guide is for operations, IT and finance leaders who need to know the current default for each job and the questions to put to a vendor. Never invent your own cryptography.Read

Article · 9 min read

How to build a system that handles hundreds of millions of data pointsA high volume data pipeline works in stages: a durable ingestion buffer, stream processing, raw data kept cheaply in object storage as the source of truth, and pre-aggregated rollups that answer the questions people actually ask. The design choice that matters most is deciding those questions first, because they set what you aggregate and how long you keep detail. This guide is for operations and IT leaders at companies of roughly 20 to 200 people who collect sensor, image or event data at volume.Read

One useful email a month.

New guides, tools and practical notes on putting AI to work. No sales sequences.

See how an idea becomes a working solution.

Explore how we scope, build and hand over AI projects, with clear decisions at each stage.