如何将网络请求分派到(地理位置上最近的)服务器 [英] how to dispatch network requests to the (geographically) closest server

查看:217
本文介绍了如何将网络请求分派到(地理位置上最近的)服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java编码员,对网络的工作方式(基本的UDP/TCP连接除外)不是很熟悉

I'm a Java coder and not very familiar with how networks work (other than basic UDP/TCP connections)

说我在美国,亚洲,拉丁美洲和欧洲的计算机上运行着服务器.当用户请求服务时,我希望他们的请求发送到离他们最近的服务器.

Say I have servers running on machines in the US, Asia, Latin America and Europe. When a user requests a service, I want their request to go to the server closest to them.

我是否可以拥有一个地址:mycompany.com,并以某种方式将请求路由到适当的服务器?显然,当有人访问cnn.com时,他们会从附近的服务器接收图片,视频等.坦白说,我不知道它是如何工作的.

Is it possible for me to have one address: mycompany.com, and somehow get requests routed to the appropriate server? Apparently when someone goes to cnn.com, they receive the pictures, videos, etc. from a server close to them. Frankly, I don't see how that works.

顺便说一句,我的服务器不提供网页服务,它们提供其他服务,例如股票市场数据…….以防万一.

By the way, my servers don't serve web pages, they serve other services such as stock market data....just in case that is relevant.

由于我是一名程序员,所以我很想知道一个人将如何在软件中做到这一点.由于这仅仅是一种好奇心,所以指向商业产品或服务的指针对理解这个问题不是很有帮助:)

Since I'm a programmer, I'm interested to know how one would do it in software. Since this is little more than an idle curiosity, pointers to commercial products or services won't be very helpful in understanding this problem :)

推荐答案

一种简单的方法是查看进入UDP DNS请求的IP地址的第一个字节(A类),然后根据您可以提供的内容正确的地理位置IP.

One simple approach would be to look at the first byte (Class A) of the IP address coming into the UDP DNS request and then based off that you could deliver the right geo-located IP.

这篇关于如何将网络请求分派到(地理位置上最近的)服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