← Amazon Interview Insights

Amazon·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Apr 2026

Summary

System design round at Amazon for a software engineering role, focused entirely on database high availability. The whole session was about primary-replica failover: detection, orchestration, recovery, the works. Pretty intense if you haven't thought deeply about replication semantics before.

Questions Asked (7)

Q1

Design a high-availability failover system for a primary-replica relational database. Cover how you detect primary failure, promote a replica with minimal downtime and bounded data loss, and return the system to a healthy state.

System DesignTechnical Trade-offs
Author's notes

This is the main question and it's a lot.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: define availability target, acceptable RPO/RTO, and consistency needs. Then walk through the three phases—failure detection, promotion, and recovery—highlighting trade-offs and AWS-specific services like RDS Multi-AZ, Aurora, or ElastiCache for leader election. Conclude by discussing how to handle split-brain and reintegrate the old primary.

Pro tip: Emphasize that bounded data loss is achieved by monitoring replication lag and only promoting a replica that is within an acceptable lag threshold; this shows you understand the trade-off between availability and consistency.

1. Clarify Requirements and Assumptions

Ask about availability SLA, acceptable data loss (RPO), recovery time (RTO), and whether the system is single-region or multi-region. This sets the context for design decisions.

2. Design Failure Detection

Describe a health-check mechanism using heartbeats, consensus (e.g., Raft, Paxos), or a quorum-based system. Mention tools like ZooKeeper, etcd, or AWS services (Route 53 health checks, CloudWatch alarms) to avoid false positives.

3. Promote a Replica with Minimal Downtime and Bounded Data Loss

Explain how to select the most up-to-date replica, ensure it has applied all available WAL/binlog, and promote it. Use DNS failover or a proxy (e.g., ProxySQL, HAProxy) to redirect writes, and set a replication lag threshold to bound data loss.

4. Handle Split-Brain and Reintegrate the Old Primary

Discuss fencing (STONITH) to prevent the old primary from accepting writes, and once it recovers, reconfigure it as a replica, possibly using pg_rewind or rebuilding from a snapshot.

5. Return to Healthy State and Monitor

After failover, ensure the new primary is stable, update monitoring and alerts, and consider automating the failover process for future incidents. Also discuss post-mortem and testing via game days.

Key Points to Mention

  • Replication lag monitoring and its role in bounding data loss (RPO).
  • Consensus algorithms (Raft, Paxos) or quorum-based systems for leader election and failure detection.
  • DNS failover vs. proxy-based redirection for minimizing downtime.
  • Split-brain prevention using fencing mechanisms (e.g., STONITH, AWS EC2 instance termination).
  • Automated failover with tools like AWS RDS Multi-AZ, Aurora, or Orchestrator for MySQL.
  • Post-failover steps: reintegrating the old primary, updating configuration, and testing the failover process regularly.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

What RPO is acceptable for this system, and how does that choice affect your replication mode selection?

Technical Trade-offsSystem Design
Author's notes

They asked this as a clarifying question early on and I think I gave a wishy-washy answer about 'it depends on the business.' Which, fine, but they wanted me to commit to a number and reason from it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying that RPO is a business-driven decision, not a purely technical one, and that it directly dictates the replication mode (synchronous vs. asynchronous). Then walk through a concrete example, such as a financial transaction system requiring zero data loss (RPO=0) leading to synchronous replication, versus a social media feed where minutes of data loss are tolerable (RPO>0) allowing asynchronous replication.

Pro tip: Quantify the trade-off: synchronous replication increases write latency and reduces availability during network partitions, so always tie the RPO choice to the cost of data loss versus the cost of latency/availability. This shows you understand the business impact, not just the technology.

1. Define RPO and its business context

Explain that RPO is the maximum acceptable amount of data loss measured in time, and that it should be derived from business requirements, compliance needs, and user expectations.

2. Map RPO to replication mode

Describe how RPO=0 typically requires synchronous replication (e.g., multi-AZ in AWS), while RPO>0 allows asynchronous replication (e.g., cross-region). Mention that synchronous replication ensures every write is confirmed by multiple replicas before acknowledgment.

3. Analyze trade-offs

Discuss the impact on latency, availability, and cost: synchronous replication adds write latency and can cause availability drops during failures, while asynchronous replication risks data loss but offers lower latency and higher availability.

4. Consider hybrid or tiered approaches

Propose using different replication modes for different data types or tiers (e.g., synchronous for critical transactions, asynchronous for logs/analytics) to balance RPO and performance.

5. Validate with monitoring and testing

Emphasize the need to monitor replication lag and regularly test failover to ensure the chosen mode meets the RPO under real-world conditions.

Key Points to Mention

  • RPO definition and its role as a business requirement
  • Synchronous vs. asynchronous replication and their guarantees
  • Trade-offs: latency, availability, cost, and complexity
  • AWS services like Multi-AZ (synchronous) and Cross-Region Replication (asynchronous)
  • The concept of 'RPO=0' and its implications for system design
  • Monitoring replication lag and testing disaster recovery

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

