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 'rails', '~> 4.2'
gem 'simplecov' gem 'simplecov'
gem 'minitest' gem 'minitest'
gem 'toxiproxy'
platforms :rbx do platforms :rbx do
gem 'rubysl', '~> 2.0' # if using anything in the ruby standard library 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 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| Sidekiq.configure_server do |config|
config.redis = { db: 13 } config.redis = { db: 13, port: 6380 }
#config.redis = { db: 13 }
config.options[:queues] << 'default' config.options[:queues] << 'default'
config.logger.level = Logger::ERROR config.logger.level = Logger::ERROR
config.average_scheduled_poll_interval = 2 config.average_scheduled_poll_interval = 2
@ -27,7 +41,7 @@ class LoadWorker
end end
def perform(idx) def perform(idx)
raise idx.to_s if idx % 100 == 1 #raise idx.to_s if idx % 100 == 1
end end
end end
@ -114,12 +128,15 @@ end
begin begin
#RubyProf::exclude_threads = [ Monitoring ] #RubyProf::exclude_threads = [ Monitoring ]
#RubyProf.start #RubyProf.start
launcher = Sidekiq::Launcher.new(Sidekiq.options) Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
launcher.run Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
launcher = Sidekiq::Launcher.new(Sidekiq.options)
launcher.run
while readable_io = IO.select([self_read]) while readable_io = IO.select([self_read])
signal = readable_io.first[0].gets.strip signal = readable_io.first[0].gets.strip
handle_signal(launcher, signal) handle_signal(launcher, signal)
end
end end
rescue SystemExit => e rescue SystemExit => e
#Sidekiq.logger.error("Profiling...") #Sidekiq.logger.error("Profiling...")