Rainbows! Rack HTTP server user/dev discussion
 help / color / Atom feed
* rainbows slower?
@ 2012-06-08 16:04 Joseph McDonald
       [not found] ` <CAKN4AWvqRyxTMOVNjc5bGzrkOKGZJ6TsTwBuYu_ZekXaeqT9ag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph McDonald @ 2012-06-08 16:04 UTC (permalink / raw)
  To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw

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

config.ru looks like:
require './webserver'
run Sinatra::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.

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

thanks,
Joe
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: rainbows slower?
       [not found] ` <CAKN4AWvqRyxTMOVNjc5bGzrkOKGZJ6TsTwBuYu_ZekXaeqT9ag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-06-08 17:39   ` Eric Wong
       [not found]     ` <20120608173920.GA20100-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2012-06-08 17:39 UTC (permalink / raw)
  To: Rainbows! list

Joseph McDonald <superjoe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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.
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: rainbows slower?
       [not found]     ` <20120608173920.GA20100-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
@ 2012-06-08 23:31       ` Eric Wong
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Wong @ 2012-06-08 23:31 UTC (permalink / raw)
  To: Rainbows! list; +Cc: Joseph McDonald

Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org> wrote:
> 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)

I suspect it's RACK_ENV being "development" by default and slowing
things down heavily (Rack::Lint).  I wasn't able to reproduce the
drastic differences between thin and Rainbows with RACK_ENV=none on
Rack::Lobster.  Not a real app I know, but in the absence of a real one,
it's all I've got.

I used the following config.ru
------------------------------
require "rack/lobster"
use Rack::ContentLength
use Rack::ContentType
run Rack::Lobster.new
------------------------------

and my rainbows.conf.rb
------------------------------
worker_processes 2 # only 2 cores on this machine, I also tried with 1
Rainbows! do
  use :EventMachine
  worker_connections 1024
end
------------------------------

thin 1.3.1
rainbows 4.3.1
rack 1.4.1
Ruby 1.9.3-p194
Linux 3.4.1 on x86-64

Commands used:
	ab -n 1000 -c 100 -k http://127.0.0.1:3000/
	RACK_ENV=none thin start -R config.ru
	RACK_ENV=none rainbows -c rainbows.conf.rb config.ru -p 3000

I tested without keepalives (-k), too but again, it's too close
to say one server is faster than another based on Rack::Lobster.
For "hello world"-type apps, Rainbows! will use worker_processes
more effectively with keepalives.
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-08 16:04 rainbows slower? Joseph McDonald
     [not found] ` <CAKN4AWvqRyxTMOVNjc5bGzrkOKGZJ6TsTwBuYu_ZekXaeqT9ag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-08 17:39   ` Eric Wong
     [not found]     ` <20120608173920.GA20100-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-06-08 23:31       ` Eric Wong

Rainbows! Rack HTTP server user/dev discussion

Archives are clonable:
	git clone --mirror http://bogomips.org/rainbows-public
	git clone --mirror http://ou63pmih66umazou.onion/rainbows-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.rainbows
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.rainbows

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git