Page 1 of 1

Why don't use Pear To Pear communications?

Posted: 29 March 2020, 16:31
by FAngelo94
I noticed that in this days the connection is slow caused of a lot of people that are connected.
To solve this problem why don't you use pear to pear communications?
In this way in every game:
1) When the game start server send all informations to clients and to each cliend send also the IP address of the other clients
2) When someone move something in own client it sends the move information to all client are connected for the game
3) Every 1 minutes (or less) clients send to the server a "backup" of the game, in this way if every client lost connection and they will connect again they don't lose the entire game
4) When only one client reconnect again, the server sents the IP of other client and they share own informations to synchronize the game of the client reconnected

Ok I explained everything with few words and the mechanism can be improve a lot, but it is just an idea of what I mean when I say "use pear to pear". I know this type of communication maybe is more difficult and can cause a few delay but in the most of board game it isn't necessary a perfect timing.

This isn't a suggestion but a question, why don't you use it to solve server overload? Because you think is too difficult or also for other reasons?

Thanks in advance

Re: Why don't use Pear To Pear communications?

Posted: 29 March 2020, 17:36
by JustinFernal
From what I've read, the games themselves are not the bottleneck. You can easily span new servers to host more games, and that's what they did. However, some elements are challenging to scale up, like the matchmaking from what I got.

As you mentioned, the solution involves some complexity (like moving the game logic toward the client, ensuring that nobody can cheat, how to reconcile games at different states...), and doesn't solve the performance bottleneck they are currently facing, at best it might reduce the number of servers needed to run the games.

(I'm not at all an admin of this site, so I just explain what I think I've understood from earlier communications)

Re: Why don't use Pear To Pear communications?

Posted: 04 April 2020, 14:12
by shadowphiar
The biggest problem is that you would have to trust the browsers.

The code running in the browsers manages the user interface, reads what moves the player wants to make, and displays what's going on. This is written in javascript. Javascript is sent to the browser as source text files. There are usually some changes to make it smaller and harder to read, but you can't stop people from doing that. They can examine the game logic - and possibly change it. They can examine the information sent to and from the other computers – and possibly change it.

In fact, the only information that browsers are sent, is what they will then display. There is state that none of the clients know - e.g. the order of cards in a face-down deck. This is never sent outside BGA servers, because someone could open the browser's Developer Tools to see secret information and cheat.

The actual rules decisions, keeping track of what pieces are allowed to move and where they are, is code written in PHP and always runs on servers that BGA control. To run this peer-to-peer, not only would you have to translate this all into javascript, but you would have to make decisions about which browser had the master copy of the board state, and what to do if they ever got out of sync or disagreed (either because of bugs, or if one browser crashed or had to be reloaded, or because of deliberate attempts to cheat).