0

I am trying to create an hosting service for websites basically using multiple machines. Then, when a user creates a website, I give him a random identifier (ex: "a4589", "pu8we" and so on) used as a subdomain.

Then, because I will have multiple physical servers, I was wondering to create a record in the DNS for each subdomain. More or less like these records:

a4589 A 192.168.0.23
pu8we A 192.168.0.23
az336 A 192.168.0.25
z012p CNAME ec2-89-65-36.amazon.com

But it will create many entries (thousands of entries) and I am not sure about the resilience of such solution. The main advantage is the capability to switch from a server to another with some transparency.

Have you some ideas to do this another way or do you think this solution is correct? Using virtual hosts on the final machines (Apache servers) is of course the last part of the resolution (I give this precision due to a comment made on this question).

William R
  • 3
  • 3
  • If vhosts are "not avaible", how do you set up two sites on the same IP-Adress? Also, DNS is pretty mature and *very* resilient. A few thousand hosts entrys will not kill your DNS. – bjoster Sep 12 '19 at 12:37
  • 1
    In general: the number of entries in a single DNS zone is practically unlimited with most DNS servers. But please note that there are [many different name server implementations](https://en.wikipedia.org/wiki/Comparison_of_DNS_server_software) and one implementation might work better for you than another. For instance maintaining a classic bind zone file, incrementing the SOA serial and reloading the zone is probably not nearly as efficient as making an automated API call or adding/deleting an entry in a SQL database backend when you have a new sign-up and/or cancellation. – HBruijn Sep 12 '19 at 13:23

1 Answers1

0

There is no single solution. You can have a huge number of entries in a zone - you may want to look at a database driven nameserver like powerdns to make managing the domains easier (ie you can just use SQL commands or a frontend to manipulate it).

An alternative might be to change your naming convention. Instead of having a single subdomain, yoy can break it up into (at least) 2 parts, eg randombit.group.mydomain.com and then use wildcards, so you can have *.group1.mydomain.com A x.x.x.y. and *.group2.mydomain.com A x.x.x.z

Be careful to run low ttls to reduce downtime during changeovers, and watch/avoid the format of cnames - they likely do not work how you think they do.

Depending on your design - if the servers all mirror the same sites, and this is being done for redundancy/load reasons you may want to look at a simpler DNS solution and using load balancing techniques instead.

davidgo
  • 5,964
  • 2
  • 21
  • 38