rainbows slower?

Eric Wong normalperson at yhbt.net
Fri Jun 8 17:39:20 UTC 2012

Joseph McDonald <superjoe at gmail.com> wrote:
> Hi,
> I have a "hello world" sinatra app, benchmark:
> ab -n 1000 -c 100 http://$mysite/
> Total transferred:      264000 bytes
> HTML transferred:       13000 bytes
> Requests per second:    308.76 [#/sec] (mean)
> Time per request:       323.871 [ms] (mean)
> Time per request:       3.239 [ms] (mean, across all concurrent requests)
> If I put rainbows in front of it, I get:
> Total transferred:      272000 bytes
> HTML transferred:       13000 bytes
> Requests per second:    61.62 [#/sec] (mean)
> Time per request:       1622.745 [ms] (mean)
> Time per request:       16.227 [ms] (mean, across all concurrent requests)
> rainbow config looks like:
> worker_processes 7  # i'm on an 8 core system
> Rainbows! do
>   use :EventMachine   # sinatra app using "thin"
>   worker_connections 1024
> end

What is your RACK_ENV set to?  I'm not sure how Thin sets it or defaults
to, but you can pass the "-E" switch to Rainbows!:

  rainbows -E none ...

(or use the RACK_ENV environment variable)

Iff you're on Linux, and RACK_ENV doesn't help, can you try:

  listen host_port, :tcp_defer_accept => false

I still need to investigate what (I think) is a bug in Linux which
makes TCP_DEFER_ACCEPT behave erratically.

> config.ru looks like:
> require './webserver'
> run Sinatra::Application

Can you show us your application?

> ruby version is: ruby 1.9.3p194
> I tried telling apachebench to use keepalives (-k) and that slowed
> rainbows down more (and sped up the straight sinatra app).
> I have changed worker_processes and worker_connections with no effect.
>  I added keepalive_timeout 0 to the Rainbows! block with no effect.

Can you also verify your app is setting Content-Length (or
Transfer-Encoding: chunked) in its responses?

> any idea why rainbows is slower?  I'd like to take advantage of all my
> cores.

I've listed what I can think of above.  Thanks for giving Rainbows!
a short.  I'd like to figure out why performance is worse, too.

More information about the rainbows-talk mailing list