0

I have a web.py program acting as a web service, delivering responses according to the files in its directory.

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?

null
  • 5,207
  • 1
  • 19
  • 35
  • I don't think there is anything build in that will just solve your problem out of the box... but perhaps you want to make the request sent to collate the data from other servers 'special' so the other servers know that they should not attempt to search other servers... alternatively have uuid passed around with the request so once you get a loop you can identify it and break it – user3012759 May 27 '15 at 15:31

1 Answers1

0

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 (i.e. point to point) communications, in a 1:1 request/response model - no loops.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • I'm not sure what delimiter to choose for the list of addresses, "|" seems to be a good choice as it is not allowed in urls. – null May 27 '15 at 19:45
  • Shouldn't matter if you put that in the request payload/data prior to encoding for HTTP transmission. – Dan Cornilescu May 27 '15 at 21:26