Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it better to have a fewer A records and dozens of CNAME records or vice verca?

One (or few) A records per unique IP and many CNAME records per A record:

@   3600    IN  A   123.123.123.123

a   3600    IN  CNAME   @
b   3600    IN  CNAME   @
c   3600    IN  CNAME   @

Bunches of A records:

@   3600    IN  A   123.123.123.123
a   3600    IN  A   123.123.123.123
b   3600    IN  A   123.123.123.123
c   3600    IN  A   123.123.123.123
share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

Better for what?

From a performance perspective, it's marginally (and by "marginally", I mean "technically, but not noticeably") better to use the A records, as your DNS responses will not need to include the extra data.

If the CNAME points to another domain for which your server is not authoritative, it can have a greater impact due to a resolver needing to make more requests to get to the result.. but in the example you've provided, the performance impact is completely negligible.

From a manageability perspective, the CNAME may be easier, as you'd only need to make one change instead of several to account for an IP change to the system.

If the deployment is as simple as the example that you've provided, then it honestly doesn't matter either way.

share|improve this answer
add comment

Is it better to have a fewer A records and dozens of CNAME records or vice verca?

No. Less glibly, there really isn't much reason to prefer one to the other, provided that you don't point CNAME to CNAME along the way.

The main advantage that the CNAME choice would mean is that you don't have to add an MX record, or other ephemera, to each subdomain. The main drawback is that you can't vary those without converting back to an A record.

share|improve this answer
add comment

Re: CNAME vs A - it really doesn't matter for performance, per other answers.

However, if you do use a CNAME, don't make it a pointer to @, make it a pointer to some other sub-domain in the zone.

The reason is that @ also contains other records, e.g. your SOA, NS, MX records etc.

If your CNAME points to @, then all those other records will (incorrectly) start to exist for your aliased subdomains too.

BTW, if your web host becomes multihomed (i.e. it has multiple A records, or even an A and AAAA) then a CNAME to the real host machine is only a single record to maintain. If you had used A records you'd need to duplicate the list over and over for each subdomain.

share|improve this answer
    
Thanks for your input, as I do currently have sites with multiple CNAME records pointing to @. –  Stuart Powers Feb 4 '12 at 1:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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