Problem
A marketplace needs one place that decides, per request, which experiments a user is in. At Ozon this started as an Excel sheet for the analytics lead plus per-service configs, so some experiments ran unnoticed, interfered with others, and needed a deploy to start or stop. A central service fixes this but adds a lookup to every request. Its answer must also reach every backend without exceeding header limits or overloading the platform.
Example from the article: once all experiments were written into one request header, it passed 4 KB, hit the Nginx limit, and staging returned an error on every request.
Solution in brief
Keep one service (ab-test-api) that holds all experiments in memory and computes each experiment's group from a hash of the user ID plus a per-experiment salt. Call it once per request at the gateway and pass the result down in a header as a compact binary key. Backends use that key as a cache key, so repeat lookups cost almost nothing.
Questions this case answers
- How to serve per-user experiment assignments to many microservices at high request rates while keeping assignments uniform across concurrent experiments
- How to carry experiment context across a call chain when header size and extra lookups limit the obvious design
- How to build a user-splitting service that serves experiment assignments at high RPS without slowing every backend call?
- How to pass the list of active experiments through a chain of microservices without breaking header limits?
Tools and methods
- A/B test — the experiments served, including a speed-degradation test
- Hash bucketing with salt —
hash(userID + salt) % 100gives each experiment its own split - etcd — key-value store that ab-test-api subscribes to
- Nginx — its 4 KB header limit forced the compact key
- Prometheus — response-time buckets in the load-test tool
Google or a one-time email code. No password.
