abcrunch 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/README.md +180 -0
  2. data/abcrunch.gemspec +1 -0
  3. data/lib/abcrunch/version.rb +1 -1
  4. metadata +11 -10
  5. data/README +0 -176
@@ -0,0 +1,180 @@
1
+ # Ab Crunch
2
+ *by TrueCar*
3
+
4
+ The idea behind Ab Crunch is that basic performance metrics and standards should
5
+ be effortless, first-class citizens in the development process, with frequent visibility
6
+ and immediate feedback when performance issues are introduced.
7
+
8
+ Other tools exist for measuring performance, but we found that they had some drawbacks:
9
+
10
+ * Not easily integrated into routine development practices, such as automated testing and CI
11
+ * Take a long time to set up.
12
+ * Take a long time to use.
13
+
14
+ We wanted a tool that, while simple, was valid enough to surface basic performance
15
+ issues and fast/easy enough to use throughout all our projects.
16
+
17
+ Ab Crunch uses Apache Bench to run various strategies for load testing web sites.
18
+ It generates rake tasks for running all or some of our tests. These can be configured
19
+ to be just informational, or to fail when specified standards are not met. The rake
20
+ tasks can then be added to our Continuous Integration (CI) builds, so builds fail when
21
+ performance degrades.
22
+
23
+ ### Credits
24
+
25
+ Christopher "Kai" Lichti, Author
26
+ Aaron Hopkins, adviser / contributed strategies
27
+ John Williams, adviser / contributed strategies
28
+ TrueCar, Inc, for giving us jobs and letting us share this gem
29
+
30
+ ### Prerequisites
31
+
32
+ Must have Apache Bench installed and 'ab' on your path
33
+
34
+ ### Quick Start Guide
35
+
36
+ To see some immediate action, require the gem, and run 'rake abcrunch:example'
37
+
38
+ Now to use it on your own pages:
39
+
40
+ First, define the pages you want to test, and (optionally), the performance
41
+ requirements you want them to meet. If you exclude any requirements, your
42
+ load test will be informational only, and won't log or raise any errors
43
+ based on performance standards.
44
+
45
+ For Example:
46
+
47
+ @load_test_page_sets = {
48
+ :production => [
49
+ {
50
+ :name => "Google home page",
51
+ :url => "http://www.google.com/",
52
+ :min_queries_per_second => 20,
53
+ :max_avg_response_time => 1000,
54
+ },
55
+ {
56
+ :name => "Facebook home page",
57
+ :url => "http://www.facebook.com/",
58
+ }
59
+ ],
60
+ :staging => [
61
+ {
62
+ :name => "Github home page",
63
+ :url => "http://www.github.com/",
64
+ :max_avg_response_time => 1000,
65
+ }
66
+ ]
67
+ }
68
+
69
+ require 'abcrunch'
70
+ AbCrunch::Config.page_sets = @load_test_page_sets
71
+
72
+ In Rails, you can do this in your development and test environments.
73
+
74
+ Once you've configured Ab Crunch, you can run rake tasks to load test your pages, like this:
75
+
76
+ rake abcrunch:staging
77
+ - or -
78
+ rake abcrunch:all
79
+
80
+ ### Configuring Pages
81
+
82
+ * `:name`: (required) User-friendly name for the page.
83
+ * `:url`: (required) Url to test. Can be a string or a Proc. Proc example:
84
+
85
+ :url => proc do
86
+ "http://www.google.com/?q=#{['food','coma','weirds','code'][rand(4)]}"
87
+ end,
88
+
89
+ **Performance requirements (will raise so CI builds break when requirements fail)**
90
+
91
+ * `:min_queries_per_second`: page must support at least this many QPS
92
+ * `:max_avg_response_time`: latency for the page cannot go higher than this
93
+
94
+ **Other Options**
95
+
96
+ * `:num_requests` - how many requests to make during each (of many) runs [Default: 50]
97
+ * `:max_latency` - global maximum latency (in ms) considered to be acceptable [Default: 1000]
98
+ * `:max_degradation_percent` - global max percent latency can degrade before being considered unacceptable [Default: 0.5 (iow 50%)]
99
+
100
+ ### Examples
101
+
102
+ **Iterative Optimization**
103
+
104
+ Running a focus load test to iterate fixing a performance issue.
105
+
106
+ If a specific page is too slow, you can iterate on that page using a focus rake task, like so:
107
+
108
+ rake abcrunch:dev:focus[3]
109
+
110
+ **Configuring the same URLS in multiple environments (dev, qa, staging, prod...)**
111
+
112
+ Here's an example showing how you might dry up the AbCrunch configuration to support multiple environments.
113
+
114
+ def init_env
115
+ if ['development', 'test'].include? RAILS_ENV
116
+ require 'abcrunch'
117
+ AbCrunch::Config.page_sets = ab_crunch_page_sets
118
+ end
119
+ end
120
+
121
+ def ab_crunch_page_sets
122
+ def page_with_domain(page, domain)
123
+ new = page.clone
124
+ new[:url] = page[:url].gsub '<domain>', domain
125
+ new
126
+ end
127
+
128
+ result = {
129
+ :dev => AB_CRUNCH_PAGE_SET_TEMPLATE.collect { |page| page_with_domain(page, 'http://localhost:3000') },
130
+ :qa => AB_CRUNCH_PAGE_SET_TEMPLATE.collect { |page| page_with_domain(page, 'http://qa.myapp.com') },
131
+ :staging => AB_CRUNCH_PAGE_SET_TEMPLATE.collect { |page| page_with_domain(page, 'http://staging.myapp.com') },
132
+ :prod => AB_CRUNCH_PAGE_SET_TEMPLATE.collect { |page| page_with_domain(page, 'http://www.myapp.com') },
133
+ }
134
+
135
+ result
136
+ end
137
+
138
+ AB_CRUNCH_PAGE_SET_TEMPLATE = [
139
+ {
140
+ :name => "Home",
141
+ :url => "<domain>/",
142
+ :min_queries_per_second => 50,
143
+ },
144
+ {
145
+ :name => "Blog",
146
+ :url => "<domain>/blog?user=honest_auto",
147
+ :max_avg_response_time => 450,
148
+ }
149
+ ]
150
+
151
+
152
+ ### Known Gotcha
153
+
154
+ Apache Bench does not like urls that just end with the domain. For example:
155
+ `http://www.google.com` is BAD, but
156
+ `http://www.google.com/` is fine, for reasons surpassing understanding.
157
+ ...so for root level urls, be sure to add a trailing slash.
158
+
159
+ ### License
160
+
161
+ The MIT License
162
+ Copyright (c) 2011 TrueCar, Inc.
163
+
164
+ Permission is hereby granted, free of charge, to any person obtaining a copy
165
+ of this software and associated documentation files (the "Software"), to deal
166
+ in the Software without restriction, including without limitation the rights
167
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
168
+ copies of the Software, and to permit persons to whom the Software is
169
+ furnished to do so, subject to the following conditions:
170
+
171
+ The above copyright notice and this permission notice shall be included in
172
+ all copies or substantial portions of the Software.
173
+
174
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
175
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
176
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
177
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
178
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
179
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
180
+ THE SOFTWARE.
@@ -25,6 +25,7 @@ DESC
25
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
26
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
27
27
  s.require_paths = ["lib"]
