We have a rails app that makes http calls to a data cloud. The rails
app runs under tomcat. We need to make between 1-3 outgoing http
calls per incoming request to rails. The first requirement is http
keep-alive support, and a secondary goal is parallel requests. So
I’ve been looking at several options most of which involve threads.
#1. Use the apache HttpClient which supports connection pools and
keep-alives. I think it supports parallel requests, can’t remember
#2. Use eventmachine and come up with some type of synchronous
interface for making http requests. I’ve used EM a lot in the past,
but mainly in server code. I was thinking of using thread queues to
communicate between the rails threads and an EM thread. How expensive
would it be to start up a thread queue per rails thread? Another
thought is to use zeromq to communicate between the rail threads and
the EM thread. It provides a blocking interface. Fibers would be
cool, but 1.9 support isn’t quite good enough yet for rails, our app
won’t even startup with --1.9 and it fails in rails core, not some
obscure third party gem.
Specifically for using EM, are there other approaches anyone can think
of that might work better?