Trust, but verify: how we at KION are moving along the path of product events

Aleksey Zhiryakov26 Nov 2024

Problem

The KION online cinema receives more than 400 million product events per day (over 6,000 RPS at peak) from 8+ product verticals. Product managers build metrics and A/B tests on them, so one bad field, such as a negative viewing time, can distort a metric and the decision based on it. Third-party event systems capped volume, delayed historical reloads and gave no real-time stream for the web. A new app release could also change a field type or silently stop sending a field, and this was found only after release.

Example from the article: for a TV-viewing event the team checks that viewing time is positive and that the event name and user profile are present.

Solution in brief

KION built its own event receiver: an HTTP service puts raw events into Kafka, consumers parse, validate and enrich them, and ClickHouse stores the result. Data quality is checked in two layers: strict schema validation (Pydantic), and monitoring with deduplicated alerts and release smoke tests.

Questions this case answers
  • How to validate a high-volume stream of client-generated events against per-type schemas and business rules before the data is used for analytics and experiments
  • How to detect a broken event contract in a new client release before it ships, using the same ingestion path as production
  • How to stop wrong or missing product event fields from reaching analysts and corrupting A/B test metrics?
  • How to validate hundreds of event types at hundreds of millions of events per day without burning CPU?

Tools and methods

  • Kafka — raw and parsed event topics.
  • ClickHouse — temporary raw store, permanent parsed store.
  • FastAPI, Pydantic 2 — receiver service and per-event schema validation.
  • Redis with an in-memory cache — one Telegram alert per unique error per day.
  • Airflow — logical-level checks of data arrival and deviations.
Continue reading — it's free

Google or a one-time email code. No password.