Database Scaling

Preview — 3 of 10 questions

In a primary-replica (master-slave) database setup, how are reads and writes typically distributed?

javascript
┌──── Replica 1 (reads)
Primary ──┤──── Replica 2 (reads)
(writes)  └──── Replica 3 (reads)
AAll reads and writes go to all nodes simultaneously to ensure consistency.
BWrites go to the primary; reads can be served by both the primary and replicas, distributing read load.
CReads go exclusively to the primary; replicas only receive writes.
DThe primary handles odd-numbered requests; replicas handle even-numbered requests.

What is the main consistency risk of multi-primary (master-master) replication compared to primary-replica?

javascript
Client A ──▶ Primary 1  ──sync──▶ Primary 2 ◀── Client B
ABoth primaries accept writes simultaneously, which can create write conflicts when both modify the same record concurrently.
BMulti-primary replication cannot handle concurrent reads from multiple clients.
CMulti-primary replication requires twice the storage because data is duplicated.
DOnly one primary can be active at a time, defeating the purpose of having two primaries.

What does database federation mean and what problem does it solve?

javascript
Before federation:
  ┌────────────────────────────────┐
      Monolithic DB               
    users + orders + products       single bottleneck
    + reviews + analytics + ...  
  └────────────────────────────────┘

After federation:
  ┌──────────┐  ┌──────────┐  ┌───────────┐
   Users DB    Orders DB│  │Products DB│
  └──────────┘  └──────────┘  └───────────┘
  Each database is smaller, has fewer connections,
  fits more data in memory  better cache locality
AFederation combines multiple databases into a single schema accessed through one connection string.
BFederation replicates the entire database across multiple geographic regions.
CFederation splits one large database into multiple smaller databases by domain/function (e.g., users DB, orders DB, products DB), reducing load on each.
DFederation is a NoSQL pattern that replaces JOINs with denormalized documents.

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.