How do you avoid split-brain when detecting primary failure? What prevents two nodes from both believing they are the primary?

System DesignTechnical Trade-offs
Author's notes

This is where I struggled most.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the fundamental problem of split-brain in distributed systems and why it occurs during primary failure detection. Then describe the mechanisms used to prevent it, such as quorum-based consensus, fencing tokens, and lease-based leadership. Finally, discuss trade-offs and how these mechanisms apply in practice, especially in cloud environments like AWS.

Pro tip: Emphasize that split-brain prevention is about ensuring only one node can act as primary at any time, often achieved by requiring a majority quorum for leader election and using fencing to isolate the old primary. Mention that in AWS, services like RDS and DynamoDB use these techniques, and you can reference Amazon's own systems like Aurora to show deeper understanding.

1. Define the problem

Explain what split-brain is and why it's dangerous: two nodes believing they are primary can lead to data corruption and inconsistent state.

2. Explain failure detection

Describe how primary failure is detected, e.g., via heartbeats, timeouts, or health checks, and note that false positives can trigger unnecessary failovers.

3. Introduce prevention mechanisms

Discuss quorum-based consensus (e.g., Paxos, Raft) where a majority must agree on the new primary, and fencing (e.g., STONITH) to ensure the old primary cannot continue serving requests.

4. Discuss leases and time-bound leadership

Explain how leases grant leadership for a limited time, requiring periodic renewal, and how clock drift and network delays must be accounted for.

5. Cover trade-offs and real-world examples

Talk about trade-offs between consistency and availability, and give examples like Amazon Aurora, DynamoDB, or etcd to show practical application.

Key Points to Mention

  • Quorum-based leader election (majority required)
  • Fencing tokens or STONITH to isolate old primary
  • Lease-based leadership with time-bound validity
  • Heartbeat and timeout mechanisms for failure detection
  • Consistency vs. availability trade-offs (CAP theorem)
  • Real-world systems: Amazon Aurora, DynamoDB, etcd, ZooKeeper

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Among multiple replicas, how do you decide which one to promote after the primary goes down?

System DesignAlgorithms & Data Structures
Author's notes

Easier one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the system's requirements and constraints, then discuss the trade-offs between different promotion strategies. Focus on how to achieve consensus among replicas and ensure data consistency, while minimizing downtime and avoiding split-brain.

Pro tip: Emphasize that the decision should be automated and based on a consensus protocol like Raft or Paxos, and mention the importance of fencing tokens to prevent the old primary from continuing to operate.

1. Clarify Requirements and Assumptions

Ask about the system's consistency requirements, replication mode (synchronous vs asynchronous), and failure detection mechanisms. This sets the stage for choosing an appropriate strategy.

2. Choose a Consensus Protocol

Explain that a consensus protocol like Raft or Paxos is typically used to elect a new leader. Describe how the protocol ensures only one leader is elected and how it handles network partitions.

3. Define Promotion Criteria

Discuss criteria such as the replica with the most up-to-date data (highest log index), lowest latency, or predefined priority. Mention that the choice depends on whether the system prioritizes consistency or availability.

4. Handle Failure Detection and Split-Brain

Describe how to detect primary failure (e.g., heartbeats, timeouts) and prevent split-brain using quorum-based elections and fencing mechanisms.

5. Implement and Monitor

Explain the need for automated failover, monitoring, and testing (e.g., chaos engineering) to ensure the promotion process works correctly and to handle edge cases.

Key Points to Mention

  • Consensus algorithms (Raft, Paxos) for leader election
  • Data consistency and replication lag considerations
  • Quorum-based decision making to avoid split-brain
  • Fencing tokens or epochs to prevent stale primary writes
  • Automated failover and health checks
  • Trade-offs between consistency and availability (CAP theorem)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q5

How do you handle downstream consumers of the replication stream, like CDC pipelines or search indexers, when a failover happens and the log position changes?

System DesignAPI & Integrations
Author's notes

This came as a follow-up and I wasn't ready for it at all.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by acknowledging that failover changes the log position, which can disrupt downstream consumers. Then describe a robust strategy that decouples consumers from the primary log position, such as using a stable intermediary like a log sequence number (LSN) mapping or a message queue, and ensuring consumers can resume from a consistent point. Emphasize idempotency, checkpointing, and monitoring to handle duplicates and gaps.

Pro tip: Highlight the importance of designing consumers to be idempotent and able to handle out-of-order or duplicate events, as failover often introduces these issues. Also, mention that at Amazon, we often use a service like Kinesis or MSK to buffer and replay events, which simplifies failover handling.

1. Acknowledge the challenge

Explain that failover causes the replication log position to change, potentially leading to data loss or duplication for downstream consumers. This sets the context and shows you understand the problem.

2. Decouple consumers from the primary log

Describe using an intermediary like a message queue (e.g., Kafka, Kinesis) or a change data capture (CDC) service that abstracts the log position. This allows consumers to read from a stable endpoint and handle failover transparently.

3. Ensure consumer resilience

Discuss designing consumers to be idempotent and to checkpoint their progress. They should be able to resume from a known good position and handle duplicates or gaps gracefully.

