- Why Stoat Doesn't Use Peer-To-Peer
Peer-to-peer (P2P) is a networking model where, instead of using a centralised server which all clients connect to, clients all connect to each other in a distributed model. Peer-to-peer is great in that there isn’t anything to host on an instance level. The onus of distribution is handled by users themselves.
So, why doesn’t Stoat use a peer-to-peer approach for voice and video streaming? Peer-to-peer was briefly considered and experimented with but ultimately deemed unsuitable for a few reasons. They are:
- Privacy and security. As clients are communicating directly, there is high chance of leaking sensitive data, such as IP addresses. It also limits Stoat’s ability to enforce privacy protections.
- Latency and scale. Real-time peer-to-peer streaming works reasonably well with a handful of people of close geographical proximity, but as it scales the amount of data throughput becomes larger, which increases latency. Streaming to many people is also hard on device performance. Channels can have hundreds of users in them, and peer-to-peer breaks down at that scale. Implementing peer-to-peer for small-scale situations and client-server for large-scale situations is possible, but is a significant amount of work.
- Usability. Peer-to-peer often works great, but sometimes it doesn’t. Occasionally there will be firewall issues or devices won’t have the performance required to stream smoothly. Features like scaling video for users on lower bandwidth connections, recording chats, transcribing speech, and smoothly handling moderation are all things that become much more difficult or demanding (and in some cases impossible) in a peer-to-peer architecture.
- Complexity. While it is possible to engineer around some of these issues, doing so introduces a lot of complexity. Stoat has a small team with limited availability, so avoiding additional overhead is important to be able to actually get something out the door that can be maintained. A server-client model is also consistent with Stoat’s behaviour as a whole.