webmeshproj / webmesh

A simple, distributed, zero-configuration WireGuard mesh solution
https://webmeshproj.github.io
Apache License 2.0
420 stars 16 forks source link

Scaling #15

Closed lonnietc closed 1 year ago

lonnietc commented 1 year ago

Hello,

I have been on the hunt for a library or project that might be useful as the core for a type of P2P mesh relay network system that massively scales.

The idea is to have a core server node running on a physical machine that provides the P2P mesh network relay system and then to build some P2P applications (ecommerce, distributed database, etc.) that will call their local server API to communicate across the network to other similar applications on other nodes.

It sounds like your webmesh might be a good start but I would like to investigate more as well. Thanks

tinyzimmer commented 1 year ago

You have me intrigued, but with many questions :stuck_out_tongue:

I'll try to break down what I think I understand next to the features that are currently there.

The idea is to have a core server node running on a physical machine that provides the P2P mesh network relay system

Webmesh seems appropriate for this. For the sake of discussion let's call your bootstrap/core node the "supernode". In an ideal world for the best throughput - you'd be running it on a physical machine with a strong NIC capable of jumbo frames. In similar setups I've been able to get 5-10Gbps depending on various factors. Unless you have the utmost faith in that node (or aren't particularly concerned with ephemeral data loss) you'd likely want to run at least one or two other Raft members to ensure HA. The data that gets stored in the mesh state isn't sensitive and pretty easy to replace (just bootstrap a new network and let everyone back in). So it really just comes down to a matter of preference there.

and then to build some P2P applications (ecommerce, distributed database, etc.) that will call their local server API to communicate across the network to other similar applications on other nodes.

Several ways you could accomplish this right now. Most recently I've implemented the "App Daemon". Which is effectively just running a webmesh node in a sort of "stand-by" mode that receives RPC commands from an external process. The code ain't pretty, but you can see an example of using this over in the fyne-app repo. Another possibility is to simply embed the webmesh library in your app. I'm trying to make sure that remains doable, but better documentation and testing is definitely needed. That approach would also require your app run with at least NET_ADMIN privileges for managing interfaces. The App Daemon concept takes care of that by allowing an unprivileged process to control the privileged node.

In addition to the above, there is the concept of "Features" advertised by each node. You aren't able to register your own right now, but it's something I want to make possible. Similar to CRDs in Kubernetes if you are familiar. You'd call the API to figure out who has what features, but after that you don't really need the API anymore. Once you're in the network you have persistent WireGuard tunnels to all your peers, and an optional DNS server for resolving addresses internally.


So it sounds like the potential is there for what you are wanting to build - but you'd likely find issues along the way that still need resolving. Happy to help in any way I can.