0

I have a backend hosted at api.example.com using Flask. I would like to be able to make changes to this api without interrupting live traffic. I'm thinking of ways to accomplish this but without using a load balancer.

What I have done so far:

  1. I created two A endpoints (api-main.example.com) & (api-backup.example.com) and a CNAME (api.example.com). Everytime I would like to make a change I would set the target of the api.example.com to the api-backup.example.com, make changes to api-main.example.com, test everything and then set the target of the api.example.com back to api-main.example.com. The problem with this is that it is not instant, it takes time for the DNS to change so it's not something that can be used.

  2. Another method I tried is using Cloudflare's load balancer to load balance between 1 IP and two endpoints. Again I have api-main.example.com with weight 1 and api-backup.example.com with weight 0. Everytime I would like to make a change I would flip the weights so as api-backup to be 1 and api-main to be 0. Once I update the code I would flip the weights back. This method WORKS perfectly, but I would not like to use a load balancer as it defeats the purpose of a load balancer and I have to pay every thousand queries.

I'm looking for a better way to accomplish this, either setting up a load balancer of my own, or if anyone has a better suggestion I would really appreciate it.

0 Answers0