📜 ⬆️ ⬇️

Choose the closest nodes in the network



Network delays have a significant impact on the performance of applications or services that interact with the network. The lower the delay, the better the performance. This is true for any network service, ranging from a regular site and ending with a database or network storage.

A good example is the domain name system (DNS). DNS is by its nature a distributed system, the root nodes of which are scattered throughout the planet. To simply access any site, you first need to get its IP address.

I will not describe the entire process of recursive passage through the “tree” of domain zones, but I will limit myself to the fact that in order to convert a domain into an IP address, we need a DNS resolver that will do all this work for us.
')
So, where do I get the resolver DNS address?

  1. The ISP provides the address of your DNS resolver.
  2. Find the address of the public resolver on the Internet.
  3. Raise your own or use the built-in your home router.

Either of these options will allow you to enjoy carefree surfing on the world wide web, but if you have a need to convert a large number of domains to IP, then it’s better to choose a resolver more carefully.

As I already wrote, in addition to the resolver of the Internet provider, there are many public addresses, for example, you can get acquainted with this list. Some of them may be much more preferable because they have better network connectivity than the default resolver.

When the list is small, you can easily “ping” it with your hands and compare the delay time, but if you at least take the list mentioned above, then this occupation becomes unpleasant.

Therefore, in order to facilitate this task, I, filled with the imposter syndrome, sketched on Go a proof-of-concept of my idea called get-closer .

As an example, I will not check the entire list of resolvers, but I will limit myself to the most popular ones.

$ get-closer ping -f dnsresolver.txt -b=0 --count=10 Closest hosts: 1.0.0.1 [3.4582ms] 8.8.8.8 [6.7545ms] 1.1.1.1 [12.6773ms] 8.8.4.4 [16.6361ms] 9.9.9.9 [40.0525ms] 

At one time, when I chose a resolver for myself, I limited myself only to checking the main addresses (1.1.1.1, 8.8.8.8, 9.9.9.9), because they are so beautiful, and what to expect from backup ugly addresses.

But once there was an automated way to compare delays, why not expand the list ...

As the test showed, the “backup” address of Cloudflare is more suitable for me, as it is plugged into spb-ix, which for me is much closer than msk-ix, which is stuck in beautiful 1.1.1.1

The difference, as you see, is significant, because even the fastest ray of light cannot reach from St. Petersburg to Moscow in less than 10 ms.

In addition to simple ping, in PoC there is still an opportunity to compare delays using other protocols, such as http and tcp, as well as the time to convert domains to IP through a specific resolver.

The plans have a task of comparing the number of nodes between hosts using traceroute, to make it easier to find the hosts to which there is a shorter path.

The code is raw, there are not enough heaps of checks, but it works reasonably well on clean data. I would be grateful for any feedback, stars on the githaba , and if anyone liked the idea of ​​the project, then we would like to be a contributor.

Source: https://habr.com/ru/post/451866/


All Articles