HomeInterview QuestionsHow would you design a real‑time data pipeline tha…

How would you design a real‑time data pipeline that ingests information from millions of users into a data warehouse using Kafka and a fan‑out architecture?

🔴 Hard System Design Senior level
1Times asked
Jun 2026Last seen
Jun 2026First seen

💡 Model Answer

A scalable pipeline starts with a lightweight client SDK or API gateway that publishes user events (clicks, page views, transactions) to a Kafka cluster. Use a topic per event type and partition by user ID to preserve ordering. Enable replication (3 replicas) and enable log compaction for idempotent events.

Next, run a stream processor (Kafka Streams, Flink, or Spark Structured Streaming) to enrich events: enrich with user profile, geo‑location, and session data, and perform transformations (e.g., aggregations, anomaly detection). The enriched stream is written to a second Kafka topic.

For the data warehouse, use Kafka Connect with a sink connector (e.g., Snowflake, BigQuery, Redshift) that consumes the enriched topic. Configure schema registry to enforce Avro/JSON schema and use CDC‑style offsets to guarantee exactly‑once delivery. Partition the sink tables by date and user ID for efficient querying.

Monitoring: use Prometheus/Grafana for Kafka metrics, and set up alerting for lag, under‑replicated partitions, and connector failures. Scale the cluster by adding brokers and increasing partitions. Use a load balancer and auto‑scaling for producers.

Complexity: Ingestion is O(1) per event; stream processing is O(n) per batch; sink connector writes are O(n). The overall system is horizontally scalable and fault‑tolerant.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.

Get Assisting AI — Starts at ₹500