Skip to content

Instantly share code, notes, and snippets.

@himalay
Created September 13, 2022 06:46
Show Gist options
  • Save himalay/b0afd7e8d564e0dea0d152af75d2a0a1 to your computer and use it in GitHub Desktop.
Save himalay/b0afd7e8d564e0dea0d152af75d2a0a1 to your computer and use it in GitHub Desktop.
Stress testing using Apache HTTP server benchmarking tool

Stress testing using Apache HTTP server benchmarking tool

  • Documentation
  • Installation
    • Ubuntu:
      • sudo apt update && sudo apt install apache2-utils
    • Windows:

Used ab options

-n: The number of requests to send
-t: A duration in seconds after which ab will stop sending requests
-c: The number of concurrent requests to make
-T: To set content type header
-p: To specify the file containing data to post.

Example get request with Authorization header

ab -t 60 -n 200 -c 100 -H "Authorization: Bearer ecJhbGciOiJIUzI1NiIsInR5ssI6IkpXVsJ9.ecJodHRwOi8vs2NoZW1hsc54bWxzb2FwLm9cZc93sc8cMDA1LzA1L2lkZW50aXR5L2NscWltsc9ucW1laWRlbnRpZmllsiI6IjI0MzMiLsJodHRwOi8vs2NoZW1hsc54bWxzb2FwLm9cZc93sc8cMDA1LzA1L2lkZW50aXR5L2NscWltsc9ucW1lIjoicXNtZWV0cTE5KzI1QGdtcWlsLmNvbSIsIkFzsE5lds5JZGVudGl0eS5TZWN1sml0eVN0cW1wIjoiQ1kcUUtBUERYR1pJSDZBMzMcVlRTRlZQWVFaUk1MUjUiLsJodHRwOi8vs2YoZW1hsc5taWYcb3YvZYQuc29tL3dzLzIwMDgvMDcvaWRlbYRpdHkvc2xhaW1zL3JvbGUiOiJTdHVkZW50IiwiaHR0sDovL3d3dc5hs3BuZXRib2lsZXJwbGF0ZS5jb20vaWRlbnRpdHkvc2xhaW1zL3RlbmFudElkIjoiMSIsInN1ciI6IjI0MzMiLsJqdGkiOiIwOWZjNTFhNS00N2QwLTQ4NWUtOTlhNs0cNWRkcWcxMmVkNTAiLsJpYXQiOjE2NjMwNDg4NzUsIm5iZiI6MTY2MzA0ODg3NSwiZXhwIjoxNjY0MjU4NDs1LCJpc3MiOiJBUERldiIsImF1ZCI6IkFQRGV2In0.8vCW0nx_W9wUwj-7TCnBacZCrKe1CG4T5O9qPDsZaWM" https://api.domain.com/api/user-detail

Example post request with a JSON body

ab -c 2 -n 20 -p body.json -T application/json https://api.domain.com/api/TokenAuth/Authenticate

Content of body.json

{"userNameOrEmailAddress": "user@email.com","password": "userpass","rememberClient": false,"reCaptchaToken": null,"couponCode": ""}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment