1. How many users connect at a time? Let us assume 1M DAU(Daily Active Users) Active users/ min = 1M/(24*60) = 900 users/ min Let us assume that, on average, a game lasts for 5 mins. Then we can assume a load of 5000 connected users. In place of any event/ peak we can consider this value equal to 20K connected users.
2. Capacity to be computed by matching engine If we assume each request to have size 1KB, we can have total memory to be 20K * 1KB = 20MB We are using a Balanced BST to find O(logN) matches. That's 20K*log(20K) = 300K instructions
/user/signUp{ "username": "XYZ", "password": "Encrypted Text"}/user/login{ "username": "XYZ", "password": "Encrypted Text"}{ "token": "Auth_Token", "expiresAt": "Expiration Time"}/game/playRequest{ "type": "Type of Game", "color": "Blue", "preferences": { "time": "Max Time Limit", "maxRating": "opponent's rating", "minRating": "opponent's rating" }}/game/moveValidate{ "pieceType": "Pawn", "currentPosition": "e2", "newPosition": "e4"}{ "validate": "ok"}
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
A. User Service - Flow
Note : Concurrency Management:
C. Game Engine - Flow
Already covered in flows
Can we avoid the connection between client and server?
1. We can’t do that because we use the game engine to validate moves.
2. The client code or requests may be compromised. Hence it cannot be used as a source of truth.
3. To validate the move, we store the state of the game and check if it's legal on the server
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?