Log-normal distributions of delay

The Log-normal distribution is a pretty accurate description of a server latency. The Log-normal distribution defines by 2 parameters μ and σ. We will compute these parameters from mean and median of a server response time. These values you can see in your monitoring of the production server. If need you can adjust response time by min and max parameters.

Let’s apply a random log-normal distributed delay to all responses. First, we need to create and export a simulation.

hoverctl start
hoverctl mode capture
curl --proxy localhost:8500 http://echo.jsontest.com/b/c
curl --proxy localhost:8500 -X POST http://echo.jsontest.com/b/c
hoverctl export simulation.json
hoverctl stop

Take a look at the "globalActions" property within the simulation.json file you exported. It should look like this:

1      "globalActions": {
2         "delays": [],
3         "delaysLogNormal": []

Edit the file so the "globalActions" property looks like this:

 1      "globalActions": {
 2         "delaysLogNormal": [
 3            {
 4               "urlPattern": ".",
 5               "httpMethod": "",
 6               "min": 100,
 7               "max": 10000,
 8               "mean": 5000,
 9               "median": 500
10            }
11         ]
12      }

Hoverfly will apply a delay to all URLs that match the "urlPattern" value. We want the delay to be applied to all URLs, so we set the "urlPattern" value to the regular expression ".".

Now import the edited simulation.json file, switch Hoverfly to Simulate mode and make the requests again.

hoverctl start
hoverctl import simulation.json
curl --proxy localhost:8500 http://echo.jsontest.com/b/c
curl -X POST --proxy localhost:8500 http://echo.jsontest.com/b/c
hoverctl stop