cloudparts

Manhattan

Twitter’s in-house, multi-tenant distributed key-value store, eventually consistent by default with opt-in strong consistency per dataset, which serves Tweets, users and direct messages.

Type
Commercial product
Made by
X Corp. (formerly Twitter)
License
Proprietary; internal to X, not released
Facts checked
24 October 2026

What it is

Manhattan is the database Twitter built for itself and runs as an internal service: engineers ask for storage size and queries per second in a self-service portal and get a dataset on a shared cluster in seconds, without waiting for hardware or a schema. A dataset is a group of keys for one use case, like a table. Keys have two parts, a partition key that decides where a record lives and sorted local keys under it, and since many datasets share a cluster, every stored key also carries the dataset’s ID. It is described as the default store at Twitter for persistent real-time serving, holding core data such as Tweets, users and direct messages.

Stateless coordinators accept requests and route them to storage nodes; each key belongs to one shard, and a storage node holds hundreds or thousands of shards. By default the system is eventually consistent in the style of Amazon’s Dynamo: a write waits only for its local zone, other zones and datacenters receive it asynchronously, and replicas converge through continuous replica reconciliation, read repair and hinted handoff. Rate limiting at sub-second granularity and quotas stop one tenant from hurting the others. ZooKeeper holds the cluster topology but is not on the read or write path.

Datasets that need more can opt into strong consistency. Then every operation on a key goes through a per-shard replicated log in DistributedLog, Twitter’s log service, with one elected writer per log; storage nodes apply each log in order, so all replicas reach the same state. That gives atomic check-and-set, increments and strongly consistent reads per partition key, within one datacenter (tens of milliseconds at p99) or across all of them (hundreds), but no transactions across keys. Storage engines are pluggable: the original ones were an LSM engine, a B-tree engine built as a MySQL plugin over InnoDB, and a read-only format for data imported from Hadoop; from 2018 Twitter moved its main clusters to RocksDB.

Why teams pick it

  • Storage as a self-service product: teams provision a dataset in seconds on shared, rate-limited clusters
  • Consistency chosen per dataset: always-on eventual consistency for most data, per-key strong consistency where it matters
  • Bulk import of multi-terabyte datasets built in Hadoop, shipped as binary diffs between versions
  • Ran Twitter’s core data at a scale of tens of thousands of nodes and tens of millions of requests a second

Watch out for

  • Internal to Twitter and X: there is no release, product or documentation outside its engineering blog posts
  • A key-value model: no joins, and strong consistency covers one partition key at a time, not multi-key transactions
  • Strongly consistent global operations cost hundreds of milliseconds, and a log writer failover can pause a shard
  • Operating it took a dedicated team and its own automation, which X’s Realtime Storage team still provides
Data model
Keys of a partition key plus sorted local keys, grouped in datasets
Transactions
None across keys; atomic check-and-set and increments per partition key in strong mode
Consistency
Eventual by default; strong per dataset through a per-shard log
How it scales
Each key belongs to one shard; hundreds or thousands of shards per storage node
Replication
Dynamo-style: local-zone quorum, then asynchronous to other zones; DistributedLog in strong mode
Multi-region
Asynchronous between datacenters by default; strong global operations take hundreds of ms
Storage engine
Pluggable; RocksDB on the main clusters since 2018
Ways to run it
Internal to X only

Alternatives

What all key-value stores have in common →Compare side by side →

How it fits with other technologies

Two consistency modes#

The mode is set per dataset, so one application can mix them. Even strongly consistent datasets can be read in the cheaper, eventually consistent way.

Eventual consistency

the default

A write is acknowledged once a quorum in the local zone has it; other zones and datacenters get it asynchronously. Fast and available during failures, but two clients can both insert the same key, check-and-set can interleave, a partial write can linger, and a reader in another datacenter may not see a write that just happened.

Strong consistency

per-key log

The coordinator writes each operation to the shard’s DistributedLog log and waits for storage nodes to apply it in order and answer. Updates to one partition key are atomic and seen in the same order everywhere, so uniqueness checks, counters and check-and-set work, at tens to hundreds of milliseconds per operation.

See it in a real stack

No architecture uses Manhattan yet. Drop it into the playground and wire it up yourself.Open playground →
Where it came from2012–2025

Twitter started as a Ruby on Rails monolith backed by a single MySQL server, then moved to microservices and multiple datacenters, and used Cassandra for horizontal scale. By the early 2010s it needed storage that served millions of queries a second at low latency across several regions, and its engineers were, in their words, spending far too much time firefighting production systems and building a new cluster by hand for every feature. In 2012 the Core Storage team decided to build its own database.

Manhattan was announced in April 2014, after about two years in production. It favoured availability, with a schemaless key-value model and Dynamo-style eventual consistency at its core, and treated multi-tenancy, quality of service and self-service as first-class features. A Strong Consistency service using a consensus log followed, described in detail in 2016.

From 2017 Twitter evaluated RocksDB to replace its two in-house read-write engines, finished the integration by mid-2018 and moved the clusters holding Tweets, user profiles and direct messages over the next two years, cutting disk use by about half. In 2020 it described 20 production clusters, more than 1,000 databases and tens of millions of requests a second. After Twitter became X, the Realtime Storage team still listed Manhattan among the systems it owns in a job posting removed in August 2025.

Why it’s built this way

Availability first, strong consistency opt-in
Most of Twitter’s data fit eventual consistency, and many use cases couldn’t accept even a few seconds of unavailability while a new master was elected. So the core stays always-on, and stricter guarantees are a choice per dataset.
Storage as a multi-tenant service
Building a cluster per feature wasted hardware and operator time. Shared clusters with quotas and sub-second rate limiting let teams start in seconds and absorbed traffic spikes, because tenants rarely peak together.
Strong consistency per key, not distributed transactions
Internal customers mostly needed uniqueness, check-and-set and counters on single keys. Keeping each operation inside one shard’s log avoided the cost of coordinating multi-key transactions.
Pluggable storage engines
Different workloads wanted different on-disk formats, and the engine layer later let Twitter replace two in-house engines with RocksDB without changing the rest of the system.

Timeline

  1. 2012

    Twitter decides to build Manhattan

  2. 2014

    Manhattan announced in April, after two years in production

  3. 2016

    Twitter describes Manhattan’s strong consistency service

  4. 2017

    Evaluation of RocksDB as a storage engine begins

  5. 2018

    RocksDB engine ready for production by mid-year

  6. 2020

    20 production clusters and over 1,000 databases

  7. 2025

    X’s Realtime Storage team still lists Manhattan among its systems

Sources4 · facts checked 24 October 2026

Improve this page on GitHub