Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad request error using derailed_benchmarks gem

I am trying to use the derailed_benchmark gem to track down a memory leak in a rails app.

When I run the test

USE_SERVER=puma bundle exec derailed exec perf:mem_over_time

the test runs until the memory usage starts to level off, then then the test throws an error:

RuntimeError: Bad request to "curl 'http://localhost:3000/' -s --fail 2>&1" Response:

How do I fix this?

The output is as follows:

perf:mem_over_time
Booting: production
Endpoint: "/"
/Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/derailed_benchmarks-1.3.1/lib/derailed_benchmarks/tasks.rb:72: warning: already initialized constant DERAILED_APP
/Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/derailed_benchmarks-1.3.1/lib/derailed_benchmarks/tasks.rb:23: warning: previous definition of DERAILED_APP was here
Port: 3000
Server: "puma"
Puma 2.16.0 starting...
* Min threads: 0, max threads: 16
* Environment: none
* Listening on tcp://0.0.0.0:3000
PID: 17093
125.01171875
128.15234375
132.0546875
133.5078125
133.68359375
133.8828125
bundler: failed to load command: derailed (/Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/bin/derailed)
RuntimeError: Bad request to "curl 'http://localhost:3000/' -s --fail 2>&1" Response:
""
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/derailed_benchmarks-1.3.1/lib/derailed_benchmarks/tasks.rb:85:in `call_app'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/derailed_benchmarks-1.3.1/lib/derailed_benchmarks/tasks.rb:174:in `block (3 levels) in <top (required)>'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/derailed_benchmarks-1.3.1/lib/derailed_benchmarks/tasks.rb:173:in `times'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/derailed_benchmarks-1.3.1/lib/derailed_benchmarks/tasks.rb:173:in `block (2 levels) in <top (required)>'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
  /Users/Chris/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/derailed_benchmarks-1.3.1/bin/derailed:41:in `exec'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/gems/derailed_benchmarks-1.3.1/bin/derailed:92:in `<top (required)>'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/bin/derailed:23:in `load'
  /Users/Chris/.rvm/gems/ruby-2.2.1@golf_mentor221/bin/derailed:23:in `<top (required)>'
like image 896
Obromios Avatar asked May 19 '16 10:05

Obromios


3 Answers

With help from the derailed_benchmark team, I found that it was because I was using the rack-attack gem to throttle requests.

like image 91
Obromios Avatar answered Oct 05 '22 23:10

Obromios


I had a similar issue

derailed_benchmarks-1.3.4/lib/derailed_benchmarks/tasks.rb:106:in `call_app': Bad request: <html><body>You are being <a href="https://example.org/api/v0/valid">redirected</a>.</body></html> (RuntimeError)

Mine was caused by a production only configuration to enforce SSL either:

config.force_ssl=true

or

config.middleware.insert_before ActionDispatch::Static, Rack::SslEnforcer, only_environments: ['production', 'staging']

I commented these out to get past that issue

like image 42
stujo Avatar answered Oct 05 '22 23:10

stujo


In my case, it is because I needed to tell derailed to use puma as the server.

USE_SERVER=puma bundle exec derailed exec perf:mem_over_time
like image 26
frostymarvelous Avatar answered Oct 05 '22 22:10

frostymarvelous