Skip to content

Instantly share code, notes, and snippets.

@DannyBen
Forked from seyhunak/apache_bench.sh
Created October 10, 2015 17:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DannyBen/92dec729f3b2299ed54a to your computer and use it in GitHub Desktop.
Save DannyBen/92dec729f3b2299ed54a to your computer and use it in GitHub Desktop.
Rails - Apache Bench - Load Testing (if Devise Sign-in Required)
1.
LOGIN_PAGE=http://localhost/users/sign_in
curl --cookie-jar cookie_file $LOGIN_PAGE | grep csrf-token
2.
<meta content="csrf-token" name="csrf-token" />
TOKEN=csrf-token
3.
EMAIL=your@email.com
PASSWORD=yourpass
curl --cookie cookie_file \
--cookie-jar cookie_file \
--data "user[email]=$EMAIL&user[password]=$PASSWORD" \
--data-urlencode authenticity_token=$TOKEN \
$LOGIN_PAGE
4.
INTERNAL_PAGE="http://localhost/activities/feed?locale=en&venue=1"
curl --cookie cookie_file $INTERNAL_PAGE
5.
cat cookie_file
# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
lvh.me FALSE / FALSE 0 request_method POST
#HttpOnly_lvh.me FALSE / FALSE 0 _app_session cookie_value
6.
COOKIE="_app_session=cookie_value"
7.
TRIALS=100
CONCURRENCY=10
ab -n $TRIALS -c $CONCURRENCY -C $COOKIE $INTERNAL_PAGE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment