peer-pad icon indicating copy to clipboard operation
peer-pad copied to clipboard

Switch from websocket-star to the rendezvous protocol

Open mkg20001 opened this issue 7 years ago • 18 comments

Currently peer-pad uses the websocket-star protocol. I would like to help with switching it over to the rendezvous protocol.

This issue is currently blocked by the completion of the javascript implementation of the libp2p rendezvous protocol

mkg20001 avatar May 30 '18 13:05 mkg20001

@mkg20001 could you, in a gist, give us the advantages of the rendezvous protocol over using ws-star? Could you also list the issues this depends on? Thank you!

pgte avatar May 30 '18 20:05 pgte

Comparison of both protocols: https://gist.github.com/mkg20001/7328e2ee1851adc2467911940983e4ec

Currently the only blocking issue is this pr but @VictorBjelkholm seems to be working on a less-complicated version of this module.

mkg20001 avatar May 31 '18 15:05 mkg20001

Thank you Maciej for explaining! (when I said a gist, I meant it in the figurative sense, not necessarily a GitHub gist, but this works great!)

If I understand correctly, by PeerPad using this protocol, we can spread the load between several rendez-vous servers and this won't limit visibility of peers, as they still will be able to find each-other.

Somewhat related is the one problem we're I'm trying to solve here (and in peer-star in general) is to prevent every peer to connect to every peer. While this has allowed us to do quick peer discovery for PeerPad, it's not particularly scalable, as a connection is something expensive.

Right now, IPFS connects to every peer it discovers. Do you see an IPFS configuration that would allow us, by using this protocol, to have better scalability at the document level?

pgte avatar Jun 01 '18 08:06 pgte

If I understand correctly, by PeerPad using this protocol, we can spread the load between several rendezvous servers and this won't limit visibility of peers, as they still will be able to find each-other.

Yes, although currently that has some limitations. If peer A and peer B announce register at rendezvous 1 only and peer C registers at rendezvous 2 only peer A/B and C will never see each other.

The planned solution for this is to use federation to exchange the registrations across multiple rendezvous servers.

Right now, IPFS connects to every peer it discovers. Do you see an IPFS configuration that would allow us, by using this protocol, to have better scalability at the document level?

Edit: This could be achieved by disabling discovery for the global namespace (which should be possible after the interface change) and then only registering to a specific namespace such as pad-123

Currently there is no example code as the libp2p interface-discovery would have to be changed to support registering/unregistering to specific namespaces. There is some discussion going on in this issue about how the interface should be changed.

mkg20001 avatar Jun 01 '18 13:06 mkg20001

@mkg20001 thank you, this sounds very much like something very beneficial. Please do keep us posted on the evolution of this transport.

pgte avatar Jun 01 '18 16:06 pgte

I created a WIP PR on peer-pad-core: https://github.com/ipfs-shipyard/peer-pad-core/pull/19

mkg20001 avatar Jun 12 '18 12:06 mkg20001

According to our scaling requirements, we need 150 concurrent users accessing the same pad. Some back-of-the-napkin math tells me that, to endure that, each node will be connected to 15 other nodes, sending a broadcast message every 500ms.

@mkg20001 Is it possible to do some load tests to see how far off we are from scaling to that?

pgte avatar Jun 19 '18 11:06 pgte

@pgte The rendezvous-protocol does not handle the data transfer, that is done by circuit. For the discovery part: The discovery interval could easily be changed to 500ms (from currently 10s) to enable faster discovery (also once a node is registered it does not need to re-announce itself until the TTL for the announcement expires, so there is no extra load for that).

Edit: tl;dr with a fast p2p-circuit relay server this could be done.

mkg20001 avatar Jun 19 '18 11:06 mkg20001

@mkg20001 this broadcast message is not for discovery, it's an estimate of the messages deriving from the operations. What do we need to scale to that?

pgte avatar Jun 19 '18 11:06 pgte

@mkg20001 ping :)

pgte avatar Jun 20 '18 11:06 pgte

@pgte If you're talking about transferring data then likely fast p2p-circuit relays and/or webrtc instead of p2p-circuit, otherwise I might not have gotten correctly what you were asking for.

mkg20001 avatar Jun 20 '18 11:06 mkg20001

@mkg20001 Not sure. What I'm asking is: could you please create some load tests to make sure we can endure the load when the time comes?

pgte avatar Jun 20 '18 13:06 pgte

This would be a load test that connects many different peers to the same server, with them randomly connecting to each other (15 connections each), and sending messages to each other. Then we would need to somehow, at each peer, measure message delivery and latency. At the end of the test, aggregate all the data and display it. @mkg20001 do you think you could do something like this?

pgte avatar Jun 21 '18 09:06 pgte

@pgte Yes. I will work on that this weekend or next week, depending on when I get the time to do it.

mkg20001 avatar Jun 21 '18 12:06 mkg20001

Awesome, thank you! :)

pgte avatar Jun 21 '18 13:06 pgte

@mkg20001 moved load tests issue to #184 . Could you assign yourself and post updates there?

pgte avatar Jun 27 '18 11:06 pgte

@pgte Yes

mkg20001 avatar Jun 27 '18 11:06 mkg20001

~~@pgte I can't assign myself as I don't have permission for the ipfs-shipyard organization...~~ Edit: Have seen the invite now

mkg20001 avatar Jun 27 '18 11:06 mkg20001