Katkat

Design document-tag classes with concurrency safety

AmazonSoftware Engineer · Onsite

Last updated

Design document-tag classes with concurrency safety evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

Design classes to manage documents and tags. Support operations: create/delete document; create/delete tag; add/remove a tag on a document; list all documents for a given tag; list all tags for a given document; and query documents by the intersection of multiple tags. Specify class interfaces, core data structures and indices, handling of duplicates/normalization (e.g., case sensitivity), and complexity of key operations. Then extend the design to be thread-safe under concurrent reads/writes: discuss concurrency control (locking granularity, immutable data, copy-on-write, or concurrent maps), consistency guarantees, deadlock avoidance, and approaches to testing concurrency correctness.