4. Implement monitoring and alerting

Mention the need to monitor consumer lag, error rates, and data consistency. Alerts can trigger automated recovery or manual intervention when failover occurs.

5. Test failover scenarios

Emphasize the importance of regularly testing failover and recovery processes to ensure downstream consumers behave as expected. This includes chaos engineering and game days.

Key Points to Mention

  • Idempotent consumers to handle duplicate events
  • Checkpointing and resuming from a consistent offset
  • Using a message queue or CDC service as a buffer
  • Monitoring consumer lag and data consistency
  • Automated failover and recovery mechanisms
  • Testing failover scenarios regularly

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q6

A replica that was lagging by 8 seconds gets promoted. What exactly is lost, how do you detect it, and what do you tell affected clients?

System DesignRoot Cause Analysis
Author's notes

Follow-up question toward the end.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the replication model (async vs sync) and the nature of the 8-second lag, then systematically walk through what data is permanently lost, how to detect the gap using replication coordinates and checksums, and finally how to communicate the impact and remediation to clients with transparency and ownership. Emphasize that the answer depends on the replication topology and the write patterns during the lag window.

Pro tip: Quantify the blast radius: estimate how many writes occurred in the 8-second window using write throughput metrics, and mention that you'd check if any of those writes were idempotent or could be replayed from an upstream log. This shows you think in terms of recoverability, not just data loss.

1. Clarify replication model and lag cause

Determine whether replication was asynchronous or semi-synchronous, and why the replica lagged (e.g., network partition, slow disk, long-running transaction). This sets the boundary of what could be lost.

2. Identify exactly what is lost

List the data that existed only on the old primary and was not yet replicated: committed transactions, uncommitted transactions, and any writes in the replication stream that were never applied. Also consider lost metadata like auto-increment counters or sequence values.

3. Detect and quantify the gap

Use replication coordinates (e.g., binlog position, LSN, GTID) to find the exact divergence point. Compare checksums or row counts between the old primary (if recoverable) and the new primary. Estimate the number of affected rows/transactions using write throughput metrics.

4. Assess impact and remediation options

Determine which clients and operations are affected. Check if lost writes can be replayed from an upstream log, application retry queue, or idempotent client retries. Decide whether to restore from backup or accept data loss.

5. Communicate with clients

Notify affected clients promptly with a clear, honest explanation: what happened, what data may be missing, what you are doing to recover it, and what they should do (e.g., retry failed operations). Provide a timeline and follow-up plan.

Key Points to Mention

  • Asynchronous replication means committed transactions on the old primary that hadn't been applied to the replica are lost.
  • Replication coordinates (binlog position, GTID, LSN) are used to pinpoint the exact divergence and detect the gap.
  • Data loss can include user writes, updates, deletes, and schema changes that occurred during the 8-second window.
  • Impact assessment should consider idempotency and whether lost writes can be replayed from upstream logs or client retries.
  • Client communication must be transparent, include a root cause, remediation steps, and a timeline for recovery.
  • Preventive measures like semi-synchronous replication, monitoring replication lag, and automated failover with consistency checks should be discussed.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q7

How would you extend this design to support multi-region disaster recovery, and what new consistency trade-offs does WAN replication introduce?

System DesignTechnical Trade-offs
Author's notes

Last question, felt like a bonus.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the current design's consistency model and SLAs, then propose a multi-region DR strategy that balances RTO/RPO with cost and complexity. Explicitly discuss the new consistency trade-offs introduced by WAN replication, such as increased latency and potential for conflicts, and how to mitigate them.

Pro tip: Demonstrate awareness of Amazon's global infrastructure by mentioning services like DynamoDB Global Tables or S3 Cross-Region Replication, and emphasize that the choice of consistency model should be driven by business requirements, not technical convenience.

1. Clarify Requirements and Current Design

Ask about the existing architecture, SLAs, and business requirements for DR (RTO/RPO). Identify the current consistency model and data stores.

2. Propose Multi-Region DR Strategy

Outline a strategy such as active-passive or active-active, with specific replication mechanisms (e.g., synchronous vs asynchronous) and failover procedures.

3. Analyze Consistency Trade-offs

Discuss how WAN replication affects consistency: increased latency, potential for stale reads, and conflict resolution in active-active setups.

4. Mitigate and Monitor

Describe techniques to handle trade-offs, such as conflict-free replicated data types (CRDTs), read-repair, or tunable consistency, and how to monitor replication lag.

5. Summarize and Validate

Recap the proposed design, highlighting how it meets requirements and manages trade-offs. Suggest validation through chaos engineering or DR drills.

Key Points to Mention

  • RTO and RPO definitions and how they influence replication strategy
  • Synchronous vs asynchronous replication and their impact on latency and consistency
  • CAP theorem and the trade-off between consistency and availability in a WAN context
  • Conflict resolution strategies for active-active (e.g., last-write-wins, CRDTs)
  • Amazon services like DynamoDB Global Tables, Aurora Global Database, or S3 Cross-Region Replication
  • Monitoring replication lag and automated failover mechanisms

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.