From 1d9dc5e367c45f4887660ae5c102c448a556588c Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Fri, 28 Feb 2025 17:25:45 +0300 Subject: [PATCH] feat: introduce apachebench --- knowledge base/ab.md | 70 ++++++++++++++++++++++++++++++++++++++++++++ snippets/ab.fish | 10 +++++++ snippets/curl.sh | 3 ++ 3 files changed, 83 insertions(+) create mode 100644 knowledge base/ab.md create mode 100644 snippets/ab.fish diff --git a/knowledge base/ab.md b/knowledge base/ab.md new file mode 100644 index 0000000..02d3028 --- /dev/null +++ b/knowledge base/ab.md @@ -0,0 +1,70 @@ +# Apache HTTP server benchmarking tool + +> TODO + +Intro + + + +1. [TL;DR](#tldr) +1. [Further readings](#further-readings) + 1. [Sources](#sources) + +## TL;DR + +
+ Setup + +```sh +apt install 'apache2-utils' +dnf install 'httpd-tools' +``` + +
+ +
+ Usage + +```sh +# Limited number of requests +ab -n '750' -c '1' 'http://grafana.example.org/' + +# Sustained load for 't' seconds +# Default requests limit is 50000 +ab -t 300 -c 100 http://192.168.29.20/ +``` + +
+ + + +## Further readings + +- [Website] + +### Sources + +- [Load Testing in Linux With ApacheBench (ab)] + + + + + + + +[website]: https://httpd.apache.org/docs/current/programs/ab.html + + +[load testing in linux with apachebench (ab)]: https://www.baeldung.com/linux/ab-apachebench-load-testing diff --git a/snippets/ab.fish b/snippets/ab.fish new file mode 100644 index 0000000..2a50c1d --- /dev/null +++ b/snippets/ab.fish @@ -0,0 +1,10 @@ +#!/usr/bin/env fish + +# Install +apt install 'apache2-utils' +dnf install 'httpd-tools' + +ab -n '750' -c '1' 'http://grafana.example.org/' +ab -t 100 -c 250 -C 'GITLAB_TOKEN=0123…' 'https://gitlab.example.org/' + +parallel ab -t 40 -c 100 -C 'GITLAB_TOKEN=1234…' {} ::: https://gitlab.{production,staging}.example.org/ diff --git a/snippets/curl.sh b/snippets/curl.sh index dc95e54..bf305e4 100644 --- a/snippets/curl.sh +++ b/snippets/curl.sh @@ -26,3 +26,6 @@ curl --url 'https://gitlab.com/api/v4/runners/all' \ curl -fsX 'PUT' 'https://gitlab.com/api/v4/runners/{}' -H 'PRIVATE-TOKEN: glpat-m-…' -F 'paused=true' curl --fail --silent --request 'PUT' 'https://gitlab.com/api/v4/runners/{}' \ --header 'PRIVATE-TOKEN: glpat-m-…' --form 'paused=true' + + +curl -v --cookie "USER_TOKEN=Yes" http://127.0.0.1:5000/