Deploying Blue-Green App

Apcera supports blue-green deployments using route weighting.

A blue-green deployment is an approach to deploying an updated version of a web application application that minimizes potential downtime and risk. You start with the current ("blue") version of an application that is receiving all of the external traffic at a given route ("", for example). A new ("green") version of the application is deployed at the same route, but initially receives no traffic. Gradually, the amount of traffic routed to the "green" app is increased to 100 (all traffic), while the amount routed to "blue" is decreased to 0 (no traffic).

This tutorial uses APC to perform the deployment. You can also perform a blue-green deployment from the Web Console. See Managing Job Routes for more information.

Deploy app versions

To perform a blue-green deployment using APC, follow these instructions.

1) Deploy the "blue" version of the sample java-web-app with a route.

cd \sample-apps\example-java-web

Substitute your domain name in the route.

apc app create blue --routes blue.route.cluster-name.tld --start --batch

For example, if is the domain:

apc app create blue --routes --start --batch

Check the route in a browser and verify deployment. You should see "Hello World."

2) Update the app.

Open the file \example-java-web\ in a text editor.

Change the output to "Hello Universe."

Save the changes.

3) Deploy the "green" version of the app and disable default route generation.

apc app create green --disable-routes --batch

When you create an app it is assigned a default route in the form of app name, current namespace, domain name. In this case, we want the "green" app's route to be the same as the "blue" app's route, so we disable default route generation with the --disable-routes option (see Default Routes and Ports for more information).

4) Expose a port on green app.

apc job update green --port-add 0

The --port-add 0 option means that Apcera will randomly select an available port and provide it to the application on its $PORT environment variable. You can also select a specific port, like 8080.

5) Start the green app.

apc job start green

Add route and weights

6) Add the blue route to the green app and set its weight.

apc route add --app green --weight 25
  • Route Type (http/tcp) [http]: http (default)
  • App Name [green]: green (default)
  • Endpoint []: (must enter)
  • Port Number (on app) [choose open port]: 0 (default)
  • Weight [25]: (confirm)

To bypass the menu options, you can specify the --type http option.

7) Check the route weights.

To see the current route weighting for each app, use the route show <route> command:

apc route show

The output indicates that green is receiving some of the traffic and blue is receiving the remainder. A route weight of "0" means that the designated app will receive all remaining traffic. Note that route weight does not equate to traffic percentage.


8) Test route weighting.

Go to the route web page and press Enter repeatedly. On the fourth enter, the output should display "Hello Universe." The app is load balanced so that some of the time traffic is routed to the green version of the app.

Adjust route weighting

9) Split the traffic between the green and blue apps.

apc route weight --app green --weight 50%

Test and verify results. With 50 weight, the traffic is split between the two apps.

apc route show

10) Increase the traffic to green.

apc route weight --app green -w 75

Test and verify the results. The green version should receive a majority of the traffic.

apc route show

11) Continue increasing traffic to green until it is receiving all of the load.

apc route weight --app green --weight 100
apc route show

Delete the route

12) Delete the route from the blue app.

Once you increase the weight to 100 for green so that all traffic is directed to it, you can delete the the route from blue app.

apc route delete --app blue