CDP:Scheduled Autoscaling Pattern
Turning Batch Servers On and Off Automatically
Problem to Be Solved
In many systems, batch processes are performed at specific times, and often a scheduler (such as cron in UNIX) is used on a server that is always running. However, the time for performing the batch processes is actually short, wasting the server resources at other times, causing poor cost effectiveness. The question is how to use the resources of the batch servers efficiently in such applications.
Explanation of the Cloud Solution/Pattern
In the past, with batch servers that run at specific times, it has been necessary to assign one server to run at all times. If you were clever, you could increase the efficiency by having that server perform other functions (processes) as well. AWS Cloud allows you to limit the use of the virtual servers to only when they are required, making it practical to run the virtual servers only when actually performing batch processes.
Batch processes that are executed at set times require a system for launching the virtual server at the set times. You can achieve this through using the scheduling system in AWS Cloud.
AWS has a system known as "Auto Scaling" that is able to increase or decrease the number of EC2 instances automatically. Auto Scaling has a function that allows you to increase or decrease EC2 instances at specific times, which you can use for batch processes that are performed at specific times.
- Prepare an Amazon Machine Image (AMI) (a machine image) for executing the batch process when launched.
- In Auto Scaling, set up the EC2 instance to be launched at the specified time from the AMI.
- Set up the EC2 instance itself and Auto Scaling to terminate the EC2 instance after processing has been completed.
- The EC2 instance for processing batches at specific times does not have to run constantly. The EC2 instance is started only when a process is to be executed, reducing costs substantially.
- When it is difficult to determine the timing with which the batch processing will be completed, you can use a method where the EC2 instance itself shuts itself down after completion of batch processing.
- EC2 instances are charged by unit time, with a one-hour minimum, so one hour of time will be billed if an EC2 instance is launched and then shut down in a short period of time. Because of this, you need to be aware of the timing of launching and termination of instances.