How to efficiently implement a blocking call with Rails, while letting the client wait for the reply

Posted by Kyle Heironimus on Stack Overflow See other posts from Stack Overflow or by Kyle Heironimus
Published on 2010-06-10T16:44:39Z Indexed on 2010/06/10 16:52 UTC
Read the original article Hit count: 201

We have a web service written in Rails. The API is published and we cannot change it. Our app communicates with a remote web service that sometimes hangs or takes several seconds to reply.

 Client -> Our Web Service -> Remote Web Service

Currently, if the remote web service hangs for 5 seconds, one of our rails processes on our web service also hangs with it, which is what we need to avoid.

I've seen things such as mod-x-sendfile, modporter, and delayed jobs, but the best I can tell, they all assume the client is not waiting for an answer. Since the API is already established, we cannot tell the client "I'm attempting to do what you want, check back later for the answer."

The best option we have come up with so far is to add a second, non-rails web server running eventmachine to process these particular calls. Is there a better way?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about web-services