Why is webrick sooo slow?

G

George Moschovitis

Hello everyone,

I just finished the first working version of the new abstract rendering
pipeline for Nitro. This new pipeline, allows for multiple adaptors
(webrick, fastcgi, cgi, modruby, etc) running the same web application.


Even though the new pipeline is not yet optimized, I run a benchmark to
compare webrick's performance vs fastcgi. I was quite shocked to see
the following results on my trusty old laptop:

$ ab -n 200 -c 5 localhost/index

lighttpd/fastcgi: 175.22 requests/sec
webrick: 29.02 requests/sec

I find this performance delta rather suprising.

On the topic of fastcgi, I always had the following question: Isn't an
apache-fastcgi-rubyserver configuration equivalent to an
apache-mod_proxy-rubyserver configuration?


regards,
George.
 
G

George Moschovitis

Whats makes this performance difference more amazing is that I used the
pure-ruby fcgi library. I 'll try again with the C-version library
later.

-g.
 
G

George Moschovitis

Well,

the C fcgi library was faster as expected:

x1. lighttpd/C-fastcgi: 225.41 requests/sec
x2. lighttpd/ruby-fastcgi: 175.22 requests/sec
x3. webrick: 29.02 requests/sec

x1-x2 is excpected, but I think that x2-x3 is too much.
Any comments?

George.
 
M

Michael Neumann

George said:
Whats makes this performance difference more amazing is that I used the
pure-ruby fcgi library. I 'll try again with the C-version library
later.

hm, what are you doing that you only get 30 req/sec? On my Centrino 1300
laptop, I got 333 req/sec with a simple static WEBrick filehandler (3728
bytes), and still 85 req/sec when using Wee to render the same page, and
165 req/sec just for the action phase in Wee (the real req/sec is of
course 1/(1/85 + 1/165) = 56 ).

Regards,

Michael
 
G

George Moschovitis

Hello Michael,

I hit a page with that session (reads session cookie), there is some
simple
processing and some gfx.

In my benchmark I have 5 concurrent users (ab -n 200 -c 5)

My laptop uses a P3 at 1000 Ghz, this is *much* slower than the
Centrino.

Hmm, maybe I am doing something stupid (like having some debug flags
on). I 'll investigate further? Anyone else, has more comments?

-g.
 
G

George Moschovitis

Well, not only webrick is slow, so is my laptop :)
I got 333 req/sec with a simple static WEBrick filehandler

I benchmark this simple page:

<html>test</html>

with Webricks FileHandler and I got 48 req/seq. This is exactly the
same as I get with the original Nitro benchmark if I dissable the
session from the page.

So the question remains, is Webrick sooo much slowet than
lighttpd/fcgi?

-g.
 
J

Joao Pedrosa

Hi,
So the question remains, is Webrick sooo much slowet than
lighttpd/fcgi?

I'm afraid that total independence of the webservers is not possible
yet. WEBrick is fast enough for development and small servers, and
that's it. :)

Maybe someone could rewrite WEBrick in RubyC. :)

YARV is interesing with the general performance improvements. But how
long till we can run WEBrick on it? :)

When I think about serving large binary files with WEBrick, I soon
realize that we really need webservers.

Cheers,
Joao
 
A

Alexander Kellett

When I think about serving large binary files with WEBrick, I soon
realize that we really need webservers.

with large files the difference is theoretically
*much* lower. its the small files that suffer from
latency problems for a webserver written in pure ruby.

i imagine that ruby2c + some clever profiling will
get some damn impressive results.

Alex
 
A

Alexander Kellett

Note that for raw IO, a well-tuned server can use OS-depended calls
like sendfile(2), which are not directly accessible through Ruby.

but a quick 5 minute ruby/inline job would
make it available on supported platforms :)

Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top