I am planning to deploy my web app to EC2. I have several webserver instances. I have 1 primary database instance. I have 1 failover database instance. I need a strategy to redirect the webservers to the failover database instance IP when the primary database instance fails.

I was hoping I could use an Elastic IP in my connection strings. But, the webservers are not able to access/ping the Elastic IP. I have several brute force ideas to solve the problem. However, I am trying to find the most elegant solution possible.

I am using all .Net and SQL Server. My connection strings are encrypted in my web.config.

Does anybody have a strategy for failing over a database instance in EC2 using some form of automation or DNS configuration?

Please let me know.


Your webservers probably can't access the Elastic IPs because of firewall rules associated with your security groups. You should be sending traffic over the internal IP addresses, anyway, or you'll be charged extra for data transfer.

Instead of Elastic IPs (which take a few minutes to transfer anyway), you could use a service like DNS Made Easy's dynamic IP addresses, set with very low TTLs, where the database hostname is changed from HostA's internal IP to HostB's internal IP on failover.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy