Simple trick for huge AWS EC2 savings
Using AWS Lambda functions to schedule EC2 instances
Most developers run allot of staging, QA, research and testing servers, it’s one of the most powerful features of cloud providers like AWS. Giving developers the ability to spin up servers at need.
The downside of this power is its all too easy to unwittedly wrack up huge bills through leaving instances running that are not being used. Alas! Using AWS Lambda functions we can schedule tasks that shutdown and startup our non-essential instances when they are not being used.
For example extrapolating with some simple math:
Here at EthicalJobs.com.au we have a fleet of 10 x t2.small and 5 m3.medium instances we use in our staging and CI/CD build pipelines.
OnDemand — Sydney region (ap-southeast-2)
10 * t2.small = $292.80 pm
3 * m3.medium = $204.24 pm
Monthly = $497.04
Yearly = $5,964.48
Only running during office hours 8am — 7pm, excluding weekends:
10 * t2.small = $86.00 pm
3 * m3.medium = $60.00 pm
Monthly = $146.00
Yearly = $1,752.00
Thats a saving of $4,212 per year!!!!
Therefore we wrote https://github.com/andrewmclagan/aws-lambda-ec2-start-stop
A simple lambda function that can be scheduled to shutdown and startup ec2 instances on demain.
Read the documentation on the repo. it’s very straight forward.
Go have fun.