Blue-Green Deployment, Zero Downtime Updates and Failover Protection with Traffic Distribution Add-On

| July 21, 2020

The absolute majority of production environments need to be accessible to customers at any time, and the most common problem here is the process of project re-deployment. Usually, it is solved with the help of additional software, but their integration is rather complicated and may require extra human resources, as well as the valuable time spent for configuring these tools. Also multiple environment copies can be used as an insurance of high availability. In this situation you can face the problem of proper traffic distribution between such project copies, including aspects like method for requests routing, servers loading rates, etc. Solving all of these issues can become a challenge even for experienced developers.

So in this article we’d like to talk about the solutions that allow to implement an advanced traffic routing, maximally automate this process and get a number of benefits, like:

  • Apply the implicit blue-green deployment or zero-downtime update by redirecting portion or all traffic to a new version of an application
  • Perform ongoing A/B testing by routing part of the traffic to a newer application version to compare performance and UX rates
  • Achieve advanced failover protection and high availability through sharing the load between two fully functional application copies in different cloud regions 
Traffic Distribution Add-On

Let’s go through the main traffic routing methods, see how to manually configure them based on the example of NGINX server and as well how to automate this process using add-on that can be installed in one click.

Round Robin

Round Robin is the most simple and frequently used routing method. It allows to distribute requests one-by-one among the servers with preconfigured priorities and traffic ratio.

Round Robin traffic distribution
Note that this method should be selected only when you have identical content on your endpoints, since data requested by users will be loaded from both backends.

Sticky Sessions

Sticky Sessions method assigns every end user to a specific backend that receives their requests until the corresponding session is live. Herewith, on the first visit, customer is routed based on the servers’ weights, while assigned backend is remembered, ensuring that all subsequent requests from this user go to the same environment.

Sticky Sessions traffic distribution

Commonly, this is implemented through remembering IP address, which is not optimal, as there could be a lot of customers behind a proxy, resulting in unfair balancing. Thus, there can be used a solution based on the session cookies to make a persistent routing, when each browser becomes an unique “user”, allowing to make balancing more even.

In such a way, Sticky Sessions distribution of a new users is similar to the round robin method and is performed according to the pre-set priority. For example, setting 50% to 50% will make both application versions being visited by the equal amount of unique users, which is useful. But, irrespectively of the server’s weights, the “old” user’s requests will always be redirected to the hosts they are assigned to, until their session is expired or cookie is removed.

Also, upon setting 100% ratio for any server, the second one won’t be removed from the settings completely, so it will be able to process the already existing sessions.


Failover traffic routing allows to redirect the customers to a backup standby server in case of any failure on production server. In other words, you have primary server and backup one - all the requests are initially forwarded to the first endpoint, while the second one is used only in case the primary service goes down. The requests will be automatically redirected to the working server, so that your users, probably, won’t even notice any interruption in the application work.

Failover traffic distribution

Automated Traffic Distribution

In order to automate the settings, there can be used a Traffic Distributor add-on that is available for one-click installation through Jelastic Marketplace

install traffic distributor

It provides smart traffic routing using the method and distribution ratio specified by the developer or system administrator within the user-friendly wizard.

Automated Traffic Distribution

With the help of Traffic Distributor, it’s simple to perform so-called “invisible” updates that will cause no downtime for your application due to traffic ratio slider functionality. You can do traffic switching between backends while add-on installation or later on with add-on reconfiguration. To do this click on Add-Ons > Configure.

configure Traffic Distributions

Change Routing method (round robin, sticky sessions or failover) and Traffic ratio based on your needs.

Traffic Distribution routing method

Such possibility is highly demanded in the current reality of the rapid development and fast growing concurrency, as you need to constantly update your project in order to remain demanded, conquer new users and, generally, not to fall behind your competitors. 

Managing Traffic Distributor via API

Jelastic allows to automate the Traffic Distributor management using the platform embedded API methods. So, let’s see how to control load balancing between your projects without GUI:

1. In order to work with Platform via API, you need to get a platform access token. Then such API call can be performed as POST request to install traffic distributor add-on, for example, you can do this with the curl command.

2. Now, you can create the Traffic Distributor using the install method:



{session} - user’s session or access token 

{env_name} - name of the target environment

{env_display_name} - the visible name of the environment in the Dashboard

{addon_settings} - list of add-on specific settings in JSON format (key/value pairs)

Available settings:

  • extip [boolean / number] - enables the public IP(s) for the Traffic Distributor
  • balancerCount [number] - amount of the balancers inside the Traffic Distributor
  • routingMethod [string] - defines the necessary method of the traffic's routing. Possible values: 
    • round-robin
    • sticky-sessions
    • failover
  • backend1 [string] - host of the first backend
  • backend2 [string] - host of the second backend
  • range [number] -  percent of the traffic routed to the first environment

API request example:

curl -X POST '' -d session=a4b66e7376064865a0c512c5fd21b7a3b32ca3d8 -d jps=traffic-distributor -d envName=traffic-distributor -d displayName=TrafficDistributor --data-urlencode settings='{ "extip": true, "balancerCount": 1, "routingMethod": "round-robin", "backend1": "applicationap1", "backend2": "applicationap2", "range": 60 }'

3. Traffic distributor reconfiguration can be done with API executeappaction method:



  • {session} - user’s session or authentication token 
  • {app_unique_name} - unique name of the installed add-on. Could be found as the value of the uniqueName key in the response of GetEnvInfo method.
  • {your_addon_settings} - list of add-on specific settings in JSON format (described above).

API request example:

curl -X POST '' -d session=a4b66e7376064865a0c512c5fd21b7a3b32ca3d8 -d appUniqueName=f5698359-f4ff-42fd-8955-1f9a750abcd9 -d action=configure --data-urlencode params='{ "extip": true, "balancerCount": 1, "routingMethod": "round-robin", "backend1": "application1", "backend2": "application2", "range":0 }

With Jelastic Traffic Distribution add-on you can easily get advanced traffic routing with maximum automation in order to smoothly perform blue-green deployment, zero-downtime updates or ongoing A/B testing, as well as achieve advanced failover protection and high availability. Try out at one of the Jelastic PaaS hosting service partners.