Jon Evans
2006-Jun-26 13:25 UTC
[Rails] Serialising multiple accesses to external web service
Hi all, I have an external web service that I need to log into at a specific part of my web app,. The problem is that I only have one login to this web service, and if another login attempt is made while an existing login session is still active, the existing session gets terminated. How can I best serialise access across my mongrel cluster to this external API? I thought of creating an external drb service that all cluster nodes connect to, but that could also be re-introducing a single point of failure that I eliminated by using a cluster. I could do something with db transactions and a "locks" table... any other ideas? Thanks Jon
Zed Shaw
2006-Jun-26 23:36 UTC
[Rails] Serialising multiple accesses to external web service
On Mon, 2006-06-26 at 14:25 +0100, Jon Evans wrote:> Hi all, > > I have an external web service that I need to log into at a specific > part of my web app,. The problem is that I only have one login to > this web service, and if another login attempt is made while an > existing login session is still active, the existing session gets > terminated. > > How can I best serialise access across my mongrel cluster to this > external API? > > I thought of creating an external drb service that all cluster nodes > connect to, but that could also be re-introducing a single point of > failure that I eliminated by using a cluster. >A single point of failure that you know about and can protect is better than a lot of brittle locations that always fail. Many times an SPF can be a good thing since it funnels potential trouble to one location that is easy to manage. But, you can also use tools to eliminate the SPF. You can typically mirror the protocol or state between two servers or balance between them (much simpler) so that when one goes down the other picks up. So, I would say do the DRb server, and then scale it up as you need. This is much easier than trying to cram some sophisticated locking system into all of the Mongrel servers, which adds a larger potential failure to all of the processes. Also, DRb is cake, you could probably have this done in an hour to a day. With all your free time you could then learn about Rinda or how to do TCP balancing with pen or balance. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/
Jon Evans
2006-Jun-28 19:54 UTC
[Rails] Serialising multiple accesses to external web service
Hi Zed, On 27 Jun 2006, at 00:35, Zed Shaw wrote:> So, I would say do the DRb server, and then scale it up as you need. > This is much easier than trying to cram some sophisticated locking > system into all of the Mongrel servers, which adds a larger potential > failure to all of the processes. > > Also, DRb is cake, you could probably have this done in an hour to a > day. With all your free time you could then learn about Rinda or > how to > do TCP balancing with pen or balance.Very useful advice, thanks very much. I hadn''t even heard of Rinda, pen or balance, but I''ve bookmarked their respective sites to look at after I''ve thrown the DRb server together. You''re right, it shouldn''t take very long at all - I already have all the code written inside a class in my rails lib directory, just need to wrap it in a bit of DRb glue. Jon