# Defining workloads

For a live optimization study, it is required to specify which component metrics represent the different workloads observed on the target system. A workload could be represented by either a metric directly measuring that workload, such as the application throughput, or a proxy metric, such as the percentage of reads and writes in your database.

The [Workload selection](https://docs.akamas.io/akamas-docs/3.1.2/akamas-reference/construct-templates/study-template/workload-selection) page of the [Study template](https://docs.akamas.io/akamas-docs/3.1.2/akamas-reference/construct-templates/study-template) section in the reference guide describes how to define the corresponding structure.

Akamas features automatic detection of workload contexts, corresponding to different patterns for the same workload. For example, workload context could correspond to the peak or idle load, or to the weekend or weekday traffic. This allows Akamas to recommend safe configurations based on the observed behavior of the system under similar workload conditions.

Akamas provides several parameters governing how the Akamas optimizer operates and leverages the workload information while a live optimization study is being executed. The most important parameter is the **online mode** (see [here below](#online-mode)) as it related to whether the human user is part of the approval loop when the Akamas AI recommends a configuration to be applied.

Moreover, Akamas also provides customizable safety policies that drive the Akamas optimizer in evaluating candidate configurations with respect to defined goal constraints.

### Online mode

Live optimizations can operate in one of the following online modes:

* **recommendation (or manual) mode** (the default mode): Akamas does not immediately apply a configuration identified by Akamas AI: a new configuration is first recommended to the user, who needs to approve it, possibly after modifying it, before it gets applied - this is also referred to as **human-in-the loop** scenario;
* **fully autonomous (or automatic) mode**: new configurations are immediately applied by Akamas as soon as they are generated by the Akamas AI, without being first recommended to (and approved by) the user.

It is worth noticing that under a recommendation mode, there might be a significant delay between the time a configuration is identified by Akamas and the time the recommended changes get applied. Therefore, the Akamas AI leverages the workload information differently when looking for a new configuration, depending on the defined online mode:

* in the **recommendation mode**, Akamas takes into account all the defined workloads and looks for the configuration that best satisfies the goal constraints for all the observed workloads and provides the best improvements for all of them
* in the **fully autonomous mode**, Akamas works on a single workload at each iteration (based on a customizable **workload strategy** - see below) and looks for an optimized configuration for that specific workload to be immediately applied in the next iteration, even if it might not be the best for the different workloads

The online mode can be specified at the study level and can also be overridden at the step level (only for steps of type "optimize" - see section [Defining optimization steps](https://docs.akamas.io/akamas-docs/3.1.2/using-akamas/preparing-optimization-studies/creating-optimization-studies/defining-optimization-steps)). The [Optimize step](https://docs.akamas.io/akamas-docs/3.1.2/akamas-reference/construct-templates/study-template/steps/optimize-step) page of the [Study template](https://docs.akamas.io/akamas-docs/3.1.2/akamas-reference/construct-templates/study-template) section in the reference guide describes how to define the corresponding structure. This can be done either from the Akamas command line (see page [Optimizer option commands](https://docs.akamas.io/akamas-docs/3.1.2/akamas-reference/cli-reference/optimizer-options-commands)) or from the Akamas AI (see the following figure).

<figure><img src="https://2641073690-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4ubiK4vpNilxkD7Fauar%2Fuploads%2FlO4F55B1LTtdfI4yPdlv%2FScreenshot%202023-01-24%20at%2011.55.07.png?alt=media&#x26;token=a595976b-f471-4bd3-872b-33c3f1acc990" alt=""><figcaption><p>Changing from automatic to manual mode</p></figcaption></figure>

Notice that the online mode can be changed at any time, that is while the optimization study is running, to become immediately effective. For example, a live optimization could initially operate in recommendation mode and then be changed to fully autonomous mode afterward.
