> Csaba: You can run anything multithreaded on Windows by using Ruby > Threads.> > Second, I''d like to ask you if there''s any way to make a simple mongrel > > script run multithreaded?you get threaded handlers for free, by default. you have to explicitly go out of your way to defeat this behavior.. grep -i mutex in the rails or camping handler to see how its done> > > > Since win32 lacks fork, I don''t know if I can make it process multiple > > request simultaneously.fork() is implemented in win32/process extension. not that youd want to use that, or anything, i tried it once in a real-world script that would fork itself and spawn gcc children and it was very weird, to say the least (lots of return values were just corrupt garbled crap). compounded by running mingw''s bash where things are wonky already. but this doesnt matter, since mongrel''s ruby isnt actually forking, apache-style, to enable concurrency... if youre further curious, check out wyhaines'' evented mongrel
Hi All, First, I''m new to the list, so I''d like to say hello to all fellow mongrelists :) Second, I''d like to ask you if there''s any way to make a simple mongrel script run multithreaded? No rails, just plain old class MyHandler < Mongrel::HttpHandler . . . h = Mongrel::HttpServer.new("127.0.0.1", "80") stuff. Since win32 lacks fork, I don''t know if I can make it process multiple request simultaneously. I''ve read about the mongrel rails service thing, but that''s only for rails, if I''m not mistaken. Thank you in advance, Ochronus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20071120/904668c1/attachment.html
Csaba: You can run anything multithreaded on Windows by using Ruby Threads. These are green threads, not native ones, and they are non-blocking, which is what you would want. Look up some examples of using the Thread class, which is in the Ruby language core, and you should be on your way. You can create them in a loop and get many running. I am new to Ruby, otherwise I would give you a concrete example. On Nov 20, 2007 7:46 AM, Csaba Okrona <ochronus at gmail.com> wrote:> Hi All, > > First, I''m new to the list, so I''d like to say hello to all fellow > mongrelists :) > > Second, I''d like to ask you if there''s any way to make a simple mongrel > script run multithreaded? > > No rails, just plain old > > class MyHandler < Mongrel::HttpHandler > . > . > . > h = Mongrel::HttpServer.new("127.0.0.1", "80") > > stuff. > > Since win32 lacks fork, I don''t know if I can make it process multiple > request simultaneously. > I''ve read about the mongrel rails service thing, but that''s only for rails, > if I''m not mistaken. > > Thank you in advance, > Ochronus > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >
Thank you both, Geoffrey and cdr for your help. I didn''t know it was threaded on win32 by default :) Then I don''t really get why there''s so big performance difference bw/ a unix backed mongrel and a win32 one... On Nov 20, 2007 1:04 PM, cdr <_ at whats-your.name> wrote:> > Csaba: You can run anything multithreaded on Windows by using Ruby > > Threads. > > > > Second, I''d like to ask you if there''s any way to make a simple > mongrel > > > script run multithreaded? > > you get threaded handlers for free, by default. you have to explicitly go > out of your way to defeat this behavior.. grep -i mutex in the rails or > camping handler to see how its done > > > > > > > > Since win32 lacks fork, I don''t know if I can make it process multiple > > > request simultaneously. > > fork() is implemented in win32/process extension. not that youd want to > use that, or anything, > > i tried it once in a real-world script that would fork itself and spawn > gcc children and it was very weird, to say the least (lots of return values > were just corrupt garbled crap). compounded by running mingw''s bash where > things are wonky already. > > but this doesnt matter, since mongrel''s ruby isnt actually forking, > apache-style, to enable concurrency... > > > if youre further curious, check out wyhaines'' evented mongrel > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20071121/949e50a0/attachment-0001.html
On Nov 21, 2007 4:49 AM, Csaba Okrona <ochronus at gmail.com> wrote:> Thank you both, Geoffrey and cdr for your help. > I didn''t know it was threaded on win32 by default :) > > Then I don''t really get why there''s so big performance difference bw/ a unix > backed mongrel > and a win32 one... >The current (official) build of ruby on windows is compiled with a older, not-so-optimized compiler (Visual C 6.0). It is 30% slower than the same code compiled with GCC 3.4.5 (or 4.2.1). Future versions of ruby for windows will provide updated builds, we are working on that :-) -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi