On May 12, 3:08 pm, Peter van Hardenberg <p...@heroku.com> wrote:
> Sinatra only started handling SIGTERM correctly in 1.1, so you could look at 
> the source for that and monkeypatch accordingly.

On May 12, 1:26 pm, Oren Teich <o...@heroku.com> wrote:
> If you are on bamboo, you can put thin in your gemfile on the latest version
> (1.2.11) and you'll get the correct behavior responding to signals.

I've correctly bundled Sinatra 1.2.6 and Thin 1.2.11 gems and
dependencies and unfortunately the error is still showing up.


Here's my test case code. (Replace myapp with your app name). Scroll
to the bottom for the step by step instructions to reproduce the
error.

#### config.ru

require 'rubygems'
require 'bundler'
Bundler.require

require 'myapp'

run Sinatra::Application


#### myapp.rb

require 'sinatra'

get '/' do

  delay = params[:delay].to_f
  sleep(delay)

  queue_depth = env['HTTP_X_HEROKU_QUEUE_DEPTH']
  queue_wait = env['HTTP_X_HEROKU_QUEUE_WAIT_TIME']
  "queue_depth: #{queue_depth} queue_wait: #{queue_wait} delay:
#{delay}"
end


#### heroku_stress_test.rb

require 'rubygems'
require 'typhoeus'
# using typhoeus version 0.1.29

status_code_success = 200

num_threads = 1
num_requests_per_thread = 100
hydra_concurrency = 10

delay = 0.0 # seconds between each thread
url = 'http://myapp.heroku.com/?delay=0.5'

user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US)
AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4'

$total_successes = 0

threads = []

num_threads.times do |i|
  sleep(delay)
  threads << Thread.new {
    hydra = Typhoeus::Hydra.new(:max_concurrency => hydra_concurrency)
    hydra.disable_memoization
    num_requests_per_thread.times do |j|
      request = Typhoeus::Request.new(url)
      request.user_agent = user_agent
      hydra.queue request
      debug = ""
      request.on_complete do |response|
        debug += "\nthread: #{i}"
        debug += " | response.code:#{response.code}"
        debug += " | response.time:#{response.time.to_s}"

        if response.code != status_code_success
          debug += 'error -----'
          debug += response.body
        else
          $total_successes += 1
          debug += "\n"+response.body
        end

        puts "\n"
        puts debug
        p $total_successes

      end
    end
    puts 'hydra.run'
    hydra.run
  }

end

# make sure the program has ended
threads.each do |thread|
  thread.join
end


#### how to reproduce the error:

1. upload myapp to heroku and make sure it works
2. open Heroku resources page for the app
3. place the slider at 10 and "Save and Apply" changes
4. place the slider at 5 but *don't* "Save and Apply" changes yet
5. run heroku_stress_test.rb in your local terminal
6. when responses start flowing in, "Save and Apply" changes in
resources page.
7. you should see a number of errors (error numbers vary)
7. repeat the process multiple times. in my experience I see something
between 0 to 5 request failures (503 errors) each time I run the test
with these dyno numbers.

The dyno numbers are just an example that I've observed have a high
chance of showing errors. I've also tested it with subtracting only
one dyno, and there's a roughly 50% chance of having one request
failing, maybe less.

Worth noting that it seems like the number of errors in this test is
never larger than the number of dynos subtracted. If I subtract one
dyno, not more than 1 error will appear. If I subtract 5, I can
observe up to 5 errors.

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to heroku@googlegroups.com.
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to