Codebuild service usage optimization

1

Hello,

Is there a way to optimize the usage of CodeBuild? We are using the CodeBuild a lot these days, and at times QUEUED phase duration is too high, which may be the reason. Is there a way to reduce this duration, because it is causing huge charges for us? I am open to any suggestions to reduce the billing on CodeBuild compute usage.

Thank you in advance.

1 Answer
1
Accepted Answer

CodeBuild has an on-demand fleet, which scales based on incoming customer volume. If capacity is not immediately available, CodeBuild tries to queue the builds for additional capacity to be available in the build fleet. So, QUEUED time is vary based on the resources availability with respect to availability of resources in region. Unfortunately, we do not have any option to reduce Code Build QUEUED phase duration. As said, it is subject to availability and allocation of resources to provision build container in particular region. More importantly, CodeBuild charges are applicable from PROVISIONING phase and QUEUED phase duration not calculated towards billing.

The following are some additional options for cost optimization in relation to CodeBuild.

  • Rightsize your compute resources. CodeBuild allows you to choose from different compute types like BUILD_GENERAL1_SMALL to BUILD_GENERAL3_LARGE. Choosing an appropriately sized instance based on your build workload can help reduce costs.

  • Use AWS Graviton processors where possible. Graviton processors on EC2 instances offer better price performance compared to x86 based instances and can lower your CodeBuild costs.

  • Keep build durations short. CodeBuild charges per minute, so optimizing builds to complete faster helps minimize costs. Some ways to do this include only running necessary steps, using caching, and addressing inefficiencies.

  • Leverage build caching. Caching dependencies, artifacts, and previous build steps can avoid unnecessary recompilation and testing, speeding up builds.

Additionally, I would suggest to verify the compute environments selected and analyze the past month usage metrics Memory and CPU. Based on that data, check the feasibility in selecting lower compute environments to reduce the cost. [+] Monitoring CodeBuild resource utilization metrics: https://docs.aws.amazon.com/codebuild/latest/userguide/monitoring-utilization-metrics.html [+] Build environment compute modes and types: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment.types

profile pictureAWS
answered 4 months ago
  • Thank you for replying and detailed information about optimization.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions