forked from usegalaxy-au/galaxy-media-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
locustfile.py
61 lines (41 loc) · 1.53 KB
/
locustfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Load test a remote web server.
`requirements.txt` should be pip installed into a virtual env.
See locust.sh for example run with 4 CPUs.
Start a master process:
HOST=https://usegalaxy-au-2.neoformit.com
locust --host=$HOST --locustfile locustfile.py --master
Start a worker process (probably fork and run several in separate terminal):
locust --host=$HOST --locustfile locustfile.py --worker &
N.B. You may need to change your host machine's "open file limits".
On Linux you can do this on a per-session basis with:
$ ulimit -S -n 20000
You may also need to change fail2ban settings on the target weserver in order
to allow such a high volume of requests to be accepted from a single IP.
"""
from locust import FastHttpUser, task, between
class WebsiteUser(FastHttpUser):
"""Define a site user.
The homepage will be hit 40X more often than other pages.
"""
wait_time = between(10, 30)
@task(40)
def homepage(self):
"""Request the homepage.
This involves a db query to get events and news items followed by an
HTML render.
"""
self.client.get('/')
@task(1)
def events_index(self):
"""Visit the events page.
This requires a slightly larger db query than the homepage.
"""
self.client.get('/events')
@task(1)
def news_index(self):
"""Visit the news page."""
self.client.get('/news')
@task(1)
def event_article(self):
"""Visit an event article page."""
self.client.get('/events/1/')