N
Nick Brown
I've read that "threading is considered harmful" for Ruby web apps.
Well, I'm writing a Sinatra app which will build a page based on the
responses of several servers (Net::HTTP.get). I want to do these .gets
in parallel, as doing them synchronously would obviously mean the users
would wait for a long time.
Would it be "considered harmful" to do:
resp_a, resp_b, resp_c = nil
thread_a = Thread.new { resp_a = Net::HTTP.get site_a }
thread_b = Thread.new { resp_b = Net::HTTP.get site_b }
thread_c = Thread.new { resp_c = Net::HTTP.get site_c }
thread_a.join
thread_b.join
thread_c.join
Is there any possible harm that could come from this? Can threading
interfere with Rack in some way? I haven't done much previous
development of threaded apps, so I would appreciate any tips.
Well, I'm writing a Sinatra app which will build a page based on the
responses of several servers (Net::HTTP.get). I want to do these .gets
in parallel, as doing them synchronously would obviously mean the users
would wait for a long time.
Would it be "considered harmful" to do:
resp_a, resp_b, resp_c = nil
thread_a = Thread.new { resp_a = Net::HTTP.get site_a }
thread_b = Thread.new { resp_b = Net::HTTP.get site_b }
thread_c = Thread.new { resp_c = Net::HTTP.get site_c }
thread_a.join
thread_b.join
thread_c.join
Is there any possible harm that could come from this? Can threading
interfere with Rack in some way? I haven't done much previous
development of threaded apps, so I would appreciate any tips.