Skip to content

Commit 1b897e6

Browse files
author
Ben Peterson
committedMar 8, 2017
Perform last sanity-check load test using random keys. Update docs.
1 parent a11c068 commit 1b897e6

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed
 

‎.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ ubuntu-*.log
66
.idea
77

88
# Vegeta output folder
9-
vegeta
10-
9+
vegeta/*.bin
10+
vegeta/*.html
11+
random*

‎README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,23 @@ MIX_ENV=prod mix compile.protocols
8080
MIX_ENV=prod PORT=3333 elixir -pa _build/prod/consolidated -S mix phoenix.server
8181
```
8282

83-
Vegeta is not really necessary for testing but it *is* really useful. Installing it and running the following command from the repository's `vegeta` driectory on a separate host will really pile on the hurt:
84-
83+
Vegeta is not really necessary for testing but it *is* really useful. Installing it and running the following command from the repository's `vegeta` directory on a separate host will perform a simple load test, useful for checking the math. It's recommended that you empty the database and restart the python processes before testing.:
8584
```
86-
python create_targets.py 9000 targets.txt && vegeta attack -rate 9000 -output vegeta/out.bin -targets targets.txt
85+
cd vegeta
86+
echo "POST http://<yourserver>:3333/increment" | vegeta attack -rate 1100 -output out.bin -header "Content-Type: application/x-www-form-urlencoded" -body "./testbody"
8787
```
8888

89-
You can also run the test profile, which provides a moderate load, but does it in such a way that you can easily check the math in the database afterward. It's recommended that you empty the database and restart the python processes before testing.
89+
You can also run the insane mode profile, which really piles on the hurt:
90+
```
91+
python create_targets.py 9000 <yourserver> && vegeta attack -rate 9000 -output out.bin -header "Content-Type: application/x-www-form-urlencoded" -targets random_targets.txt
92+
```
9093

94+
After a test, you can run the following to see a simple report:
9195
```
92-
cd vegeta
93-
echo "POST http://<yourserver>:3333/increment" | vegeta attack -rate 1100 -output out.bin -header "Content-Type: application/x-www-form-urlencoded" -body "./testbody"
96+
vegeta report -inputs out.bin -reporter text
9497
```
9598

99+
See the Vegeta docs for more details on testing options and reporting output.
96100

97101
# Design Choices
98102

‎vegeta/create_targets.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sys
2+
import random
3+
import uuid
4+
5+
# Generate some random targets for Vegeta to obliterate
6+
if len(sys.argv) > 2:
7+
num_targets = int(sys.argv[1])
8+
target_server = sys.argv[2]
9+
print "Generating {} random targets for server {}...".format(num_targets, target_server)
10+
11+
random_content = []
12+
with open('./random_targets.txt', 'w') as targets_file:
13+
for i in range(0, num_targets):
14+
with open("./random{}".format(i), 'w') as body_file:
15+
content = "key={}&value={}".format(uuid.uuid4(), random.randint(-10000, 10000))
16+
body_file.write(content)
17+
targets_file.write("POST http://{}:3333/increment\n".format(target_server))
18+
targets_file.write("@./random{}\n".format(i))
19+
targets_file.write("\n")
20+
21+
print "Done."
22+
else:
23+
print "This program requires <num_targets> followed by <target_server>. Exiting."
24+

‎vegeta/testbody

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
key=test1&value=1

0 commit comments

Comments
 (0)
Please sign in to comment.