28
+ s.license = "MIT"
28
29
 
29
30
  s.add_runtime_dependency "rspec"
30
31
  s.add_runtime_dependency "rr"
@@ -1,3 +1,3 @@
1
1
  module AbCrunch
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abcrunch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-25 00:00:00.000000000Z
12
+ date: 2011-11-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2155910360 !ruby/object:Gem::Requirement
16
+ requirement: &2168620300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2155910360
24
+ version_requirements: *2168620300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rr
27
- requirement: &2155909940 !ruby/object:Gem::Requirement
27
+ requirement: &2168619880 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2155909940
35
+ version_requirements: *2168619880
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: colorize
38
- requirement: &2155909520 !ruby/object:Gem::Requirement
38
+ requirement: &2168619460 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2155909520
46
+ version_requirements: *2168619460
47
47
  description: ! 'The idea behind Ab Crunch is that basic performance metrics and standards
48
48
  should
49
49
 
@@ -69,7 +69,7 @@ files:
69
69
  - .rvmrc
70
70
  - Gemfile
71
71
  - Gemfile.lock
72
- - README
72
+ - README.md
73
73
  - Rakefile
74
74
  - ab_honk.rb
75
75
  - abcrunch.gemspec
@@ -102,7 +102,8 @@ files:
102
102
  - spec/spec_helper.rb
