What to Do When Merging Faster than Your Continuous Deployment Process

CI/CD
May 30, 2024
Dan Manges
What to Do When Merging Faster than Your Continuous Deployment Process

CI/CD platforms offer concurrency controls to limit the number of simultaneous jobs that can be running. This is useful for feature branches; when an engineer pushes a new commit, if a build was running on a previous commit, it can be cancelled. It's also useful for continuous deployment to make sure only one deployment happens at a time. Effectively, concurrency controls provide a lock around the deployment process.

Although locking is an effective solution to ensure that only one deployment is happening at a time, it can also create a backlog. If multiple engineers merge pull requests at the same time, deploying them all sequentially may take a while. If an engineering team is big enough, there is potential to create a very large backlog.

We considered these use cases when designing concurrency pools in Mint and added some options that most other CI/CD platforms do not have.

Cancel Waiting

In the Continuous Deployment use case when multiple commits are merged in rapid succession, rather than creating a backlog of deployments, a reasonable solution is to skip deploying the earlier commits and only deploy the most recent one.

You can easily do this in Mint by configuring the on-overflow behavior to cancel-waiting

1
2
3
4
5
6
7
8
9
on:
  github:
    push:
      if: ${{ event.git.branch == 'main' }}

concurrency-pools:
  - id: your-org/your-repo:main
    capacity: 1
    on-overflow: cancel-waiting

Cancel Running

For CI builds on feature branches, it's more common to cancel any in progress runs. You can do this in Mint by configuring the on-overflow behavior to cancel-running

1
2
3
4
5
6
7
8
9
10
11
on:
  github:
    push:
      if: ${{ event.git.branch != 'main' }}
      init:
        branch: ${{ event.git.branch }}

concurrency-pools:
  - id: your-org/your-repo:branch-${{ init.branch }}
    capacity: 1
    on-overflow: cancel-running

Queue

Although it's not used as commonly, Mint also offers another configuration option for when you do want to run everything sequentially without canceling any in progress or waiting runs. In this scenario, you can configure the on-overflow behavior to queue

1
2
3
4
5
6
7
8
9
on:
  github:
    push:
      if: ${{ event.git.branch == 'main' }}

concurrency-pools:
  - id: your-org/your-repo:main
    capacity: 1
    on-overflow: queue

More Flexibility

We've designed Mint to be as flexible as possible to accommodate a wide variety of use cases. A few additional configuration options are available that most other CI/CD platforms do not provide.

You can configure the capacity on the pool to allow more than 1 concurrent run.

concurrency-pools accepts an array, so you can have more than one pool apply.

You can configure an if condition on the pool to determine whether it should apply for the run.

For more details, see the documentation on concurrency pools.

Follow Along

We write a lot about software engineering best practices, CI/CD pipelines, and Mint. Follow along on X at @rwx_research, LinkedIn, or our email newsletter

Never miss an update

Get the latest releases and news about RWX and our ecosystem with our newsletter.

Share this post

Enjoyed this post? Pleas share it on your favorite social network!

Related posts

Read more on updates and advice from the RWX engineering team

See all posts
More CPU and Memory for Tasks
CI/CD

More CPU and Memory for Tasks

RWX now supports running tasks with up to 64 CPUs and 256 GB of memory.

Sep 24, 2024
Read now
Adaptive CI Pipelines with Dynamic Tasks
CI/CD

Adaptive CI Pipelines with Dynamic Tasks

Dynamic tasks enable building CI pipelines which are adaptive based on things like the commit contents or data from external data sources. They unlock a lot of possibilities for building highly performant CI pipelines.

May 31, 2024
Read now
Implementing a Remote Debugger with Node and tmux
CI/CD

Implementing a Remote Debugger with Node and tmux

We built a remote debugger into Mint using a familiar construct: setting a breakpoint. It's as easy as calling mint-breakpoint from a task and then using the local CLI to run mint debug {debugId}.

May 29, 2024
Read now