Introduction

This solution

Tesfy provides a simple and free but complete solution to develop A/B Tests and Feature Flags on both Server and Client Side without relying in any storage layer while providing the best possible performance.

How does it work ?

The tesfy Engine allocates users in a given experiment or feature depending on the configuration that is set. This is a deterministic process, which means that if the configuration is the same, the allocation will always be the same. To ensure a correct distribution a hash function is used.

Hash function

A hash function is any function that can be used to map data of arbitrary size to fixed size values. The values returned by a hash function are usually called hashes.

In this case the Engine takes a userId (e.g. 4qz936x2-62ex) and a experiment or feature key (e.g. experiment-1) defined in the configuration to build a enhanced key that will be the concatenation of both of them. From this new key a hash is created by using a hash function.

Hashing process

Bucketing

Currently the hash function used is MurmurHash (this will be able to be configured in the future). MurmurHash is a non-cryptographic hash function suitable for general hash-based lookup.

The following code shows how a bucket is created from a hash value.

const enhancedKey = '4qz936x2-62ex-experiment-1';
const hash = murmurhashv3(enhancedKey, 1);
const ratio = hash / MAX_VALUE; // value between 0 a 1
const bucket = parseInt(hashRatio * TOTAL_BUCKETS, 10) // value between 0 a 10000

Once the bucket is created. It will be compared with the bucketing ranges generated by the allocation defined in the configuration. If the bucket is within one of the ranges, the proper variation will be assigned and if not it will be treated as excluded.

Flow

To determine which variation is assigned to an experiment the following flow is executed.

Flow
  • Forced variation assignments are checked. Forcing variations could be useful for cases like testing or whitelisting.
  • Sticky bucketing querying the storage layer is checked.
  • Audience evaluation, if the audience does not match, no variation will be assigned.
  • Bucketing.
  • Sticky bucketing persisting the variation in the storage layer.

A reduced flow is executed in the case of features. The storage steps will be skipped since this only applies to experiments.