Integrate Traffic Distributor with Running Application
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 with 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:
Add Application Copy to Routing
For this example, we run 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.
2. Now we are ready to install Traffic Distributor, specifying both these environments as backends.
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 Entrypoint 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).
For the proper redirection of requests (i.e. to process them through distributor), we need to move the appropriate entrypoint to TD environment. In such a way, it will be placed in front of the chosen pair of backends 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
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. Now, click the Swap button and confirm this action within the appeared pop-up to apply the changes.
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 of 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 entrypoint 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 according to the set traffic ratio between application backends.