Skip to content
Lubo Bali
All projects

Data pipelinesWeb · Marketing

Real-time web sessions (Flink)

Live website clicks grouped into visits as they happen, with each visitor's location added

5 minof quiet ends a visit

See the code on GitHub (opens in a new tab)

Proof you can check:Code on GitHub

Data pipelines

Clicks become visits, live

3 sessions from one visitor: a new session starts after 5 min of quiet.

Lubo Bali · lubobali.com

No. 22Illustration of the session rule

The problem

Raw clickstream data doesn't say what a visit is. Without sessions, questions like "how long do people stay" can't be answered while the data is still fresh.

What I built

A Flink job that reads web events from Kafka, adds the visitor's location from their IP, groups events into sessions that end after 5 minutes of quiet, and writes the result to PostgreSQL and back to Kafka.

Tech & why

Flink works on event time with a watermark, so late or out-of-order clicks still land in the right session.

  • Apache Flink
  • Kafka
  • PostgreSQL
  • Python

The result

Live sessions per visitor and website, ready for clickstream analytics like average events per visit, while the data is still minutes old.

Similar projects

Have a problem like this? Get your free AI blueprint in about a minute.

Tell me your problem. I'll find a way to build the solution.

Available now

Book a free 30-min call (opens Calendly in a new tab)

No obligation. Pick a time that suits you.

Prefer email?data@lubobali.com