Today we open source Marco Polo DNS Daemon.
KKBOX provides music services over 6 regions, including Taiwan, Hong Kong, Singapore, Malaysia, Japan, and Thailand. We deploy technologies to improve performance and user experience. We build serveral data centers in Taiwan, and partner with EdgeCast, Akamai, and CloudFront to make sure our users get best performance.
We implemented algorithms in API-level to select best server or CDN vendor for delivering audio data. API-level algorithms gave us flexibility to dispatch clients.
However, there is still something we cannot control in API-level, like image service. We want to dispatch clients to different data centers or CDN vendors in DNS-level.
Marco Polo DNS Daemon is a DNS server written by Perl, which can return different CNAME results based on client’s DNS resolver IP address and edns-client-subnet information. This allows us to control traffic by country code and AS number.
For example, we want to use country code and expect it returns a CNAME record to
$ dig test.kkcube.com.country.mp.kkcube.com @22.214.171.124
And it returns:
;; ANSWER SECTION: test.kkcube.com.country.mp.kkcube.com. 20 IN CNAME TW.test.kkcube.com.
Which is because I am in Taiwan. And if you want to use AS number:
$ dig test.kkcube.com.asn.mp.kkcube.com @126.96.36.199
Then it will return:
;; ANSWER SECTION: test.kkcube.com.asn.mp.kkcube.com. 20 IN CNAME 3462.test.kkcube.com.
Which AS3462 belongs to my ISP, HiNet. Now you can setup
test.kfs.io CNAME to
test.kkcube.com.country.mp.kkcube.com, and setup another DNS record for
TW.test.kkcube.com to accelerate Taiwan’s clients.
Please feel free to give us feedback in GitHub.
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.