How to build your back-end in the cloud
Linode's Will Blew explores the options available to developers who want to use the cloud to host their back-end
For any game developer, making their next launch a success involves a range of different priorities -- coming up with a game idea that resonates, designing and building the world around that idea, and then developing the engine and infrastructure to support your players. Making the right choices around how you run and support your game over time can be daunting, but there are lots of options available to help.
Using the cloud to host your back-end is an obvious choice for many developers -- whether you work at a small company launching an independent title or a AAA studio targeting millions of players at launch, the cloud is supposed to provide the scale and service levels that your game will need. However, you will have some decisions to make.
Where to start
For a lot of game developers, their development work starts with the game engine -- the core service that will run the game experience for players and organise how the art and design assets are displayed, particularly for games that will be multiplayer.
A good game engine will make a game run well and provide that great experience for players. The game will also take whatever data gets created by players -- from high scores to character designs -- and will store them for later use.
You can have more freedom if you have developed your own engine from scratch, but this does represent an overhead
The decision you make here will also affect your back-end infrastructure choices. For example, you may choose a service like Unity or Unreal Engine to run your game, particularly if you are developing a first person game or a massive multiplayer game. These services can provide you with what you need to power your game, but they may also have specific requirements on how and where you can host your IT systems.
Alternatively, you can have more freedom if you have developed your own engine from scratch, both in terms of how you develop your game and your infrastructure. However, this does represent an overhead in terms of management and maintenance over time.
Alongside your engine, you will normally have multiple other components that make up your game experience for players. These might include matchmaking services and player lobbies, scoreboards, or other public player data sharing systems, but they will also have to be considered in your overall design and how you will scale over time. Whichever path you take, you will have to think about hosting.
All these systems will have to be hosted somewhere, and this can be something that you do yourself or in partnership with another provider. For most companies, the expense of building up your own data centre is prohibitive at the start, so cloud hosting is the most popular approach. By looking at your hosting approach, and how you approach running on these services, you can avoid some future problems around scaling up your implementations. For those not familiar with planning capacity or running servers, this can be a steep learning curve.
Root cause analysis
Normally, developers will focus on getting games completed and out to the wide world so they can start earning revenue. This can then be where problems are discovered that weren't found in testing. For end-users, poor performance can be caused by many things -- bad Internet connections, lag, or underpowered machines at their ends.
However, the host infrastructure can also be responsible for problems, such as lobbies not working properly or poor performance. This can be down to net code that is not able to handle player volumes efficiently, or the infrastructure itself not being right for the game.
As an example, you can look at dedicated game servers for the basic principles. Most developers will be familiar with dedicated servers from their own gaming -- these provide the infrastructure for hosting players and running the game from a central location. They will have different capacity levels depending on the hardware they have in place and the number of players per game. For some hosts, hundreds or thousands of players will be able to play on one physical server, while others will have tens of players per machine due to the increased compute and resources needed to support players. Each machine should be able to scale up and comfortably support players to the limit, but this is not always the case.
As machines get to their player limits, they can struggle to support that strong play experience that everyone wants. This can lead to players voicing their frustrations on support forums or social media. It's therefore better to be ahead of the curve when it comes to preventing problems.
Gaming infrastructure is similar, but the problems are scaled up. The biggest challenges for games developers normally come around areas like knowing how to scale up infrastructure to cope with player number growth. It's here that developers will fall into two categories -- those that have experience diagnosing issues already, and those that have to hunt out the specific problem for the first time.
The biggest challenges come around knowing how to scale up infrastructure to cope with player number growth
For experienced developers that are used to looking out for problems, this can be a simple task which involves looking at how to scale up more efficiently. Cloud services are great options for this, whether you look at hyperscalers or alternative cloud providers. This is particularly true for areas where offloading compute or storage workloads can deliver better results, such as looking at volume or object storage for games files. Integrating these approaches to resources can make it easier to scale up using the cloud, but they have to be thought about so that the costs for assets like storage don't go up without appropriate revenues coming in from players too.
For those that have less experience here, it can be more difficult to know why a problem is taking place, and take longer to find and fix the specific issues involved. This is where expert advice can come in very handy, so don't be afraid to ask others around their experience during scaling events or with particular problems. It can help avoid a lot of time spent investigating the wrong areas, and put the focus on fixing problems as soon as possible. If you are using a cloud or hosting company, then ask their support teams for help -- they should be able to provide good advice on what other companies taking similar approaches have done in these situations.
What are the issues coming up?
Planning ahead can help massively when it comes to building and running IT infrastructure to support your players. So what are the biggest issues coming up? The first is how to deal with growth effectively.
The COVID-19 pandemic has led to more people playing games. Gaming, along with other entertainment and media sectors, is one of the few markets that has seen growth continue over the past six months based on research by Deloitte. According to the company's 14th Digital Media trends survey, 34% of US adults played video games with their family at home, while 27% played with friends to connect socially. The biggest live streaming service for gaming has seen 50% growth in hours watched during the pandemic, too.
For developers, this represents an opportunity to get more people playing their games. However, it means that the trend around growth can be unpredictable. For some developers, this can be part of their incremental growth plans and help them achieve their objectives on player numbers more easily, as people want more games to play. For others, it can be too much growth, as things either grow faster than planned and have not been budgeted for or even go viral through streamer interest or celebrity endorsement.
This can be the definition of a "nice problem to have" but it is still a problem, nevertheless. Being able to scale up and support player growth successfully is something to discuss and plan for in advance, so that you can benefit from the effort that you have put in over time. Using cloud services can help you manage these problems, as you can work with a company that is used to scaling up and down in response to demand levels. The most important element here is the support team that you will have available to you, and how they will respond when you get in touch. Ask around and find which companies have human support teams that respond fast enough to queries, and that have experience around gaming.
Looking at what kind of data you will use can help you to make the right choice on how to host that data over time
Linked to this is how you plan and manage your budgets for IT too. With many games now supporting multiplayer experiences and persistent worlds, you may have much more data to store over time. This will require a budget. Depending on how you architect your applications and games, you may have to keep player data for a long time, leading to growth in what you store and an increasing budget. Thinking about this in advance can really help.
This data can be expensive to host, so planning ahead is essential to manage your costs as you grow, if not reduce them. As data gets created continuously, you can avoid problems rather than having to work around them under pressure. Looking at what kind of data you will use for your games -- so assets for gaming, and object storage for specific player files, for instance -- can help you to make the right choice on how to host that data over time. If you need instant, real-time access to data as part of your game experience, then this will be more expensive than storage that takes longer to retrieve and share back. Tiering data and planning ahead on how to manage this data over time can help you get the best balance of performance and cost.
Six technologies to look at in the cloud
There are multiple infrastructure technologies that you can run in the cloud to support your game. Here are the top five to look at, and where you can make use of them:
- 1. Storage
Whatever kind of game you create, you will need to store data over time. There are multiple different types of storage available that can be used to manage that data over time, and they suit different purposes.
- Object storage is useful when you have large volumes of items to store -- each item is a separate object alongside its associated metadata, and all these objects are part of a global identifier list for those assets. This is useful for static media assets.
- File storage is a more traditional approach to storing data, based on hierarchies and folders -- this is used in different ways depending on the size of the game and how many assets are needed. In smaller games, these assets will be compiled in or provided from local storage on the device, but for larger games these assets would be supplied from local storage and from content delivery networks as required, based on when files are needed or updated.
- Block storage is another approach where individual groups of blocks in disks are managed directly.
- 2. Compute instances
Cloud providers offer compute based on the size of server instances that customers might want. If you need more compute, then you can either increase the size of an instance or use multiple instances to deliver the right level of support. These compute instances will be responsible for interacting with the player, so they have to be sized for maximum performance while also being the right level of cost.
Modern games will use multiple instances to process instructions from player devices and return the results, as well as manage the results and the impact on other players or the game environment. Depending on the volume of players that your game will look to host, and the amount of data that those players will create each, you can estimate the size of instances that you will need to run, and how many of each instance.
- 3. Kubernetes
Kubernetes is becoming increasingly popular for modern applications, able to automate the creation of new instances as they are needed. For gaming infrastructure, where the number of players may go up and down during the day, this can make it easier to scale. This goes alongside developers making more use of microservices and smaller application components.
For gaming, Kubernetes services can help you scale your instances and services up to cope with more players. However, you have to be supporting a game that is designed to work in this way from the start.
Picking a database will involve understanding the requirements that you have for a given use case
- 4. Databases
While game servers are part of the front-end and interact with the player, game databases are responsible for the data management side on the back-end. These are used alongside storage to handle data, and they are responsible for managing data over time. For example, this can be used for information around the game environment or player data, or for holding game information to be used in things like scoreboards or rankings lists.
For any game, picking a database will involve understanding the requirements that you have for a given use case. Will the database need to update in real time, or can it handle updates less frequently? How many transactions will it have to handle, and how many writes and reads will it need to support? Alongside the current level, you should also consider how you will scale up over time.
- 5. Analytics
Alongside your game infrastructure, you will want to look at the data that your game creates. This will be useful for your own monitoring around your game infrastructure, as well as for looking at things like player behaviour or game state. Using analytics, you can get more insight into what is taking place within your game and use this to make decisions over time.
Depending on how expansive your game, this could provide simple metrics like player numbers over time through to more detailed analysis into how fast players are going through game content. Using data held in your database, you can carry out analytics and then either create reports or run dashboards.
- 6. Security
Wherever there are rules, there will always be those that want to get around them. In gaming, this covers people that want to break into the game and affect it, through to those that want to cheat in-game for play advantages or to steal in-game items.
Whatever your game, you will have to harden your game infrastructure to prevent attacks or data being stolen including putting firewalls in place on your game servers. Adding anti-cheat integrations to common services such as Easy Anti-Cheat can make it easier to deal with attacks.
Alongside this, you should look at your security logs to see how many attacks are taking place on your infrastructure over time, and look for Denial of Service protection if anyone attacks your hosts with additional traffic. Lastly, you can use your analytics data to spot anomalies in player behaviour that represent cheating or other bad behaviour.
Will Blew is software engineering manager at cloud hosting company Linode and the co-founder of the wildly popular WesterosCraft, which is dedicated to recreating the fictional world of Westeros as imagined by author George R.R. Martin in Minecraft.