Hi,
I am working on a mini site that will run capistrano with different configuration. So I use combination of sidekiq and cap. Inside the sidekiq worker I call system "cap production deploy". But before that, I want to stress test the code with a simple rake task (see below). The task is just printing the application variable.
When I run once
(1..1).each {|i| HardWorker.perform_async('test',i)}
the output is great because it's finished in 0.709 sec for each worker to finish
When I run five times like so:
(1..5).each {|i| HardWorker.perform_async('test',i)}
the output took double the time 1.55 sec for each worker to finish
And it gets worse when I run 15 times like so:
(1..15).each {|i| HardWorker.perform_async('test',i)}
the output become
4.72 sec for each worker So is there anything in particular that cause capistrano to run slower when invoked several time at the same time?
Thank you,
Versions:
- Ruby 2.0
- Capistrano 3.1.0
- Rake / Rails / etc 4.0
Platform:
# app/workers/hard_worker.rb
class HardWorker
include Sidekiq::Worker
def perform(name, count)
puts "Doing hard work #{name} #{count}"
system "cap stress stress:test"
end
end
namespace :stress do
desc "Spit out variable application"
task :test do
puts "application variable => #{fetch(:application)}"
end
end
set :user, "ubuntu"
set :group, "www-data"
#set :use_sudo, false
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# require rvm on remote server to run rake tasks
#require 'capistrano/rvm'
#require helpers
import 'helpers/checks.rb'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('tasks/*.rake').each { |r| import r }
set :custom_variables, "SOMEVARIABLES"
set :format, :pretty
# set :log_level, :info
set :pty, true
set :keep_releases, 3