Design a near-real-time pipeline that consumes clickstream events from Kafka, processes them with Spark Structured Streaming, and serves both live dashboards and SQL tables for batch reconciliation.
Functional requirements
- Consume partitioned topics from a message queue
- Spark streaming jobs with windowed aggregations
- Write to a serving layer (SQL tables + cache) for dashboards
- Checkpointing for exactly-once or at-least-once recovery
Non-functional requirements
- End-to-end latency under 30 seconds for key metrics
- Handle consumer lag spikes without data loss