Abstract
Data replication is crucial in modern distributed systems as a means to provide high availability. Many techniques have been proposed to utilize replicas to improve a system's performance, often requiring expensive coordination or sacrificing consistency. In this paper, we present SCAR, a new distributed and replicated in-memory database that allows serializable transactions to read from backup replicas with minimal coordination. SCAR works by assigning logical timestamps to database records so that a transaction can safely read from a backup replica without coordinating with the primary replica, because the records cannot be changed up to a certain logical time. In addition, we propose two optimization techniques, timestamp synchronization and parallel locking and validation, to further reduce coordination. We show that SCAR outperforms systems with conventional concurrency control algorithms and replication strategies by up to a factor of 2 on three popular benchmarks. We also demonstrate that SCAR achieves higher throughput by running under reduced isolation levels and detects concurrency anomalies in real time.
Introduction
In distributed databases, developers frequently encounter a fundamental trade-off between consistency and performance. To maintain strong consistency (serializability), systems typically employ primary-backup replication where all read and write operations are routed through a primary node. While this ensures data integrity, it introduces significant latency, especially when nodes are geographically dispersed.
Attempts to improve performance by reading from local backup replicas often risk data staleness. Traditional solutions either sacrifice consistency (e.g., Eventual Consistency) or require backups to validate every read with the primary, negating the performance benefits of local copies. SCAR (Strong Consistency using Asynchronous Replication) addresses this by providing the speed of local backup reads while maintaining the rigorous guarantees of serializable transactions.
The SCAR Mechanism: Local Validation and Logical Timestamps
SCAR minimizes coordination through several novel mechanisms centered around logical time. Every record is stored with two 64-bit integers: a write timestamp (wts) and a read validity timestamp (rts). The rts serves as a promise from the primary node that the record will remain unchanged until that specific logical time.
When a transaction reads from a backup, it performs Local Validation. It checks if its own commit time falls within the record's rts window. If it does, the read is guaranteed to be consistent, eliminating the need for a network round-trip to the primary node. Writes are applied to the primary first and then shipped to backups asynchronously. To handle potential out-of-order updates at the backup, SCAR utilizes the Thomas Write Rule, where a backup only applies an update if the incoming wts exceeds its current version.
Consistency Guarantees and Ordering
A key insight of SCAR is the use of Non-Order-Preserving Serializability. While the system ensures that all transactions appear to occur in a valid serial order, this order may not strictly match the wall-clock time of submission. This minor relaxation of external consistency allows for massive gains in coordination reduction by avoiding unnecessary transaction retries.
Furthermore, SCAR uses logical counters rather than physical clocks (like Google’s Spanner), avoiding the "uncertainty wait" periods required by physical clock synchronization. To ensure fault tolerance, SCAR employs Epoch-based Commits, grouping transactions into 10ms windows. A transaction only fully commits once its entire epoch is safely replicated.
Performance Evaluation
The authors evaluated SCAR against industry-standard benchmarks including Retwis, YCSB, and TPC-C across wide-area network (WAN) environments using Amazon EC2 instances.
- Throughput Gains: SCAR outperformed traditional Optimistic Concurrency Control (OCC) by up to 2x on Retwis and YCSB.
- WAN Performance: In high-latency geographic environments, SCAR achieved 2.3x higher throughput than standard OCC due to its ability to validate reads locally.
- Scalability: Unlike traditional OCC, which struggles with coordination overhead as replicas increase, SCAR’s performance improved by 2.2x when scaling to 8 replicas.
- Snapshot Isolation (SI): SCAR also supports SI with a lightweight anomaly detector, providing an additional 2x performance boost over full serializability while identifying non-serializable transactions in real-time.
Conclusion and Future Work
SCAR demonstrates that shifting the cost of coordination from the active read path to background "promises" can significantly enhance distributed database performance without abandoning strong consistency. While the system does not guarantee external consistency and requires additional memory for fault tolerance, its performance in write-heavy and geographically distributed workloads is superior to traditional methods. Future work includes integrating these logical timestamp techniques into Multi-Version Concurrency Control (MVCC) systems to further minimize coordination overhead.
Summary updated