Sign inSign up

virag/http-loadgen

By virag

โ€ขUpdated about 1 year ago

HTTP benchmarking and workload simulation tool

Image
0

251

virag/http-loadgen repository overview

โ http-loadgen

Latest Release Build Go Version License

http-loadgen banner


http-loadgen is a high-throughput, configurable HTTP benchmarking and workload simulation tool.
Use it to load test any read/write API โ€” including permission systems like Ory Ketoโ .


โ ๐Ÿš€ Quick Start

./scripts/run.sh

This runs the default benchmark defined in config/config.yaml.


โ ๐Ÿ“Š Benchmark Matrix

To run multiple configurations and generate a report:

./scripts/run.sh --benchmark

Results are written to:

benchmark_results.csv

โ ๐Ÿงช Example: Test Ory Keto

Use this config:

# api/keto.yaml
api:
  write_api: http://localhost:4467
  read_api: http://localhost:4466

requests:
  write:
    method: PUT
    url: "{{ .WriteAPI }}/admin/relation-tuples"
    headers:
      Content-Type: application/json
    body: |
      {
        "namespace": "documents",
        "object": "{{ .object }}",
        "relation": "viewer",
        "subject_id": "user:{{ .subject }}"
      }

  read:
    method: POST
    url: "{{ .ReadAPI }}/relation-tuples/check"
    headers:
      Content-Type: application/json
    body: |
      {
        "namespace": "documents",
        "object": "{{ .object }}",
        "relation": "viewer",
        "subject_id": "user:{{ .subject }}"
      }

And run:

./http-loadgen --workload-config=./config/config.yaml --log-file=run.log

โ ๐Ÿ“ Folder Layout

api/              # API-specific configurations (e.g., Keto)
config/           # Loadgen settings: concurrency, retries, durations
scripts/          # run.sh and benchmark automation
internal/         # Core logic: request engine, metrics, generator
cmd/              # CLI entrypoint (main.go)

โ ๐Ÿ”ง CLI Flags

FlagDescription
--duration-secDuration to run the test
--concurrencyNumber of concurrent workers
--checks-per-secondMax read requests per second
--read-ratioRead to write ratio (e.g., 100 = 100:1)
--workload-configPath to YAML config file
--log-fileWhere to write logs
--verboseEnable detailed logging
--max-retriesRetry attempts per request
--retry-delayDelay between retries (ms)
--request-timeoutTimeout per HTTP request (sec)
--max-open-connsMax HTTP connections
--max-idle-connsMax idle connections
--serve-metricsKeep Prometheus metrics server alive
--dry-runRun logic without making real HTTP calls

โ ๐Ÿ“ฆ Build

make build

โ ๐ŸŽ macOS Gatekeeper (Quarantine) Fix

When downloading the macOS binary (http-loadgen_darwin_arm64 or http-loadgen_darwin_amd64), macOS may block it with this error:


"http-loadgen" cannot be opened because the developer cannot be verified.

To fix it:

xattr -d com.apple.quarantine ./http-loadgen_darwin_arm64
chmod +x ./http-loadgen_darwin_arm64
./http-loadgen_darwin_arm64 --help

Alternatively, allow the app manually via:

๏ฃฟ System Settings โ†’ Privacy & Security โ†’ Allow Anyway


โ ๐Ÿณ Docker Usage

Build the image locally:

docker build -t http-loadgen:latest .

โ ๐Ÿš€ Run with built-in config (zero setup)
docker run --rm virag/http-loadgen:latest \
  --workload-config=/app/config/config.yaml \
  --log-file=/app/run.log

โœ… This works out of the box because the default config is baked into the image at /app/config/config.yaml.


โ โš™๏ธ Override config from local machine
docker run --rm \
  -v $(pwd)/config:/app/config \
  virag/http-loadgen:latest \
  --workload-config=/app/config/custom.yaml \
  --log-file=/app/run.log

โœ… This mounts your local config/ folder into the container, replacing the default.


โ ๐Ÿงช Use dry-run mode to test
docker run --rm virag/http-loadgen:latest \
  --workload-config=/app/config/config.yaml \
  --dry-run

โ ๐Ÿ“ˆ Live Metrics

Run with:

--serve-metrics

Then scrape:

http://localhost:2112/metrics

Prometheus-compatible metrics include:

  • retry_attempts_total
  • retry_success_total
  • permission_check_total
  • retry_duration_seconds

โ ๐Ÿ’ก Why Benchmark APIs Instead of the DB?

This tool mimics real-world client behavior โ€” it:

  • Hits live HTTP endpoints
  • Tests retry logic, latency, and concurrency
  • Measures API performance under real query pressure

Not just the raw DB underneath.


โ ๐Ÿ“– References

Tag summary

Content type

Image

Digest

sha256:ac8657f85โ€ฆ

Size

11.8 MB

Last updated

about 1 year ago

docker pull virag/http-loadgen