[Rails] Re: Rails: concurrency question

2009-05-30 Thread Jonathan Rochkind

Steve Hull wrote:
 BUT Rails is essentially single-threaded (only a single request
 processed at a time), so if I have only a single call to my singleton
 instance method per http request, then it should be impossible to get
 concurrency problems with it.  Right?
 

It's actually possible to write various kinds of concurrent code in 
Rails -- it really ALWAYS was possible to have some concurrency, but not 
concurrent request handling, and whatever concurrency you added you'd 
add yourself.

But in more recent versions of Rails, even some concurrent request 
handling is supported. allow_concurrency!. And perhaps Passenger in 
certain modes as Roderick says, I'm not familiar with Passenger.

But you're basically right about the 'ordinary' mode of Rails execution, 
that only a single request will be processed at a time. This is 
increasingly not the only option for Rails though.

But, yeah, you're also right that if you had Rails executing in a mode 
that allowed concurrent request handling, you'd need to take care of 
making sure your singleton object itself is concurrent-access safe -- 
the singleton pattern will take care of _instantiation_ of the Singleton 
object being concurrency-safe, but can't take care of it's own internal 
logic.  So you can either do that -- or you can note in comments that 
this thing isn't concurrency-safe, and shouldn't be used in a 
concurrent-request environment.
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails: concurrency question

2009-05-27 Thread Roderick van Domburg

Your line of reasoning is correct. The only caveat I can see is that 
you'd use Passenger in smart spawning mode, and create the singleton in 
the environment. In this case it'll be forked and have concurrency 
issues.

--
Roderick van Domburg
http://www.nedforce.com
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails: concurrency question

2009-05-27 Thread Steve Hull

Roderick van Domburg wrote:
 The only caveat I can see is that 
 you'd use Passenger in smart spawning mode

Thank you for the response Roderick!

Also thanks for pointing out the possible concurrency in Passenger.  I 
have yet to dive into Passenger, currently using Thin.  Anyway the the 
singleton is not created in the environment, so I should be OK even if I 
do choose to leverage Passenger.

Cheers!

-Steve
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---