← Amazon Interview Insights

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

Senior
Jul 2026

Summary

Amazon system design round focused entirely on a document and tag management system, starting from basic class design and scaling up to full concurrency. Pretty intense for a single question that kept growing.

Questions Asked (2)

Q1

Design a system to manage documents and tags, including class interfaces, core data structures, and support for operations like creating/deleting documents and tags, adding/removing tags on documents, listing documents by tag, listing tags by document, and querying documents by the intersection of multiple tags.

System DesignAlgorithms & Data StructuresData Modeling
Author's notes

I started with two hashmaps, one mapping document IDs to their tag sets and another mapping tags to document sets.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and scale, then define clear class interfaces and choose data structures that optimize for the most frequent operations. Discuss trade-offs between different indexing strategies and how to handle multi-tag intersection queries efficiently.

Pro tip: At Amazon, always tie your design decisions back to customer impact and operational excellence—mention how your data structures affect latency, throughput, and cost at scale, and consider eventual consistency vs strong consistency for tag updates.

1. Clarify Requirements and Scale

Ask about expected number of documents, tags, operations per second, read/write ratio, and consistency requirements. This will guide your data structure and indexing choices.

2. Define Core Classes and Interfaces

Outline classes like Document, Tag, DocumentManager, and TagManager with methods for CRUD and association operations. Specify method signatures and return types.

3. Design Data Structures and Indexes

Choose structures like hash maps for document/tag storage and inverted indexes (tag -> set of documents) for efficient lookups. Consider using sets for fast add/remove and intersection.

4. Implement Multi-Tag Intersection Query

Explain how to compute intersection of multiple tags efficiently, e.g., by iterating over the smallest set and checking membership in others, or using sorted lists and merge algorithms.

5. Discuss Trade-offs and Scalability

Address trade-offs between memory and speed, handling large-scale data (sharding, caching), and consistency models. Mention potential bottlenecks and mitigation strategies.

Key Points to Mention

  • Inverted index mapping tags to document IDs for fast tag-based lookups
  • Using sets (or sorted lists) for document-tag associations to enable efficient add/remove and intersection
  • Optimizing intersection queries by starting with the smallest tag set and using hash-based lookups
  • Handling concurrency and consistency (e.g., locking, eventual consistency) for tag updates
  • Scalability considerations: sharding by document ID or tag, caching frequent queries
  • Trade-offs between memory usage and query performance, and between simplicity and optimization

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

Q2

How would you extend the document and tag management design to be thread-safe under concurrent reads and writes? Cover locking granularity, consistency guarantees, deadlock avoidance, and how you'd test for concurrency correctness.

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

This is where I started to sweat a little.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data model and access patterns (read-heavy vs write-heavy, document-tag relationships). Then propose a layered locking strategy: fine-grained locks for individual documents/tags, coarse-grained locks for global structures, with a clear lock ordering to prevent deadlocks. Finally, discuss consistency guarantees (e.g., linearizability vs eventual consistency) and how you'd test concurrency with stress tests and model checking.

Pro tip: Emphasize that thread-safety is not just about locks—consider lock-free data structures, immutable snapshots, and optimistic concurrency control with versioning. Also, mention that you'd measure contention and adapt granularity based on real workload, showing a pragmatic trade-off mindset.

1. Clarify Requirements and Data Model

Ask about read/write ratio, consistency needs, and the relationships between documents and tags (e.g., many-to-many). Define what operations must be atomic (e.g., adding a tag to a document).

2. Choose Locking Granularity

Propose fine-grained locks per document and per tag, plus a global lock for the tag index. Discuss trade-offs: finer locks increase concurrency but add overhead and deadlock risk.

3. Define Lock Ordering and Deadlock Avoidance

Establish a strict lock acquisition order (e.g., always lock document before tag) and use timeouts or deadlock detection. Consider lock-free alternatives like copy-on-write for read-heavy paths.

4. Specify Consistency Guarantees

State whether you provide linearizability, serializability, or eventual consistency. Explain how you'd implement it (e.g., two-phase locking, MVCC, or versioned snapshots) and the impact on performance.

5. Outline Testing Strategy

Describe stress tests with many threads, using tools like ThreadSanitizer, Jepsen-style linearizability checks, and model checking (e.g., TLA+). Include deterministic simulation and fault injection.

Key Points to Mention

  • Fine-grained locking (per-document, per-tag) vs coarse-grained (global) and when to use each.
  • Lock ordering to prevent deadlocks, and alternatives like optimistic concurrency or lock-free structures.
  • Consistency models: linearizability, serializability, and how they affect design (e.g., MVCC for snapshot isolation).
  • Read-write locks or reader-writer locks to allow concurrent reads while writes are exclusive.
  • Testing concurrency: stress tests, race detectors, linearizability checkers, and formal methods.
  • Performance trade-offs: contention, scalability, and adapting granularity based on workload.

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