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

Add docs

FoxxMD (Sep 19, 2025, 3:26 PM EDT) ec200415 0a3ed25b

+63 -1
+1 -1
.env.example
··· 1 - URL=http://my-cool-site 1 + URL=http://traefik 2 2 TARGET=1 3 3 DURATION=10s 4 4 RANDOMIZE=true
+62
README.md
··· 1 + # Crowdsec Benchmark 2 + 3 + This docker stack can be used to benchmark an out-of-the-box crowdsec installation. It contains: 4 + 5 + * [Traefik](https://doc.traefik.io/traefik/getting-started/install-traefik/) reverse proxy 6 + * Configured with [Access Logs](https://doc.traefik.io/traefik/observe/logs-and-access-logs/#access-logs) that Crowdsec can consume 7 + * Wired to serve [mendhak/http-https-echo](https://github.com/mendhak/docker-http-https-echo), a simple web server that accepts any paths and echos back the request as JSON 8 + * [Crowdsec](https://docs.crowdsec.net/) 9 + * Configured to consume Traefik logs 10 + * With Collections required for parsing those logs and basic web traffic 11 + * [k6](https://grafana.com/docs/k6/latest/) load testing tool 12 + * Configured to generate concurrent requests and duration of load using ENVs 13 + * Randomized path (`RANDOMIZE=true`) 14 + * Randomized User-Agent 15 + 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/memory using [`psrecord`](https://github.com/astrofrog/psrecord), if it installed. 17 + 18 + # Usage 19 + 20 + ## Create .env 21 + 22 + Use the sample [`.env.example`](/.env.example) to create an `.env` for your scenario. 23 + 24 + * `TARGET` = number of concurrent requests to make 25 + * `DURATION` = number of seconds to run load 26 + * `RANDOMIZE` = randomize url path 27 + * `URL` = leave as default unless modifying this project for your own use 28 + 29 + ## Run Load 30 + 31 + ### Using `bench.sh` 32 + 33 + Install [`psrecord`](https://github.com/astrofrog/psrecord), if not present: 34 + 35 + ```shell 36 + pipx install psrecord[plot] 37 + ``` 38 + 39 + Run `bench.sh` from the project directory, providing the duration the load will be run: 40 + 41 + ```shell 42 + # DURATION=12 from .env then... 43 + ./bench.sh 12 44 + ``` 45 + 46 + After the run has finished an image `plot_[unix_timestamp].png` will be generated in the project directory. 47 + 48 + ### Manually 49 + 50 + 1. Start docker services required to run the load 51 + 52 + ```shell 53 + docker compose up traefik echo crowdsec -d 54 + ``` 55 + 56 + 2. Start any monitoring/profiling software for crowdsec 57 + 58 + 3. Run load 59 + 60 + ```shell 61 + docker compose up k6 62 + ```