CDP:Floating IP pattern
Floating IP Address
Problem to Be Solved
You need to stop the server when applying a patch to a server, or when upgrading the server (to increase the processing capabilities). Because stopping a server stops the services it provides, you need to to minimize the downtime.
For web servers, you can use the Domain Name System (DNS) to swap the server. However, in this case as well, typically the swapping time cannot be shortened to less than the Time to Live (TTL) value, so this is not suited to instant swapping.
Explanation of the Cloud Solution/Pattern
With the physical servers of the past, you would have to provide a spare server to prepare for taking down a server. After you had taken down the actual server, you would have to start up the spare server to take over processing. You would have to set up the IP address (to that of the actual server).
You can achieve this easily and extremely quickly through the AWS Cloud. You can prepare a machine image that will enable you to start up the required virtual server whenever you need it. Moreover, because an API for specifying the IP address is also available, you can write a script to automate all the processes from starting up the server through setting the IP address.
A static IP address used in Amazon Web Services (AWS) is known as an "Elastic IP Address (EIP)." You can use this to reassign IP addresses. You can detach an EIP from an existing EC2 instance and attach it to another ECP instance, to swap the virtual server that provides the services.
- Assign an EIP to an EC2 instance.
- When there is a failure or when you are going to perform an upgrade, launch a new EC2 instance. You can use the Stamp Pattern when launching the new EC2 instance. You can perform the swap more rapidly by launching the other EC2 instance in advance.
- After launching the instance, detach the EIP from the current EC2 instance and attach it to the new EC2 instance.
- You can swap servers by merely reassigning the EIP, unaffected by the TTL of the DNS.
- When performing an upgrade, you can achieve instantaneous fall-back through assigning the EIP back to the original server in the event of an error in the server to which the EIP had been swapped temporarily.
- Because you can apply EIPs across different Availability Zones (AZs), even if there were a failure on an AZ level, you can reassign the EIP to a server in a different AZ.
- Switching an EIP normally takes several seconds.
- In a Virtual Private Cloud (VPC), you can assign a static private IP address to a network card. You can assign network card to another EC2 instance, enabling you to apply this pattern even under a private network. Note, however, that address switching outside of the subnet is not possible in VPC.
- When you make a Secure Shell (SSH) connection to an EIP, a potential security issue warning will be issued, and login may become impossible.
- You may use monitoring software such as HeartBeat, Nagios, or Zabbix to detect a failure. Because you can use a program to perform the EIP reassignment, you can automate this process through a combination with the monitoring software.
- You can use this in parallel with Server Swapping Pattern to not only reassign the EIP, but to swap the EBS as well, enabling data inheritance.
- There is also a technique for switching to a spare server using Elastic Load Balancing (ELB) without using the EIP, by adding or deleting a health check file.