dmotz / trystero

✨🤝✨ Build instant multiplayer webapps, no server required — Magic WebRTC matchmaking over BitTorrent, Nostr, MQTT, IPFS, Supabase, and Firebase
https://oxism.com/trystero
MIT License
1.33k stars 92 forks source link

maximum connections, full mesh vs partial mesh #40

Closed resession closed 7 months ago

resession commented 1 year ago

what is the maximum connections we can have?

webrtc will not be able to handle too many connections at the same time since you have to connect to each peer separately, lots of usage of resource.

there is "partial mesh" where you forward data to your peers, so if you are indirectly connected with a common peer, then the data and messages still gets sent across the network.

like this https://github.com/lazorfuzz/liowebrtc or https://github.com/geut/discovery-swarm-webrtc

any thoughts on this or scalability? do we know around how many connections trystero can do, is there any maximum limit we know of with trystero?

jeremyckahn commented 1 year ago

Direct connections would be limited by the browser's WebRTC connection limit. That limit seems to be different across the various browsers, but at least on Chrome it appears to be 500 connections. This Stack Overflow post has more info.

rogersanick commented 8 months ago

Any updates here? I'm most of the way through building a game that I think (hope) will have more than 255 players.

I'd love to use trystero for the lobby / matchmaking to keep it fully decentralized. Otherwise, I'll just use trystero for matches and use a small server for matchmaking.

dmotz commented 8 months ago

Partial meshing isn't underway yet, but there's a new version in the works on the next branch that rewrites most of the library and uses a new peer connection management layer. This won't have partial meshing out of the gate but does open the door to adding that mode in the future. One goal of this new branch is to also reuse peer connections when the same peers are in overlapping rooms simultaneously.

rogersanick commented 7 months ago

Thanks @dmotz - that's awesome. When can we expect the next branch to be merged? Anything I can help with? For reference I'm using your library to build a decentralized board game. Going live at the end of April.

dmotz commented 7 months ago

@rogersanick I mentioned this on the other ticket, but try using trystero@next in your project and report back with any issues. The API hasn't changed beyond the default strategy being swapped to Nostr (which has vastly more public relays than WebTorrent). The new version aims to have much faster connection times and is rewritten to open the door to more optimizations down the road.