KatInterview

Selecting a Database for High-Volume Activity Tracking

System DesignModel answer
MediumModel answerSystem Designdatabasesscalabilitydata-modeling

Last updated

Evaluate NoSQL versus relational storage for a log ingestion system with extreme write throughput and petabyte-scale growth.

Context

You're building a backend service that tracks user activity events for a SaaS platform. The system needs to store every action users take and provide quick access to recent history.

Requirements

Your service must support:

  • Write throughput: 50,000 events per second at peak load
  • Query patterns:
    • Retrieve the most recent 50 events for any given user
    • Count how many events a user generated within a date range
  • Scale: Data volume will reach multiple petabytes within three years
  • Reliability: Writes must be durable—no accepted events can be lost
  • Performance: Response times should remain predictable as data grows
  • Cost: Budget matters, but availability and latency are top priorities

Your Task

You're evaluating two options: a managed NoSQL key-value store (like DynamoDB) versus a managed relational database (like RDS MySQL).

For each option:

  1. Design the schema — Show how you'd structure the data
  2. Analyze trade-offs — Discuss scalability, consistency guarantees, and operational complexity for this specific workload
  3. Make a recommendation — Choose one approach and defend your decision with specific reasoning

Questions to Address

  • How would each system handle retrieving the top N records efficiently?
  • What happens to write performance under high concurrency in each architecture?
  • How does query performance change as tables grow past 100 TB?
  • What operational burden does each choice create?

Hints

Hint 1

Start by calculating storage volume from write rate and record size—this drives architectural constraints

Hint 2

Consider whether the query patterns require relational features like joins or transactions across multiple entities

Hint 3

Think about how each system partitions data and what that means for hot spots when one user generates far more events than others