What is the main purpose of master-slave database replication?
To copy data from the master database to one or more slave databases to improve read performance and provide data redundancy.
Click to reveal answer
beginner
In master-slave replication, which database handles write operations?
The master database handles all write operations, while slaves handle read operations.
Click to reveal answer
intermediate
What is a common challenge in master-slave replication related to data consistency?
Slaves may lag behind the master, causing eventual consistency rather than immediate consistency.
Click to reveal answer
intermediate
How does asynchronous replication differ from synchronous replication in master-slave setups?
Asynchronous replication allows the master to continue without waiting for slaves to confirm data receipt, while synchronous waits for confirmation, ensuring stronger consistency but higher latency.
Click to reveal answer
intermediate
Name one advantage and one disadvantage of master-slave replication.
Advantage: Improves read scalability by distributing reads to slaves. Disadvantage: Single point of failure at the master and potential data lag on slaves.
Click to reveal answer
In master-slave replication, which database is responsible for processing write requests?
AMaster
BSlave
CBoth master and slave
DNeither
✗ Incorrect
The master database handles all write operations, while slaves handle read operations.
What is a common issue caused by asynchronous replication in master-slave setups?
AMaster cannot accept reads
BSlaves block writes
CSlaves may have outdated data temporarily
DSlaves overwrite master data
✗ Incorrect
Asynchronous replication can cause slaves to lag behind the master, leading to temporary outdated data.
Which of the following is NOT a benefit of master-slave replication?
AAutomatic failover without configuration
BImproved read scalability
CData redundancy
DLoad distribution for reads
✗ Incorrect
Master-slave replication does not provide automatic failover by default; additional setup is needed.
What happens if the master database fails in a typical master-slave setup without failover?
AReads and writes continue normally
BSlaves automatically become masters
CSlaves reject all queries
DWrites stop until master is restored
✗ Incorrect
Without failover, the master failure stops all write operations until it is fixed.
Which replication type waits for slaves to confirm data receipt before completing a write?
AMulti-master replication
BSynchronous replication
CMaster-slave replication
DAsynchronous replication
✗ Incorrect
Synchronous replication waits for slaves to confirm data receipt, ensuring stronger consistency.
Explain how master-slave replication works and its main benefits and drawbacks.
Think about who writes and who reads, and what happens if the master fails.
You got /6 concepts.
Describe the difference between synchronous and asynchronous replication in a master-slave database system.
Consider how quickly the master waits for slaves before confirming writes.
You got /5 concepts.
Practice
(1/5)
1. What is the primary role of the master in a master-slave database replication setup?
easy
A. Handle all write operations and propagate changes to slaves
B. Serve read requests only
C. Backup data from slaves
D. Monitor network traffic between nodes
Solution
Step 1: Understand master responsibilities
The master database is responsible for handling all write operations to ensure data consistency.
Step 2: Understand slave responsibilities
Slaves replicate data from the master and typically handle read requests to reduce load on the master.
Final Answer:
Handle all write operations and propagate changes to slaves -> Option A
2. Which of the following is the correct sequence for setting up master-slave replication?
easy
A. Configure slaves only, master is optional
B. Configure slaves, then configure master, then start replication
C. Start replication, then configure master and slaves
D. Configure master, then configure slaves, then start replication
Solution
Step 1: Configure master first
The master must be configured first to accept writes and log changes for replication.
Step 2: Configure slaves after master
Slaves are then configured to connect to the master and replicate its data.
Final Answer:
Configure master, then configure slaves, then start replication -> Option D
Quick Check:
Master setup before slaves [OK]
Hint: Master setup precedes slaves setup [OK]
Common Mistakes:
Configuring slaves before master
Starting replication before configuration
Ignoring master configuration
3. Consider a master-slave setup where the master receives 100 writes per second and each slave replicates with a 2-second lag. If a read request is sent to a slave immediately after a write, what is the likely result?
medium
A. The slave returns the latest data including the write
B. The slave crashes due to replication lag
C. The slave returns stale data missing the latest write
D. The slave rejects the read request
Solution
Step 1: Understand replication lag effect
Replication lag means slaves are behind the master by 2 seconds, so recent writes are not yet applied.
Step 2: Analyze read request timing
A read immediately after a write will hit the slave before replication applies the change, so stale data is returned.
Final Answer:
The slave returns stale data missing the latest write -> Option C
Quick Check:
Replication lag causes stale reads [OK]
Hint: Replication lag means slaves have delayed data [OK]
Common Mistakes:
Assuming slaves always have latest data
Thinking slaves reject reads during lag
Believing slaves crash due to lag
4. A system uses master-slave replication but experiences inconsistent reads from slaves. Which change can fix this issue?
medium
A. Allow writes on slaves to sync data faster
B. Increase monitoring and reduce replication lag
C. Disable replication and use only master for reads
D. Add more slaves without changing replication
Solution
Step 1: Identify cause of inconsistent reads
Inconsistent reads usually happen due to replication lag causing slaves to have outdated data.
Step 2: Fix by reducing replication lag
Improving monitoring and optimizing replication reduces lag, making slave reads more consistent.
Final Answer:
Increase monitoring and reduce replication lag -> Option B
Quick Check:
Reduce lag to fix inconsistent reads [OK]
Hint: Reduce lag to fix stale slave reads [OK]
Common Mistakes:
Allowing writes on slaves breaks consistency
Disabling replication loses read scaling
Adding slaves without lag fix doesn't help
5. You are designing a high-availability system using master-slave replication. Which approach best ensures minimal downtime and data loss during master failure?
hard
A. Automatically promote a slave to master and redirect writes
B. Stop all writes until the master is manually restored
C. Allow writes on slaves during master downtime
D. Use only one master without slaves to avoid complexity
Solution
Step 1: Understand master failure impact
If the master fails, writes cannot proceed unless a new master is available.
Step 2: Use automatic failover
Promoting a slave to master automatically and redirecting writes ensures availability and minimal data loss.
Step 3: Evaluate other options
Stopping writes causes downtime; writing on slaves breaks consistency; single master lacks redundancy.
Final Answer:
Automatically promote a slave to master and redirect writes -> Option A
Quick Check:
Automatic failover ensures availability [OK]
Hint: Auto-promote slave for failover [OK]
Common Mistakes:
Stopping writes causes downtime
Writing on slaves breaks data integrity
Ignoring failover leads to outages
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.