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

7 1 0

Clone this repository

https://tangled.org/foxxmd.dev/crowdsecBench https://tangled.org/did:plc:mtxqvks6cxft2thojnblhc5f
git@tangled.org:foxxmd.dev/crowdsecBench git@tangled.org:did:plc:mtxqvks6cxft2thojnblhc5f

For self-hosted knots, clone URLs may differ based on your setup.



README.md

Crowdsec Benchmark#

This docker stack can be used to benchmark an out-of-the-box crowdsec installation. It contains:

  • Traefik reverse proxy
    • Configured with Access Logs that Crowdsec can consume
    • Wired to serve mendhak/http-https-echo, a simple web server that accepts any paths and echos back the request as JSON
  • Crowdsec
    • Configured to consume Traefik logs
    • With Collections required for parsing those logs and basic web traffic
  • k6 load testing tool
    • Configured to generate concurrent requests and duration of load using ENVs
    • Randomized path (RANDOMIZE=true)
    • Randomized User-Agent

Additionally, the bash script bench.sh can be used to orchestrate the load call, monitor the crowdsec process, and create a .png plot of CPU/memory using psrecord, if it installed.

Usage#

Create .env#

Use the sample .env.example to create an .env for your scenario.

  • TARGET = number of concurrent requests to make
  • DURATION = number of seconds to run load
  • RANDOMIZE = randomize url path
  • URL = leave as default unless modifying this project for your own use

Run Load#

Using bench.sh#

Install psrecord, if not present:

pipx install psrecord[plot]

Run bench.sh from the project directory, providing the duration the load will be run:

# DURATION=12 from .env then...
./bench.sh 12

After the run has finished an image plot_[unix_timestamp].png will be generated in the project directory.

Manually#

  1. Start docker services required to run the load
docker compose up traefik echo crowdsec -d
  1. Start any monitoring/profiling software for crowdsec

  2. Run load

docker compose up k6