-2

Normally in a private LAN, suppose that I have a web application that needs to access a database on another machine. Which is a better practice?

  1. Access the database with its IP address
  2. Or access the database with its domain name

If it is via a domain name, then we would need to setup something like BIND (https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-ubuntu-16-04) to map the domain names to IP addresses then.

  • 1
    I do not understand the people down voting this question without any explanation. This is a real world question and affects every upcoming startup. – kn330 Nov 4 '16 at 8:36
  • @kn330 Lol. I guess a lot of mean people out there. Perhaps this kind of question is too dumb to be asked on this site. Haha. – sivabudh Nov 5 '16 at 14:27
4

Using domains is always a good practice as you get the liberty to replace the server without having to make any changes to your application(s). Imagine you have a web application running on a single machine (HostA) and your Database running on a single machine (DB1).

A few weeks later you start getting more and more traffic and it is time to scale so you start adding web application machines and now you have HostA, HostB, HostC and HostD running your web application but as you can now see that your Database activity has also increased and you need to move your DB to a bigger and better machine. You go ahead and prepare a new machine (DB2) and now its time time for migration of applications from old DB1 to new DB2.

IP address: Make changes to your application(s), deploy to all 4 or 400 machines.
FQDN: Change the DNS record for the fqdn and it gets propagated to all the application hosts, be it 4 or 400.


If you are just starting out and do not have an infrastructure of more than 50 hosts then you can very well go ahead without DNS, but sooner or later you are going to need it. You will have more than one application running on more than one host and you will need an internal DNS service.

An alternate to DNS is using /etc/hosts where you use an FQDN (db.example.com) in your applications and ensure that all your application hosts have a relevant entry in there hosts file, which can be managed with any configuration management tool. This is more of a hack than a solution but it works and is dead simple to maintain.

  • Thanks much! Any DNS servers you recommend in particular? My stack is Ubuntu, and Python (Django). We normally use PostgreSQL. – sivabudh Nov 4 '16 at 8:06
  • 1
    BIND is a good option. – kn330 Nov 4 '16 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.