Skip to content

Instantly share code, notes, and snippets.

@rootcss
Created April 25, 2019 08:57
Show Gist options
  • Select an option

  • Save rootcss/f263a0ddcc49e4db4a22d296b08012e2 to your computer and use it in GitHub Desktop.

Select an option

Save rootcss/f263a0ddcc49e4db4a22d296b08012e2 to your computer and use it in GitHub Desktop.
Apache Bench Examples

Installation:

sudo apt-get install apache2-utils

GET example

ab -n 10 -c 2 http://dummy.restapiexample.com/api/v1/employees

POST example

ab -p ./post.txt -T application/json -H 'Some-Header: value_of_header' -n 10 -c 2 http://dummy.restapiexample.com/api/v1/create

Content of post.txt:

{"name":"test","salary":"123","age":"23","id":"719"}

Parameters dictionary:

 -p : POST a file (post.txt has the JSON data to be POST'ed)
 -H : Add a header
 -T : Set a content type
 -c : no. of concurrent clients
 -n : total no. of requests
@nitishparkar
Copy link
Copy Markdown

This one is useful too. Significantly increases requests/sec
-k : Use HTTP KeepAlive feature

https://blog.getpolymorph.com/7-tips-for-heavy-load-testing-with-apache-bench-b1127916b7b6#1f86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment