Nick S. wrote:
Good point, but that still slows it down (with WEBrick not being the
fastest server on the planet).
I don’t think WEBrick itself is much of a problem. About a month ago, in
the thread “Webrick in production?”, Eric H. wrote:
On Feb 27, 2006, at 9:55 PM, Ben M. wrote:
Eric H. wrote:
I serve over two million image hits a day via WEBrick and startup
and shutdown are handled by FreeBSD’s rc.subr just like apache.
So what about the mythical “mutex on each request” that WEBrick has?
I don’t know about Rails, but no such thing exists in WEBrick. (Note
that I’m not using WEBrick to serve Rails requests, I’m using it for
You don’t ever have long page waits?
Do you consider ~ 50-60ms long? A typical request is handled in the
There still may be a few optimizations I can make in the image lookup
code that will reduce the standard deviation.
It never crashes?
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
www 6036 2.0 0.5 25268 10040 ?? S Sun11PM 23:00.12
Is this one instance of WEBrick handling all those hits?
I fork 8 processes per machine on three machines to distribute the load
a little better since static image requests are very bursty and I have
machines with multiple CPUs. I may cut it back to 6 or 4 processes now
that I correctly handle conditional HTTP requests to save on memory.
(2% CPU is high for these processes.)
I ask because I’ve wished for a web container to run my rails apps
in, and WEBrick could be that other than for all the stern warnings
about it not being suitable for production.
I can’t tell you if Rails + WEBrick is suitable for serving high-volume
traffic or not, I haven’t looked. WEBrick itself is certainly suitable
for high-volume traffic when you write your servlets correctly (and,
possibly, fork()). Rails may simply be missing something that allows it
to run well multi-threaded.
(Been meaning to check out Mongrel too… but I’m still on 1.82)
If I can serve static images with a lookup in MogileFS in 12ms and
Apache can serve static content without any lookups straight off disk in
6ms I don’t see what benefit Mongrel would give me.
My speed boost comes from using sendfile(). WEBrick makes it easy to
match a URL with a File so I can pass it right in.
But it is the case that Rails itself is single-threaded, and this means
that Rails on WEBrick can only handle one request at a time