Introduction

This lesson covers optimizations and tradeoffs to meet the proposed non-functional requirements. We also discuss response time, which is a key factor in our service's efficiency. Let's see how we meet the non-functional requirements, especially when dealing with global player interactions.

Non-functional requirements

We are achieving the non-functional requirements of the game API as follows in the sections below.

Availability

By separating gameplay and CRUD operations on game assets, we ensure service decoupling and improve service availability. Our solution ensures that game configurations are on healthy servers through regular checks and backups. In the unlikely event of a server failure, we can quickly rebuild the session from the most recent backup. Furthermore, we can cap the maximum number of players who can join a game to manage resources efficiently.

Scalability

Regionally distributed clusters make scaling services easier. This is a scalable and cost-effective approach because the cluster controller manages and handles multiple game servers and adding and removing game servers is much easier. Asynchronous communication between the cluster controller and game services enables efficient resource management and load balancing during periods of increased traffic.

Security

We implement authentication/authorization by using a login mechanism. Joining a game lobby requires a JWT access token, which is only issued when there is enough space for players or teams willing to join the game. The JWT token also helps identify the user and the user's privileges in the game. When a game ends, the game server shares game stat updates with the game service via a private cloud to avoid any data manipulation. We also have a patch controller for security and version updates, ensuring that every client joining the game has installed the services' critical updates. To prevent in-game hacking and cheating, each client periodically synchronizes its state with the server. Furthermore, our API validates state changes on the server before merging and broadcasting to other players.

Low latency

We achieve low latency by sending as little data (state changes) as possible over the wire. For global tournaments, we replicate contestant data (weapon appearance, avatars, and other defaults) across regionally distributed clusters so we don’t have to send this information across regions during the gameplay. We implement lag compensation and client move prediction to reduce the user-perceived latency and improve the gameplay experience. We also buffer and prefetch a small data threshold before showing it to other players. Additionally, data is transferred over a dedicated VPC channel with preallocated bandwidth and is specifically configured for high-priority requests to keep latency as low as possible.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.