Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 74 lines (56 sloc) 1.723 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

login = "-i ~/.ssh/fauna-default-keypair.pem ec2-user@ec2-23-20-42-109.compute-1.amazonaws.com"

servers = [
  # App folder and subdomain, URL
  ["scala-finagle", "/"],
  ["c-c", "/"],
  ["java-jetty", "/"],
  [ "js-node", "/"],
  ["ruby-sinatr", "/"],
  ["java-tomcat", "/servlet"],
  ["python-bottle", "/"]
]

dynos = ARGV[0].to_i
raise if dynos < 1

# 1 4 7 10

low = 20 * dynos
high = 240 * dynos
step = 10 * dynos
calls = 25
test_time = 30

puts "Dynos: #{dynos}"
puts servers.inspect

dir = "results_#{dynos}"

unless File.exist?(dir)
  Dir.mkdir(dir)
end

def run(command)
  puts "--> #{command}"
  system(command)
end

watcher = Thread.new do
  while(1)
    line = `ssh #{login} \"sudo ps auwx | grep h[t]tperf\"`
    line = line.split(" ")
    if line[9].to_i >= 1
      puts "Killing #{line[1]} (#{line[9]} minutes)"
      run "ssh #{login} sudo kill #{line[1]}"
    end
    sleep(5)
  end
end

Dir.chdir(dir) do
  servers.each do |prefix, uri|
    results = prefix + uri[1..-1] + ".csv"
    output = prefix + uri[1..-1] + ".out"

    autobench = "sudo env PATH=/usr/local/bin:$PATH autobench --single_host --host1 #{prefix}.herokuapp.com --uri1 #{uri} --low_rate #{low} --high_rate #{high} --rate_step #{step} --num_call #{calls} --const_test_time #{test_time} --timeout 30 --output_fmt csv --file #{results} 2>&1 | tee -a #{output}"

    File.unlink(results) if File.exist?(results)
    File.unlink(output) if File.exist?(output)

    puts "*** #{prefix} ***"
    run("cd ../#{prefix} && heroku restart && heroku ps:scale web=#{dynos}")
    sleep(1)
    run("ssh #{login} #{autobench}")
    run("cd ../#{prefix} && heroku ps:scale web=1")
    run("scp #{login}:#{results} .")
  end
end

Thread.kill(watcher)


Something went wrong with that request. Please try again.