Advanced DBMS needs and architectures
Advanced DBMS needs and architectures: why modern databases use different architectures (shared-nothing, shared-disk, cloud DBaaS, scale-up vs scale-out), the trade-offs (consistency, availability, partition tolerance), and how these affect performance, transactions and recovery.
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
Modern applications need databases that can scale, tolerate failures and meet latency and consistency requirements. An engineer chooses a DBMS architecture (for example shared‑nothing or shared‑disk, on‑premise or DBaaS) based on workload patterns, cost and required guarantees such as ACID or eventual consistency; understanding these trade-offs guides system design, capacity planning and operational choices.
Key ideas
Start from first principles: a database must store data and answer queries reliably and fast. When systems grow, a single machine is often insufficient. Two main scaling strategies are:
- Scale‑up (vertical scaling): increase resources (CPU, RAM, storage) of one server. Simpler but limited by hardware and cost.
- Scale‑out (horizontal scaling): add more servers and distribute data and work across them. Common partitioning schemes include range, hash, and consistent hashing; rebalancing handles data skew and node addition/removal.
Define architectures:
- Shared‑nothing architecture: every node owns its CPU, memory and storage; nodes communicate only by message passing. Assumption: network is available but may be slower than local I/O. Advantage: good horizontal scalability and fault containment.
- Shared‑disk architecture: nodes share access to the same storage (SAN or distributed filesystem) but have separate CPU and memory. Assumption: a fast coherent storage layer exists. Advantage: easier failover; disadvantage: concurrency control over shared storage is needed.
- Shared‑memory (shared‑everything): single memory space accessed by multiple processors (typical of multicore machines). Assumption: hardware supports coherent shared memory. Advantage: low-latency access to shared data, but limited scalability beyond one machine.
Transaction and consistency trade-offs:
ACID: stands for Atomicity, Consistency, Isolation, Durability. Exact university-style definition:
- Atomicity: a transaction is an indivisible unit; either all its effects occur, or none occur.
- Consistency: a transaction takes the database from one valid state to another, preserving all declared integrity constraints.
- Isolation: concurrently executing transactions behave as if they were executed in some serial order (serialisability is a formal criterion often used).
- Durability: once a transaction commits, its effects persist despite crashes. Assumptions: a transactional log and recovery protocol exist to enforce durability and atomicity.
BASE: stands for Basically Available, Soft state, Eventual consistency. It is a weaker model often used for highly distributed systems where strict ACID is impractical. Definition: the system allows temporary inconsistency but aims to converge to a consistent state.
CAP theorem (exact statement used in exams): In a distributed data system, it is impossible to simultaneously provide more than two of the following three guarantees: Consistency (C), Availability (A), and Partition tolerance (P). Assumptions: asynchronous network where partitions (communication loss) can occur. Derivation commonly given: show that if a partition splits nodes, to remain available each side must accept requests (sacrificing consistency) or to remain consistent they must reject requests (sacrificing availability). Extension: PACELC theorem states that in the absence of partitions (Else), systems often trade latency (L) versus consistency (C), in addition to the CAP trade-off under partition.
Distributed transactions and commit protocols:
- Two‑Phase Commit (2PC): protocol ensuring atomic commit across multiple nodes. Phases: (1) prepare phase where coordinator asks participants to prepare and participants write a prepared record; (2) commit phase where coordinator decides commit and tells participants. Exact properties: 2PC guarantees atomicity but is blocking: if coordinator fails after participants vote yes, participants may wait indefinitely.
- Three‑Phase Commit (3PC): attempts to avoid blocking by adding a precommit step; requires bounded-delay/partial synchrony and fail-stop assumptions, and is unsafe under network partitions; less used in practice.
Performance and parallelism laws:
- Amdahl's Law for speedup: if fraction p of a task is perfectly parallelisable and (1-p) is serial, maximum speedup on N processors is S = 1 / ((1-p) + p/N). Assumption: no parallel overhead (idealised) and fixed total work.
- Little's Law: in a stable system, average number of items L = arrival rate λ × average time in system W. Assumption: long-run averages and stability (arrival rate = departure rate).
Fault tolerance and replication:
- Replication: keep copies of data on multiple nodes to increase availability and read throughput. Consistency protocols include synchronous replication (strong consistency, higher latency) and asynchronous replication (lower latency, possibly eventual consistency). In quorum-based systems with replication factor N, choosing read quorum R and write quorum W such that R + W > N yields single-copy consistency under crash failures; typical strategies include leader/follower, multi-leader, and leaderless designs with different trade-offs.
- Consensus (e.g., Paxos for single-decree, Multi-Paxos/Raft for a replicated log): exact problem statement: ensure a set of distributed processes agree on a value, and in practice on a sequence of values via a log, despite failures. Properties required: safety (no two correct processes decide different values) and liveness (eventually some value is decided) under assumptions about message delivery and leader election.
Draw diagrams (what to draw and label):
- For shared‑nothing, draw three boxes labelled Node1, Node2, Node3; inside each box draw CPU, RAM, Disk; draw network lines connecting the boxes and label them "network".
- For 2PC, draw Coordinator above two Participants. Draw arrows: Coordinator -> Participants "prepare"; Participants -> Coordinator "vote (yes/no)"; Coordinator -> Participants "commit/abort". Label each arrow with the message name and the participant actions (write prepare record, commit, release locks).
- For CAP, draw a triangle with vertices C, A, P and a note that under a network partition you must choose between C and A; without partitions you can have both C and A (the “pick any two” shorthand applies only during partitions).
Assumptions for proofs and derivations: when proving Amdahl use ideal parallelism and no communication; CAP assumes possibility of network partitions.
Where unsure: choice of real-world systems that strictly meet theoretical models—note these are approximations in practice.
Formulas
S = 1 / ((1 - p) + p / N) — S is speedup (dimensionless), p is fraction of parallelisable work (0..1), N is number of processors (dimensionless). Applies to idealised parallel tasks (Amdahl's Law).
L = λ · W — Little's Law: L is average number of requests in system (dimensionless), λ is arrival rate (s⁻¹), W is average time in system (s). Applies for stable, long-run systems.
Throughput ≈ N · μ — N is number of worker threads/nodes (dimensionless), μ is service rate per worker (requests·s⁻¹). Approximate and assumes independent workers and no contention; actual throughput is bounded by bottlenecks and arrival rate (e.g., ≤ N·μ), and coordination/queueing overheads often reduce it.
Availability = MTBF / (MTBF + MTTR) — MTBF mean time between failures (s), MTTR mean time to repair (s), Availability is fraction (0..1). Applies for simple reliability models.
Worked examples
- Amdahl speedup numerical Problem: 90% of a query execution is parallelisable (p = 0.90). Calculate speedup for N = 4 and N = 16. Steps:
- Formula:
S = 1 / ((1 - p) + p / N). - For N = 4: S = 1 / ((1 - 0.90) + 0.90 / 4) = 1 / (0.10 + 0.225) = 1 / 0.325 = 3.076923...
- For N = 16: S = 1 / (0.10 + 0.90 / 16) = 1 / (0.10 + 0.05625) = 1 / 0.15625 = 6.4 Final answers: Speedup with 4 processors ≈ 3.08; with 16 processors = 6.4.
- Two‑Phase Commit trace (algorithmic trace) Problem: Coordinator C, Participants P1 and P2. Both participants have prepared successfully. Show messages and state changes. Steps (numbered):
- C -> P1,P2: PREPARE (request to prepare). P1,P2 write "prepared" record to stable log and reply YES.
- P1 -> C: VOTE=YES (stable), P2 -> C: VOTE=YES.
- C, upon receiving all YES, decides COMMIT. C -> P1,P2: COMMIT.
- P1,P2 perform commit, write commit to log, release locks, and reply ACK.
- C receives ACKs and can forget state. If C crashes after collecting all YES and deciding COMMIT but before sending the decision to some participant(s), those participants remain in the prepared (uncertain) state and must block (holding locks) until the coordinator recovers or a termination protocol reveals the outcome (illustrates the blocking property). Final: show the importance of logs and blocking if coordinator fails.
- Short model answer question (theory): Why choose shared‑nothing for a large OLAP system? Model answer: list reasons—linear horizontal scalability (add nodes), avoids single storage bottleneck, easier to shard data, fault isolation, cost-effective commodity hardware. Also mention trade-offs: need for distributed query planning and joins across nodes, possible data skew and network traffic.
Common mistakes
- Applying Amdahl's Law without accounting for communication and coordination overhead; giving unrealistic speedup numbers.
- Saying 2PC is non‑blocking (it is blocking under coordinator failure). Mixing up blocking vs synchronous/asynchronous replication.
- Forgetting units in Little's Law (λ in s⁻¹ and W in s) or misusing it when the system is not stable.
- Drawing shared‑disk as identical to shared‑nothing (they differ by whether storage is shared).
For your exam
Typical question types:
- Definitions and short notes: define shared‑nothing, shared‑disk, scale‑up/scale‑out, ACID, BASE, CAP theorem. Full marks: give precise definition, assumptions and one line of implication (e.g., when to use).
- Derivations: derive Amdahl's law and explain assumptions. Full marks: show step-by-step fraction decomposition and the limiting case as N→∞.
- Numericals: compute speedup with given p and N, apply Little's Law given λ and W. Full marks: write formula, substitute numbers with units, compute and give results with correct significant digits.
- Algorithms/traces: trace 2PC with messages. Full marks: show messages, logs, states and discuss blocking.
- Diagrams: draw architecture (shared‑nothing) or CAP triangle. Full marks: label components and explain traffic/coordination.
- Short essays: compare replication strategies and their impact on latency and consistency. Full marks: list synchronous vs asynchronous, use-cases and trade-offs.
Quick check
- What does "shared‑nothing" mean?
- State CAP theorem in one sentence.
- Little's Law relates which three quantities?
Answers: 1) Each node has its own CPU, memory and storage and communicates over network. 2) In a distributed system you cannot simultaneously guarantee consistency, availability and partition tolerance; you can pick at most two. 3) Average number in system L = arrival rate λ × average time W.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?