Performance testing tools

From Ever changing code
Revision as of 12:02, 28 August 2021 by Pio2pio (talk | contribs) (Pio2pio moved page Test tools to Performance testing tools without leaving a redirect)
Jump to navigation Jump to search

Vegeta

Standalone install

LATEST=$(curl --silent "https://api.github.com/repos/tsenart/vegeta/releases/latest" | jq -r .tag_name | tr -d "v"); echo $LATEST
TEMPDIR=$(mktemp -d)
curl -L https://github.com/tsenart/vegeta/releases/download/v${LATEST}/vegeta_${LATEST}_linux_amd64.tar.gz -o $TEMPDIR/vegeta_${LATEST}_linux_amd64.tar.gz
sudo tar xzvf $TEMPDIR/vegeta_${LATEST}_linux_amd64.tar.gz -C /usr/local/bin vegeta

vegeta -version
Version: 
Commit: 
Runtime: go1.14.2 linux/amd64
Date:

Docker and Kubernetes

Docker images


Kubernetes deployment <syntaxhighlightjs lang="yaml"> kubectl apply -f <(cat <<EOF apiVersion: apps/v1 kind: Deployment metadata:

 name: vegeta
 labels:
   app: vegeta

spec:

 replicas: 1
 selector:
   matchLabels:
     app: vegeta
 template:
   metadata:
     labels:
       app: vegeta
   spec:
     containers:
     - name: vegeta
       image: peterevans/vegeta:6.9.1-vegeta12.8.4
       args:
       - sh
       - -c
       - sleep 36000 # 3600
       ports:
       - containerPort: 80
       resources:
         limits:
           cpu: 4000m # '1'
           memory: 1Gi
         requests:
           cpu: 2000m # '1'
           memory: 1Gi
     nodeSelector:
      node.kubernetes.io/lifecycle: spot

EOF ) --dry-run=server </syntaxhighlightjs>


Operations

URL=http://example.com/healthcheck
NAME=example.com
RATE=50/1s
DURATION=600s
DIR=/results
FILE=$DIR/$DATE-$NAME-r${RATE/\//in}-d$DURATION
DATE=$(date +"%Y%m%d-%H%M"); echo $DATE
echo "GET $URL" | vegeta attack -name $NAME -rate=$RATE -duration=$DURATION -timeout=120s | tee $FILE-results.bin | vegeta report
cat $FILE-results.bin | vegeta plot -title $URL > $FILE-plot.html
cat $FILE-results.bin | vegeta report # print report again

# Multi target
vegeta attack -name $NAME -rate=$RATE -duration=$DURATION -timeout=120s -targets=<(cat <<EOF
GET http://example1.com/healthcheck
GET http://example2.com/healthcheck
EOF
) | tee $FILE-results.bin | vegeta report

# | -cpus int          Number of CPUs to use (default 8)
# | attack
# |   -duration duration Duration of the test [0 = forever]
# |   -name string       Attack name
# |   -output string     Output file (default "stdout")
# |   -rate value        Number of requests per time unit [0 = infinity] (default 50/1s)
# |   -targets string    Targets file (default "stdin")
# |   -workers uint      Initial number of workers (default 10)
# | plot
# |   -output string     Output file (default "stdout")
# |   -title string      Title and header of the resulting HTML page (default "Vegeta Plot")
# | report
# |   -output string     Output file (default "stdout")
# |   -type string       Report type to generate [text, json, hist[buckets], hdrplot] (default "text")

# On a laptop
kubectl cp vegeta/vegeta-5847d879d8-p9kqw:plot.html ./plot.html -c vegeta

Repositories