Parallel deployments

You may find that Release's default serial deployment is slow. A series of 30-second deployments can add up to several minutes when executed serially.

To improve on deployment time, you can break your Release workflow up into steps and allow steps to run tasks in parallel.

Let's take a look at how parallel deployment works.

Steps

Steps run sequentially.

You can break your workflow up into serial-dependent steps to ensure that prerequisites are set up first, before dependent services or databases are deployed. This is the same way the default serial deployment works.

Tasks

You can then group tasks together under the workflow steps, and each step can run in parallel as long as there are no interdependencies between tasks in a step.

Errors

Errors are typically ignored during tasks because Kubernetes can automatically restart and keep trying until a service succeeds.

For example, if service B depends on service A, and you mistakenly run service B before service A, service B may fail to start. Kubernetes will retry service B and if service A is now functioning, then service B will start properly.

This may not be the behaviour you want, however. A job in a task might be critical to some dependency further on in the tasks or steps, and you may prefer the whole chain to fail as soon as a failure is detected. In such a case, you can use the halt_on_error: true key to stop the stage and abort the deployment. Any services or jobs successfully started in a previous step or task may still be running or have run, though, so we recommend you assess how you will clean up on the next run.

Waiting

You may not want to wait for a task to succeed completely before moving on. This may be the case, for example, if a frontend takes a long time to deploy and has no particular dependencies in the steps. You can start the task in an earlier step and use the wait_for_finish: false key to let it run in parallel with the other steps.

Visualizing parallel deployments

Here's an example workflow definition:

workflows:
  - name: setup
    parallelize:
    - step: frontend
      tasks: [services.frontend]
      wait_for_finish: false
    - step: migrate
      tasks: [jobs.migrate, jobs.scrub]
      halt_on_error: true
    - step: backend
      tasks: [services.backend]

These steps would deploy like this:

Last updated