Once you’ve automated the scaling-down of your infrastructure during off-hours, if your applications and services have been running for more than a couple of weeks, you can use the usage history to identify usage patterns and identify areas for additional tuning. There are different approaches you can take, depending on whether you scale your infrastructure horizontally by adding additional instances of the same service, or vertically by increasing the size of the instance running your application.
For horizontal scaling, there are many options to choose from. AWS offers scheduled and dynamic scaling, which can scale your Auto Scaling Group (ASG) in response to a schedule or in response to traffic and resource usage. Third-party solutions are also available if you have more specialized scaling needs. Online retailers such as Ticketmaster, for example, can anticipate an increase in demand due to the scheduled release of tickets for popular events, and employ custom solutions to scale their infrastructure out ahead of the demand.
For vertical scaling, an AWS CloudFormation template can be used to automate the process of stopping an application and restarting it on a different instance size to handle an increase or decrease in demand. While this process may take a few minutes to execute, it allows you to automate the change, and execute on a schedule. CloudFormation is AWS’s solution for Infrastructure as code and provides users with a common language for defining and describing infrastructure, which is then executed to affect the infrastructure changes. The CloudFormation template contains the details for an infrastructure “stack” and can be stored alongside your code in a code repository, allowing changes to be versioned and deployment information packaged alongside the code.