views:

20

answers:

1

I have a number of Windows servers. I want to run one copy of the same Windows Service (written in .NET) on each of the servers such that at any one time only one of them is "active" and all the others are passive. If the active windows service dies then a very short time later one, and only one, of the remaining passive windows services becomes active.

Any ideas of simple ways to achieve this?

+1  A: 

Well you need to keep them in sync, the easiest way to go would be to have an entry somewhere in a database that they can all access. Have the active service update a particular row etc. every so many minutes. If an update isn't found within a specific amount of time, the other services can take that as the active one has gone offline. Of course your problem here is that if the database goes off line, then the services will have problems, so that is potentially a single point of failure. You can alleviate this by having the db clustered as well though.

You could have them all communicate with each other like a peer to peer network too, but that will be more work, for essentially the same outcome, although this approach does have it's benefits.

Kevin
the clustered db method is the current solution that I have. It is a peer to peer solution I was wanting but havent thought of a way to avoid timing issues that might cause more than one active.
freddy smith
The easy way to go about it is to have all of them check to see if a service is active at different intervals. Once a service realizes that there is no active service running, have it communicate to all the others and tell them "Hey, I've got this. No need to wake up." It them becomes the active one while the others sleep.
Kevin