NewSQL and modern database trends
Concise study notes on NewSQL and modern database trends covering definitions, trade-offs (CAP, PACELC), architectures, ACID vs BASE, scaling laws, example traces, common exam mistakes and question types.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Two or three sentences: where an engineer uses this.
Modern applications (web, mobile, IoT) need databases that scale like NoSQL but keep the strong transactional guarantees of traditional RDBMS. An engineer uses NewSQL designs and the trade-offs in CAP/PACELC when choosing or designing a storage layer for high-throughput, low-latency, geographically distributed services.
Key ideas
Explain plainly and define every term before using it.
- Database — a structured collection of data stored so that it can be queried and updated. Use this as the base term.
- Relational DBMS (RDBMS) — a DBMS that stores data in tables with fixed schema and supports SQL queries and transactions. Typical features: joins, ACID transactions.
- NoSQL — a class of non-relational database systems that relax relational models or consistency for scalability (examples: key-value stores, document stores, wide-column stores, graph databases). NoSQL commonly prioritises horizontal scaling and availability.
- NewSQL — a class of database systems that aim to provide the scalability and performance of NoSQL while preserving ACID transactional guarantees and SQL or SQL-like interfaces. Examples of architectural approaches: distributed SQL, sharded transactional systems, in-memory engines with distributed consensus.
- ACID — set of transactional properties: Atomicity (transaction all-or-nothing), Consistency (database moves between valid states according to constraints), Isolation (concurrent transactions behave as if serialised), Durability (once committed, effects survive crashes). Universities expect these exact terms and short definitions.
- BASE — alternative set of properties used in some NoSQL systems: Basically Available (system responds), Soft state (state may change over time without new input), Eventual consistency (given no new updates, replicas converge). BASE trades stronger consistency for availability and partition-tolerance.
- CAP theorem (Brewer's theorem) — exact statement used in exams: "In a distributed data system that can experience network partitions, it is impossible to simultaneously provide more than two of the following three properties: Consistency (all nodes see the same data at the same time), Availability (every request to a non-failing node receives a non-error response in finite time), and Partition tolerance (the system continues to operate despite arbitrary message loss between nodes)." Assumptions: asynchronous network, node failures and partitions are possible, clients may be partitioned. Draw and label: three overlapping circles labelled C, A, P; explain real systems choose two corners (CP, AP, CA but CA without P only in single-node/replicated local setups).
- Consistency (distributed sense) — here means a system-wide agreement on read results; often in practice we talk about different forms such as serializability, linearizability, or causal consistency. Define: serializability — outcome equivalent to some serial execution of transactions; linearizability — real-time ordering with single-object atomicity; causal consistency — operations that are causally related are seen by all nodes in the same order, while concurrent operations may be observed in different orders.
- PACELC — refinement of CAP: "If there is a Partition (P), a system must trade Availability vs Consistency (A vs C); Else (E), when the system is running normally, trade-off is between Latency (L) and Consistency (C)." Use PACELC to discuss latency/consistency choices in normal operation.
- Consensus protocols — algorithms (Paxos, Raft) to reach agreement among distributed nodes. They provide strong consistency (linearizability) but cost latency (round-trips) and complicate scaling.
- Architectures of NewSQL (draw):
- Single-master sharded: draw a set of client arrows to a proxy/router; router to several shard nodes; each shard has local MVCC engine; label shard key. Note: single-master per shard simplifies transactions but limits cross-shard transactions.
- Distributed consensus-based: draw clients → SQL layer → multiple replicas using Raft/Paxos; indicate leader per shard and Raft log replication. Label steps: client→leader→followers.
- In-memory distributed engines: show memory node cluster with persistent log for durability.
Explain typical design choices: strong transactions require coordination (consensus or 2PC) which increases latency; scale-out needs partitioning that makes cross-partition transactions expensive. NewSQL systems try to reduce coordination (e.g., single-shard transactions fast, cross-shard use fast distributed commit with optimistic concurrency, or use hierarchical consensus).
Derivations universities commonly ask for:
- Derive why consensus requires at least 2f+1 nodes to tolerate f failures for crash-fault tolerant algorithms (majority quorums). Step: to have overlapping quorums of size >f, quorum size q > N/2 so N >= 2f+1. Describe steps: assume f failures, two quorums must intersect to avoid split-brain; intersection size ≥1 => choose N minimal.
- Derive trade-off of coordination on latency: one round trip costs at least one network RTT between replicas; consensus-based transactions require a fixed number of round trips per phase (e.g., 1–2), independent of the number of nodes. Latency increases with the number of coordination phases and with inter-replica/region RTTs.
Formulas
Each formula on its own line with symbol definitions and units when meaningful.
Availability A = MTBF / (MTBF + MTTR) — MTBF = mean time between failures (s), MTTR = mean time to repair (s). Applies to system availability calculation.
Speedup S(n) = T(1) / T(n) — T(1) = time on single node (s), T(n) = time on n nodes (s). Used when analysing parallel performance.
Amdahl's law: T(n) = T(1) * ( (1 - p) + p / n ) — p = fraction of task parallelisable (dimensionless), n = number of parallel workers, T times in seconds. Use to calculate theoretical limit of scaling.
Throughput(n) ≈ n * Throughput(1) * efficiency(n) — Throughput measured in transactions per second (tps); efficiency(n) ≤ 1 drops with coordination overhead. Use when estimating cluster throughput.
For distributed transactions remember protocol-step syntax (informal):
- Two-phase commit (2PC) steps: Coordinator -> PREPARE -> participants vote -> participants -> VOTE (YES/NO) -> Coordinator -> COMMIT/ABORT -> participants.
Worked examples
Two examples, step-by-step, university-exam style.
Example 1 — Amdahl scaling for transactional DB. Given: single-node peak throughput Throughput(1) = 2000 transactions/s, fraction parallelisable p = 0.9, use n = 10 nodes. Compute speedup S(n) using Amdahl's law and the resulting throughput. Steps:
- Amdahl multiplier m = (1 - p) + p / n.
- Substitute: m = (1 - 0.9) + 0.9 / 10 = 0.1 + 0.09 = 0.19.
- Speedup S(10) = 1 / m = 1 / 0.19 ≈ 5.263.
- Throughput(10) ≈ Throughput(1) × S(10) ≈ 2000 × 5.263 ≈ 10526 transactions/s. Final answer: With 10 nodes, throughput ≈ 10,526 tps and speedup ≈ 5.26×.
(Explain: even though p=0.9, coordination and serial fraction limit scaling — shows why NewSQL must reduce serial parts or use sharding to get near-linear scaling.)
Example 2 — Two-phase commit (2PC) trace for a two-shard transactional update. Scenario: Transaction updates keys in shard A and shard B. Steps to draw and trace messages (label message numbers):
- Client sends BEGIN + UPDATE to Coordinator (or router) — label = msg1.
- Coordinator sends PREPARE to Shard A and Shard B — msgs 2 and 3.
- Each shard writes a prepare record to its local log and replies VOTE-YES (msg4, msg5) if it can commit locally.
- Coordinator receives votes; if all YES, it writes commit record and sends COMMIT to both shards (msg6, msg7). If any NO, sends ABORT.
- Shards apply commit, reply ACK (msg8,msg9). Coordinator can reply COMPLETION to client. Explain failure handling: if coordinator crashes after receiving votes but before sending commit, participants are in prepared state and must wait for coordinator recovery or use a timeout/consensus to decide; this shows blocking behaviour of 2PC and why NewSQL prefer non-blocking commit via Paxos/Raft-based replication.
Common mistakes
- Using Amdahl's law without checking the fraction p; students often forget the serial part (1-p).
- Thinking Paxos/Raft eliminate all coordination costs; they enforce consensus but still require leader round-trips, so latency exists.
- Claiming NewSQL always gives linear scaling; it depends on workload (cross-shard transactions hurt scaling).
For your exam
Kinds of questions and what full-marks answers include:
- Definitions: define NewSQL, ACID, BASE, CAP, PACELC, serializability. Include short examples and one-line trade-off statements.
- Short notes: architecture of NewSQL (draw and explain single-master sharding vs consensus-based replication). Full marks: include diagram, pros/cons, latency and failure behaviour.
- Derivations: prove quorum size N>=2f+1 for f-fault tolerance. Full marks: stepwise argument about overlapping quorums.
- Numerical: apply Amdahl's law to given throughput numbers. Full marks: show formula, substitution, units, final numeric answer.
- Traces/algorithms: trace 2PC or Raft leader election on small node set. Full marks: label messages, show state changes and failure handling.
- Comparison question: given an app requirement (global reads, local writes, need for strict consistency), choose DB family and justify. Full marks: map requirements to CAP/PACELC, pick architecture, discuss expected latency and correctness.
Quick check
Three short questions.
- What is NewSQL in one sentence?
- State CAP theorem in one sentence and name its key assumption.
- Using Amdahl's law, if 80% of a workload is parallelisable (p=0.8) and we use 4 nodes, what factor multiplies the single-node time T(1) to get T(4)? (Give numeric multiplier.)
Answers: NewSQL = a class of databases combining SQL and ACID with horizontal scalability; CAP: cannot simultaneously provide Consistency, Availability and Partition tolerance in presence of network partitions (assumption: partitions can occur in an asynchronous network); Amdahl multiplier = (1 - 0.8) + 0.8/4 = 0.2 + 0.2 = 0.4 so T(4) = 0.4·T(1).
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?