← Amazon Interview Insights

Amazon·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Amazon ML engineer screen, one meaty streaming design problem that took up the whole session. The question had a lot of moving parts and I kept second-guessing my state management approach the whole time.

Questions Asked (1)

Q1

Design a streaming system that detects 'abusive' book reads from a live event stream. An event is abusive if a user reaches the last 5% of a book before ever completing the first 10%. A book itself is flagged abusive if more than 20% of its total events are abusive. Walk through your data structures, state management, and any concurrency concerns.

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

This one took me a while to even parse correctly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the event schema and defining the exact conditions for an abusive read. Then propose a streaming architecture with per-user and per-book state, using windowed aggregations and scalable storage. Finally, discuss concurrency control and trade-offs between accuracy and latency.

Pro tip: Emphasize that the 20% threshold requires a global view per book, so you need to aggregate across all users; consider using a distributed counter with eventual consistency and periodic recomputation to avoid hot keys.

1. Clarify Requirements and Assumptions

Ask about event schema (e.g., user_id, book_id, position, timestamp), definition of 'completing' a section, and whether events are ordered. Confirm that 'abusive' is per user per book and that book flagging is based on total events.

2. Design Per-User State for Abuse Detection

For each (user, book) pair, track whether the user has completed the first 10% and whether they reached the last 5% before that. Use a compact state like a bitmask or two booleans, stored in a key-value store (e.g., Redis) with TTL.

3. Aggregate Book-Level Metrics

Maintain per-book counters: total events and abusive events. When a user's state transitions to abusive, increment the abusive counter for that book. Use a distributed counter (e.g., Redis INCR) and compute the ratio periodically.

4. Handle Concurrency and Scalability

Use partitioning by user_id for per-user state to avoid contention. For book counters, use sharded counters or a stream processing framework (e.g., Kafka Streams, Flink) with windowed aggregations. Discuss exactly-once semantics and idempotency.

5. Discuss Trade-offs and Extensions

Compare latency vs accuracy: real-time flagging may be noisy; batch recomputation can correct. Mention handling late events, out-of-order data, and scaling to millions of users/books.

Key Points to Mention

  • Event schema and ordering assumptions
  • Per-user state representation (e.g., bitmask) and storage (Redis)
  • Distributed counters for book-level aggregation
  • Concurrency control: partitioning, sharding, idempotent updates
  • Trade-offs: real-time vs batch, accuracy vs latency
  • Handling late/out-of-order events and exactly-once processing

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