Hi guys, I need my app to make a few hundreds requests to external web services as quickly as possible. The web services are fairly fast, but still: if I do the requests one after the other, it is too slow. My understanding is I have two options: a- Threads. b- Typhoeus Typhoeus seems great. Yet, the web services are all quite different (some are SOAP, some REST...) and therefore wrapped into interfaces. I might be able to implement Typhoeus but it means a lot of changes. I have read that threads in Rails can be challenging to implement especially when dealing with the DB. Yet, this part of my code doesn''t do anything with ActiveRecord. Are threads generally "OK" if no connection to the DB is involved? Thanks a lot for your recommendations. Pierre -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello there Pierre, Threads are not really threads in ruby, so forget about threads. Instead use a background process for that. You can accomplish that using some gem for creating background processes. Delayed Job may be a solution for you. []''s Rodrigo Dellacqua On Sun, Jan 10, 2010 at 7:52 PM, PierreW <wamrewam-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi guys, > > I need my app to make a few hundreds requests to external web services > as quickly as possible. The web services are fairly fast, but still: > if I do the requests one after the other, it is too slow. > My understanding is I have two options: > a- Threads. > b- Typhoeus > > Typhoeus seems great. Yet, the web services are all quite different > (some are SOAP, some REST...) and therefore wrapped into interfaces. I > might be able to implement Typhoeus but it means a lot of changes. > I have read that threads in Rails can be challenging to implement > especially when dealing with the DB. Yet, this part of my code doesn''t > do anything with ActiveRecord. Are threads generally "OK" if no > connection to the DB is involved? > > Thanks a lot for your recommendations. > > Pierre > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Rodrigo. The thing is, my main challenge here is speed: I have to wait for the answers to the requests to be able "continue". Therefore I am not sure about background processes (or delayed job): are they going to make the requests faster? Will they be able to run concurrently? Thanks, Pierre -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Pierre, If you need speed, you can spawn multiple processes at the same time. That will increase your throughput. Logically that depends on how powerful your machine is. You can check railscasts.com for background processing casts. []''s Rodrigo Dellacqua On Sun, Jan 10, 2010 at 8:20 PM, PierreW <wamrewam-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Thanks Rodrigo. > > The thing is, my main challenge here is speed: I have to wait for the > answers to the requests to be able "continue". Therefore I am not sure > about background processes (or delayed job): are they going to make > the requests faster? Will they be able to run concurrently? > > Thanks, > Pierre > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.