简体   繁体   English

如何防止服务器网络中的循环http请求?

[英]How can I prevent circular http requests in a network of servers?

I have a web.py program acting as a web service, delivering responses according to the files in its directory. 我有一个web.py程序充当Web服务,根据其目录中的文件传递响应。

Now I want to build a network of servers, each running an instance of the program. 现在,我想建立一个服务器网络,每个服务器都运行该程序的一个实例。 Additionally, each server has a list of addresses to other servers. 此外,每个服务器都有其他服务器的地址列表。

The motivation behind this is to allow different servers to store different files, delivering a different part of the (now distributed) service. 其背后的动机是允许不同的服务器存储不同的文件,从而交付(现已分发)服务的不同部分。

So far so good, each server looks at its own files, does its thing to create the responses and then concatenates to that all responses he gets from his neighbors in the network. 到目前为止,每个服务器都查看自己的文件,执行其操作以创建响应,然后将其连接到他从网络邻居中获得的所有响应。

The problem is that this can cause circular requests if two servers have each other on their list (directly or indirectly). 问题在于,如果两台服务器在列表上(直接或间接)相互有对方,则可能导致循环请求。

How can I prevent this? 我该如何预防? I was thinking about appending a list of server addresses to each request. 我正在考虑将服务器地址列表附加到每个请求。 A server will add itself to the list when receiving the request. 服务器在收到请求时会将自己添加到列表中。 It will only request a response from those neighbors that are not on the list already. 它只会从尚未在列表中的邻居请求响应。 Is this a feasible approach? 这是可行的方法吗?

Is there something built into http (requests) to collect responses from several servers without creating endless loops? http(请求)中是否内置了一些东西来收集来自多个服务器的响应而不会产生无限循环?

Your approach should work. 您的方法应该有效。

Might be faster to check if the server sees itself on the request list - that means it already processed that request thus all the other servers it has in its list should already be in the response list - no need to check each and every one of them. 检查服务器是否可以在请求列表中看到自己的速度可能会更快-这意味着它已经处理了该请求,因此其列表中拥有的所有其他服务器都应该已经在响应列表中-无需检查每个服务器。 Or maybe use it as a redundant sanity check? 还是可以将其用作多余的完整性检查? Unless your system allows duplicate requests coming in simultaneously on multiple servers. 除非您的系统允许重复请求同时在多个服务器上出现。

AFAIK HTTP handles only client/server (ie point to point) communications, in a 1:1 request/response model - no loops. AFAIK HTTP在1:1请求/响应模型中仅处理客户端/服务器(即点对点)通信-无循环。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM