0

I need to create a (hopefully) simple p2p network where all clients need to maintain a shared set of settings. Some of the things my network needs to do:

  1. Continuously update each peer's state
  2. Perform commands
  3. Fetch & distribute shared resources to all peers

While I do have some ideas on how to go about implementing this, I'm sure I'd just be reinventing the wheel. However, my Google-fu is too weak to be able to find a starting reference / term upon which to build further searches.

Please note that establishing peers is not an issue here: I have a central server with exact info on all peers involved and peers can query the server at will.

I believe my problem can be split to two or - simplified - only one problem:

  1. Maintain a global state where the peers have a way of knowing when they're out of sync
  2. (possibly already accomplished by #1) Determine the peer that will perform the next command

2 should be relatively easy given a synced global state: if there's a task to be performed, just mark it as taken, verify that all peers are notified and then perform it.

So the one real problem I have to solve is how to maintain a global state without making hundreds of IP requests to all peers for every change in the state. I mean, I know all peers HAVE to be notified, I was just hoping for an algorithm that would not require the origin peer to do it all itself. Also, some state changes could be detected by multiple peers at the same time and there probably exists something that solves such conflicts already.

velis
  • 8,747
  • 4
  • 44
  • 64

2 Answers2

0

There's some contradictions in your statement, as you have a p2p network with a central server, but I think I get what you want.

First check out Distributed Hash Tables: https://en.wikipedia.org/wiki/Distributed_hash_table .

DHT is basically a way to assign and find arbitrary pieces of data to a p2p network. In your case you seem to have tasks in addition to data. You can modify the implementation to give each task some unique ID (preferabbly some hash that is well distributed), then run the DHT algorithm to identify the peer that would hold the data if it were regular data, but instead of storing something you would perform the computation.

You've noticed that I don't talk about storing state. That is because in this solution the state is distributed over the p2p network. No node keeps the entire state, but anybody can query the network (with the right ID) to get whatever piece of state they need.

Sorin
  • 11,863
  • 22
  • 26
  • I have looked into DHTs, but rejected them on account that they operate as hash tables: one must know the key in order to retrieve the data. I may be looking at this wrongly, but I think I have a different problem: I need EVERY node to contain ALL the data and achieve this with minimum communication. – velis Jul 11 '16 at 11:28
  • What I think I need is more like BitCoin and its transactions, I think. – velis Jul 11 '16 at 11:37
0

Searching around a lot found me this question which points to a JGroups library that specifically mentions my use case in the tutorial (2.6. Extra credits: maintaining shared cluster state).

I'm looking into it, but not sure if it's the way to go. Seems to cover communication, but not conflict resolution.

Community
  • 1
  • 1
velis
  • 8,747
  • 4
  • 44
  • 64