Setting up different application instances under one DNS

We have a custom java web app. We are setting it up in instances in different vps (different providers, different locations). We have for example:

Instance 1: http://server1/app1
Instance 2: http://server1/app2
Instance 3: http://server2/app3

Each instance is independent and self contained. We have several docens of this instances and will continue to add them.

My question is regarding the dns managment, as we want to map different subdomains to the instances.

client1.mypp.com  > http://server1/app1
client2.mypp.com  > http://server1/app2
client3.mypp.com  > http://server2/app3

clientN.mypp.com  > http://anyserver/appN

Right now we are adding the A records manually to the DNS records to relate subdomain to the ip. We will develop some code to do it using the API of the DNS provider.

Is this the most appropiate aproach? Should we use some kind of proxy instead? We expect to have thousands of isntances accros different servers. I am interested in perfomance and availability.


Solution 1:

The most effective approach would be to ditch the reliance on IP/port and use something inside your URL to direct you to the correct service.

client1.mypp.com app1 http://server1/app1

client2.mypp.com app2 http://server1/app2

This could be a load balancer or reverse proxy. See, e.g., nginx, haproxy, pound, etc.

enter image description here