Skip to content

Commit

Permalink
merge load changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Oct 8, 2015
2 parents 89a1914 + 69b0254 commit f8e6275
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 11 deletions.
1 change: 1 addition & 0 deletions Gemfile
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
2 changes: 1 addition & 1 deletion Pro-Changes.md
Expand Up @@ -3,7 +3,7 @@ Sidekiq Pro Changelog

Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.

HEAD
2.1.0
-----------

- Explicit support for sharding batches. You list your Redis shards and
Expand Down
31 changes: 23 additions & 8 deletions bin/sidekiqload
Expand Up @@ -12,12 +12,11 @@ require_relative '../lib/sidekiq/launcher'
include Sidekiq::Util

Sidekiq.configure_server do |config|
config.redis = { db: 13 }
config.redis = { db: 13, port: 6380 }
config.options[:queues] << 'default'
config.logger.level = Logger::ERROR
config.average_scheduled_poll_interval = 2
end
Sidekiq.redis {|c| c.flushdb}

class LoadWorker
include Sidekiq::Worker
Expand All @@ -27,10 +26,22 @@ class LoadWorker
end

def perform(idx)
raise idx.to_s if idx % 100 == 1
#raise idx.to_s if idx % 100 == 1
end
end

# 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"
}])

self_read, self_write = IO.pipe
%w(INT TERM USR1 USR2 TTIN).each do |sig|
begin
Expand All @@ -42,6 +53,7 @@ self_read, self_write = IO.pipe
end
end

Sidekiq.redis {|c| c.flushdb}
def handle_signal(launcher, sig)
Sidekiq.logger.debug "Got #{sig} signal"
case sig
Expand Down Expand Up @@ -114,12 +126,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
9 changes: 9 additions & 0 deletions test/test_web.rb
Expand Up @@ -39,6 +39,15 @@ def perform(a, b)
rackenv = {'HTTP_ACCEPT_LANGUAGE' => 'en-us'}
get '/', {}, rackenv
assert_match(/Dashboard/, last_response.body)
rackenv = {'HTTP_ACCEPT_LANGUAGE' => 'zh-cn'}
get '/', {}, rackenv
assert_match(/信息板/, last_response.body)
rackenv = {'HTTP_ACCEPT_LANGUAGE' => 'zh-tw'}
get '/', {}, rackenv
assert_match(/資訊主頁/, last_response.body)
rackenv = {'HTTP_ACCEPT_LANGUAGE' => 'nb'}
get '/', {}, rackenv
assert_match(/Oversikt/, last_response.body)
end

describe 'busy' do
Expand Down
3 changes: 3 additions & 0 deletions test/test_web_helpers.rb
Expand Up @@ -41,6 +41,9 @@ def test_locale_determination
obj = Helpers.new('HTTP_ACCEPT_LANGUAGE' => 'zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4,ru;q=0.2')
assert_equal 'zh-cn', obj.locale

obj = Helpers.new('HTTP_ACCEPT_LANGUAGE' => 'nb-NO,nb;q=0.2')
assert_equal 'nb', obj.locale

obj = Helpers.new('HTTP_ACCEPT_LANGUAGE' => 'en-us; *')
assert_equal 'en', obj.locale

Expand Down
12 changes: 10 additions & 2 deletions web/locales/no.yml → web/locales/nb.yml
@@ -1,5 +1,5 @@
# elements like %{queue} are variables and should not be translated
no:
nb:
Dashboard: Oversikt
Status: Status
Time: Tid
Expand Down Expand Up @@ -33,6 +33,7 @@ no:
NextRetry: Neste forsøk
RetryCount: Antall forsøk
RetryNow: Forsøk igjen nå
Kill: Kill
LastRetry: Forrige forsøk
OriginallyFailed: Feilet opprinnelig
AreYouSure: Er du sikker?
Expand All @@ -58,7 +59,6 @@ no:
OneMonth: 1 måned
ThreeMonths: 3 måneder
SixMonths: 6 måneder
Batches: Samlinger
Failures: Feil
DeadJobs: Døde jobber
NoDeadJobsFound: Ingen døde jobber funnet
Expand All @@ -67,3 +67,11 @@ no:
Thread: Tråd
Threads: Tråder
Jobs: Jobber
Paused: Pauset
Stop: Stopp
Quiet: Demp
StopAll: Stopp alle
QuietAll: Demp alle
PollingInterval: Oppdateringsintervall
Plugins: Innstikk
NotYetEnqueued: Ikke køet enda

0 comments on commit f8e6275

Please sign in to comment.