Reputation: 2208
I am interested in hearing some thoughts about a problem which I have to solve. I have a web application with a list of entries and I need to call different web services (e.g. twitter and youtube) for each entry in order to "resolve" an item. The problem is that the web services tend to be slow and as soon as I have multiple entries I will end up with long response times.
So I have several approaches in mind. One would be doing an ajax call for each entry which means I will end up with: entries * services (e.g.2).
Another idea would be the use of faye on rails in order to send messages to server. So in theory I could make several requests in parallel and push the response to the client as soon as I get a response from the webservice ???
Another one which pops into mind is node js, but I have no experience so far with node.js
So I am looking forward to read any ideas and comments..
Best, Phil
Upvotes: 0
Views: 338
Reputation: 3334
I am using Faye on node.js for a very similar application and so far I really like it. When a user request is registered at in the browser, it sends a message to the webserver using Faye. The message results in an action that when it finishes, I return a message to the browser to let it know what happened.
In the meantime while the first action is being processed, the browser stays active and the user can simply keep requesting actions and the browser continues to simply send them along to the server which then acts on them. The amount of simultaneous requests I can handle at the webserver is essentially only limited by the bandwidth I have and the amount of memory the machine has.
I did some prototype work using AJAX but found it was a bit more complicated than I wanted it to be and once I found Faye and how simple it was to setup and use, I was hooked. I also checked out a library called socket.IO that is available for node that you can tie to rails(http://liamkaufman.com/blog/2012/02/25/adding_real-time_to_rails_with_socket.IO_nodejs_and_backbonejs_with_demo/) , but it seems more complicated than just using Faye with rails.
Give Faye a good hard look, that's what I ended up choosing because of its flexibility. I did some stress testing with Faye over a period of several days on a node.js express server and it held the connection the whole time while I was connecting and disconnecting multiple browser windows at random time intervals programatically. In short, I have no reason to be concerned about it's reliability at this point.
One other thing, there is a good community on google that is using Faye with some good Q/A on there. Also, the author of Faye responded to one of my questions regarding cleanly shutting down directly on the google forum and engaged in a back and forth with me, so you will get some help when and if you have questions.
Upvotes: 1