Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Share WS connection between Peers #3342

Closed
MaciejBaj opened this issue Apr 24, 2018 · 5 comments
Closed

Share WS connection between Peers #3342

MaciejBaj opened this issue Apr 24, 2018 · 5 comments
Assignees

Comments

@MaciejBaj
Copy link
Contributor

Parent #1882

Expected behavior

2 Peers will always share the same WS connection. Both for client and server calls.
https://github.com/LiskHQ/lisk/blob/development/api/ws/rpc/connect.js
Contains logic responsible for establishing Client WS connection. It should be moved and merged with establishing Server WS connection - https://github.com/LiskHQ/lisk/blob/development/api/ws/workers/peers_update_rules.js.
Remaining logic of connect.js - registerRPC should redirect all peer.rpc client calls to the corresponding worker which will handle the request and return the results. A corresponding worker will be identified by storing workerId field - worker process which is responsible for P2P communication with selected Peer.

Advantages:

  • One source of truth about the Peers WS connections stored in the worker,
  • Easier to control connect/disconnect peers actions handling,
  • Decreased resources used by P2P WS connection,
  • Logic ensuring the existence of 1 WS connection per-Peer only.

Actual behavior

  • Client WS are stored as part of peer object on Master process. Server Connections are stored on worker process. Data integrity between processes needs to be kept which seems to be a problem currently.

Which version(s) does this affect? (Environment, OS, etc...)

1.0.0

@nazarhussain
Copy link
Contributor

@MaciejBaj If we need to store workerId which probably is the PID of the socket-cluster worker, then there probably is some really wrong approach in our P2P architecture. Peer communication should always be independent irrespective of the worker or worker count.

Two peers on the network can do full-duplex communication. And for its reliability, they should maintain their own separate connections in any case.

@MaciejBaj MaciejBaj self-assigned this Apr 26, 2018
@pcdinh
Copy link

pcdinh commented May 9, 2018

I found that there are 2 developers working on this issue

https://github.com/LiskHQ/lisk/tree/1935-reuse_socket
https://github.com/LiskHQ/lisk/tree/1935-reuse_socket_peer_pool

Why not joining effort?

@MaciejBaj
Copy link
Contributor Author

@pcdinh branches are relying on each other.

The issue scheduled do to eventually after 1.0.0 release.

@MaciejBaj
Copy link
Contributor Author

The issue is suspended until the following improvements on the P2P layer will be elaborated.

@MaciejBaj
Copy link
Contributor Author

Shared WS connection will be considered to be introduced as part of https://github.com/LiskHQ/lisk-elements/milestone/14 on Lisk Elements.

@MaciejBaj MaciejBaj transferred this issue from LiskArchive/lisk-sdk Nov 27, 2018
@shuse2 shuse2 transferred this issue from LiskArchive/lisk-elements Apr 15, 2019
@diego-G diego-G self-assigned this May 13, 2019
jondubois added a commit that referenced this issue May 27, 2019
…_peers

Share a single ws connection between peers - Closes #3342
@shuse2 shuse2 closed this as completed May 29, 2019
@jondubois jondubois added this to the P2P robust peer selection milestone Jun 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants