← Amazon Interview Insights

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

Senior
Jul 2026

Summary

Amazon system design round for a software engineer role. The question was a single massive prompt covering basically every layer of input handling you can imagine, from raw key events up through IME composition and crash recovery. Dense but interesting if you're into that kind of thing.

Questions Asked (6)

Q1

Design an input processing system that captures keyboard and mouse events and can reconstruct what the user typed. The system should support multiple input devices, maintain a total ordering of events, persist an event log, and support replay to derive the final text state.

System DesignData ModelingTechnical Trade-offs
Author's notes

This question is enormous.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and scale, then propose a high-level architecture with an event ingestion layer, a total ordering mechanism, a durable event log, and a replay engine. Dive into data modeling for events, ordering strategies (e.g., logical clocks), and trade-offs between consistency, latency, and complexity.

Pro tip: Emphasize idempotency and exactly-once processing in the replay engine to avoid duplicate text, and discuss how to handle out-of-order events from multiple devices using vector clocks or a centralized sequencer.

1. Clarify Requirements and Scope

Ask about scale (events per second, number of devices), latency needs, durability guarantees, and whether the system is client-side or server-side. Define what 'reconstruct what the user typed' means (e.g., final text vs. keystroke sequence).

2. Design Event Ingestion and Ordering

Propose how to capture events from multiple devices (e.g., agents, SDKs) and assign a total order. Consider centralized sequencer (e.g., Kafka with single partition) vs. distributed logical clocks (Lamport timestamps, vector clocks) and their trade-offs.

3. Model and Persist Events

Define the event schema (device ID, timestamp, sequence number, event type, payload). Choose a durable, append-only log (e.g., Kafka, Kinesis, or a database with WAL) and discuss partitioning, retention, and indexing for replay.

4. Implement Replay and State Reconstruction

Design a replay engine that reads the event log in order and applies events to a state machine (e.g., text buffer). Ensure idempotency, handle late/out-of-order events, and support snapshots for faster recovery.

5. Address Trade-offs and Extensions

Discuss trade-offs: consistency vs. latency, centralized vs. decentralized ordering, storage cost vs. replay speed. Mention extensions like real-time analytics, conflict resolution (e.g., CRDTs), and security.

Key Points to Mention

  • Total ordering mechanisms: centralized sequencer (Kafka partition) vs. distributed logical clocks (Lamport/vector clocks) and their trade-offs.
  • Event schema design: include device ID, sequence number, timestamp, event type, and payload; consider versioning for schema evolution.
  • Durability and persistence: append-only log (Kafka, Kinesis, WAL) with replication and retention policies.
  • Replay engine: state machine that applies events in order; idempotency and exactly-once semantics to avoid duplicates.
  • Handling out-of-order and late events: buffering, watermarking, or reordering based on sequence numbers.
  • Scalability and partitioning: sharding by user/session to maintain order per key while scaling horizontally.

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

Q2

How would you handle event ordering and timestamps across multiple input devices to ensure a consistent total order?

System DesignTechnical Trade-offs
Author's notes

Talked about monotonic clocks and a sequencer that stamps events as they enter a single queue.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: what level of consistency is needed, what are the latency constraints, and whether the devices are in a distributed system. Then propose a solution using logical clocks (e.g., Lamport timestamps or vector clocks) combined with a tie-breaking mechanism (e.g., device ID) to achieve a total order, and discuss trade-offs with physical clocks and centralized sequencing.

Pro tip: Mention that while physical clocks (NTP) are simple, they can drift and cause ordering issues; logical clocks provide causality but require a tie-breaker for total order. Also, highlight that the choice depends on whether you need causality tracking or just a consistent total order.

1. Clarify Requirements

Ask about consistency level (total order vs. causal), latency tolerance, scale, and whether devices are synchronized. This shows you understand the problem context.

2. Discuss Physical Clocks

Explain that using timestamps from physical clocks (e.g., NTP) is straightforward but suffers from clock skew and drift, which can violate ordering. Mention that it's unsuitable for strict total order without synchronization.

3. Introduce Logical Clocks

Describe Lamport timestamps for partial order and vector clocks for causality. Explain that Lamport timestamps can be extended to total order by using device ID as a tie-breaker.

4. Propose a Total Order Mechanism

Combine logical timestamps with a unique tie-breaker (e.g., device ID) to create a total order. Alternatively, use a centralized sequencer or a consensus protocol (e.g., Paxos) for strict ordering, but note the trade-offs in latency and complexity.

