DNS Routing Failover Route53 to deploy .NET Windows Service in Active/Passive manner

22 views Asked by At

I am deploying a Windows Service written in ASP.NET 4.7 using CI/CD pipeline through GitHub Actions in Active/Passive mode. Here is the link for the workflow file: https://repost.aws/questions/QUoRKOK-hFRbeBJxxuZNlJvg/dns-failover-routing.

Having said that the deployment happened successfully on both the servers, but I want the service to be running actively on one server at a time i.e. the Primary server and the Secondary server will come into use when the Primary server goes down.

To get more insights on deploying a Windows service using DNS failover routing I asked ChatGPT about the same and the solution it gave me:

Step-by-Step Implementation:

Step 1: Set Up AWS Resources

Create EC2 Instances:

  • Launch two EC2 instances in the desired AWS region.
  • Install and configure your .NET Windows Service on each instance.

Configure Health Checks:

  • Set up health checks for your EC2 instances. This could be done using an HTTP endpoint, TCP check, or another method.
  • Configure health checks to determine the availability of your Windows Service.

Create an Elastic Load Balancer (ELB):

  • Create an Elastic Load Balancer to distribute traffic between the two EC2 instances.
  • Configure the ELB with health checks to monitor the health of each instance.

Step 2: Implement DNS Failover with Route 53

Create a Hosted Zone in Route 53:

  • In the Route 53 console, create a hosted zone for your domain.
  • Create DNS Records:
    • Add DNS records (A or CNAME) pointing to the Elastic Load Balancer's DNS name. Initially, both records will direct traffic to the ELB.

Configure DNS Failover:

  • Edit the DNS records to enable failover routing.
  • Set up a failover configuration with one record as the primary (active) and the other as the secondary (passive) with a health check.
  • If the health check for the primary record fails, Route 53 will automatically route traffic to the secondary record.

Step 3: Configure .NET Windows Service

Implement Health Check in Your Service:

  • Modify your .NET Windows Service to expose a health check endpoint or implement a health check mechanism that can be used by Route 53.
  • Install AWS SDK for .NET using bash: Install-Package AWSSDK

Update DNS Records Programmatically:

  • Use the AWS SDK for .NET to update DNS records in Route 53 based on the health status of your service.
  • Implement logic to switch the DNS record from the primary to the secondary (and vice versa) in case of a failure.

Step 4: Test and Monitor

Test Failover:

  • Test the failover mechanism by intentionally stopping the Windows Service on the active instance or simulating a failure.
  • Confirm that Route 53 reroutes traffic to the passive instance.

Monitor and Adjust:

  • Set up monitoring for your Windows Service, EC2 instances, and Route 53 health checks.
  • Monitor logs, health checks, and system metrics to identify and address any issues.
  • Adjust health check parameters, DNS record TTL, or other settings based on performance and testing results.

This guide should help you set up a robust and automated active/passive deployment for your .NET Windows Service with Route 53 DNS Failover Routing. As always, thoroughly test your implementation in a controlled environment before deploying to production.

My question is knowing the fact that the service doesn't have an endpoint i.e. IP address or Domain name then how I am going to create the Route53 health check for the same.

So please suggest me a better solution with step-by-step implementation for the same as I am confused how to approach with this and in case it is not achievable do let me know that too.

0

There are 0 answers