Same service endpoint, but different code versions with Route 53

Let’s imagine we want to gradually deploy a new version of our service or we want to run an A/B testing in production to gather some data. Is this possible with Elastic Beanstalk? By default no, but we can do some DNS magic and solve problem. And when we are saying “DNS magic”, we are referring to Route 53, because we are in the cloud. We take the opportunity to say again and again that some knowledge about DNS is required for any engineer who wants to work with distributed systems.

The solution

In order to solve this problem, you need 2 Beanstalk environments, each having its own code version. After that, you have to create a record set having type A, pointing to one Beanstalk environment, similar with what is in the below print screen:

In the same way, we’ll create another record set, for the the other Beanstalk environment:

 

Basically, the endpoint round.<your-domain>.com has 2 services behind, with different weights: if we make 3 calls, 1 call is served by the environment 1 and 2 by the second one.To do that, simple curl the dns you defined in Route 53 and you see how your requests are balanced across are those 2 endpoints. Keep in mind that there are situations when a host caches the DNS result, but overall this setup is tested and it works.

Don’t forget to share this article with anyone that could be interested in this topic or to add your comment below!

Happy cloud computing with AWS to all of you!