-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
st2CICD Reducing costs #104
Comments
One possible reduction which would amount to reducing pre-tax EC2 CI/CD server to $81 or $74 would be following:
However if we use the AWS Instance Scheduler that probably costs us $10 a month to achieve that (https://docs.aws.amazon.com/solutions/latest/instance-scheduler-on-aws/cost.html). Or for our use case, we should be able to achieve the same for less just with Lambda functions, eg. https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-eventbridge/ as we don't really need those lambda functions running every 5 mins every day which the instance scheduler is doing. This might be an easy win to reduce the costs quickly but then move onto a solution where we get the logs off the boxes so don't need the CI servers for debugging. Also perhaps the ST2 workflow that deletes old running EC2 instances that are older than 6 hours from a CI/CD server, could be removed and replaced by a Lambda function to delete any that are running at particular times of day? Then we don't need to keep CI server up for 6 hours after a run. We could also tighten the schedule even more, e.g. just have both stable and unstable run on the same day and once a week, e.g. Then we could keep the servers up maybe just from Tuesday 10am UTC to Thursday 10pm UTC. This would then just have a cost of approx $40 + tax a month for the c5a.xlarge instance. And gives us 54 hours after a failed run to debug. Which could be an interim solution, until either we rebuild with newer ST2 version and smaller size, plus getting logs off box so we can investigate a failure without the EC2 instance being up. |
A solution that is a bit less flexible compared to the AWS Instance Scheduler is to use Scheduled scaling for EC2 Auto Scaling: https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-scheduled-scaling.html It allows you to configure any ASG capacity (min, max and desired) to be applied at any time with a cron-like syntax. Let me just share a screenshot to show the capabilities: So, when we say
We could have a config like
The shutdown would be scheduled to a later point of time which depends on whether we want to keep the instances alive for debugging or export relevant logs to S3 for example.
Terraform documentation: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_schedule An example to start an instance every Tuesday at 1 pm and shut it down at 3 pm again:
|
@winem Doesn't the above terminate rather than just shutdown the instance? https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-groups.html - "and launches or terminates the instances as needed". |
I think it's a great idea with the lambda function to start/stop the instance on a schedule 👍 |
Agreed in TSC meeting for go-ahead to start/stop via lambda and keep CI server up for just a few days a week. |
Schedule of new builds (times based on US/Pacific): Tues @ 18:00 Orphan run (cicd repo) Schedule AWS Lambda control the st2cicd EC2 instance with: Start Tues@16:00 |
Lambda functions and rules setup. Monitoring changed to just Weds. Awaiting stop on Friday 4am UTC, and start at Tues midnight UTC. |
Our current AWS CICD server costs approximately $122.4 plus tax to run a month just on EC2 costs (other costs such as EBS not included). This is a c5.xlarge server running 24x7 (cost above based on 30 day month).
The actual CI/CD runs currently are:
Each day at 1am UTC it also runs a check to see if any of the instances created to run the CI jobs need deleting.
We have a number of ways we could reduce this cost, some of these can be combined:
Once we loose credits, and by time we add in tax costs it would be good to reduce this cost.
Interested in people's preferences and thoughts.
The text was updated successfully, but these errors were encountered: