Hi, can someone explain to me backgroundrb and mongrel?

hi,
i am trying to grasp some concepts about mongrel, rails, and
backgroundrb on how they all work in terms of threads and such. is there
a book about distributed ruby and processes? i havent seen any on amazon
yet…

from my blog reading, i have some questions…

rails can handle 1 request at a time and can buffer to a certain extent?

when mongrel instances are created, a copy of the rails app is loaded
into each mongrel instance’s memory space?

these mongrel instances can read and write to the mysql database
simultaneously?

the middleman of backgroundrb, is he on his own thread outside the rails
app or is he using a mongrel instance?

how about the middleman’s workers, are they on their own thread outside
the rails app or would they be working with a mongrels instance?

thanks for any help! my main goal is to create a scalable video service
or other fun things!

Hi!

On Fri, Jan 25, 2008 at 03:36:47AM +0100, Bbq P. wrote:
[…]

rails can handle 1 request at a time and can buffer to a certain extent?

Rails doesn’t do the buffering, it’s the Server running it (i.e.
Mongrel) that delivers requests one at a time to Rails. To distribute
requests across multiple Mongrel instances you need some additional
piece of software, i.e. Apache’s mod_proxy_balancer.

when mongrel instances are created, a copy of the rails app is loaded
into each mongrel instance’s memory space?

exactly.

these mongrel instances can read and write to the mysql database
simultaneously?

yes. Each Mongrel instance is a separate independent process.

the middleman of backgroundrb, is he on his own thread outside the rails
app or is he using a mongrel instance?

the middleman is just a handle to access the backgrounDRb server, which
is running in a separate process outside of Rails and the Mongrels.

how about the middleman’s workers, are they on their own thread outside
the rails app or would they be working with a mongrels instance?

The workers are running in separate threads inside the DRb server
process. In fact that’s the whole point of backgrounDRb - free up the
Mongrel processes from having to handle long-running tasks.

Cheers,
Jens


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold

On Fri, Jan 25, 2008 at 6:24 PM, Jens K. [email protected] wrote:

piece of software, i.e. Apache’s mod_proxy_balancer.

yes. Each Mongrel instance is a separate independent process.

the middleman of backgroundrb, is he on his own thread outside the rails
app or is he using a mongrel instance?

the middleman is just a handle to access the backgrounDRb server, which
is running in a separate process outside of Rails and the Mongrels.

Thats right MiddleMan is just a client to the BackgrounDRb server. Its
connected to BackgrounDRb server through TCP Socket.

how about the middleman’s workers, are they on their own thread outside
the rails app or would they be working with a mongrels instance?

The workers are running in separate threads inside the DRb server
process. In fact that’s the whole point of backgrounDRb - free up the
Mongrel processes from having to handle long-running tasks.

Thanks Jens, but just to correct a bit, workers run in their own
process.


Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://gnufied.org

On Fri, Jan 25, 2008 at 08:54:58PM +0530, hemant wrote:
[…]

how about the middleman’s workers, are they on their own thread outside
the rails app or would they be working with a mongrels instance?

The workers are running in separate threads inside the DRb server
process. In fact that’s the whole point of backgrounDRb - free up the
Mongrel processes from having to handle long-running tasks.

Thanks Jens, but just to correct a bit, workers run in their own process.

Ah, thanks for pointing that out. I didn’t follow the recent development
of backgrounDRb, I guess that’s one thing that has changed with it’s
rewrite?

Jens


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold

thanks Jens K. and Hemant K.!!!

more questions and clarifications if i may…

apache mod proxy balancer buffers requests to pass to the rails app or
does the proxy pass requests to each mongrel instance? im thinking
basically when running mongrels, i should be thinking of instances of a
rails app where there is no root rails app right?

memcache, the cache is loaded in memory, outside the rails app, and not
duplicated by mongrel instances. each mongrel instance can read from
that cache?

can workers of the middleman exist on a different physical machine? so
if the middleman is on his own handler, he can pass off jobs to workers
someplace else?

to determine how many workers i can have on a box, i would have to
determine how much load i would like the workers to handle, and how cpu
intensive is the particular job for the worker?

the middleman buffers jobs in a queue to pass to the next available
worker?

big question about video site!

a form with a few text fields and a file field for video. when this form
is submitted, it would be submitted to my rails app and data would be
saved(title, author, text, video etc…). i then would like to pass the
video file off to the middleman so he can scedule a worker to
convert/store the video. now this video, as it is being transferred from
the client to rails app, is it being uploaded to a rails app directory
(hence tieing up a mongrel process), or can mongrel pass that incoming
file quickly to the middleman and then the incoming download is now
outside the mongrel process so the middleman can start work? ive read
the mongrel tutorial and i know the conversion can be outside mongrel,
but i am not too sure about the actual client upload to server
process…wouldnt that tie up a mongrel?

thanks