This whitepaper is for historical reference only. Some content might be outdated and some links might not be available.
Build phase
The process of building an application involves many steps, including compilation, resource generation, and packaging. For large applications, each step involves multiple dependencies such as building internal libraries, using helper applications, generating resources in different formats, generating the documentation, and so on.
Some projects might require building the deliverables for multiple
CPU architectures, platforms, or operating systems. The complete
build process can take many hours, which has a direct impact on the
agility of the software development team. This impact is even
stronger on teams adopting approaches like
continuous
integration
Schedule builds
To mitigate this problem, teams working on projects with lengthy build times often adopt the “nightly build” (or neutral build) approach, or break the project into smaller sub- projects (or a combination of both). Doing nightly builds involves a build machine checking out the latest source code from the repository and building the project deliverables overnight. Development teams may not build as many versions as they would like, and the build should be completed in time for testing to begin the next day. Breaking down a project into smaller, more manageable parts might be a solution if each sub-project builds faster independently. However, an integration step combining all the different sub-projects is still often necessary for the team to keep an eye on the overall project, and to ensure the different parts still work well together.
On-demand builds
A more practical solution is to use more computational power for the build process. On traditional environments where the build server runs on hardware acquired by the organization, this option might not be viable due to economic constraints or provisioning delays. A build server running on an Amazon EC2 instance can be scaled up vertically in a matter of minutes, reducing build time by providing more CPU or memory capacity when needed.
For teams with multiple builds triggered within the same day, a
single Amazon EC2 instance might not be able to produce the builds
quickly enough. A solution would be to take advantage of the
on-demand and pay-as-you-go nature of
AWS CodeBuild
If you use a build tool on EC2 instances running as a fleet of
worker nodes, the task distribution to the worker nodes can be
done using a queue holding all the builds to process. Worker nodes
pick the next build to process as they are free. To implement this
system, Amazon Simple Queue Service
You can further enhance this setup by dynamically adjusting the
pool of worker nodes consuming the queue.
Auto
Scaling
You can define scaling conditions using
Amazon CloudWatch

Amazon CloudWatch can monitor the number of messages in the build queue and notify Auto Scaling that more or less capacity is needed
Storing build artifacts
Every time you produce a build, you need to store the output
somewhere. Amazon S3 is an appropriate service for this.
Initially, the amount of data to be stored for a given project is
small, but it grows over time as you produce more builds. Here the
pay-as- you-go and capacity characteristics of S3 are particularly
attractive. When you no longer need the build output, you can
delete it, or use the S3
lifecycle
policies to delete or archive the objects to
Amazon S3 Glacier
To distribute the build output (for example, to be deployed in test, staging, or production, or to be downloaded to clients), AWS offers several options. You can distribute build output packages directly out of S3 by configuring bucket policies and/or ACLs to restrict the distribution. You can also share the output object using an S3 presigned URL.
Another option is to use
Amazon CloudFront