Skip to content

Instantly share code, notes, and snippets.

@kuntalchandra
Last active August 1, 2022 05:53
Show Gist options
  • Save kuntalchandra/07b1fd69564da3fe0a57c9fad835bc94 to your computer and use it in GitHub Desktop.
Save kuntalchandra/07b1fd69564da3fe0a57c9fad835bc94 to your computer and use it in GitHub Desktop.
Load testing example using Apache Bench (ab) to POST JSON to an API
# Shoot off 300 requests at the server, with a concurrency level of 10, to test the number of requests it can handle per second
# -p POST
# -H Authentication headers
# -T Content-Type
# -c Concurrent clients
# -n Number of requests to run
# -l Accept variable document length
# -k Connection keep-alive
# -v Verbosity level
nohup ab -p transaction.txt -T application/json -H 'Accept: application/json' -H 'Authorization: Basic SoMEtoKEN==' -H "Cookie: My_Session=AnOTheRTOken" -c 10 -n 300 -l -k -v 2 http://my.staging.server.com/api/v1/portfolios/123456/transactions > transaction_post_results.txt &
{
"position" : {
"id" : 123456
},
"currency" : {
"id": 123456,
"code":"INR"
},
"type": "buy",
"share": 10,
"price": 10,
"transactionDate": "1995-01-01"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment