> OctoPerf load testing - Policies documentation page. How to configure the policies of a User profile.

Source: https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/options/policies/

# Policies

![Policies](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/img/policies.png "Policies")

Several options are available by clicking on the _Advanced Configuration_ button:  

## Error handling

The error policy defines what to do when an error occurs (i.e. an assertion failed):

* Continue: the error is ignored and the test goes on.
* Start next VU Iteration: the current Virtual User iteration is stopped and a new one is started.
* Stop VU: The current Virtual User execution is completely stopped.
* Stop Test: The load generator where the error is encountered is stopped.
* Stop Test Now: The load generator where the error is encountered is stopped without waiting for threads to end.

## End

![Iterations](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/img/iterations.png "Iterations")

The iterations field lets you **limit the Virtual Users execution to a number of iterations**.

You still need to set up a duration for the User Profile, so make sure that the execution of all iterations wil not take more time than the specified duration. 

## Think time

By default, the Think Time policy is **As recorded**: each HTTP request of the Virtual User uses its own [think time](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/http-actions/#think-time), and each [Delay action](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/logic-actions/delay-action/) its own duration.

Select **Overridden** to replace the think time of every HTTP request of the Virtual User for this user profile, without changing the Virtual User itself. Delay actions and [pacing](#pacing) keep their own values. For example, with a think time overridden to a constant 2 seconds:

| Step of the Virtual User | As recorded | Overridden (2 s) |
|---|---|---|
| HTTP request | its own think time | **2 s instead** |
| Delay action | its duration | its duration |
| Pacing | its duration | its duration |
| [Set Up and Tear Down](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/options/setup-teardown/#think-times) | the think times of their own Virtual User | the think times of their own Virtual User |
| Other actions (JSR223 scripts, WebSocket, imported JMeter actions...) | no pause | no pause |

The override only changes the value of the pauses, never where they are: it adds no pause where there was none, and it never lengthens the pacing.

!!! note
    The user profiles of Playwright and Selenium Virtual Users have no Think Time policy. A Playwright test pauses where its spec says so, or with the **Think Time** of the **Playwright** panel of the user profile, which slows down every action. A Selenium action has no think time. An override saved on such a profile before version 18.0.0 no longer has any effect, Throughput included.

When overridden, the think time is set to a constant of 1 second by default. You can then choose between 4 modes:

* **Constant**: All think times have the same value.

![Think Time Constant](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/img/think-time-constant.png "Think Time Constant")

* **Range**: Think times vary between a lower bound and an upper bound.

![Think Time Range](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/img/think-time-range.png "Think Time Range")

* **Text**: All think times have the same value defined in milliseconds but the value can be passed through a variable like `${thinktime}`:

![Think Time Text](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/img/think-time-text.png "Think Time Text")

* **Throughput**: think times adapt to reach a hit rate, see [Throughput](#throughput) below.

### Throughput

*Throughput* is another option for think time. When selected the think times will be adapted on the fly to try to **match the requested hit rate for each virtual user running**.

Typically with 10 hits per second and 100 users, you can expect a total of 1000 hits per seconds, **provided your application can answer fast enough** (in less than 1/10th of a second in that example):

![Think Time Hits](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/img/think-time-hits.png "Think Time Hits")

With a throughput, the throughput decides when each step of the Virtual User starts, [Delay actions](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/logic-actions/delay-action/) included. A Delay action still waits its full duration before the next step, and it counts as one step of the rate. To get an exact number of HTTP requests per minute, disable the Delay actions of the Virtual User. To set a number of iterations per minute, use a [pacing](#pacing) instead.

Activating this option will automatically disable [pacing](#pacing) since it is another way to achieve a similar goal.

!!! warning
    This option is incompatible with the [follow redirects](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/http-actions/#settings) and [Download resources](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/http-actions/#download-resources) options because both can generate an **unpredictable amount of hits per request**.
    You can deactivate *Download resources* from the [Device tab](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/options/device/#download-resources).

## Pacing

Iteration *pacing* is another way to achieve a controlled injection rate for your tests. The way it works is as a **minimum delay for each iteration**.

For example if the virtual user iteration is finished in less than 55 seconds, this pacing will **wait until 55 to 60 seconds elapsed** before running another iteration:

![Pacing](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/img/pacing.png "Pacing")

This way **instead of controlling hits for all requests, you control the number of iterations you will execute over a period of time**.

Activating this option will automatically disable [Throughput](#throughput) since it is another way to achieve a similar goal.

!!! note
    A fixed value can be used by providing the same number in *From* and *To*.
    This option is incompatible with the [follow redirects](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/http-actions/#settings) and [Download resources](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/http-actions/#download-resources) options because it applies at the iteration level, whatever the number of requests executed.

!!! warning
    Pacing occurs at the end of an iteration. For that reason, if the current iteration is stopped because of an error policy or any other similar mechanism, the pacing will not be applied.
