The situation
On a marketplace, sellers update their prices all the time. Sometimes a price is wrong, a missing digit for example, and the item can sell far below its real price before anyone notices.
The goal was to catch price errors as soon as they happen.
How it works
The solution is a streaming pipeline built with Apache Beam and running on Google Dataflow. It does the same checks as the batch job, but on each price update as it arrives.
It has three parts:
- The core pipeline: reads the live price updates and the sold units from Kafka, through a CDC pipeline, compares each price with its reference threshold, filters out the false positives, and sends the errors to BigQuery and Slack.
- The cache pipeline: reads the CDC topics of blocked items, products and sellers, and keeps their current state in Redis.
- Redis: the cache that the core pipeline reads from.
The thresholds and the data used to filter false positives (like whitelisted prices, running campaigns, etc.) live in BigQuery. Querying BigQuery for every price update would be expensive, since it’s built for analytics, not for lookups. So every time one of these tables is updated, a scheduled task exports it to Redis, and the pipeline only reads from Redis.
The result
A wrong price is flagged as soon as the update arrives, day and night. The errors was also published to a topic, so other teams can use them, and the same setup can be reused for other real-time checks.