CDP:Clone Server Pattern
Cloning a Server
Problem to Be Solved
A scale-out structure is a common technique, but in systems that start small often the structure is not one where it is possible to provide Multi-Server services using multiple servers at all. In such a case, establishing measures to handle increased load may be time-consuming.
Explanation of the Cloud Solution/Pattern
This pattern allows you to take a system that has not taken distribution of load into account, and easily make it into a system where load distribution is possible. A server that already exists is used as a master, and a machine image is prepared for a server to be added. In the machine image, content synchronization and coordination of database connections has been performed in advance. This allows you to achieve load distribution through scale-out by merely starting up the machine image.
Use the Load Balancer service (Elastic Load Balancing (ELB)) and an Amazon Machine Image (AMI). Produce an AMI for cloning where content synchronization, and the like, have been adjusted to enable load distribution. If the load becomes too great, start up an EC2 instance from this AMI for cloning. Having the EC2 instance subject to load distribution by ELB makes lets you perform scale-out with essentially no changes to the existing system.
- Startup the ELB (for a structure with only one EC2 instance), and place the EC2 instance under the control thereof.
- Create, from the EC2 instance that is currently running, an EC2 instance for cloning.
- Periodically use rsync, or the like, as necessary, to perform file synchronization with the master EC2 for the EC2 for cloning.
- Depending on the load (or when a high load is anticipated), start up the required numbers of EC2 instances for cloning that are required, and add to the ELB.
- This lets you perform load distribution through Scale Out easily, without modifying the existing system.
- The master EC2 instance becomes a single point of failure (SPOF).
- If a database is running in the master EC2 instance, do not run the database in the clone EC2 instance, but rather have the master EC2 instance as the destination for the database connection.
- If there will be file uploads or writing, do so using the master EC2 instance (such as through using mod_proxy of Apache to proxy from a clone virtual server of only the applicable URL to the master virtual server, or the like).