103
103
  - spec/tasks/spec.rake
104
104
  homepage: https://github.com/kurisu/abcrunch
105
- licenses: []
105
+ licenses:
106
+ - MIT
106
107
  post_install_message:
107
108
  rdoc_options: []
108
109
  require_paths:
data/README DELETED
@@ -1,176 +0,0 @@
1
- Ab Crunch
2
-
3
- The idea behind Ab Crunch is that basic performance metrics and standards should
4
- be effortless, first-class citizens in the development process, with frequent visibility
5
- and immediate feedback when performance issues are introduced.
6
-
7
- Other tools exist for measuring performance, but we found that they had some drawbacks:
8
- - Not easily integrated into routine development practices, such as automated testing and CI
9
- - Take a long time to set up.
10
- - Take a long time to use.
11
-
12
- We wanted a tool that, while simple, was valid enough to surface basic performance
13
- issues and fast/easy enough to use throughout all our projects.
14
-
15
- Ab Crunch uses Apache Bench to run various strategies for load testing web sites.
16
- It generates rake tasks for running all or some of our tests. These can be configured
17
- to be just informational, or to fail when specified standards are not met. The rake
18
- tasks can then be added to our Continuous Integration (CI) builds, so builds fail when
19
- performance degrades.
20
-
21
-
22
- Credits
23
- Christopher "Kai" Lichti, Author
24
- Aaron Hopkins, adviser / contributed strategies
25
- John Williams, adviser / contributed strategies
26
-
27
-
28
- Prerequisites
29
-
30
- Must have Apache Bench installed and 'ab' on your path
31
-
32
-
33
- Quick Start Guide
34
-
35
- To see some immediate action, require the gem, and run 'rake abcrunch:example'
36
-
37
- Now to use it on your own pages:
38
-
39
- First, define the pages you want to test, and (optionally), the performance
40
- requirements you want them to meet. If you exclude any requirements, your
41
- load test will be informational only, and won't log or raise any errors
42
- based on performance standards.
43
-
44
- For Example:
45
-
46
- @load_test_page_sets = {
47
- :production => [
48
- {
49
- :name => "Google home page",
50
- :url => "http://www.google.com/",
51
- :min_queries_per_second => 20,
52
- :max_avg_response_time => 1000,
53
- },
54
- {
55
- :name => "Facebook home page",
56
- :url => "http://www.facebook.com/",
57
- }
58
- ],
59
- :staging => [
60
- {
61
- :name => "Github home page",
62
- :url => "http://www.github.com/",
63
- :max_avg_response_time => 1000,
64
- }
65
- ]
66
- }
67
-
68
- require 'abcrunch'
69
- AbCrunch::Config.page_sets = @load_test_page_sets
70
-
71
- In Rails, you can do this in your development and test environments.
72
-
73
- Once you've configured Ab Crunch, you can run rake tasks to load test your pages, like this:
74
-
75
- rake abcrunch:staging
76
- - or -
77
- rake abcrunch:all
78
-
79
-
80
- Configuring Pages
81
-
82
- :name - (required) User-friendly name for the page.
83
- :url - (required) Url to test. Can be a string or a Proc. Proc example:
84
- :url => proc do
85
- "http://www.google.com/?q=#{['food','coma','weirds','code'][rand(4)]}"
86
- end,
87
-
88
- Performance requirements (will raise so CI builds break when requirements fail)
89
- :min_queries_per_second - page must support at least this many QPS
90
- :max_avg_response_time - latency for the page cannot go higher than this
91
-
92
- Other Options
93
- :num_requests - how many requests to make during each (of many) runs [Default: 50]
94
- :max_latency - global maximum latency (in ms) considered to be acceptable [Default: 1000]
95
- :max_degradation_percent - global max percent latency can degrade before being considered unacceptable [Default: 0.5 (iow 50%)]
96
-
97
-
98
- Example: Iterative Optimization
99
- Running a focus load test to iterate fixing a performance issue.
100
-
101
- If a specific page is too slow, you can iterate on that page using a focus rake task, like so:
102
-
103
- rake abcrunch:dev:focus[3]
104
-
105
-
106
- Example: Configuring the same URLS in multiple environments (dev, qa, staging, prod...)
107
-
108
- Here's an example showing how you might dry up the AbCrunch configuration to support multiple environments.
109
-
110
- def init_env
111
- if ['development', 'test'].include? RAILS_ENV
112
- require 'abcrunch'
113
- AbCrunch::Config.page_sets = ab_crunch_page_sets
114
- end
115
- end
116
-
117
- def ab_crunch_page_sets
118
- def page_with_domain(page, domain)
119
- new = page.clone
120
- new[:url] = page[:url].gsub '<domain>', domain
121
- new
122
- end
123
-
124
- result = {
125
- :dev => AB_CRUNCH_PAGE_SET_TEMPLATE.collect { |page| page_with_domain(page, 'http://localhost:3000') },
126
- :qa => AB_CRUNCH_PAGE_SET_TEMPLATE.collect { |page| page_with_domain(page, 'http://qa.myapp.com') },
127
- :staging => AB_CRUNCH_PAGE_SET_TEMPLATE.collect { |page| page_with_domain(page, 'http://staging.myapp.com') },
128
- :prod => AB_CRUNCH_PAGE_SET_TEMPLATE.collect { |page| page_with_domain(page, 'http://www.myapp.com') },
129
- }
130
-
131
- result
132
- end
133
-
134
- AB_CRUNCH_PAGE_SET_TEMPLATE = [
135
- {
136
- :name => "Home",
137
- :url => "<domain>/",
138
- :min_queries_per_second => 50,
139
- },
140
- {
141
- :name => "Blog",
142
- :url => "<domain>/blog?user=honest_auto",
143
- :max_avg_response_time => 450,
144
- }
145
- ]
146
-
147
-
148
- KNOWN GOTCHA: Apache Bench does not like urls that just end with the domain. For example:
149
- http://www.google.com is BAD, but
150
- http://www.google.com/ is fine, for reasons surpassing understanding.
151
- ...so for root level urls, be sure to add a trailing slash.
152
-
153
- <<-LICENSE
154
-
155
- The MIT License
156
- Copyright (c) 2011 TrueCar, Inc.
157
-
158
- Permission is hereby granted, free of charge, to any person obtaining a copy
159
- of this software and associated documentation files (the "Software"), to deal
160
- in the Software without restriction, including without limitation the rights
161
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
162
- copies of the Software, and to permit persons to whom the Software is
163
- furnished to do so, subject to the following conditions:
164
-
165
- The above copyright notice and this permission notice shall be included in
166
- all copies or substantial portions of the Software.
167
-
168
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
169
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
170
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
171
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
172
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
173
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
174
- THE SOFTWARE.
175
-
176
- LICENSE