You're tasked with designing a distributed data processing system using Apache Spark and Apache Kafka. The system needs to process 10 million events per second and write the results to a data warehouse. How would you design the system and what technologies would you use?
💡 Model Answer
To handle 10 M events/second, I would build a horizontally scalable pipeline. First, Kafka would serve as the ingestion layer: a cluster with many brokers, each with 8–12 partitions per topic, and a replication factor of 3 to ensure durability. Producers would use compression (e.g., Snappy or LZ4) and batch size tuned to ~1 MB to reduce network overhead. A Spark Structured Streaming cluster would consume the Kafka stream. I’d use a large number of executors (e.g., 200+), each with 8–16 cores and 32–64 GB RAM, and enable shuffle service for efficient data shuffling. Spark would perform stateful aggregations or windowed joins, using Kryo serialization and Tungsten execution for speed. For fault tolerance, checkpoints would be stored in HDFS or S3. The output would be written to a columnar data warehouse such as Snowflake, BigQuery, or a Delta Lake on S3/HDFS, using micro‑batch writes (e.g., every 5 seconds) to keep latency low. I’d also integrate a schema registry (Confluent Schema Registry) to enforce data contracts, and use Kafka Connect for source/sink connectors. Monitoring would be handled by Prometheus/Grafana for cluster metrics, and alerting for lag or backpressure. This architecture scales linearly with added brokers and executors, and the use of columnar storage keeps query performance high in the warehouse.
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 on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500