1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Add 1ms of latency to benchmarks

This commit is contained in:
Mike Perham 2015-10-07 16:56:10 -07:00
parent 561d9d43d7
commit 3d805807d7
2 changed files with 25 additions and 7 deletions

View file

@ -4,6 +4,7 @@ gemspec
gem 'rails', '~> 4.2'
gem 'simplecov'
gem 'minitest'
gem 'toxiproxy'
platforms :rbx do
gem 'rubysl', '~> 2.0' # if using anything in the ruby standard library

View file

@ -11,8 +11,22 @@ require_relative '../lib/sidekiq/launcher'
include Sidekiq::Util
# brew tap shopify/shopify
# brew install toxiproxy
# gem install toxiproxy
require 'toxiproxy'
# simulate a non-localhost network for realer-world conditions.
# adding 1ms of network latency has an ENORMOUS impact on benchmarks
Toxiproxy.populate([{
"name": "redis",
"listen": "127.0.0.1:6380",
"upstream": "127.0.0.1:6379"
}])
Sidekiq.configure_server do |config|
config.redis = { db: 13 }
config.redis = { db: 13, port: 6380 }
#config.redis = { db: 13 }
config.options[:queues] << 'default'
config.logger.level = Logger::ERROR
config.average_scheduled_poll_interval = 2
@ -27,7 +41,7 @@ class LoadWorker
end
def perform(idx)
raise idx.to_s if idx % 100 == 1
#raise idx.to_s if idx % 100 == 1
end
end
@ -114,6 +128,8 @@ end
begin
#RubyProf::exclude_threads = [ Monitoring ]
#RubyProf.start
Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
launcher = Sidekiq::Launcher.new(Sidekiq.options)
launcher.run
@ -121,6 +137,7 @@ begin
signal = readable_io.first[0].gets.strip
handle_signal(launcher, signal)
end
end
rescue SystemExit => e
#Sidekiq.logger.error("Profiling...")
#result = RubyProf.stop