Integrate Traffic Distributor into Your Running Application

| October 26, 2016

In most cases, developers face the problem of traffic distribution between several backends when already having some running application, with a pool of existing users and constant incoming load. Thus, beside of the general traffic sharing configuration difficulties, it is additionally complicated by the necessity to apply the appropriate “on-fly” changes to the front-end application instance. In many cases, it causes a temporary app downtime. So in order to minimize such negative influence on your customers, below we’ll consider the ways to easily and painlessly integrate Jelastic Traffic Distributor (TD) solution into your running application topology.

Traffic Distributor provides ability to benefit on a number of useful solutions, like:

In case you want to install Traffic Distributor manually for the newly created environments, please use the detailed walkthrough.

And to make this add-on available for already running applications follow the instructions below.

Add Application Copy to Routing

For this example, we run an application in Apache server within the primary-env environment.


1. First of all, you need to set up one more environment with the same application inside (we’ll name it second-env).


  • If you are handling Docker-based service, its copy can be easily recreated from scratch through the appropriate image deployment within a separate environment.
  • You can also use the environment cloning feature, to instantly get the identical environment copy (i.e. with all the appropriate data and settings being already set up inside) of any type. However, in this case you should be aware that your customers may experience a brief downtime during this operation, as environment should be stopped for being cloned.


Note: Don’t forget to properly configure the hardcoded data (e.g. direct links, IPs, etc) for application inside your cloned environment if such are used.

2. Now we are ready to install Traffic Distributor, specifying both these environments as endpoints.

Tip: If there are several environment regions available at the chosen hosting provider platform, you can subsequently migrate one of your environments to a different hardware set. This will grant better failover protection, as you’ll be able to deal with the hardware-dependent problem at one of your backends (if such occurs) by routing requests to the instance, that remained operable.

3. That’s it! Traffic Distributor is already set and ready to handle requests to our application.
The only thing that remained to do is to redirect incoming traffic from the first environment to Traffic Distributor.

Configure App Entry Point via TD

If being run in production, most likely your application has some custom domain name already bound to our initial environment (primary-env in our case).

Tip: To bind a custom domain name to environment, follow one of these guides depending on used entry point:

For the proper redirection of requests (i.e. to process them through the distributor), we need to move the appropriate entry point to TD environment. In such a way, it will be placed in front of the chosen pair of endpoints and share the incoming load among them based on specified settings.

In order to accomplish this, follow one of the next simple procedures based on the used custom domain binding method:

  • if using CNAME redirect - swap domains among the initial and TD environments
  • if using A Record - swap Public IPs to transfer used external IP to the TD environment

Swap Domains

1. Hover over the environment your custom domain is bound to (e.g. primary-env) and select Settings from the set of appeared functional icons.
2. Within the opened environment settings tab, the required Custom domains section will be displayed by default, so just select your Traffic Distributor environment within drop-down list of the Swap domains suboption.swap-domains-jelastic

Now, click the Swap button and confirm this action within the appeared pop-up to apply the changes.

3. In a minute your application custom domain name will be moved to the environment with Traffic Distributor so that both of your backends will become available via this domain.

Swap Public IPs

The easiest way to pass Public IP from primary-env (i.e. the one your custom domain is attached to) to Traffic Distributor is using the corresponding External Addresses Swap functionality, available through Jelastic CLI.

It allows to perform the required configurations in a single command, sparing you from the manual A Record reconfiguration.

However, if you prefer to work via GUI, this operation can also be accomplished with a manual change of Public IP address your domain points to. For that:

1. Ensure that NGINX balancer instance in your Traffic Distributor environment has external IP address attached and get its value through the dashboard.
2. Then, re-configure your A record via DNS manager, so that it leads to this new IP address.


  • For these changes to be applied, you need to wait for the current DNS record cache expiration (as until this happens, DNS servers may return old domain address upon request). To know the exact period the domain’s old IP address will be kept in cache, check the TTL setting value within your DNS manager (usually states in seconds).
  • Do not forget to recheck your application configurations for the hardcoded IP-dependent settings and adjust them accordingly.

3. After the application entry point address is changed, you can detach Public IP from the initial primary-env (if it is no more required for direct access) and do not pay for the unused option.

That’s it! Now all incoming traffic for your custom domain will be processed by Jelastic Traffic Distributor solution, which, in its turn, will route it accordingly to the set traffic ratio between application endpoints. Test drive it on your own at one of Jelastic hosting partners.

Related Articles

Automated Traffic Distribution for Blue-Green Deployment, Zero Downtime Updates and Failover Protection

Jelastic Launched Smart Traffic Distribution Add-On for Blue-Green Deployment and Failover Protection