0
0
HLDsystem_design~10 mins

ACID properties in HLD - Scalability & System Analysis

Choose your learning style9 modes available
Scalability Analysis - ACID properties
Growth Table: ACID Properties at Different Scales
Users / TransactionsAtomicityConsistencyIsolationDurability
100 usersSimple commit/rollback works wellEnforced by DB constraints easilyLow contention, simple locks sufficeDurability via local disk is reliable
10,000 usersTransactions still manageable, some retries neededConsistency checks may slow writesHigher contention, need better isolation levelsDurability requires WAL and backups
1,000,000 usersAtomicity challenged by distributed transactionsConsistency harder, may use eventual consistency in partsIsolation costly, may use snapshot isolation or weakerDurability needs distributed consensus and replication
100,000,000 usersAtomicity across shards is complexStrong consistency expensive, often relaxedIsolation often relaxed for performanceDurability via geo-replication and multi-region backups
First Bottleneck

The first bottleneck is the database transaction manager. As users and transactions grow, ensuring atomicity and isolation becomes costly. Locking and coordination overhead increase, slowing down throughput.

Scaling Solutions
  • Horizontal scaling: Partition data (sharding) to reduce transaction scope.
  • Optimistic concurrency control: Reduce locking by retrying conflicts.
  • Weaker isolation levels: Use snapshot isolation or read committed to improve performance.
  • Distributed transactions: Use two-phase commit or consensus protocols carefully.
  • Caching: Cache reads to reduce load on transactional systems.
  • Asynchronous durability: Use write-ahead logs and replication with controlled delays.
Back-of-Envelope Cost Analysis

Assuming 1 million users with 1 transaction per second:

  • Transactions per second (TPS): ~1,000,000 TPS
  • Single DB instance handles ~5,000 TPS → Need ~200 DB instances or sharding
  • Network bandwidth for logs and replication: ~100 MB/s or more
  • Storage: Each transaction log entry ~1 KB → 1 TB per 1,000,000 seconds (~11.5 days)
Interview Tip

Start by explaining each ACID property simply. Then discuss how each property affects scaling. Identify the bottleneck (usually transaction coordination). Propose solutions like sharding and weaker isolation. Show understanding of trade-offs between consistency and performance.

Self Check

Your database handles 1000 QPS. Traffic grows 10x to 10,000 QPS. What do you do first?

Answer: Add read replicas and implement caching to reduce load. For writes, consider sharding or partitioning data to distribute transactions and reduce contention.

Key Result
ACID properties ensure reliable transactions but become bottlenecks at high scale due to coordination overhead; scaling requires data partitioning, weaker isolation, and distributed transaction strategies.