Problem
Klarna's decision engine approves or rejects credit on every order, using a policy and a statistical credit model fed by features from a streaming pipeline. Stakeholders often ask to change, add or remove features. The streaming pipeline keeps only the latest state of each order, so past states cannot be read back. Rebuilding them means reprocessing all historical events, which is slow and expensive. Without past values, a new model can be trained only on data from the new feature version, so the team has to wait until that data matures.
Example from the article: count how many fully paid orders each customer had one year ago, as of the moment of a past decision.
Solution in brief
Rerun the same event aggregation logic in a batch Spark job, but cut the events off at each historical decision time. Split the job into several stages that shrink the data early, so the heavy Python aggregation runs on gigabytes rather than terabytes.
Questions this case answers
- How to reconstruct feature values as of each historical decision time when the production pipeline stores only the latest state and the feature definition has changed
- How to run a heavy Python aggregation over terabytes of event data in Spark without shuffling and Python worker memory becoming the bottleneck
- How to recompute a changed feature as it would have looked at every past decision without reprocessing all raw events each time?
- How to train a credit model on history when the feature logic has changed and the live pipeline keeps only the latest state?
Tools and methods
- Point-in-Time flow — batch recomputation of features for every past decision from raw events
- Apache Spark (PySpark) on AWS Glue — batch engine, run on demand instead of a permanently running EMR cluster
- States dataset (projections) — per-order state built from events up to the decision time
- Amazon S3, AVRO — storage of raw events, historical decisions and results
Google or a one-time email code. No password.