当前位置:网站首页>A little understanding of GSLB (global server load balance) technology

A little understanding of GSLB (global server load balance) technology

2022-07-04 05:45:00 Day by day

gslb(global server load balance) A little understanding of Technology

Preface

For larger Internet companies , Users may be all over the world , here , To enhance the user experience , Companies usually set up computer rooms close to users , To serve the requests of these users .

For example, wechat mainly serves domestic , In China, there will be a large number of computer rooms in many cities to serve domestic users , in addition , Because in North America 、 There are users in Europe , therefore , There will also be corresponding computer rooms in Europe and North America .

here , As a service provider , Naturally, I hope users can visit nearby , Guangdong users visit Shenzhen computer room , North American users visit the North American computer room .

How to do this , For example, everyone visits at the same time www.qq.com, How to ensure the nearest visit ?

This is it. gslb(global server load balance) The stage of .

gslb Implementation scheme of dns

dns programme , It should also be the most mainstream solution , We can think about it first , visit www.qq.com when , What will you do ? First of all, get the name behind the domain name ip, There will be dns recursive query .

  • User dns request , First enter the local dns The server , For example, my side is Shenzhen Telecom broadband , Theoretically, it entered Shenzhen Telecom dns The server , This is what we call localDns
  • localDns I'll check root dns The server ,root dns The server only maintains the top-level domain name dns Server address , So it will return .com This top-level domain name corresponds to dns The server ( Write it down as tld, namely top level domain Top-level domain server )
  • localDns Next , towards .com The top-level domain name server initiates a request , It will return resolvable qq.com Domain name dns The server ( It is called authoritative server )
  • localDns Next , towards qq.com Domain name dns Server initiates request , It will parse www This host corresponds to ip, And back to
  • localDns Get www.qq.com Of ip after , Return to the user .

You can read pictures directly without reading words .

image-20220703200630957
image-20220703200630957

however , One thing you should remember , From beginning to end , All are localDns Helping us run around , So our agent , In the process ,root、tld dns The server 、 Authoritative server , Are only with localDns Dealing with , Completely unaware of the existence of our users , therefore , One thing is very important ,root、tld dns The server 、 Authoritative servers only know localDns Of ip, Without knowing our users ip.

Now we know , Ultimately, I am responsible for qq.com Server's dns server To help us analyze the behind ip, The problem is coming. , This dns server Can you help us to access nearby , The answer is , not always , This is usually for www.qq.com Configure multiple A Record , That is, multiple machine rooms ip, Such as Shenzhen computer room ip、 North American computer room ip, This dns The server is not very intelligent , It returns pollingly ip, That's probably , North American users got the domestic computer room ip, Then how to play , It's jammed .

The problem is , This dns The server is not very intelligent , Can't meet our personalized needs , What shall I do? , There are solutions , You can see the picture below .

image-20220703203122812
image-20220703203122812

Here you can give www.qq.com To configure ns Record , Let it point to another dns service , And this dns service , We can achieve one by ourselves , Nothing more than writing a background service , Open a port , receive dns request , Correct implementation dns Agreement is enough ,gslb It's such a customized dns service .

NS representative “ Domain name server ”, The domain name server record indicates which DNS The server does not respond to this request Domain Authoritative ( namely , Which server contains the actual DNS Record ). Basically ,NS The record tells the Internet where to find the domain IP Address . A domain usually has multiple NS Record , These records can indicate Primary and secondary domain name servers . If not configured correctly NS Record , Users will not be able to load websites or applications .

Here's a NS Record examples :

example.comrecord type:value:TTL
@NSns1.exampleserver.com21600

It is introduced. gslb after ,dns analysis , It becomes such a process .

  • localDns The previous steps are similar , The difference is , To qq.com Domain name dns After the server initiates the request ,qq.com Domain name resolution www.qq.com, Find out www.qq.com Configured with ns Record , here , It will return ns In record value to localDns, And this value, It points to Tencent itself gslb service
  • localDns To Tencent gslb Service initiated request , Be careful , As we have said , At this point udp dns Inquire about , client ip yes localDns Of ip,gslb The server will only get localDns Of ip, such as , Take me for example ,gslb Can't get mine ip, Only Shenzhen Telecom ip.
  • gslb Upon receipt of the request , Theoretically available data include : Which country does the request come from , The requested ip The operator , The requested ip Province and city , Such as China - Shenzhen - telecom , here ,gslb You can choose to return to Shenzhen machine room ip to localDns, Instead of the North American computer room ip, In this way, the nearest access is achieved

gslb Realization

I took a look at Tencent , Should be 06 I made this thing in , I don't know the specific implementation , Just refer to the open source framework , But I guess , It may be based on bind This open source dns Parser to change , After all, now the mainstream dns service , Mainly bind、dnsmasq, I want to practice this these two days gslb, I also built a bind( But I finally found that I couldn't parse my own bind Service , Read the description of the domain name resolver , It seems that you can't ns The record points to my privately built dns service )

Generally, big factories must have their own gslb Realized , I also saw relevant in Ctrip's technical article gslb Technical description .

Suppose we were in a small factory , No self-study ability , So what ?

Actually ,dns Analyzers still have advanced capabilities , Is my low 了 , This is very simple , As long as the cash capacity , You can solve it .

With what I use now dnspod For this parser , By default, it supports several routes , Like telecommunications 、 Move , Different directions can be configured ip.

image-20220703205516324
image-20220703205516324
image-20220703205548217
image-20220703205548217

I understand , What about the big factory , It should have this research and development ability , Unwilling to spend this unjust money , After all , When the company was small , Rent cheap , After growing up , More than one domain name , Compared with self-study , It may not be cheap ; And if you study by yourself , It can also be combined with business depth , Make some flowers to live .

summary

You can also share your views ,gslb To achieve this part , It's all my nonsense , however dns Analytic quotient , What is provided is gslb An implementation of

原网站

版权声明
本文为[Day by day]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207040531454752.html