redis_cluster_cache_benchmark 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/bin/redis_cluster_cache_benchmark +4 -0
- data/bin/worker +17 -0
- data/examples/hiredis.yml +3 -0
- data/examples/redis-cache.conf +117 -0
- data/examples/w1r10.rb +10 -0
- data/lib/redis_cluster_cache_benchmark.rb +9 -0
- data/lib/redis_cluster_cache_benchmark/cli.rb +27 -0
- data/lib/redis_cluster_cache_benchmark/logging_client.rb +32 -0
- data/lib/redis_cluster_cache_benchmark/memory_storage.rb +20 -0
- data/lib/redis_cluster_cache_benchmark/spawner.rb +85 -0
- data/lib/redis_cluster_cache_benchmark/summary.rb +38 -0
- data/lib/redis_cluster_cache_benchmark/version.rb +3 -0
- data/lib/redis_cluster_cache_benchmark/worker.rb +68 -0
- data/redis_cluster_cache_benchmark.gemspec +30 -0
- data/spec/redis_cluster_cache_benchmark_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +170 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6a02c9c6f2939f400e5226fc9aca6101f7a744f5
|
4
|
+
data.tar.gz: 53c7df4eb1d340e9eb767003d19c015a8d5991d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1300605cecf388848c09338610537182de324a343f1c0127a467cb12a173594c5d0729df79fcba4fa00d650f08dd3394b027e4595f57b6590b964eec5265c48c
|
7
|
+
data.tar.gz: d43404fe8ec96d0faa36324e7fcedd8ede3008f76c89079f1e850fa813d88f19a07bb7385a6619cd667f28f61fdd0866cb4d73102f8c8290f25dedd2b14585b8
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 akima
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# RedisClusterCacheBenchmark
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'redis_cluster_cache_benchmark'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install redis_cluster_cache_benchmark
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/redis_cluster_cache_benchmark/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/worker
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path("../../lib", __FILE__)
|
3
|
+
|
4
|
+
require 'redis_cluster_cache_benchmark'
|
5
|
+
require 'tengine/support/yaml_with_erb'
|
6
|
+
|
7
|
+
options = {
|
8
|
+
scenario: nil,
|
9
|
+
classname: nil,
|
10
|
+
config_path: nil,
|
11
|
+
}
|
12
|
+
ENV.each do |k, v|
|
13
|
+
next unless k =~ /\ARCCB_/
|
14
|
+
options[k.sub(/\ARCCB_/, '').downcase.to_sym] = v
|
15
|
+
end
|
16
|
+
|
17
|
+
RedisClusterCacheBenchmark::Worker.new(options).run
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#
|
2
|
+
#
|
3
|
+
# see https://raw.github.com/antirez/redis/2.6/redis.conf
|
4
|
+
#
|
5
|
+
#
|
6
|
+
|
7
|
+
# Specify the server verbosity level.
|
8
|
+
# This can be one of:
|
9
|
+
# debug (a lot of information, useful for development/testing)
|
10
|
+
# verbose (many rarely useful info, but not a mess like the debug level)
|
11
|
+
# notice (moderately verbose, what you want in production probably)
|
12
|
+
# warning (only very important / critical messages are logged)
|
13
|
+
loglevel notice
|
14
|
+
|
15
|
+
################################ SNAPSHOTTING #################################
|
16
|
+
#
|
17
|
+
# Save the DB on disk:
|
18
|
+
#
|
19
|
+
# save <seconds> <changes>
|
20
|
+
#
|
21
|
+
# Will save the DB if both the given number of seconds and the given
|
22
|
+
# number of write operations against the DB occurred.
|
23
|
+
#
|
24
|
+
# In the example below the behaviour will be to save:
|
25
|
+
# after 900 sec (15 min) if at least 1 key changed
|
26
|
+
# after 300 sec (5 min) if at least 10 keys changed
|
27
|
+
# after 60 sec if at least 10000 keys changed
|
28
|
+
#
|
29
|
+
# Note: you can disable saving at all commenting all the "save" lines.
|
30
|
+
#
|
31
|
+
# It is also possible to remove all the previously configured save
|
32
|
+
# points by adding a save directive with a single empty string argument
|
33
|
+
# like in the following example:
|
34
|
+
#
|
35
|
+
# save ""
|
36
|
+
|
37
|
+
# save 900 1
|
38
|
+
# save 300 10
|
39
|
+
# save 60 10000
|
40
|
+
|
41
|
+
save ""
|
42
|
+
|
43
|
+
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
|
44
|
+
# is reached. You can select among five behaviors:
|
45
|
+
#
|
46
|
+
# volatile-lru -> remove the key with an expire set using an LRU algorithm
|
47
|
+
# allkeys-lru -> remove any key accordingly to the LRU algorithm
|
48
|
+
# volatile-random -> remove a random key with an expire set
|
49
|
+
# allkeys-random -> remove a random key, any key
|
50
|
+
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
|
51
|
+
# noeviction -> don't expire at all, just return an error on write operations
|
52
|
+
#
|
53
|
+
# Note: with any of the above policies, Redis will return an error on write
|
54
|
+
# operations, when there are not suitable keys for eviction.
|
55
|
+
#
|
56
|
+
# At the date of writing this commands are: set setnx setex append
|
57
|
+
# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
|
58
|
+
# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
|
59
|
+
# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
|
60
|
+
# getset mset msetnx exec sort
|
61
|
+
#
|
62
|
+
# The default is:
|
63
|
+
#
|
64
|
+
# maxmemory-policy volatile-lru
|
65
|
+
|
66
|
+
maxmemory-policy allkeys-lru
|
67
|
+
|
68
|
+
# The name of the append only file (default: "appendonly.aof")
|
69
|
+
# appendfilename appendonly.aof
|
70
|
+
|
71
|
+
# The fsync() call tells the Operating System to actually write data on disk
|
72
|
+
# instead to wait for more data in the output buffer. Some OS will really flush
|
73
|
+
# data on disk, some other OS will just try to do it ASAP.
|
74
|
+
#
|
75
|
+
# Redis supports three different modes:
|
76
|
+
#
|
77
|
+
# no: don't fsync, just let the OS flush the data when it wants. Faster.
|
78
|
+
# always: fsync after every write to the append only log . Slow, Safest.
|
79
|
+
# everysec: fsync only one time every second. Compromise.
|
80
|
+
#
|
81
|
+
# The default is "everysec", as that's usually the right compromise between
|
82
|
+
# speed and data safety. It's up to you to understand if you can relax this to
|
83
|
+
# "no" that will let the operating system flush the output buffer when
|
84
|
+
# it wants, for better performances (but if you can live with the idea of
|
85
|
+
# some data loss consider the default persistence mode that's snapshotting),
|
86
|
+
# or on the contrary, use "always" that's very slow but a bit safer than
|
87
|
+
# everysec.
|
88
|
+
#
|
89
|
+
# More details please check the following article:
|
90
|
+
# http://antirez.com/post/redis-persistence-demystified.html
|
91
|
+
#
|
92
|
+
# If unsure, use "everysec".
|
93
|
+
|
94
|
+
appendfsync no
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
|
100
|
+
# order to help rehashing the main Redis hash table (the one mapping top-level
|
101
|
+
# keys to values). The hash table implementation Redis uses (see dict.c)
|
102
|
+
# performs a lazy rehashing: the more operation you run into an hash table
|
103
|
+
# that is rehashing, the more rehashing "steps" are performed, so if the
|
104
|
+
# server is idle the rehashing is never complete and some more memory is used
|
105
|
+
# by the hash table.
|
106
|
+
#
|
107
|
+
# The default is to use this millisecond 10 times every second in order to
|
108
|
+
# active rehashing the main dictionaries, freeing memory when possible.
|
109
|
+
#
|
110
|
+
# If unsure:
|
111
|
+
# use "activerehashing no" if you have hard latency requirements and it is
|
112
|
+
# not a good thing in your environment that Redis can reply form time to time
|
113
|
+
# to queries with 2 milliseconds delay.
|
114
|
+
#
|
115
|
+
# use "activerehashing yes" if you don't have such hard requirements but
|
116
|
+
# want to free memory asap when possible.
|
117
|
+
activerehashing no
|
data/examples/w1r10.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require "redis_cluster_cache_benchmark/version"
|
2
|
+
|
3
|
+
module RedisClusterCacheBenchmark
|
4
|
+
autoload :Spawner , "redis_cluster_cache_benchmark/spawner"
|
5
|
+
autoload :Worker , "redis_cluster_cache_benchmark/worker"
|
6
|
+
autoload :LoggingClient, "redis_cluster_cache_benchmark/logging_client"
|
7
|
+
autoload :MemoryStorage, "redis_cluster_cache_benchmark/memory_storage"
|
8
|
+
autoload :Summary , "redis_cluster_cache_benchmark/summary"
|
9
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'redis_cluster_cache_benchmark'
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
options = {
|
6
|
+
name: nil,
|
7
|
+
process: 10,
|
8
|
+
repeat: 1,
|
9
|
+
scenario: nil,
|
10
|
+
classname: nil,
|
11
|
+
log_dir: File.expand_path("./log"),
|
12
|
+
}
|
13
|
+
|
14
|
+
OptionParser.new{|opt|
|
15
|
+
opt.version = RedisClusterCacheBenchmark::VERSION
|
16
|
+
opt.on("-N", "--name=#{options[:name]}" , "name of test pattern" ){|v| options[:name] = v }
|
17
|
+
opt.on("-p", "--process=#{options[:process]}" , "number of process" ){|v| options[:process] = v.to_i }
|
18
|
+
opt.on("-r", "--repeat=#{options[:repeat]}" , "number of repeat" ){|v| options[:repeat] = v.to_i }
|
19
|
+
opt.on("-s", "--scenario=#{options[:scenario]}" , "path to scenario file"){|v| options[:scenario] = v }
|
20
|
+
opt.on("-C", "--classname=#{options[:classname]}", "client class name" ){|v| options[:classname] = v }
|
21
|
+
opt.on("-c", "--config=#{options[:config_path]}" , "path to config file" ){|v| options[:config_path] = v }
|
22
|
+
opt.on("-l", "--log-dir=#{options[:log_dir]}" , "path to log file directory"){|v| options[:log_dir] = v }
|
23
|
+
}.parse!
|
24
|
+
|
25
|
+
raise "--name must be given." unless options[:name]
|
26
|
+
|
27
|
+
RedisClusterCacheBenchmark::Spawner.new(options).run
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "redis_cluster_cache_benchmark"
|
2
|
+
|
3
|
+
module RedisClusterCacheBenchmark
|
4
|
+
class LoggingClient
|
5
|
+
def initialize(impl, logger)
|
6
|
+
@impl = impl
|
7
|
+
@logger = logger
|
8
|
+
end
|
9
|
+
|
10
|
+
def get(key)
|
11
|
+
__logging__("[GET]"){ @impl.get(key) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def set(key, value, options = {})
|
15
|
+
__logging__("[SET]"){ @impl.set(key, value, options) }
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
MEGA = 1_000_000
|
21
|
+
|
22
|
+
def __logging__(msg = nil)
|
23
|
+
t0 = Time.now.to_f
|
24
|
+
begin
|
25
|
+
return yield
|
26
|
+
ensure
|
27
|
+
@logger.info("%s %6.9f microsec" % [msg, (Time.now.to_f - t0) * MEGA])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "redis_cluster_cache_benchmark"
|
2
|
+
|
3
|
+
module RedisClusterCacheBenchmark
|
4
|
+
class MemoryStorage
|
5
|
+
attr_accessor :logger
|
6
|
+
|
7
|
+
def initialize(*)
|
8
|
+
@impl = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(key)
|
12
|
+
@impl[key]
|
13
|
+
end
|
14
|
+
|
15
|
+
def set(key, value, options = {})
|
16
|
+
@impl[key] = value
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'redis_cluster_cache_benchmark'
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module RedisClusterCacheBenchmark
|
6
|
+
class Spawner
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@base_name = "%s_%s_p%d_r%d" % [options[:classname] || 'Memory', options[:name], options[:process], options[:repeat]]
|
10
|
+
@process_number = options.delete(:process).to_i
|
11
|
+
@process_number = 5 if @process_number < 1
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
FileUtils.mkdir_p(@options[:log_dir])
|
17
|
+
redis_server_starting_rss = process_rss("redis-server")
|
18
|
+
options = @options.each_with_object({}) do |(k,v), d|
|
19
|
+
unless v.to_s.empty?
|
20
|
+
d["RCCB_#{k.upcase}"] = v.to_s
|
21
|
+
end
|
22
|
+
end
|
23
|
+
cmd = File.expand_path("../../../bin/worker", __FILE__)
|
24
|
+
log_path_base = File.expand_path("#{@base_name}.log", @options[:log_dir])
|
25
|
+
system("rm #{log_path_base}.*")
|
26
|
+
pids = []
|
27
|
+
@process_number.times do |idx|
|
28
|
+
if log_path_base
|
29
|
+
options["RCCB_LOG_PATH"] = "#{log_path_base}.#{idx + 1}"
|
30
|
+
end
|
31
|
+
options["RCCB_WORKER_NO"] = (idx + 1).to_s
|
32
|
+
pids << Kernel.spawn(options, cmd)
|
33
|
+
end
|
34
|
+
pids.each do |pid|
|
35
|
+
begin
|
36
|
+
Process.waitpid(pid)
|
37
|
+
rescue Errno::ECHILD => e
|
38
|
+
$stderr.puts("WARN [#{e.class}] #{e.message}")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
redis_server_completed_rss = process_rss("redis-server")
|
42
|
+
system("cat #{log_path_base}.* > #{log_path_base}")
|
43
|
+
system("grep \"\\[GET\\]\" #{log_path_base} > #{log_path_base}.get")
|
44
|
+
system("grep \"\\[SET\\]\" #{log_path_base} > #{log_path_base}.set")
|
45
|
+
system("grep \"\\[RSS\\] starting\" #{log_path_base} > #{log_path_base}.rss_starting")
|
46
|
+
system("grep \"\\[RSS\\] completed\" #{log_path_base} > #{log_path_base}.rss_completed")
|
47
|
+
|
48
|
+
File.open(File.expand_path("#{@base_name}.md", @options[:log_dir]), "w") do |f|
|
49
|
+
calc_array_summary(f, "#{log_path_base}.get", "[GET]", / ([\d\.]+) microsec\Z/, "%3s: %9.3f microsec")
|
50
|
+
calc_array_summary(f, "#{log_path_base}.set", "[SET]", / ([\d\.]+) microsec\Z/, "%3s: %9.3f microsec")
|
51
|
+
calc_array_summary(f, "#{log_path_base}.rss_starting" , "memory before start" , / \d+: (\d+) KB\Z/, "%3s: %d KB")
|
52
|
+
calc_array_summary(f, "#{log_path_base}.rss_completed", "memory after complete", / \d+: (\d+) KB\Z/, "%3s: %d KB")
|
53
|
+
f.puts
|
54
|
+
f.puts "redis-server"
|
55
|
+
f.puts "starting : #{redis_server_starting_rss} KB"
|
56
|
+
f.puts "completed: #{redis_server_completed_rss} KB"
|
57
|
+
end
|
58
|
+
system("rm #{log_path_base}.*")
|
59
|
+
end
|
60
|
+
|
61
|
+
def calc_array_summary(f, path, caption, pattern, fmt)
|
62
|
+
values = []
|
63
|
+
File.open(path) do |f|
|
64
|
+
f.each_line do |line|
|
65
|
+
values.push line.scan(pattern).flatten.first.to_f
|
66
|
+
end
|
67
|
+
end
|
68
|
+
summary = Summary.new(values)
|
69
|
+
f.puts
|
70
|
+
f.puts caption
|
71
|
+
f.puts "cnt: #{summary[:cnt]}"
|
72
|
+
%w[sum avg max 99 95 90 80 50 min].each do |k|
|
73
|
+
f.puts fmt % [k, summary[k].to_f]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def process_rss(command_name)
|
78
|
+
r = `ps a -o pid,command | grep #{command_name} | grep -v grep\\ #{command_name}`
|
79
|
+
return 0 if r.nil? || r.empty?
|
80
|
+
pid = r.strip.split(/\s+/, 2).first.to_i
|
81
|
+
`ps -o rss= -p #{pid}`.to_i
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RedisClusterCacheBenchmark
|
3
|
+
class Summary
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
DEFAULT_POSITIONS = [99, 95, 90, 80, 50].freeze
|
7
|
+
|
8
|
+
# @param [Array<Numeric>] values 整数あるいは実数の配列
|
9
|
+
def initialize(values, positions = DEFAULT_POSITIONS)
|
10
|
+
values = values.sort
|
11
|
+
cnt = values.empty? ? 0 : values.length
|
12
|
+
sum = values.empty? ? 0 : values.inject(:+)
|
13
|
+
@hash = {
|
14
|
+
cnt: cnt,
|
15
|
+
sum: sum,
|
16
|
+
avg: (cnt == 0) ? 0 : sum / cnt,
|
17
|
+
min: values.first || 0,
|
18
|
+
max: values.last || 0,
|
19
|
+
}
|
20
|
+
positions.each do |pos|
|
21
|
+
idx = (cnt * pos / 100).round
|
22
|
+
@hash[pos.to_s.to_sym] = values[idx] || 0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_hash
|
27
|
+
@hash.dup
|
28
|
+
end
|
29
|
+
|
30
|
+
def each(&block)
|
31
|
+
@hash.each(&block)
|
32
|
+
end
|
33
|
+
|
34
|
+
def [](key)
|
35
|
+
@hash[key.to_s.to_sym]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require "redis_cluster_cache_benchmark"
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
require 'redis'
|
6
|
+
require 'redis-sentinel'
|
7
|
+
require 'redis_wmrs'
|
8
|
+
|
9
|
+
module RedisClusterCacheBenchmark
|
10
|
+
class Worker
|
11
|
+
def initialize(options)
|
12
|
+
@options = options
|
13
|
+
@repeat = (options[:repeat] || 1).to_i
|
14
|
+
@worker_no = (options[:worker_no] || 0).to_i
|
15
|
+
@classname = load_option(:classname, "RedisClusterCacheBenchmark::MemoryStorage")
|
16
|
+
@log_path = load_option(:log_path)
|
17
|
+
@config_path = load_option(:config_path)
|
18
|
+
@scenario = load_option(:scenario)
|
19
|
+
end
|
20
|
+
|
21
|
+
def load_option(key, default_value = nil)
|
22
|
+
r = @options[key]
|
23
|
+
r = nil if r && r.empty?
|
24
|
+
r || default_value
|
25
|
+
end
|
26
|
+
|
27
|
+
def logger
|
28
|
+
unless @logger
|
29
|
+
@logger = Logger.new(@log_path || $stdout)
|
30
|
+
@logger.level = Logger::INFO
|
31
|
+
end
|
32
|
+
@logger
|
33
|
+
end
|
34
|
+
|
35
|
+
def new_client
|
36
|
+
config =
|
37
|
+
@config_path ? YAML.load_file_with_erb(@config_path) :
|
38
|
+
{host: "127.0.0.1", port: 6379}
|
39
|
+
case @classname
|
40
|
+
when 'Redis', 'RedisWmrs' then
|
41
|
+
klass = Object.const_get(@classname)
|
42
|
+
original = klass.new(config)
|
43
|
+
original.client.logger = logger
|
44
|
+
return LoggingClient.new(original, logger)
|
45
|
+
when "RedisClusterCacheBenchmark::MemoryStorage" then
|
46
|
+
original = RedisClusterCacheBenchmark::MemoryStorage.new
|
47
|
+
original.logger = logger
|
48
|
+
return LoggingClient.new(original, logger)
|
49
|
+
else
|
50
|
+
raise "Unknown classname: #{@classname.inspect}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def run
|
55
|
+
$client = new_client
|
56
|
+
len = @repeat.to_s.length
|
57
|
+
logger.info("[RSS] starting #{@worker_no}: %d KB" % `ps -o rss= -p #{Process.pid}`.to_i)
|
58
|
+
@repeat.times do |idx|
|
59
|
+
begin
|
60
|
+
load(@scenario)
|
61
|
+
ensure
|
62
|
+
logger.info("No.%3d scenario %*d/%*d finished" % [@worker_no, len, idx + 1, len, @repeat])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
logger.info("[RSS] completed #{@worker_no}: %d KB" % `ps -o rss= -p #{Process.pid}`.to_i)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'redis_cluster_cache_benchmark/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "redis_cluster_cache_benchmark"
|
8
|
+
spec.version = RedisClusterCacheBenchmark::VERSION
|
9
|
+
spec.authors = ["akima"]
|
10
|
+
spec.email = ["akm2000@gmail.com"]
|
11
|
+
spec.summary = %q{redis benchmark as a cache}
|
12
|
+
spec.description = %q{redis benchmark as a cache}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "redis"
|
22
|
+
spec.add_runtime_dependency "redis-sentinel"
|
23
|
+
spec.add_runtime_dependency "redis_wmrs"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "tengine_support", "~> 1.2.0"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redis_cluster_cache_benchmark
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- akima
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: redis
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: redis-sentinel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: redis_wmrs
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tengine_support
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.2.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: redis benchmark as a cache
|
112
|
+
email:
|
113
|
+
- akm2000@gmail.com
|
114
|
+
executables:
|
115
|
+
- redis_cluster_cache_benchmark
|
116
|
+
- worker
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".travis.yml"
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- bin/redis_cluster_cache_benchmark
|
128
|
+
- bin/worker
|
129
|
+
- examples/hiredis.yml
|
130
|
+
- examples/redis-cache.conf
|
131
|
+
- examples/w1r10.rb
|
132
|
+
- lib/redis_cluster_cache_benchmark.rb
|
133
|
+
- lib/redis_cluster_cache_benchmark/cli.rb
|
134
|
+
- lib/redis_cluster_cache_benchmark/logging_client.rb
|
135
|
+
- lib/redis_cluster_cache_benchmark/memory_storage.rb
|
136
|
+
- lib/redis_cluster_cache_benchmark/spawner.rb
|
137
|
+
- lib/redis_cluster_cache_benchmark/summary.rb
|
138
|
+
- lib/redis_cluster_cache_benchmark/version.rb
|
139
|
+
- lib/redis_cluster_cache_benchmark/worker.rb
|
140
|
+
- redis_cluster_cache_benchmark.gemspec
|
141
|
+
- spec/redis_cluster_cache_benchmark_spec.rb
|
142
|
+
- spec/spec_helper.rb
|
143
|
+
homepage: ''
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
metadata: {}
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 2.2.2
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: redis benchmark as a cache
|
167
|
+
test_files:
|
168
|
+
- spec/redis_cluster_cache_benchmark_spec.rb
|
169
|
+
- spec/spec_helper.rb
|
170
|
+
has_rdoc:
|