5. Address Trade-offs and Edge Cases

Discuss trade-offs: logical clocks add overhead but ensure causality; centralized solutions are simple but introduce a single point of failure and latency. Mention handling clock drift, network partitions, and scalability.

Key Points to Mention

  • Lamport timestamps and vector clocks
  • Clock skew and drift in physical clocks
  • Tie-breaking with device ID for total order
  • Centralized sequencer vs. distributed consensus
  • Trade-offs: latency, scalability, complexity
  • Causality vs. total order requirements

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

Q3

How would you support undo and redo with sensible transaction grouping, including clipboard operations like cut, copy, and paste?

System DesignTechnical Trade-offs
Author's notes

I grouped by 'natural pause in typing' and said paste should always be its own transaction.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then propose a command pattern with transaction grouping to encapsulate operations. Discuss how to handle clipboard operations as commands that can be grouped into transactions, and explain undo/redo stacks with grouping boundaries.

Pro tip: Emphasize that transaction grouping should be based on user intent (e.g., a paste operation is one transaction) and that clipboard operations should be undoable but not affect the clipboard's content. Also, mention that redo stack is cleared on new operations.

1. Clarify Requirements

Ask about the scope: single-user vs collaborative, persistence needs, and expected transaction granularity. Confirm that clipboard operations should be undoable and that grouping should reflect logical user actions.

2. Design Command Pattern

Propose encapsulating each operation (insert, delete, cut, copy, paste) as a command object with execute and undo methods. Commands can be composed into transactions for grouping.

3. Implement Undo/Redo Stacks

Maintain two stacks: undo and redo. When a command or transaction is executed, push it onto the undo stack and clear the redo stack. Undo pops from undo, executes undo, and pushes to redo; redo does the reverse.

4. Handle Transaction Grouping

Group related commands into a single transaction (e.g., a paste operation that inserts multiple items). Provide a mechanism to begin and end transactions, ensuring atomic undo/redo.

5. Integrate Clipboard Operations

Treat cut, copy, and paste as commands. Copy does not modify the document, so it may not need to be undoable, but cut and paste should be. Ensure that undoing a paste does not affect the clipboard content.

Key Points to Mention

  • Command pattern with execute/undo methods for each operation.
  • Transaction grouping to combine multiple commands into a single undoable unit.
  • Undo and redo stacks with proper stack management (clearing redo on new action).
  • Clipboard operations: copy is non-destructive, cut and paste are undoable.
  • Consideration of memory usage and potential optimizations (e.g., command compression).
  • Edge cases: undoing a paste after clipboard content changes, redo after undo, and transaction boundaries.

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

Q4

How would you persist the event log and support crash recovery, including deterministic replay to rebuild the final text state?

System DesignData Modeling
Author's notes

Append-only log plus periodic snapshots.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: what kind of events, expected throughput, durability guarantees, and recovery time objectives. Then propose an append-only log with periodic snapshots, and explain how deterministic replay from the last snapshot rebuilds the final state. Finally, discuss trade-offs and optimizations like compaction, checksums, and idempotent operations.

Pro tip: Emphasize that deterministic replay requires events to be immutable and ordered, and that snapshots are just an optimization to avoid replaying from the beginning. Also mention that you'd include a version or sequence number to detect gaps or duplicates.

1. Clarify requirements and constraints

Ask about event volume, durability needs, recovery time, and whether the system is single-node or distributed. This shows you don't jump to solutions without understanding the problem.

2. Design the event log storage

Propose an append-only log persisted to disk (e.g., write-ahead log) with checksums for integrity. Mention options like a database table, file-based log, or distributed log (e.g., Kafka) depending on scale.

3. Implement snapshots for efficient recovery

Periodically snapshot the current state to avoid replaying the entire log. Store snapshots with the log offset so you know where to resume replay.

4. Ensure deterministic replay

Guarantee that replaying events in order produces the same state. This requires pure event handlers, no external side effects during replay, and handling of non-deterministic operations (e.g., timestamps) by storing them in the event.

5. Handle crash recovery and fault tolerance

On startup, load the latest snapshot and replay subsequent events. Use atomic writes and fsync to ensure durability. Discuss trade-offs between performance and durability (e.g., fsync frequency).

Key Points to Mention

  • Append-only log with sequence numbers and checksums for integrity
  • Periodic snapshots to bound recovery time
  • Deterministic event handlers and idempotent operations
  • Atomic writes and fsync for durability
  • Log compaction or truncation to manage disk space
  • Recovery process: load snapshot, replay events from offset, rebuild state

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

Q5

What APIs would you expose for this system, for example recording events, querying current text, managing selection, and controlling sessions?

API & IntegrationsSystem Design
Author's notes

Listed recordEvent, getCurrentText, getSelectionRange, undo, redo, startSession, endSession, replay.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the system's core entities and operations, then propose a resource-oriented API design with clear separation of concerns. Group APIs by functional area (events, text, selection, sessions) and discuss trade-offs between synchronous and asynchronous operations, idempotency, and scalability.

Pro tip: Demonstrate Amazon leadership principles by explicitly calling out customer-obsessed design decisions, such as API versioning for backward compatibility and idempotency for event recording to prevent duplicate charges or data corruption.

1. Clarify Requirements and Scope

Ask clarifying questions about the system's purpose, expected scale, consistency needs, and client types (e.g., web, mobile, third-party). This ensures your API design aligns with actual use cases.

2. Identify Core Resources and Operations

Define the main resources (e.g., events, text, selection, sessions) and map CRUD operations to them. Consider whether operations are synchronous or asynchronous and how they interact.

3. Design API Endpoints and Contracts

Propose specific endpoints (e.g., POST /events, GET /text, PUT /selection, POST /sessions) with request/response schemas, status codes, and error handling. Discuss authentication, rate limiting, and versioning.

4. Address Cross-Cutting Concerns

Cover idempotency, pagination, consistency models, and observability (logging, metrics). Explain how the API handles concurrency and partial failures.

5. Discuss Trade-offs and Alternatives

Compare REST vs. GraphQL vs. gRPC for this use case, and justify your choices based on performance, flexibility, and client needs. Mention potential future extensions.

Key Points to Mention

  • Idempotency for event recording to ensure exactly-once processing
  • Versioning strategy (e.g., URL versioning or custom headers) for backward compatibility
  • Pagination and filtering for querying current text and events
  • Session management with tokens (e.g., JWT) and expiration policies
  • Selection management with optimistic concurrency control (ETags or version numbers)
  • Rate limiting and throttling to protect the system from abuse

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

Q6

How would you handle robustness concerns like key bounce debouncing, mouse-move event coalescing, and lost or duplicated events?

System DesignTechnical Trade-offs
Author's notes

Short answer: sequence numbers for dedup, debounce window for bouncing keys, coalesce mouse-move events in the capture layer before they hit the queue.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the input sources and system constraints, then systematically address each robustness concern with specific techniques and trade-offs. Emphasize a layered approach: prevention, detection, and recovery, and tie your solutions to real-world impact like user experience and system reliability.

Pro tip: Demonstrate maturity by discussing how you would measure the effectiveness of your solutions (e.g., metrics for event loss/duplication) and by acknowledging that over-engineering can introduce latency, so you'd validate with data before scaling.

1. Clarify Requirements and Constraints

Ask about the input devices, expected event rates, latency tolerances, and whether the system is real-time or batch. This ensures your solutions are context-appropriate.

2. Address Debouncing and Coalescing

Explain techniques like time-based debouncing for key bounce and spatial/temporal coalescing for mouse moves, highlighting trade-offs between responsiveness and resource usage.

3. Handle Lost and Duplicated Events

Discuss strategies such as sequence numbers, acknowledgments, idempotent processing, and deduplication windows to ensure exactly-once or at-least-once semantics.

4. Design for Observability and Recovery

Mention logging, metrics, and alerts to detect anomalies, and describe fallback mechanisms like retries with backoff or state reconciliation.

5. Evaluate Trade-offs and Validate

Summarize the trade-offs (e.g., latency vs. accuracy) and propose how you would test and iterate, such as through load testing or A/B experiments.

Key Points to Mention

  • Debouncing techniques: hardware vs. software debouncing, time thresholds, and state machines.
  • Mouse-move coalescing: batching events, using requestAnimationFrame, and throttling to reduce processing load.
  • Lost events: sequence numbers, acknowledgments, retransmission, and persistent queues.
  • Duplicated events: idempotent handlers, deduplication caches, and exactly-once processing semantics.
  • Trade-offs: latency vs. accuracy, complexity vs. reliability, and resource consumption.
  • Monitoring and metrics: tracking event loss/duplication rates, latency percentiles, and user impact.

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