# How I Built Klarna's Experimentation System, and a LISP

- Speaker: [Dotan Nahum](/wiki/speakers/dotan-nahum.md)
- Event: [Reversim Summit 2018](/wiki/years/2018.md)
- Video: https://www.youtube.com/watch?v=DtsaKDSbVoc
- Transcript: [/transcripts/2018/35-DtsaKDSbVoc.md](/transcripts/2018/35-DtsaKDSbVoc.md)
- Language: English · Type: talk · Level: advanced
- Topics: [Performance](/wiki/topics/performance.md), [Product Management](/wiki/topics/product-management.md), [Architecture](/wiki/topics/architecture.md), [Distributed Systems](/wiki/topics/distributed-systems.md)

> Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.

## Summary

The speaker shares their experience of building a robust A/B testing and experimentation system from scratch at a major fintech company. They discuss the architectural challenges of avoiding single points of failure, scaling across numerous programming languages, and maintaining ultra-low latency under heavy traffic. To solve these problems, the speaker details a distributed, client-side approach utilizing persistent hashing and a custom hierarchical data model resembling a compiler. Ultimately, the audience learns how to design high-performance internal infrastructure by treating system configuration as a compiled language.

## Key points

- [4:15](https://www.youtube.com/watch?v=DtsaKDSbVoc&t=255s) The speaker introduces the core mechanics of an experimentation system and points out the lack of reference material on how to build one.
- [5:15](https://www.youtube.com/watch?v=DtsaKDSbVoc&t=315s) A naive centralized service creates a massive single point of failure and database bloat as traffic multiplies.
- [7:17](https://www.youtube.com/watch?v=DtsaKDSbVoc&t=437s) The constraints in a financial company require supporting multiple programming environments while guaranteeing sub-millisecond latency.
- [9:23](https://www.youtube.com/watch?v=DtsaKDSbVoc&t=563s) The solution is to build the experimentation system as a client-side library or distributed local service rather than a central database-backed API.
- [12:26](https://www.youtube.com/watch?v=DtsaKDSbVoc&t=746s) Persistent hashing allows the system to determine user experiment buckets deterministically without storing user states in a database.
- [15:30](https://www.youtube.com/watch?v=DtsaKDSbVoc&t=930s) Audience segmentation is handled by a custom, safe restricted language called HyperMatch that prevents infinite loops.
- [17:33](https://www.youtube.com/watch?v=DtsaKDSbVoc&t=1053s) A hierarchical data model containing groups, layers, experiments, and variates allows safe parallel execution of multiple experiments.
- [20:35](https://www.youtube.com/watch?v=DtsaKDSbVoc&t=1235s) Unlike typical software development, experimentation systems require early optimization and absolute resilience from day one to ensure data integrity.

## Takeaways

- Avoid central database dependencies for high-frequency infrastructure by using persistent hashing to compute state on the fly.
- Treat complex hierarchical configurations as a formal language and compile them into an in-memory AST for maximum performance.
- Recognize that experimentation infrastructure cannot rely on a standard MVP approach and must guarantee data integrity and resilience from day one.

## Questions this talk answers

- How do you run A/B testing across multiple different programming languages without maintaining separate SDK logic for each one?
- How can an experimentation platform achieve sub-millisecond latency without relying on a centralized database for user state?
- What is the best way to structure experiment configurations to prevent conflicting overlapping experiments?

## Technologies

JavaScript, Node.js, V8, Python, Java, Scala, Erlang, Haskell, Ruby, React Native, AWS S3

## Tags

a/b testing, architecture, compilers, distributed systems, microservices, performance
