1

I have been working around Gitlab CI from last one month. Initially, I setup gitlab shared runners. Then we thought having a self hosted runner on aws would be better to manage the cost at once place.

Actually, we have 6 micro-services using self hosted runner i.e., aws ec2 - t3.micro (2vCPU, 1GB). These jobs are to build and push a docker image & deploy it on the ECS cluster.

We have front-end android & ios projects, currently running on shared runners, which requires heavy cpu & memory resources may be t3.xlarge (4vCPU, 16GB).

I have planned on configuring AWS-Auto scaling GitLab runner with Spot instance so that all projects can run on AWS.

Microservices runner will have t3.micro as spot instance where as Frontend will have t3.xlarge spot instance for every job Gitlab Ci trigger. the spot instance life time is 60 minutes.

2 frontend applications runs together 12 times a day with 3 minutes each. 6 microservices runs together 10 times a day with 2 minutes each.

The following is the cost I predicted based on existing resource usage but not incurred by Gitlab or AWS so far.

Applications            Execution Time [per Job/Day/Month]  Jobs per Day    SpotInsatnce Price Monthly

2 frontend              3 mins / 36 mins / 1080 mins        12 jobs         t3.xlarge X 12 X 30 = $25

5 microservices         10 mins / 20 mins / 600 mins        2 jobs          t3.micro X 10 X 30 = $3

Where as Gitlab provides 2000 execution minutes for just $4. Here, It is costing me approx $25 using AWS.

My question here is, is it really better to have self-hosted runner with ec2 autoscaling with spot instance or is it better with gitlab shared runner?

Or let me know If I am missing something, please enlighten me regard the same.

Thanks in advance

Arvin
  • 315
  • 1
  • 3
  • 15

1 Answers1

1

Neither is better than the other since it's up to the user's opinion and circumstance.

The higher cost for AWS is balanced by full control of the runners, and not having to wait to run your jobs (doesn't always happen with shared runners, but it's a possibility). Shared Runners are balanced by their low cost and not needing to have the knowledge and time to maintain them.

Adam Marshall
  • 6,369
  • 1
  • 29
  • 45
  • Thanks for the response @adam I would like to add a point here. Since spot instances get charged for minute based, I think we can setup this on EC2 ASG however again consider the requirements such number of jobs & number of execution minutes for a job. – Arvin Jan 20 '21 at 04:36
  • Can we achieve deleting spot instance right after successful job from gitlab ci configuration? – Arvin Jan 20 '21 at 04:49
  • Yes, you can do that without an issue, but I'd check a few things in the Runners API first. First, I'd check if there are any jobs with a status of "running" for that runner (https://docs.gitlab.com/ee/api/runners.html#list-runners-jobs). If none are running, I'd then pause the runner with the API before deleting the instance (https://docs.gitlab.com/ee/api/runners.html#pause-a-runner). – Adam Marshall Jan 20 '21 at 18:27