DNS Misunderstandings
"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge." - Stephen Hawking
In my last episode I talked about "Authentication and Authorization in System Design". Previous episode link is below:
Now, let's continue the streak of learning system design. We are going to discuss about DNS in a very detailed way. So, let's begin.
DNS is a commonly used term and almost every engineer knows about it. The simple definition is "Domain Name System".
But is it that simple?
Yes, many would argue. It is a simple, domain name resolution and mapping domain names to IP addresses. Is this enough? Or is this the complete definition?
No, the power of DNS is way more than this. The function of DNS is way more than this. When you work on a distributed systems, DNS is often the best guide to help us manage the high traffic across various regions.
Understanding the simple definition first!
"There are two types of people in this world: those who make things happen and those who wonder what happened. The first group is less crowded." - Mark Twain
DNS stands for Domain Name System, which is a hierarchical decentralized naming system for computers, services, or any resource connected to the Internet or a private network. It is essentially the phonebook of the Internet, allowing users to access websites and services using easy-to-remember domain names, rather than IP addresses which are used by computers to identify each other on the Internet.
DNS works by translating human-readable domain names (such as google.com) into machine-readable IP addresses (such as 172.217.6.46), which are used by computers to communicate with each other over the Internet. When a user types a domain name into their web browser or clicks on a link, the DNS resolver on their computer sends a request to the DNS server to look up the IP address associated with the domain name. The DNS server then responds with the IP address, allowing the user's computer to connect to the appropriate server and access the requested resource.
DNS also supports other functions, such as caching and load balancing, to help improve the performance and reliability of the Internet. It is a critical component of the Internet infrastructure and is used by billions of people every day to access websites and services across the world.
How DNS does the address resolutions?
First thing, for system design interviews, this may be unnecessary to know. It could be simply understood as somehow with some hierarchy it does the resolution and that's it. But for the completeness of this article I will try to explain how it works?
DNS uses a hierarchical and distributed system to resolve domain names into IP addresses. When a user types a domain name into their web browser or clicks on a link, the DNS resolver on their computer sends a request to a DNS server to resolve the domain name.
The DNS resolution process works as follows:
Once the IP address is resolved, the user's computer can connect to the appropriate server and access the requested resource.
The DNS resolution process is fast and efficient, and allows users to access websites and services using easy-to-remember domain names, rather than having to remember complex IP addresses.
领英推荐
Let's get into the difficult part.
DNS in a highly scalable and distributed system
DNS as network layer load balancer
While DNS is often used for domain name resolution and mapping domain names to IP addresses, it can also be used as a form of network layer load balancing. This technique is known as DNS load balancing.
DNS load balancing involves using multiple IP addresses for a single domain name, with each IP address pointing to a different server. When a client requests the domain name, the DNS server returns one of the IP addresses in a round-robin fashion, distributing the load among the different servers.
While DNS load balancing can be a simple and cost-effective way to distribute network traffic among multiple servers, it has some limitations. For example, it relies on DNS caching, which can lead to uneven distribution of traffic and potential performance issues. Additionally, it cannot take into account factors such as server load or network congestion, which can impact the performance of the overall system.
As such, while DNS load balancing can be a useful technique in certain scenarios, it is not suitable for all situations. Other forms of load balancing, such as hardware or software-based load balancers, may be more appropriate for systems that require higher performance, reliability, and flexibility.
DNS for disaster recovery in distributed systems
Why did the programmer quit his job after a disaster recovery exercise?
Because he realized he was better at creating disasters than recovering from them!
In addition to load balancing, DNS can also be used to support failover and disaster recovery in distributed systems. For example, if one of the servers in the web application fails or goes offline, the DNS server can be configured to return the IP address of a backup server instead, ensuring that users can still access the application even in the event of a failure.
Overall, DNS is an important component of distributed systems, providing a scalable and reliable mechanism for resolving domain names into IP addresses and supporting key features such as load balancing, failover, and disaster recovery.
Homework
Hope you found this helpful. Thanks for reading!
We will be covering each and every topic which is a must for System design interview. So, stay tuned and follow my page for new posts.
Happy learning System Design! Check previous episode?here?here.
Follow us on?MADAlgos
Sales Associate at American Airlines
1 年Thanks for sharing
I approach 'Distraction' as an outlier, maintaining focus and prioritizing meaningful work. ??
1 年It's very much helpful.
Previously Project Manager at Infosys. Actively looking for a job.
1 年Thank you for giving good insight on DNS.