4

We are using the current CNAME record for a server, i.e.

 foo.example.com => CNAME => server1.example.com 
 server1.example.com => CNAME => ec2-34-142-138-31.compute-1.amazonaws.com 
 ec2-34-142-138-31.compute-1.amazonaws.com => A => 34.142.138.31
  1. Is this configuration common?
  2. Is the performance penalty when using 2 CNAME records critical?
  3. To minimize the impact of CNAME lookup, should I set a larger TTL for the 1st CNAME, but shorter CNAME for the 2nd CNAME?

i.e.

 foo.example.com => CNAME (TTL=86400) => server1.example.com 
 server1.example.com => CNAME (TTL=300) => ec2-34-142-138-31.compute-1.amazonaws.com 
Ryan
  • 5,831
  • 24
  • 72
  • 91
  • Potential duplicate question of http://serverfault.com/questions/460475/is-subdomain-cname-slower-than-using-original-address however the detailed sub-questions here are useful. – Simon East Jul 22 '16 at 06:13

2 Answers2

2
  1. yes. for example yahoo use it. here is the output of dig www.yahoo.fr on my machine which is in France:

    ; <<>> DiG 9.9.5-4-Debian <<>> www.yahoo.fr
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1935
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 2, ADDITIONAL: 3
    
    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 4096
    ;; QUESTION SECTION:
    ;www.yahoo.fr.                  IN      A
    
    ;; ANSWER SECTION:
    www.yahoo.fr.           300     IN      CNAME   rc.yahoo.com.
    rc.yahoo.com.           300     IN      CNAME   src.g03.yahoodns.net.
    src.g03.yahoodns.net.   300     IN      CNAME   any-src.a03.yahoodns.net.
    any-src.a03.yahoodns.net. 300   IN      A       77.238.184.150
    any-src.a03.yahoodns.net. 300   IN      A       188.125.73.108
    
    ;; AUTHORITY SECTION:
    a03.yahoodns.net.       172800  IN      NS      yf1.yahoo.com.
    a03.yahoodns.net.       172800  IN      NS      yf2.yahoo.com.
    
    ;; ADDITIONAL SECTION:
    yf1.yahoo.com.          86391   IN      A       68.142.254.15
    yf2.yahoo.com.          86391   IN      A       68.180.130.15
    
    ;; Query time: 342 msec
    ;; SERVER: 127.0.0.1#53(127.0.0.1)
    ;; WHEN: Tue Jul 29 09:57:01 CEST 2014
    ;; MSG SIZE  rcvd: 227
    

You can see the double redirection via several CNAME records returned in the same DNS packet.

  1. No. DNS uses cache mechanism and recursive resolvers such that many users don't even notice the number of DNS resolvers implied as it is fast and usually a request does not necessaraly trigger the whole resolving porcess

  2. Not necesserally. See the value for the yahoo example which are common. Here is another (french) example: a clothes merchant:

    $ dig www.laredoute.fr
    ; <<>> DiG 9.9.5-4-Debian <<>> www.laredoute.fr
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28156
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3
    
    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 4096
    ;; QUESTION SECTION:
    ;www.laredoute.fr.              IN      A
    
    ;; ANSWER SECTION:
    www.laredoute.fr.       1800    IN      CNAME   www.laredoute.fr.glb.pprgroup.net.
    www.laredoute.fr.glb.pprgroup.net. 30 IN A      217.109.67.129
    
    ;; AUTHORITY SECTION:
    pprgroup.net.           172800  IN      NS      gtm1.pprgroup.net.
    pprgroup.net.           172800  IN      NS      gtm2.pprgroup.net.
    
    ;; ADDITIONAL SECTION:
    gtm1.pprgroup.net.      172800  IN      A       194.206.254.11
    gtm2.pprgroup.net.      172800  IN      A       217.109.67.126
    
    ;; Query time: 679 msec
    ;; SERVER: 127.0.0.1#53(127.0.0.1)
    ;; WHEN: Tue Jul 29 10:03:57 CEST 2014
    ;; MSG SIZE  rcvd: 178
    

The usage is to put a normal TTL value on the CNAME record and adapt the TTL value on the A record (depending of the IP address stability, wanted DNS-based load balancing, ...).

Manu H
  • 158
  • 6
1

DNS lookups in general are very non-impacting (maybe 20-30ms depending on the response time). If you don't see the records changing very often, setting a higher TTL will help with caching.

Nathan C
  • 15,059
  • 4
  • 43
  • 62