First of all, I've seen this: http://stackoverflow.com/questions/589669/how-to-redirect-different-sub-domain-requests-to-different-servers But my problem is different.
I have a platform where a user can create a new website using a submdomain. There will be thousands of these, eg abc.mydomain.com, def.mydomain.com . Hopefully if we are successful hundreds of thousands.
I need to be able to route these domains to a particular IP where the app server is. I have this mapping in a database right now.
What are the best practices and recommended technologies here?
I see a couple options:
- Have DNS setup with a wildcard CNAME entry so that all requests go to a single IP where perhaps two machines using heartbeat (for failover) know how to look up the IP in the database and then do an http redirect to the appropriate app server. This seems clunky and slow to me.
- Run my own DNS server that can be programatically managed such that when a new site is created a DNS entry is added. We also move sites around to different app servers, so I would need to be able to update DNS entries in close to real time.
Thoughts anyone?
Thanks.