Continuous Delivery is a practice used in the software industry to automate and improve the process of software delivery. It is all about adopting practices to release high-quality software fast through automation of the build, test and deployment processes. This post describes features in Appcito Application Delivery System (ADS) to facilitate Continuous Delivery, and the specific ways our DevOps team achieves Continuous Delivery by using Appcito ADS internally.

What is Blue/Green Deployment?

An important technique for reducing risks in case of continuous deployments is known as Blue/Green deployment. Typically the current live production environment is termed as “Blue”. The technique consists of bringing up a parallel “Green” environment with the new version of the software so that the switch from Old to New (or Blue to Green) instantaneously without a downtime.

Appcito ADS provide a mechanism to reduce the risk further by allowing you to split the live traffic between Blue and Green deployments. You can test new deployments of your application by sending a small fraction of your traffic to the Green environment and monitoring the health analytics. If you see any issue, simply roll back (just by disabling the split condition) so that all traffic flows to the Blue environment. Once the issue is fixed, you can deploy the new Green instance and resume the split test. As confidence in the Green instance grows, you can increase the amount of traffic flowing to the new environment. Once 100% of traffic flows to Green and its declared as production, you can safely decommission and archive the legacy environment.

While splitting the traffic, Appcito ADS preserves the user experience by sticking the traffic to either Blue or Green.

Continuous Delivery at Appcito with Blue/Green Deployments

Below are the steps our team uses to automate Blue/Green deployment internally, including the some screen captures and sample code.

Step 1. In the Appcito ADS settings page click on the “Blue/Green” tab to configure Blue/Green service.

Appcito ADS Blue/Green tab

Step 2. Select the Blue service from drop list. A Green service will be cloned by Appcito ADS for that service.

Appcito ADS Select Service

Step 3. Supply name for Green service and you can spilt traffic based on certain rules as shown below:

Appcito ADS Define Service

For illustration lets spilt traffic based on condition:

Appcito ADS split condition

Here, I am sending traffic landing on /web/index.html which is my new resource URI to Green service.

Step 4. In next section, you need to provide Server IP of the Green server OR pick server from an existing IP address.

a) Adding Green server IP manually

Appcito ADS Enter Green IP Address

b) Picking Green server IP from existing slot.

Appcito ADS Select Blue Service

Step 5. Once the Green service has been created, you can start your benchmarking.

In this, I am using curl call to fire up couple of hundred requests to the Green server.


for i in {1..100}; do echo "Request Number:" $i ; curl ‘http:///web/index.html' -o /dev/null -w "%{http_code} \n" -s ; done
Request Number: 1
200
Request Number: 2
200
Request Number: 3
200

As you see in above sample, my calls are succeeding with a response status code of 200 – OK.

Creating the Green service, we are ensuring current traffic is not disrupted and new deployment works as expected.

Step 6. Now, confirm the traffic analytics through the Appcito ADS Analytics dashboard.

Click on Analytics —> Blue/Green

In this section, you will notice stats like Average CPU utilization

Appcito ADS Cpu Utilization

and Service Errors.

Appcito ADS Service Errors

In this case application metrics looks good. We have successfully tested the Green service.

Working Faster and Smarter with the Appcito ADS REST API

To speed up our work, our DevOps team frequently automates the steps I described above by using the Appcito ADS REST API. Here are some of the powerful API calls to automate Blue/Green Deployment:

LIST ALL TRAFFICSPLITS:

GET http://api.appcito.com/api/v2/applications/{application}/hosts/{host}/trafficsplits

Note: UserRole: ApplicationAdmin, ApplicationUser
Parameters to supply :
Response Content Type: application/json
X-Account :
X-User :
application : [optional]

CREATE A NEW TRAFFICSPLIT:

POST /applications/{application}/hosts/{host}/trafficsplits

Parameters to supply :
Response Content Type: application/json
X-Account :
X-User :
application : [required]
host: [required]
body : {
"name": "string",
"description": "string",
"state": "string",
"splitSlices": [
{
"service": "string",
"percentage": "integer",
"condition": "string",
"code": "string"
}
],
"id": "string"
}

UPDATE A TRAFFICSPLIT:

PUT /applications/{application}/hosts/{host}/trafficsplits/{trafficsplit}

Parameters to supply :
Response Content Type: application/json
X-Account :
X-User :
application : [required]
host: [required]
trafficsplit : [required]
body :
{
"name": "string",
"description": "string",
"state": "string",
"splitSlices": [
{
"service": "string",
"percentage": "integer",
"condition": "string",
"code": "string"
}
],
"id": "string"
}

As cloud service availability is critical to Appcito and our customers, we continue to find automated ways to maintain availability while rolling out new features. Blue/Green deployment is an important step in our deployment process. It is designed with the expectation that application/infrastructure failure can happen and will happen and enables us to react quickly to negative events. Having the flexibility to use a graphical interface or API calls provides even stronger control over an improved continuous delivery process.

By Prajith Nair, March 2, 2016