I have a real-time application running on an Amazon EC2 instance. I'd like to implement master/slave redundancy with a VPC, a second instance and keepalived. So far it's working reliably, but in the event of a failover, the EIP reassignment is taking about 30 seconds, which doesn't work for my scenario as current connections timeout and get dropped. I'm using a floating internal IP in the VPC and am moving that between the systems, because reassigning the public EIP takes even more time. In a local scenario with VMs, the internal IP address was reassigned and a script running arping was launched to update the router, so the failover took about 1-2s at most. Is there any way to achieve similar speeds with AWS VPC? Thank you!
I believe you can't directly speed up the EIP reassignment because there is no such configuration to take control of the process. (Maybe you can get in touch with the AWS Support Team, to get more info).
However, you can build a more reliable environment using the following options:
- Use a AWS ELB, with a low Health Check value. This scenario will route your traffic using two (or more) applications instances (preferably on separated Availability Zones) and will automatically stop send traffic bases on your configuration;
- If you are using the AWS OpsWorks for provisioning, create a HAproxy layer configured to use one application instance as a failover, for more information check this link;
- Manual setup a load balancer in front of your application to implement the automatic failover.
For all previous scenarios, your main DNS will always point to the load balancer public EIP and you will have full control to configure the environment for a fast failover.