问题
I use Netlify to host my static site example.com. Since I don't want to append www, I have to use Netlify's DNS nameservers.
example.com uses API backend api.example.com, which is a CNAME record that resolves to an ELB address *.elb.amazonaws.com.
So 2 DNS lookup is required: first to example.com then to *.elb.amazonaws.com.
Alternative:
Setup Route 53 with another custom domain example.org with an ALIAS record api.example.org that points to *.elb.amazonaws.com, and use api.example.org instead of api.example.com for example.com's API endpoints, then it'd have to look up example.com and api.example.org.
Is there any performance advantage advantage choosing the alternative? Would they be similar since the only difference is it has to lookup api.example.org instead of *.elb.amazonaws.com?
回答1:
Alias records are better than CNAME records, because they return an IP address directly upon resolution.
Example 1:
api.example.com as CNAME for *.elb.amazonaws.com
Your browser will resolve example.com first, download the HTML code, then upon execution of the page, it will need to resolve api.example.com. When it does this, it will:
- receive the CNAME result, then
- need to resolve
*.elb.amazonaws.com
So in the above, there are a total of 3 resolutions required.
Example 2:
api.example.org as ALIAS for *.elb.amazonaws.com
Your browser will resolve example.com first, download the HTML code, then upon execution of the page, it will need to resolve api.example.org. When it does this, it will:
- receive the A result (IP address) directly
So in the above, there are a total of 2 resolutions required.
来源:https://stackoverflow.com/questions/47845088/using-alias-for-elb-if-main-website-dns-manager-is-not-route-53