Created
July 9, 2012 08:32
-
-
Save floere/3075105 to your computer and use it in GitHub Desktop.
Using Ricer and no Sinatra for a high speed Picky.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove the Sinatra class from the Picky example app | |
# and replace the get call with this: | |
# | |
# Then, run e.g. | |
# ab -n 1000 -c 10 '127.0.0.1:3000/?query=a&ids=20&offset=0' | |
# (simple) | |
# or | |
# ab -n 1000 -c 10 '127.0.0.1:3000/?query=a*-a*-a&ids=20&offset=0' | |
# (complex) | |
# | |
query_string = "QUERY_STRING" | |
result_array = [200, { "Content-Type" => "text/html" }, []] | |
regexp = /\Aquery=([^&]+)&ids=([^&]+)&offset=([^\z]+)/ | |
define_method :call do |env| | |
_, query, ids, offset = *env[query_string].match(regexp) | |
results = books.search query, ids || 20, offset || 0 | |
result_array[2][0] = results.to_json | |
result_array | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load application. | |
# | |
require File.expand_path '../nosinatra', __FILE__ | |
# Load all indexes. | |
# | |
Picky::Indexes.load | |
run BookSearch.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On my 2010 MacBook Pro, I get: | |
# | |
Requests per second: 5287.76 [#/sec] (mean) | |
Time per request: 1.891 [ms] (mean) | |
Time per request: 0.189 [ms] (mean, across all concurrent requests) | |
# Using Pen as a load balancer in front of 2 Ricer/Picky servers. | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment