none
Highly available windows service RRS feed

  • Question

  • I am developing a Windows Service (.NET, C#). One of the non functional requirement is to ensure the high availability of this Windows Service. I understand that installing this Windows Service on a Failover Cluster will make this highly available. To install this service on a Cluster, is there any specific code I have to write within this service? I have heard about cluster aware services, however I have not came across any article that explains how to develop a cluster aware windows service. Is it really required to make a windows service to install it on a cluster?

    There will be only one instance of the service running at any point in time. If one fails, another one should automatically start running. How can this be implemented? 

    Friday, May 13, 2016 2:51 AM

Answers

  • The default Windows Service system allows you to have it auto-restart everytime the service exits, under the Recovery options. And that is even true on a Vista Home Basic.
    Put it as one of the services on a proper Windows Server that is never shut down and it should be reliable enough.

    If you already got a Failover Cluster for services this has not really anything to do with proramming. But with setting up the Failover Cluster itself. Wich you can read up in it's documentation.

    Polling webservices and webpages can take it's time. So as a minor option you could add a DB table to a central server where all instaces store the information when they last checked one API, what the result was, etc.
    If the old instance was halfway through a pass there is no need to start from the beginning.

    In any case proper exception handling inside the service is imperative. In particular not swallowing any Fatal Exceptions. Otherwise you could end up with unexpected behavior:
    Vexing exceptions - Fabulous Adventures In Coding - Site Home - MSDN Blogs

    Exception Handling Best Practices in .NET - CodeProject

    Friday, May 13, 2016 7:42 PM

All replies

  • Hi Rajesh,

    As far as I know that you could just develop a normal a windows service and install it on the cluster. Our service is running on cluster and there is no specific code to aware it running on cluster. Though the service is load balanced. So if one node is busy service redirect to other node automatically.

    In case of fail over you could load balanced your cluster to automatically redirect to other node. Hope this helps you.

    Thanks,

    Sabah Shariq

    Friday, May 13, 2016 10:24 AM
    Moderator
  • I am developing a Windows Service (.NET, C#). One of the non functional requirement is to ensure the high availability of this Windows Service. I understand that installing this Windows Service on a Failover Cluster will make this highly available.

    This is true. But you're right know about making an sever error: Assuming what is meant by "high availability of this Windows Service". Get a definition.

    For example a threaded service with a watch dog service on one machine could also be "high available".

    It also depends on what the service is doing. E.g. accepting socket connections, then you need to get a number (threshold) for being no longer high available.


    Friday, May 13, 2016 11:16 AM
  • Thank you, Sabah Shariq - this is same as my scenario. I am looking for the guidelines/instructions to install this service on a Cluster so that it will automatically redirect to the other node if the first node fails. Thank you for clearing my question on whether to make the service cluster aware to install it on a cluster.
    Friday, May 13, 2016 12:23 PM
  • Hi Stefan,

    This service is a very simple polling service - this polls a set of web services on a scheduled frequency. I do not have to maintain the state pf the service at any point in time - all that I am looking for is if the service is down (service stopped/hardware failure etc), another service in the cluster should automatically start running and continue with the polling. - this is how we define the high availability of the service.

    From the above answer, I understand that there is not need to make it cluster aware to install it on a cluster.  Now, I am looking for the guidelines/instructions to install this service on a Cluster so that it will automatically redirect to the other node if the first node fails. 

    Friday, May 13, 2016 12:27 PM
  • The default Windows Service system allows you to have it auto-restart everytime the service exits, under the Recovery options. And that is even true on a Vista Home Basic.
    Put it as one of the services on a proper Windows Server that is never shut down and it should be reliable enough.

    If you already got a Failover Cluster for services this has not really anything to do with proramming. But with setting up the Failover Cluster itself. Wich you can read up in it's documentation.

    Polling webservices and webpages can take it's time. So as a minor option you could add a DB table to a central server where all instaces store the information when they last checked one API, what the result was, etc.
    If the old instance was halfway through a pass there is no need to start from the beginning.

    In any case proper exception handling inside the service is imperative. In particular not swallowing any Fatal Exceptions. Otherwise you could end up with unexpected behavior:
    Vexing exceptions - Fabulous Adventures In Coding - Site Home - MSDN Blogs

    Exception Handling Best Practices in .NET - CodeProject

    Friday, May 13, 2016 7:42 PM