Skip to content

Commit

Permalink
Add 1ms of latency to benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Oct 7, 2015
1 parent 561d9d4 commit 3d80580
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 24 additions & 7 deletions bin/sidekiqload
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -114,12 +128,15 @@ end
begin
#RubyProf::exclude_threads = [ Monitoring ]
#RubyProf.start
launcher = Sidekiq::Launcher.new(Sidekiq.options)
launcher.run
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

while readable_io = IO.select([self_read])
signal = readable_io.first[0].gets.strip
handle_signal(launcher, signal)
while readable_io = IO.select([self_read])
signal = readable_io.first[0].gets.strip
handle_signal(launcher, signal)
end
end
rescue SystemExit => e
#Sidekiq.logger.error("Profiling...")
Expand Down

0 comments on commit 3d80580

Please sign in to comment.