Scrivio Interview library

Replication and high availability

25 questions in 7 subtopics.

Synchronous vs asynchronous replication

ConceptFoundations6 min read
Explain the difference between synchronous and asynchronous replication in PostgreSQL streaming replication. What does a commit wait for in each case, and what can be lost if the primary crashes?
ConceptIntermediate6 min read
Compare MySQL 8.4 asynchronous replication, semi-synchronous replication and Group Replication in terms of durability on failover and write latency.
DesignIntermediate6 min read
You run a payments database on PostgreSQL with one primary and two standbys in different availability zones of one region. Decide on synchronous settings and explain the latency and availability trade-offs.
ScenarioAdvanced7 min read
A team proposes using PostgreSQL logical replication to feed analytics, search and a new microservice from the monolith database. What are the operational risks, and how would you set it up safely?

Replication lag and read-your-writes

DebuggingFoundations6 min read
After a user updates their address, the profile page sometimes shows the old address. The service reads from a PostgreSQL replica. How do you confirm replication lag is the cause, and what quick fixes exist?
DebuggingIntermediate6 min read
A PostgreSQL hot standby used for reports shows replay lag growing to 40 minutes every afternoon, and some report queries are cancelled with 'canceling statement due to conflict with recovery'. Explain both and what settings you would review.
DesignIntermediate6 min read
Design read-your-writes consistency for a Spring Boot service using a primary and three replicas, without sending all reads to the primary.
LeadershipAdvanced6 min read
Teams across your company each implemented their own replica routing and lag handling, with different bugs. How would you standardise read scaling and consistency guarantees?

Failover and leader election

ConceptFoundations6 min read
What happens during a database failover, from the primary failing to the application writing again? Name the steps and what the Java application must do to survive it.
InternalsIntermediate7 min read
How do Patroni-managed PostgreSQL clusters elect a leader, and why do they depend on etcd, Consul or ZooKeeper instead of the nodes voting among themselves?
ScenarioIntermediate7 min read
A managed cloud database failed over during peak traffic. The database was back in 60 seconds, but your Spring Boot services returned errors for 12 minutes. Walk through what likely went wrong and how you would fix it.

Multi-region databases

DesignIntermediate6 min read
Your service runs in two regions, us-east and eu-west, with a single PostgreSQL primary in us-east. EU users see 150 ms extra latency on writes. What options exist, and what does each cost?
DesignAdvanced6 min read
Leadership wants the product to survive the loss of an entire cloud region with under 5 minutes of downtime and no lost payments. Design the database layer and explain where you would push back.
LeadershipPrincipal6 min read
Your board asks whether the company should go active-active across three regions for all products. As the senior technical leader, how do you frame the decision in terms of cost, risk and organisation?

Backups and point-in-time recovery

ConceptFoundations6 min read
Explain how point-in-time recovery works in PostgreSQL. What must you keep, and how would you restore the database to 14:32 yesterday just before a bad DELETE?
ScenarioIntermediate6 min read
An audit finds that your nightly backups have never been restored, and nobody knows how long a restore of the 4 TB database takes. What do you set up?
LeadershipAdvanced6 min read
After a ransomware incident at a peer company, your CISO asks whether your database backups would survive an attacker with admin access to your cloud account. How do you assess and improve this across 200 databases?
DesignPrincipal6 min read
Retention rules require keeping database backups for 7 years in some jurisdictions and erasing personal data within 30 days on request in others. As the senior technical leader, how do you reconcile backups, PITR and privacy obligations?

RPO and RTO

ConceptFoundations6 min read
Define RPO and RTO and give realistic values for these three setups: nightly pg_dump only; base backups with WAL archiving; synchronous standby with automated failover.
ScenarioIntermediate6 min read
Product says the order service needs 'zero data loss and zero downtime'. How do you turn this into concrete RPO and RTO targets and a design you can actually deliver?
LeadershipPrincipal6 min read
As the senior technical leader, how would you set company-wide RPO and RTO tiers for hundreds of systems and make sure they are real rather than slideware?

Split brain

ConceptFoundations6 min read
What is split brain in a replicated database, how can it happen during a network partition, and why is it worse than downtime?
DebuggingIntermediate7 min read
After a network blip, monitoring shows two PostgreSQL nodes reporting pg_is_in_recovery() = false, and both received writes for 4 minutes. How do you respond and recover?
DesignAdvanced8 min read
Your team runs its own failover scripts for MySQL using a two-node setup with a health check from a third server. Explain why this design is prone to split brain and propose a safer architecture.
LeadershipPrincipal7 min read
Over 20 years, database HA has moved from shared-disk clusters to asynchronous replicas, to consensus-based systems and managed cloud databases. What has this taught you about building versus buying HA, and what would you decide for a new platform today?