Dream11 Senior SWE HLD interview experience
Company: Dream11
Role: Senior SWE
Interview Stage: Onsite
Location: unknown
Year: unknown
Original Post Content:
Just wrapped up a fascinating system design interview! The problem was to design a Data Doc System – essentially a comprehensive telemetry and monitoring platform for applications. It touched upon many core distributed systems concepts, and I thought I'd share my approach and the areas we covered.
The Problem Statement:
Design a system to:
- Ingest events from applications (API response time, CPU usage, memory usage).
- Set up alerts based on these events.
- Provide tracing (request -> response) to identify stack trace breakages.
- Define custom metrics (e.g., cpu% as a computation over existing base metrics).
My Approach & Discussion Flow:
1. Requirements Clarification & Scope
This is always step one. I made sure to ask about:
- Functional Requirements: Confirmed event ingestion, alerting, tracing, and custom metrics as core features.
- Non-Functional Requirements: Discussed scalability (estimated ~1 million events/sec ingestion, ~86 TB/day, ~155 PB over 5 years!), low latency for recent data/alerts, high availability (99.99%), and durability.
- Clarifying Questions: Asked about raw vs. aggregated data retention, existing visualization tool integrations, and metric granularity.
2. High-Level Design (HLD)
I proposed a component-based architecture, drawing a text-based diagram (though in a real interview, I'd whiteboard this). Key components:
- Telemetry Agent/SDK: Collects data at the source.
- Load Balancers: Distributes incoming traffic.
- Ingestion Servers: Stateless entry point for raw data.
- Message Queue (Kafka): Critical for buffering, decoupling, and durability.
- Processing Workers: For aggregation, transformation, and custom metric computation.
- Time-Series Database (TSDB - e.g., Cassandra): Stores events and metrics.
- Trace Storage (e.g., Elasticsearch/Jaeger): Dedicated for distributed traces.
- Metadata DB (PostgreSQL): Stores configurations like alert rules and custom metric definitions.
- Alerting Service: Evaluates rules.
- Notification Service: Sends alerts.
- Query Service: For data retrieval by UI/Dashboards.
3. Deep Dive Areas
We picked a couple of key areas to drill down:
A. Time-Series Database (TSDB) & Data Model:
- Choice: Opted for Apache Cassandra due to its excellent horizontal scalability, high write throughput, and tunable consistency, perfect for massive time-series data.
- Schema Design: Discussed tables for raw_events and aggregated_metrics with application_id + host_id as partition keys for locality and timestamp as clustering key.
- Consistency Tuning: A big topic! Explained using W=QUORUM for aggregated metric writes and R=QUORUM for critical alert reads, balancing consistency with availability. For raw event ingestion or dashboard reads, lower consistency (W=ONE, R=ONE) is acceptable to maximize throughput/latency.
- Tiering (Hot vs. Cold): Explained distinguishing data by age (time-based partitioning) and using automated archival jobs to move older, less frequently accessed data from Cassandra (hot) to cheaper object storage like S3 Glacier (cold) for cost optimization. This ensures performance for recent data while meeting long-term retention needs.
B. Alerting System & Custom Metrics:
- Custom Metrics: Processing Workers dynamically load definitions from Metadata DB to compute new metrics (e.g., cpu% = (used/total)*100) from raw input.
- Alert Rule Evaluation:Periodicity: The Alerting Service runs periodic evaluations (e.g., every 15-60 seconds) by fetching rules from the Metadata DB and querying the TSDB for metrics.State Management: For sustained alerts (e.g., "CPU > 90% for 5 minutes"), I emphasized that the Alerting Service instances are locally stateless but use externalized, highly available state stored in a Redis Cluster. This ensures that if an Alerting Service node fails, another healthy node can pick up the evaluation from the last known state, maintaining the duration_minutes count without interruption.Flow: Rule read -> TSDB query (R=QUORUM) -> Evaluate condition -> Update state in Redis -> If triggered/resolved, publish to Kafka (alert_notifications topic) -> Notification Service dispatches.
4. Scalability, Availability & Trade-offs
- Scalability: Highlighted horizontal scaling at every layer (stateless servers, Kafka partitions, Cassandra nodes, more worker instances).
- Availability: Discussed redundancy, master-slave replication, cross-DC deployment, and Kafka's durability.
- Trade-offs: Reiterated the critical balance between Consistency vs. Latency/Availability, and the added complexity of a Message Queue for robustness.
5. Further Considerations
Briefly touched on Security (encryption, auth), Monitoring the system itself, and Data Archiving.
Follow-up Questions that came up:
- "Where is the trace_id generated?" (Answer: At the initiator – client app or edge service)
- "How would this system scale if requests increased by 100x?" (Answer: Aggressive batching, more partitions, larger clusters for all databases, specialized hardware/managed services, more granular tiering, and potentially sampling for traces).
Overall, it was a very comprehensive discussion. The interviewer really dug into the "why" behind the choices and the nuances of distributed state management. Hope this helps anyone preparing for similar interviews!