Game Backend : Chapter 1 - Introduction
Published: 2023-12-11 18:51:09

Yolo fellow game developers. I am writing this blog series to understand various aspects of game backend development. 

In this blog, we will start by understanding "What a game backend is?", and in the next upcoming blogs we'll learn the key aspects required to implement backend servers, deploying api's to them and also connecting those api's with our game. 

I will be using Unity as the game engine and AWS for implementing the backend architecture, but we will understand the core concepts behind the implementation so we can apply those concepts for any tech stack you prefer. Let's get started.


![Server room](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/72t1p5ofhl1u11vhssoo.png)

## What is a Game Backend?
In game development, the term "back end" refers to server side technologies that help in providing various remote or online services to manage player and game state and enhance the overall gaming experience.

Game Backends are usually implemented using RESTful API's that will be accessed by the game clients (games installed on your device or consoles) using HTTP/HTTPS requests.



Here is a list of few of the essential functionalities that are implemented using a gaming backend:

• **Multiplayer Support** : It helps in authenticating and authorising players, manage player accounts and data which helps in maintaining the integrity of multiplayer gaming environments. It also helps in matchmaking players with similar skills to make the game more competitive and enjoyable.

• **Data Storage and Management** : Game backends help in securely storing player profile data, game progress and statistics, leaderboard data and other types of telemetry data which help in making the game better and profitable.

• **Content Delivery** : It also helps in delivering dynamic content, updates and patches for ensuring continuous improvement without having the need to push app updates post-launch.

• **Communication** : It helps in maintaining a connection between the player and the backend services in order to sync the game and maintaining smooth gameplay. It also helps players to communicate with each other in case of multiplayer games.

• **Data and Logic Processing** : Complex game logic calculations which are too heavy for client processing are handled by backend servers. Apart from this, backend servers use real time analytics and machine learning processing to provide personalised gaming experience.

---

## Types of backend architectures
Here's an overview of some of the backend architectures:


###Instance based architecture
- These are the traditional dedicated servers which can be either physical servers or cloud based virtual servers.
- Each instance in this type of architecture can run its own operating system and own set of applications which gives the developers complete control over the server environment.
- Since resources are not shared, performance is stable which makes it suitable for games with steady player traffic.
- Games like 'Minecraft' often use dedicated servers whereas small indie games use cost effective virtualized server instances.
- Amazon EC2, Google Compute Engine, Digital Ocean droplets are few examples of cloud based instance server platforms.  


###Serverless architecture
- The term 'serverless' is misleading. It doesn't mean there are no servers in this architecture, rather it is a cloud based model where the cloud provider manages the complexity of the infrastructure and allocation of server resources when required.
- It is extremely suitable for developers who want to focus purely on the game feature development usually as microservices and not care about the underlying infrastructure complexities. That's why the name 'serverless'. 
- Game backend services with variable traffic can benefit from this architecture as you mostly pay for the resources that have been allocated by the provider based on the traffic making it cost effective and reliable.
- For example, REST API's to update player scores and store transactions can be implemented using AWS Lambda functions along with AWS Gateway API or by using Google Cloud Functions with Google API Gateway.


###Container based architecture
- This architecture involves packaging your game backend into containers.
- Containers are isolated packages containing the code, runtime, libraries required to run your backend code.
- These containers are portable and can be hosted on the developer's workstation, dedicated servers or other types of infrastructure, thus making it consistent irrespective of the underlying architecture.


###Peer-to-Peer architecture
- In this architecture, instead of relying on a central server, each player's device directly communicates with other player's device. Each peer, acts both as the client and the server.
- One peer acts as the host or the master peer, handling some of the critical functions who is selected mainly based on connection stability or hardware capabilities.


###Blockchain architecture
- Unlike storing data and in game transactions on a single server, data is stored across a network of computers or servers, thus making the data immutable and resilient to tampering.
- New monetisation models like the play to earn model use blockchain technology.
- Platforms like Enjin and Sandbox use blockchain to implement gaming ecosystem.


##Types of servers

![Types of Servers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/83se04s6yll9py9jiru2.jpg)

###Web Server
In game development, a web server manages requests over HTTP protocol and other such protocols from game clients which can be your game app or a browser. It processes the requests and provides the required response to the client which may include HTML static content, images, videos, etc. It can also act as a gateway or proxy to other servers.

Examples of web servers:
- Nginx
- Apache HTTP Server
- Windows IIS
- Node.js

###Application Server
An application server hosts the web application and api's responsible to process game logic, data processing and connecting with the database servers to serve dynamic content based on the incoming requests.

Examples of Application Servers:
- Flask Gunicorn
- .NET Application Servers
- Node.js application servers

###File Servers
A file server is used to store and manage files. It can be used to store game assets, updates and patches that player clients can download. Cloud file storage services like AWS S3 buckets can also be considered a type of file server.

## Conclusion
As we conclude the introduction of game backends, the next chapter will be more about turning theory to practice. We will learn about setting up an AWS EC2 instance with an Nginx web server making it easy for beginner developers in getting started with building their own game backend architectures.
Stay tuned!!! GG!!

---

###Social Media : 
[Daniel Yunus](linktr.ee/danibwuoy)

###Games :
[Gamebee Studio](https://gamebeestudio.com)
[CC Games Studio](https://chuchugames.com)