[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.

feat: Replace goeffel install with container

* Reduces install/usage complexity
* script no longer needs to be run as sudo
* script no longer needs to check for goeffel

FoxxMD (Sep 24, 2025, 12:23 PM EDT) acb1ceb2 801f7e74

+35 -54
+10 -19
README.md
··· 12 12 * Configured to generate concurrent requests and duration of load using ENVs 13 13 * Randomized path (`RANDOMIZE=true`) 14 14 * Randomized User-Agent 15 + * forked [goeffel](https://github.com/FoxxMD/goeffel) for capturing process activity 15 16 16 - Additionally, the bash script [`bench.sh`](/bench.sh) can be used to orchestrate the load call, monitor the crowdsec process, and create a .png plot of CPU using [`goeffel`](https://github.com/jgehrcke/goeffel), if it installed. 17 + Additionally, the bash script [`bench.sh`](/bench.sh) can be used to orchestrate the load call, monitor the crowdsec process, and create a .png plot of CPU using [`goeffel`](https://github.com/jgehrcke/goeffel). 17 18 18 19 # Usage 19 20 ··· 30 31 31 32 ### Using `bench.sh` 32 33 33 - Install latest development [`goeffel`](hhttps://github.com/jgehrcke/goeffel) version: 34 - 35 34 ```shell 36 - pipx install git+https://github.com/foxxmd/goeffel@flexplotStyling 37 - ``` 38 - 39 - Run `bench.sh` from the project directory. It requires `sudo` to collect metrics. 40 - 41 - ```shell 42 - sudo ./bench.sh 35 + ./bench.sh 43 36 ``` 44 37 45 - If the script reports that `goeffel` can not be found you can specify the location of the binary as an argument: 46 - 47 - ```shell 48 - $ which goeffel 49 - /home/myUser/.local/bin/goeffel 50 - $ sudo ./bench.sh /home/myUser/.local/bin/goeffel 51 - ``` 52 - 53 - After the run has finished an image `[date]_crowdsec-web-traffic-load-[unix_timestamp].png` will be generated in the project directory. 38 + After the run has finished an image `[date]_crowdsec-web-traffic-load-[unix_timestamp].png` will be generated in `./data/goeffel` directory. 54 39 55 40 Additional graphs can be plotted from the generated `hdf5` file using [`goeffel-analysis`](https://github.com/jgehrcke/goeffel?tab=readme-ov-file#goeffel-analysis-data-inspection-and-visualization). 56 41 ··· 63 48 ``` 64 49 65 50 2. Start any monitoring/profiling software for crowdsec 51 + 52 + Using the goeffel container EX: 53 + 54 + ```shell 55 + docker compose run --rm --no-TTY goeffel goeffel --pid MY_COOL_PROGRAM_PID 56 + ``` 66 57 67 58 3. Run load 68 59
+10 -35
bench.sh
··· 1 1 #!/bin/bash 2 2 3 - CMD=${1:-goeffel} 4 - CMD_ANALYSIS="${CMD}-analysis" 5 - 6 - if ! command -v $CMD >/dev/null 2>&1 7 - then 8 - echo "$CMD could not be found, please make sure it is installed and this shell can access it." 9 - exit 1 10 - fi 11 - 12 - ## https://askubuntu.com/a/970898 13 - if ! [ $(id -u) = 0 ]; then 14 - echo "The script need to be run as root." >&2 15 - exit 1 16 - fi 17 - 18 - if [ $SUDO_USER ]; then 19 - real_user=$SUDO_USER 20 - else 21 - real_user=$(whoami) 22 - fi 23 - 24 - trap 'exit 0;' SIGHUP SIGINT SIGKILL 3 + trap 'exit 0;' SIGHUP SIGINT 25 4 26 5 printf 'Starting traefik and echo...\n' 27 - sudo -u $real_user docker compose up traefik echo -d 6 + docker compose up traefik echo -d 28 7 29 8 printf 'Starting crowdsec container...\n' 30 - sudo -u $real_user docker compose up crowdsec -d 9 + docker compose up crowdsec -d 31 10 32 11 CS_PID=$(pgrep crowdsec --newest | head -n 1) 33 12 while [ -z "$CS_PID" ] ··· 40 19 sleep 2 41 20 42 21 printf 'Starting goeffel capture of crowdsec PID %s \n' "$CS_PID" 43 - $CMD --pid $CS_PID --no-system-metrics --label crowdsec & 44 - G_PID=$! 22 + docker compose run --rm --no-TTY goeffel goeffel --pid $CS_PID & 45 23 46 24 printf 'Starting k6\n' 47 - sudo -u $real_user docker compose up k6 -d 25 + docker compose up k6 -d 48 26 49 - #printf 'Waiting for k6 to finish...\n' 50 27 docker compose wait k6 51 28 printf 'k6 container exited!\n' 52 29 53 30 printf 'Stopping crowdsec\n' 54 - sudo -u $real_user docker compose down crowdsec 31 + docker compose down crowdsec 55 32 56 - while test -d /proc/$G_PID; do 57 - printf 'Waiting for goeffel to finish...\n' 58 - sleep 1 59 - done 33 + printf 'Waiting for goeffel to exit...\n' 34 + docker compose wait goeffel 60 35 61 - DATA=$(ls -t1 *.hdf5 | head -n 1) 36 + DATA=$(cd ./data/goeffel && ls -t1 *.hdf5 | head -n 1) 62 37 63 38 timestamp=$(date +%s) 64 39 65 40 printf 'Generating plot for %s\n' "$DATA" 66 41 67 - sudo -u $real_user $CMD_ANALYSIS flexplot \ 42 + docker compose run --rm --no-TTY goeffel goeffel-analysis flexplot \ 68 43 --series $DATA host \ 69 44 --column proc_cpu_util_percent_total \ 70 45 'CPU util (total) / %' \
+15
compose.yaml
··· 19 19 image: mendhak/http-https-echo:36 20 20 crowdsec: 21 21 image: crowdsecurity/crowdsec:latest 22 + depends_on: 23 + - traefik 22 24 environment: 23 25 COLLECTIONS: "crowdsecurity/linux crowdsecurity/traefik" 24 26 DISABLE_PARSERS: crowdsecurity/whitelists ··· 26 28 - ./crowdsec/acquis.d:/etc/crowdsec/acquis.d 27 29 - ./data/crowdsec/data:/var/lib/crowdsec/data 28 30 - ./data/traefik-log:/var/log/traefik 31 + goeffel: 32 + image: foxxmd/goeffel:edge 33 + # required for goeffel to share PID address space with host 34 + pid: host 35 + # required for goeffel to have permission to access PIDs 36 + cap_add: 37 + - CAP_SYS_PTRACE 38 + volumes: 39 + - "./data/goeffel:/app" 40 + # you want to override this 41 + command: 42 + - 'goeffel' 43 + - '-h'