Create resource in GS2

Create a resource in each GS2 microservice.

First, let’s understand the relationship between projects, regions, and microservices.

Projects and microservices have the following data structure.

Gs2Project "1" *-- "many" Region
Region "1" *-- "many" Microservice
Microservice "1" *-- "many" Namespace
Namespace "1" *-- "many" Resource

Region

A region exists directly under the project.

A region represents the region of the data center that GS2 uses to provide microservices.

Microservices

There are various functions such as property management, matchmaking, in-game stores, etc. These are hosted on a per-region basis, and the microservices database is broken out by region.

While real-time communication is appropriate to run on the machine hosted in the region closest to the player, most of the microservices provided by GS2 are mostly functions that do not require as much real-time performance. Therefore, it is possible to deploy only GS2-Realtime in multiple regions, while keeping the other microservices in a single region.

Namespace

Each microservice can have multiple namespaces. Namespaces are completely separate from each other, but can have multiple spaces.

When using GS2-Inventory, you can manage them separately as “namespace to hold consumable items”, “namespace to hold in-game currency”, and “namespace to hold acquired characters”.

Resources

Each namespace has its own resources. There are two main types of resources.

  • Master data
  • User data

Master Data

Master Data is an area that holds data predefined by the developer, such as GS2-Inventory, what items exist; GS2-Showcase, what products are sold; GS2-Schedule, what events are scheduled.

This is an area that contains data specified by the developer.

User Data

This is the data that game players individually store. For GS2-Inventory, how many items the player has; for GS2-Quest, which quests the player has already completed.

This is data that increases on its own as the game is run.

How to Create Resources

There are two main ways to create resources:

1. Manual creation from Management Console

Log in to the GS2 Management Console from your browser and create resources by entering settings on the UI. This is quick and convenient when you are in the trial-and-error stage or when there are few setting items.

Create a template file in YAML format and upload it to GS2-Deploy to automatically create resources. This method is recommended for serious development because of the following benefits:

  • Reproducibility: Resources with the same settings (development environment, production environment, etc.) can be reliably reproduced.
  • Version Control: By managing template files with Git, etc., you can keep a history of setting changes.
  • Batch Management: Resources for multiple services (Inventory, Quest, Account, etc.) can be defined together.

setup using the management console

Create a resource in a microservice using the Management Console.

Setup using GS2-Deploy

Create resources in microservices using GS2-Deploy

Setup using GS2-CDK

Create GS2-Deploy template using GS2-CDK