[READ-ONLY] Mirror of https://github.com/FoxxMD/crowdsecBench. Benchmark Crowdsec CPU usage with concurrent requests
benchmark cpu-usage crowdsec docker k6 monitoring visualization
0

Configure Feed

Select the types of activity you want to include in your feed.

crowdsecBench / bench.sh
1.5 kB 60 lines
1#!/bin/bash 2 3trap 'exit 0;' SIGHUP SIGINT 4 5TARGET='50' 6DURATION='30s' 7 8if test -f ".env"; then 9 printf 'Found .env\n' 10 export $(cat .env | xargs) 11fi 12 13printf 'RUN => %s concurrent requests over %s\n' "$TARGET" "$DURATION" 14 15printf 'Starting traefik and echo...\n' 16docker compose up traefik echo -d 17 18printf 'Starting crowdsec container...\n' 19docker compose up crowdsec -d 20 21CS_PID=$(pgrep crowdsec --newest | head -n 1) 22while [ -z "$CS_PID" ] 23do 24 printf 'Waiting for crowdsec to finish starting up...\n' 25 sleep 1 26 CS_PID=$(pgrep crowdsec --newest | head -n 1) 27done 28printf 'Crowdsec started! Waiting a few seconds for CPU to settle...\n' 29sleep 2 30 31printf 'Starting goeffel capture of crowdsec PID %s \n' "$CS_PID" 32docker compose run --rm --no-TTY goeffel goeffel --pid $CS_PID & 33 34printf 'Starting k6, will run for %s\n' "$DURATION" 35docker compose up k6 -d 36 37docker compose wait k6 38printf 'k6 container exited!\n' 39 40printf 'Stopping crowdsec\n' 41docker compose down crowdsec 42 43printf 'Waiting for goeffel to exit...\n' 44docker compose wait goeffel 45 46DATA=$(cd ./data/goeffel && ls -t1 *.hdf5 | head -n 1) 47 48timestamp=$(date +%s) 49 50printf 'Generating plot for %s\n' "$DATA" 51 52docker compose run --rm --no-TTY goeffel goeffel-analysis flexplot \ 53--series $DATA host \ 54--column proc_cpu_util_percent_total \ 55'CPU util (total) / %' \ 56"Crowdsec Web Traffic Load $timestamp" 5 \ 57--subtitle "$TARGET concurrent requests, measured with Goeffel" \ 58--legend-loc 'upper right' \ 59--mean-style solid \ 60--custom-y-limit 0 100