Skip to content
nicholas harteau edited this page Jan 3, 2011 · 13 revisions

Constraints

Task Run Order

Task run order can be computed four ways:

  • Unconstrained

  • N-parallel

  • N%-parallel

  • App/Env Constraints

The first three methods are pretty self-explanatory, unconstrained jobs execute as many tasks in parallel as there are available worker processes. N parallel allows N tasks to run simultaneously; a job with 100 target hosts and N=10 allows 10 tasks to run in parallel. N% parallel computes a percentage based on the total supplied host count; a job with 150 target hosts and N=25% allows 37 hosts to run in parallel.

The last run option is more complicated but much more powerful. With this method, hosts are grouped by application and one or more environments. Constraints are applied based on intersections of application and environment. Environments and applications may overlap, allowing complex modeling of production deployments.

Example 1: One Application, Two Environments

Our first deployment has 20 total hosts, all running the same application which we'll call frontend. There are 6 hosts on the east coast, fe{1-6}.east.example.com and 6 on the west coast, fe{1-6}.west.example.com

Here we group hosts together into applications and environments:

example-deployment:     # this is a deployment name
  apps:
    frontend:
        inline:
          - fe{1-6}.east.example.com
          - fe{1-6}.west.example.com
  envs:
    cluster:            # this is the environment type
      east:
         inline:
           - fe{1-6}.east.example.com
      west:
         inline:
           - fe{1-6}.west.example.com
  constraints:          # define some constraints;
    cluster:            # here we specify that only
      app:              # one host per cluster may be
        - frontend: 2   # run at any time

Example 2: Two Applications, Two Environments

example-deployment:
  apps:
    frontend:
        inline:
          - fe{1-6}.east.example.com
          - fe{1-6}.west.example.com
    backend:            # now we have two applications
      inline:
          - be{1-5}.east.example.com
          - be{1-5}.west.example.com
  envs:
    cluster:
      inline:
        - east:         # 'east' includes hosts from frontend AND backend
          - fe{1-6}.east.example.com
          - be{1-5}.east.example.com
        - west:
          - fe{1-6}.west.example.com
          - be{1-5}.west.example.com
  constraints:
    cluster:
      concurrency:
        frontend: 50%   # dynamically flattened at runtime
        backend:  1     # both constraints

Example 3: Sequences

example-deployment:
  apps:
    frontend:
        inline:
          - fe{1-6}.east.example.com
          - fe{1-6}.west.example.com
    backend:
      inline:
          - be{1-5}.east.example.com
          - be{1-5}.west.example.com
  envs:
    cluster:
      inline:
        - east:
          - fe{1-6}.east.example.com
          - be{1-5}.east.example.com
        - west:
          - fe{1-6}.west.example.com
          - be{1-5}.west.example.com
  constraints:
    cluster:
      concurrency:
        frontend: 50%
        backend:  1
      sequence:
        - [ backend, frontend ]