Skip to content
System Design Explorer

Comparison

Spanner vs DynamoDB: Global SQL or Predictable Key-Value

By Ankur NayakReviewed

Google Spanner and Amazon DynamoDB are both sharded databases in which every shard is a replicated consensus group, and both are described in detail by their builders: Spanner in its 2012 OSDI paper and DynamoDB in a 2022 USENIX ATC paper.

They are built for different promises. Spanner offers relational tables and externally consistent transactions across shards and continents, paying for it with synchronized clocks and commit wait. DynamoDB offers a key-value and document API whose every operation has bounded, predictable latency, and puts its engineering into multi-tenant isolation and fast healing.

Google Spanner

Full design
Google Spanner architecture diagramComponents: Application (e.g. F1), Location Proxy, Zonemaster, Spanservers (Zone A), Replica Spanservers (Zone B), Colossus, TrueTime Masters (GPS + atomic clocks), Timeslave Daemon, Placement Driver. Connections: Application (e.g. F1) to Location Proxy (where is my data?); Application (e.g. F1) to Spanservers (read / write); Application (e.g. F1) to Replica Spanservers (snapshot read); Zonemaster to Spanservers (assign data); Spanservers to Replica Spanservers (Paxos); Spanservers to Colossus (tablet files + log); TrueTime Masters to Timeslave Daemon (poll every 30 s); Timeslave Daemon to Spanservers (TT.now()); Placement Driver to Spanservers (move directories).Application (e.g. F1)ClientLocation ProxyServiceZonemasterCoordinationSpanserversZone AReplica SpanserversZone BColossusObject storageTrueTime MastersGPS + atomic clocksTimeslave DaemonServicePlacement DriverScheduler

Amazon DynamoDB

Full design
Amazon DynamoDB architecture diagramComponents: Application (AWS SDK), Request Routers, Metadata Service (MemDS), IAM & KMS, Admission Control (GAC), Storage Nodes, Autoadmin, Amazon S3. Connections: Application to Request Routers (GetItem / PutItem); Request Routers to IAM & KMS (authenticate (cached)); Request Routers to Metadata Service (where is this key?); Request Routers to Admission Control (refill tokens); Request Routers to Storage Nodes (read / write); Autoadmin to Storage Nodes (heal, split, move); Storage Nodes to Amazon S3 (archive logs + snapshots).ApplicationAWS SDKRequest RoutersLoad balancerMetadata ServiceMemDSIAM & KMSAuthAdmission ControlGACStorage NodesNoSQL databaseAutoadminSchedulerAmazon S3Object storage

Side by side

Google Spanner compared with Amazon DynamoDB
DimensionGoogle SpannerAmazon DynamoDB
Data modelSchematized semi-relational tables with SQL queriesItems addressed by partition key (and optional sort key); limited queries
Shard replicationA Paxos group per tablet, replicas placed by policy across zones and regionsA Multi-Paxos replication group per partition across three Availability Zones
LeadersLong-lived Paxos leaders with 10-second leases; leaders hold the lock tableOne leader per partition, kept by renewing a lease; serves writes and strong reads
Multi-shard transactionsTwo-phase commit between Paxos group leaders, with a TrueTime commit timestampOffered as a separate feature; the core path is single-partition operations
ConsistencyExternal consistency (linearizable) for transactions; lock-free snapshot reads at any timestampStrongly consistent reads from the leader or cheaper eventually consistent reads from any replica
ClocksTrueTime: GPS and atomic-clock masters bound uncertainty to ~1–7 msNo special clock hardware is part of the design described
Multi-tenancyPlacement driver moves directories to balance load and meet constraintsToken buckets at request routers refilled by global admission control; partitions split by consumption
Failure healingNew leader elected when a lease expires; data moved by the placement driver in minutesLog replicas added in seconds while full replicas are rebuilt; autoadmin replaces unhealthy nodes
Scale (latest public)Designed for millions of machines and trillions of rows (2012)89.2M requests per second peak on Prime Day 2021

Verdict

Choose a Spanner-style design when the data is relational and correctness across shards and regions matters more than the last millisecond: banking ledgers, inventory, ad budgets. Choose a DynamoDB-style design when access patterns are known, operations are by key, and the priority is predictable latency for many tenants at any scale. In an interview, name the promise first (global transactions or bounded latency) and let it pick the architecture.

Frequently asked questions

Is DynamoDB like Spanner?

Partly. Both split data into shards that are each replicated with a Paxos-style consensus protocol and a leader. Spanner adds relational tables, cross-shard two-phase commit and TrueTime timestamps for global consistency, while DynamoDB keeps a simpler key-value model focused on predictable latency and tenant isolation.

Why does Spanner need atomic clocks and DynamoDB doesn't?

Spanner promises that transactions are ordered consistently with real time across the whole planet, so it needs bounded clock uncertainty to assign commit timestamps. DynamoDB's core operations are single-partition, where the partition's leader orders writes, so no global clock is required.

Which is faster, Spanner or DynamoDB?

They optimise different things. DynamoDB's single-key operations are built for consistently low, single-digit-millisecond latency. Spanner's read-write transactions pay for consensus, two-phase commit across groups and commit wait, but its snapshot reads can be served lock-free from nearby replicas.

More comparisons