Creating multi-armed bandits
Creating multi-armed bandits
Creating multi-armed bandits
This topic explains how to set up and configure a multi-armed bandit (MAB) in LaunchDarkly.
Configuring a MAB requires several steps:
These steps are explained in detail below.
Before you build a MAB, you should read about and understand the following concepts:
Before you begin a MAB, create a flag or AgentControl config with the variations you plan to optimize the performance of. You do not need to toggle on the flag before you create the MAB, but you do have to toggle flags on before you start an iteration. AgentControl configs are on by default.
To learn more, read Creating new flags, Creating flag variations, Create configs, and Create and manage config variations.
You cannot run a MAB on a flag if:
You can build and run multiple MABs on the same flag or AgentControl config as long as there is only one running MAB per targeting rule. You cannot run multiple MABs on the same rule at the same time.
Metrics measure audience behaviors affected by your flags. You can use metrics to track all kinds of things, from how often end users access a URL to how long that URL takes to load a page. You can reuse existing metrics in multiple MABs, or create new ones for your MABs.
To learn how to create your own new metric, read Metrics. LaunchDarkly also automatically creates metrics for AgentControl configs. To learn more, read AgentControl config autogenerated metrics.
Multi-armed bandits support metrics using the “Average” metric analysis method. You cannot use metrics using a percentile analysis method with a multi-armed bandit.
If you want to learn which variation performs better, it must be possible for that metric to measure something in all of the variations within the MAB. To learn more, read Metrics and flag variations.
You can view all of the MABs in your environment on the Multi-armed bandits list.
To build a MAB:

A layer is a set of experiments and MABs that cannot share traffic with each other. All of the experiments and MABs within a layer are mutually exclusive, which means that if a context is included in one, LaunchDarkly will exclude it from any other experiments and MABs in the same layer.
To add the MAB to an existing layer:
If you need to create a new layer:
Multi-armed bandits can either be in a holdout or in a layer, but not both. If you added the multi-armed bandit to a layer, you will not see the option to add it to a holdout.
If needed, you can save your in-progress MAB design to finish later. To save your design, click Save at the top of the creation screen. Your in-progress MAB design is saved and appears on the Multi-armed bandits list. To finish building the MAB, click on the MAB’s name and continue editing.
After you have created your MAB, the next step is to toggle on the flag. AgentControl configs are on by default. Then, you can start an iteration.
You can also use the REST API: Create experiment
For a MAB to begin recording data, the flag or AgentControl config used in the MAB must be on. Targeting rules for AgentControl configs are on by default. To learn how to turn targeting rules on for flags, read Turning flags on and off.
After you create a MAB and toggle on the flag, you can start a MAB iteration in one or more environments. AgentControl configs are on by default.
To start a MAB iteration:


You can run a MAB indefinitely, allowing it to reallocate traffic as needed. If you are running a MAB on a time-boxed feature, such as a holiday promotion, then you can stop the MAB iteration when the promotion is over.
When you start an iteration of a MAB, LaunchDarkly sends the maintainer and anyone following the MAB an email, an in-app notification, and, if you have the Slack app integration configured, a Slack notification.
To learn more about starting and stopping iterations, read Starting and stopping experiment iterations.
You can also use the REST API: Create iteration