Skip to content

Commit

Permalink
Merge pull request #93 from AdFabConnect/loadtests
Browse files Browse the repository at this point in the history
Loadtests scenarios and README.md to use it
  • Loading branch information
gonzalezemmanuel committed Dec 19, 2016
2 parents 2eedcd9 + c68532b commit 9c9ec41
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/loadtests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Load testing Abe

In order to loadtest [Abe](https://github.com/AdFabConnect/abejs) we choose to use [Locust](http://locust.io/).
Why? Because it's simple and it's doing the job!

## Pre-req

Locust requires Python 2.6+. Python 3.x support is [coming](https://twitter.com/locustio/status/801736746727784448)

## Installation

See [locust.io installation](http://docs.locust.io/en/latest/installation.html)

# Start load testing Abe

We wrote 2 locust files called [manager.py](./manager.py) and [create.py](./create.py)
For both scenarios below you have to setup the number of users you want and the number of users spawned per second.
Start with 10 users and 1 user spawned/second to test and click `Start swarming`.

## Manager

We start with Abe's manager loadtest.

- Run `locust -f manager.py --host=http://your.abe.com` from root of your locust install.
- Go to `http://localhost:8089` on your favorite browser.
- You're all set \o/.

## Create

Then we continue with testing content creation time response.
For this test you'll have to set a abe.json file with secure cookie to false

```javascript
{
"cookie": {
"secure": false
},
"security" : false,
}
```

- Run `locust -f create.py --host=http://your.abe.com` from root of your locust install.
- Go to `http://localhost:8089` on your favorite browser.

# Abe Benchmark

Below you find a benchmark (to be completed) of response time to display a content in Abe.

## Test characteristics

- 1.000 contents in Abe
- locust parameters : 10 users | 1 user spawned/second
- Duration : 5 mins
- Each user call 1 content in abe

## Result

| Abe Version | Average Response Time (s)|
|:-------------:|:------------------------:|
| 1.8.0 |17,564 |
| 2.1.0 |6,036 |
| 2.2.1 |6,047 |
| 2.2.2 |3,082 |
| 2.3.1 |2,215 |
| 2.6.8 |0,622 |

Between 1.8.0 and 2.6.8 the Abe content load time was divided by **27**! The refactoring was on his way. Never ceased then...

To be continued...
18 changes: 18 additions & 0 deletions tests/loadtests/create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import random, string
from locust import HttpLocust, TaskSet

def create(l):
rand_str = lambda n: ''.join([random.choice(string.lowercase) for i in xrange(n)])
s = rand_str(10)
l.client.post("/abe/create/" + s, {
"selectTemplate": "index",
"name": s
})

class UserBehavior(TaskSet):
tasks = {create:1}

class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait=5000
max_wait=9000
12 changes: 12 additions & 0 deletions tests/loadtests/manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from locust import HttpLocust, TaskSet

def manager(l):
l.client.get("/abe/editor")

class UserBehavior(TaskSet):
tasks = {manager:1}

class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait=5000
max_wait=9000

0 comments on commit 9c9ec41

Please sign in to comment.