-
Notifications
You must be signed in to change notification settings - Fork 4
/
ab.sh
56 lines (50 loc) · 1.19 KB
/
ab.sh
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
#!/usr/bin/env bash
#
# Simple Apache Benchmark Script for HTTP Service
# Stress Testing and Performance Analysis.
#
# Requires: ab
#
# CentOS:
# $ yum install httpd-tools
#
# Ubuntu:
# $ apt install apache-utils
#
# Author: Sean O'Donnell <[email protected]>
#
# Stress Frequency
# Number of concurrent user/connection during simulation
NUM_CONS=500;
# Number of requests per simulated user
NUM_REQS=1000;
# Stress Targets
BASE_URL="https://www.mysite.net";
# Authentication Endpoint and Data Info
#AUTH_EP="${BASE_URL}/login"; # un-comment if using a custom login page.
AUTH_POST_TYPE="application/x-www-form-urlencoded";
AUTH_POST_DATA="post.txt"; # format: [email protected]&password=some.weak.passwd
# Application Endpoints (example)
APP_EPS=(
blog
about
about/work
about/portfolio
about/resume
cart
faq
photos
photos/albums
photos/selfies
photos/family
);
# "Authenticate"
if [ ! -z ${AUTH_EP} ]; then
ab -n ${NUM_REQS} -c ${NUM_CONS} -T ${AUTH_POST_TYPE} -p ${AUTH_POST_DATA} ${AUTH_EP}
fi
# Hit the APP Endpoints
if [ ! -z ${APP_EPS} ]; then
for i in ${APP_EPS[@]}; do
ab -n ${NUM_REQS} -c ${NUM_CONS} ${BASE_URL}/${i}
done;
fi;