Re: [mongrel2] embedding mongrel2
- From:
- Zed A. Shaw
- Date:
- 2011-06-07 @ 07:58
On Mon, Jun 06, 2011 at 11:45:43PM -0700, snacktime wrote:
> I was thinking today that mongrel2 might just make a good embedded web
> server. I've got this crazy project at work where we run the tamarin
> actionscript vm server side, and it communicates with our jruby rails
> app via zmq. Tamarin already comes with a built in mechanism to start
> up a thread pool of vm's. Right now I have each thread run code that
> starts a zmq receive/send loop, much like a mongrel2 handler. Put a
> zmq QUEUE device between that and jruby, and it works fairly well. We
> use ruby-ffi so we can use inproc sockets from both ends.
That sounds really complex.
> I was just wrapping up a mongrel2 extension for the actionscript vm
> using the c++ handler on the website, and was thinking hey it might
> just be better to embed mongrel2 itself, and just have one executable
> instead of two. If you don't have backends that need to talk to each
> other via mongrel2, why not just embed?
I imagine you could. I try to avoid globals if I can, and if I do
they're typically read-only, but the real issue will most likely be all
the ucontext and tasks. I've got no idea how those will interact with
threads.
> I was thinking this might be pretty cool for rails itself. Anyone
> tried that yet?
I was thinking about it earlier today, and really, it's kind of way more
of a pain than it would give you benefits for. I'd say, it sounds like
more of just a vanity thing than something that's actually useful. But,
if you got the itch research it and who knows. Maybe my first
impression of the difficulty is wrong.
--
Zed A. Shaw
http://zedshaw.com/
Re: [mongrel2] embedding mongrel2
- From:
- snacktime
- Date:
- 2011-06-08 @ 23:18
>
> I was thinking about it earlier today, and really, it's kind of way more
> of a pain than it would give you benefits for. I'd say, it sounds like
> more of just a vanity thing than something that's actually useful. But,
> if you got the itch research it and who knows. Maybe my first
> impression of the difficulty is wrong.
>
> --
> Zed A. Shaw
> http://zedshaw.com/
>
So I looked at embedding last night and came to the conclusion that
the reverse was much simpler and offered more benefits, like mongrel's
built in run management. I already have a tamarin shared object, so I
just linked mongrel against that and called out to tamarin from
taskmain, launching it in a pthread. Total hack but the goal was to
see what might blow up. Seemed to work just fine and took about 30
minutes to get working.
Chris
Re: [mongrel2] embedding mongrel2
- From:
- Zed A. Shaw
- Date:
- 2011-06-09 @ 00:24
On Wed, Jun 08, 2011 at 04:18:01PM -0700, snacktime wrote:
> So I looked at embedding last night and came to the conclusion that
> the reverse was much simpler and offered more benefits, like mongrel's
> built in run management. I already have a tamarin shared object, so I
> just linked mongrel against that and called out to tamarin from
> taskmain, launching it in a pthread. Total hack but the goal was to
> see what might blow up. Seemed to work just fine and took about 30
> minutes to get working.
Sexy, so you're just running it in a thread and then you'll toss
messages at it off an inproc? Can you looked at the filters stuff yet?
It might be easier to hook with a filter that starts tamarin up on the
fly instead. Take a look and let me know what might be missing from the
API so I can beef it up.
I also want to put luajit inside for writing filters.
--
Zed A. Shaw
http://zedshaw.com/
Re: [mongrel2] embedding mongrel2
- From:
- snacktime
- Date:
- 2011-06-09 @ 00:55
On Wed, Jun 8, 2011 at 5:24 PM, Zed A. Shaw <zedshaw@zedshaw.com> wrote:
> On Wed, Jun 08, 2011 at 04:18:01PM -0700, snacktime wrote:
>> So I looked at embedding last night and came to the conclusion that
>> the reverse was much simpler and offered more benefits, like mongrel's
>> built in run management. I already have a tamarin shared object, so I
>> just linked mongrel against that and called out to tamarin from
>> taskmain, launching it in a pthread. Total hack but the goal was to
>> see what might blow up. Seemed to work just fine and took about 30
>> minutes to get working.
>
> Sexy, so you're just running it in a thread and then you'll toss
> messages at it off an inproc?
To do inproc I'd have to expose the context in mongrel2. Right now
it's communicating with mongrel2 handlers in tamarin threads, I even
threw httperf at it a bit.
Can you looked at the filters stuff yet?
> It might be easier to hook with a filter that starts tamarin up on the
> fly instead. Take a look and let me know what might be missing from the
> API so I can beef it up.
I'll look at the filters. Anything that makes it less intrusive is good.
And I'm still not sure how useful this is as actionscript doesn't have
a lot of the functionality you need for a server. Tamarin doesn't
come with anything in the flash.* so you don't have http or sockets
built in. It might end up just being simpler to embed it in the main
server app and call it from there like we do now. But in any case
it's fun to hack on and see how it turns out.
Chirs