Skip to content
tezvyn:
Menu

Clickstream architecture for real-time and batch

Source: interviewMediumHow cards are made

Summary

designing a dual-path streaming pipeline.

Key points

ingest events into a log like Kafka, fan out to a real-time path for dashboards and a batch path to a lake for ad-hoc analysis.

Watch out for

a single path that can't serve both latency profiles.

What's really being asked

This evaluates whether you can architect a system that simultaneously serves low-latency dashboards and flexible historical analysis, which have conflicting requirements.

The full answer

Start with ingestion: a lightweight collector or SDK on the client sends events to an ingestion endpoint that writes them into a durable, partitioned log such as Apache Kafka or Amazon Kinesis. This decouples producers from consumers and buffers spikes. From the log you fan out into two paths.

The real-time path uses a stream processor like Flink, Spark Structured Streaming, or Kinesis Data Analytics to compute rolling aggregates, sessionization, and metrics, writing results into a low-latency store such as Redis, OpenSearch, or a time-series database that powers live dashboards within seconds.

The batch or analytics path sinks the raw events into a data lake on object storage like S3, partitioned by time, often in a columnar format such as Parquet. Data scientists run ad-hoc, schema-on-read queries with engines like Athena, Presto, or Spark, and can reprocess history. This dual-path design is the lambda architecture; a kappa variant serves both from the stream alone.

Why two paths

Dashboards need seconds of latency on aggregates; data science needs full-fidelity raw history and flexible queries. No single store optimizes both, so you split responsibilities while sharing one ingestion log.

What usually comes next

Lambda versus kappa. How do you handle late or out-of-order events. How do you avoid the small-files problem in the lake. How do you guarantee no event loss.

A concrete example

A news app sends page-view events to Kinesis. A Flink job updates a per-article view counter in Redis driving a live editor dashboard, while a Firehose delivery stream writes the same raw events as Parquet to S3, where analysts later query reading patterns by region with Athena.

Interview question

Why does a clickstream system typically fan out from one ingestion log into separate real-time and batch paths?

  • a.To duplicate data for backup in case the log is lost
  • b.To avoid using object storage, which cannot hold event data
  • c.Because low-latency dashboards and full-history ad-hoc analysis have conflicting storage needsCorrect
  • d.Because a single stream processor cannot read from Kafka
Why?

Live dashboards need second-level latency on aggregates while data scientists need flexible queries over raw history; no single store serves both well, so the pipeline splits paths after a shared log.

Just read this? Test yourself on what you have been reading.

Read the original → docs.aws.amazon.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles