Recently I have moved a company from on-premise to AWS Cloud. They operate between 10 AM IST to 6 PM IST.
During business ours we upgrade our PostgreSQL RDS to
db.t2.2xlarge because we have quite a heavy traffic and require more db connections to be able to run analytics & other reporting tools. We also set ec2
auto-scaling to minimum 2 servers.
This is really good approach to reduce costs IF you can predict how much infra you need to scale. We haven’t considered this because we didn’t wanted to commit for a year / we are not sure how we will scale. Our database doubles every 3 months and we go up to 7 ec2 instances every day during office hours.
We wanted to see if we can turn off the staging environment and reduce the production instance sizes after office hours, because no one uses it after hours. Remember this based on our specific use case.
We came up with a shell script that runs every hour as a cron job. It checks if the hours is 10 AM and executes shell functions accordingly.
AWS IAM Role:
You’ll need to create an AWS IAM role with below policies
Make sure you restrict this IAM user to execute these actions from a IP Address for security reasons.
You can modify the below shell script to fit your needs.
If you run an RDS
db.t2.2xlarge you would be paying about $433 for 720 hours. Using the above shell script we were able save for 512 hours. Thats about $288.62 / month. Remember we also saved on our staging environment.
Hope this helps!