Skip to content

Commit

Permalink
Touched up the example rake task and added a README. The steps in the…
Browse files Browse the repository at this point in the history
… README haven't yet been tested on a 3rd party project.
  • Loading branch information
truekai committed Oct 3, 2011
1 parent 9086542 commit 2e51625
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
69 changes: 69 additions & 0 deletions README
@@ -0,0 +1,69 @@
Ab Crunch uses Apache Bench to run various strategies for load testing web projects,
and provides rake tasks for analyzing performance and enforcing performance
standards on CI.

Quick Start Guide

To see some immediate action, require the gem, and run 'rake ac:example'

Now to use it on your own pages:

First, define the pages you want to test, and (optionally), the performance
requirements you want them to meet. If you exclude any requirements, your
load test will be informational only, and won't log or raise any errors
based on performance standards.

For Example:

@load_test_page_sets = {
:production => [
{
:name => "Google home page",
:url => "http://www.google.com/",
:min_queries_per_second => 20,
:max_avg_response_time => 1000,
},
{
:name => "Facebook home page",
:url => "http://www.facebook.com/",
}
],
:staging => [
{
:name => "Github home page",
:url => "http://www.github.com/",
:max_avg_response_time => 1000,
}
]
}

require 'abcrunch'
AbCrunch::Config.page_sets = @load_test_page_sets

In Rails, you can do this in your development and test environments.

Once you've configured Ab Crunch, you can run rake tasks to load test your pages, like this:

rake ac:load_test:staging
- or -
rake ac:load_test:all

Configuring Pages

:name - (required) User-friendly name for the page.
:url - (required) Url to test.

Performance requirements (will raise so CI builds break when requirements fail)
:min_queries_per_second - page must support at least this many QPS
:max_avg_response_time - latency for the page cannot go higher than this

Other Options
:num_requests - how many requests to make during each (of many) runs [Default: 50]
:max_latency - global maximum latency (in ms) considered to be acceptable [Default: 1000]
:max_degradation_percent - global max percent latency can degrade before being considered unacceptable [Default: 0.5 (iow 50%)]


KNOWN GOTCHA: Apache Bench does not like urls that just end with the domain. For example:
http://www.google.com is BAD, but
http://www.google.com/ is fine, for reasons surpassing understanding.
...so for root level urls, be sure to add a trailing slash.
4 changes: 2 additions & 2 deletions spec/tasks/test.rake → spec/tasks/example.rake
Expand Up @@ -11,7 +11,7 @@ namespace :ac do
{
:name => "Google home page",
:url => "http://www.google.com/",
:min_queries_per_second => 20,
:min_queries_per_second => 10,
:max_avg_response_time => 1000,
},
{
Expand All @@ -21,7 +21,7 @@ namespace :ac do
},
{
:name => "Bing Homepage",
:url => "http://www.bing.com",
:url => "http://www.bing.com/",
:min_queries_per_second => 50,
:max_avg_response_time => 200
}
Expand Down

0 comments on commit 2e51625

Please sign in to comment.