Company internal information! Deployment preparations before the game goes online, even a novice can do it

foreword

The game is almost finished. It's time to prepare for online test deployment. It is still very important to choose a reliable cloud server manufacturer. This time, I am going to try to use Huawei Cloud's services. In order to make sufficient preparations before going online, I will do a preview first. Save time and fuss. Also make a documentation for other colleagues.

1. Introduction to game architecture

1.1 Server Architecture

Different companies have different game server architectures, so the specific details of deployment are mostly different, but the basic deployment preparations are still the same. Let’s take a look at our game architecture first, so that readers and friends can understand the follow-up preparations.

1.1.1 The server role is specifically introduced

  • client: game client.
  • gate: The gateway server, which does not carry the link of the game, but only distributes the address of the game server, and the player obtains the ip and port of the official game server from the gate server.
  • game: There is only one game server where the player mainly resides.
  • room: room server, players will enter the battle server after matching and entering the battle, if there are many battles, it can be dynamically expanded.
  • Gm: Background management server, which can publish activities or manage player data.
  • redis: This is mainly used for caching to avoid frequent database access pressure.
  • mysql: mainly used for data persistence.

1.1.2 Player data flow

  1. The player (client) accesses the gate server through http to obtain the ip and port of the game service.
  2. The client directly connects to the game server through the obtained ip and port, so that the player logs into the server.
  3. When the player operates the character to match the battle, the required data will be sent to the room server after the match is successful, and all combat commands will also be sent to the room service.
  4. When a player needs to query data, such as a backpack, the game server will first query like redis. If the data does not exist, it will query like mysql. After the data is queried, it will be stored in the cache.
  5. When the data of the player's character changes, such as obtaining new props, the database needs to be operated at this time, and the game server will first update the database and then update the cache.
  6. Use gm when publishing events and modifying player data, by issuing commands to the game server.

1.1.3 Inter-service interaction protocol

  • http protocol: mainly occurs in places with relatively few access scenarios, between client and gate, game and Gm.
  • dubbo protocol: It is mainly used to exchange data between internal servers. The advantage is that it is simple and direct, just like operating a local method.
  • websocket: mainly used between client and game, because this is a web game server, so websocket is used.

1.2 Deployment method

There are several reasons for using docker here:

  1. Standardize application release to avoid problems caused by the environment.
  2. Save time and facilitate rapid deployment and startup.
  3. Teammates are more familiar with it, reducing the possibility of making mistakes.

2. Deployment preparation

2.1 Environment preparation

2.1.1 Machine preparation

Make a table statistics on the configuration of the server, just prepare the server. The following table is for reference on the official website of HUAWEI CLOUD.

Purchase link address: https://www.huaweicloud.com/solution/gamehosting/

Note: The specific price is subject to the actual official website price, and there are discounts during the HUAWEI CLOUD 618 marketing season (June 1-June 30)

server

server configuration

gate

X86 Computing | General Computing Enhanced | c7.xlarge.2 | 4 Cores | 8GB; CentOS | CentOS 7.x 64bit; General SSD | 40GB; General SSD | 100GB;

gm

X86 Computing | General Computing Enhanced | c7.xlarge.2 | 4 Cores | 8GB; CentOS | CentOS 7.x 64bit; General SSD | 40GB; General SSD | 100GB;

game_game server

X86 Computing | General Computing Enhanced | c7.2xlarge.2 | 8 Cores | 16GB; CentOS | CentOS 8.2 64bit; General SSD | 40GB; General SSD | 100GB;

room—combat calculation logic server

X86 Computing | General Computing Enhanced | c7.2xlarge.2 | 8 Cores | 16GB; CentOS | CentOS 8.2 64bit; General SSD | 40GB; General SSD | 100GB;

Public IP

Exclusive | full dynamic BGP | metered by traffic

redis

Basic | 5.0 | Active/Standby | X86 | DRAM | 2 copies | 8 GB;

game database

Community Edition | Replica Set | Three Nodes | General Purpose | 4 Cores 8GB; Ultra High IO | 100GB;

game database

MySQL | 8.0 | Active/Standby | Exclusive | 4-core 8GB SSD cloud disk | 100GB

2.1.2 Solution Composition

Elastic Cloud Server (ECS): It is an elastically scalable computing service that can be self-serviced at any time on the cloud, helping to create a safe, reliable, flexible, and efficient application environment.

ApsaraDB for RDS for MySQL: It has features such as out-of-the-box, stable and reliable, safe operation, elastic scaling, easy management, and economical and practical features, allowing customers to focus more on business development.

Distributed cache service Redis version: the industry's first Redis cloud service that supports Arm and x86 dual architectures, supports dual-machine hot standby HA architecture, provides stand-alone, active-standby, Proxy cluster, Cluster cluster, and read-write separation instance types to meet high-demand requirements. Read and write performance scenarios and business requirements for flexible allocation.

Cloud Log Service LTS: Provides functions such as one-stop log collection, second-level search, mass storage, structured processing, dump, and visualized charts to meet applications such as application operation and maintenance, visual analysis of network logs, security compliance, and operational analysis. Scenes.

Elastic public network IP EIP: Elastic public network IP (Elastic IP) provides independent public network IP resources, including public network IP addresses and public network egress bandwidth services. It can be flexibly bound and unbound with resources such as elastic cloud servers, bare metal servers, virtual IPs, elastic load balancing, and NAT gateways, providing the ability to access the public network and be accessed by the public network. It has a variety of flexible billing methods to meet the demands of different business scenarios.

2.2 Mirror preparation

The preparation of the image is packaged and pushed to the private warehouse. The specific method can use some plug-ins, Jenkins, or manual push. Either way, here are the manual commands that may be needed.

2.2.1 Install docker service

yum -y install docker
service docker start

2.2.2 Package image

Copy the jar package to the same directory as the dockerfile, and execute the following command to package the image.

docker build  -t ImageName:TagName dir

2.2.3 Package the image as a local file

The image is exported as a compressed package for easy transmission.

docker save image id > filename.tar

2.2.4 Unpack the image

After logging in to the server, copy the above file to the local machine, and use the following command to import the image to the current machine:

docker load < filename.tar

2.3 Department script

 docker run -itd \
  -e ENV=dev \
  -e serverId=8818 \
  -p 9223:9222 \
  --name game8818 \
  -v /home/docker/8818:/app/log \
  -v /etc/timezone:/etc/timezone:ro \
  -v /etc/localtime:/etc/localtime:ro \
  --restart=always harborserver.pdool.com/pdool/game:0.0.37-SNAPSHOT

Note: The above is the development environment, some environment variables are default, and need to be adjusted dynamically when deploying in the formal environment

2.4 Notes

  1. The gate server needs to open the public network ip.
  2. The excel configuration file should be planned in advance and mounted in the docker script
  3. The data directory and log directory mounted by docker need to be planned in advance.
  4. The port mapping inside each server should be planned in advance
  5. The environment variables need to be modified in the script, including mysql and redis database addresses, the server ip and port to be linked, and related server configurations.

3. Formal deployment

3.1 Environmental research

Pain points of the game:

The new game is released, a large number of players are online, and the expansion of high concurrent access is not timely;

The network delay is high, the game is stuck, and the player is offline; the self-build cycle is long and the cost is high, and it cannot be elastically expanded.

Most game servers are computationally intensive, so the core points for game server cloud vendors to choose are as follows:

  1. Resource expansion capability, which can expand in time, flexibly purchase resources according to demand, realize dynamic expansion, cost optimization, and support business operations in scenarios such as game server opening, server expansion, and server consolidation.
  2. Stable bandwidth, HUAWEI CLOUD internal network bandwidth forwarding efficiency is high, ELB billion-level concurrency, dynamic and automatic optimization of network structure, continuous, stable, efficient, and low-latency network.
  3. For security defense, HUAWEI CLOUD provides a single-line T-level DDoS high-defense IP service and millions of QPS-level CC protection, based on AI capabilities such as hacker attack machine learning, business risk control, and big data intelligent isolation, to ensure the long-term safe operation of mobile games.
  4. Easy-to-use and cheap tariffs are the pursuit of every company. Cost reduction and efficiency increase, multiple billing modes, low initial budget, on-demand use, pay as much as you use, effectively relieve the pressure on corporate start-up funds and save money.

Summary: HUAWEI CLOUD game cloud deployment solution provides cloud infrastructure covering the world, supports tens of millions of players to run online and stably at the same time, helps game companies create high-quality games, and ensures flexible game deployment and worry-free operation and maintenance.

3.2 Server Purchase

The following are some server screenshots at the time of purchase, which can be used as a reference configuration, and will be dynamically configured according to resources in the official production environment.

Note: Click to see a larger image

3.3 Summary of Core Advantages of HUAWEI CLOUD

  • Database capability: In high concurrency scenarios, the performance stability is better than that of competitors. Mysql master/backup switching efficiency is better than that of competitors.
  • Asia-Pacific coverage in overseas regions: Huawei's network quality (delay and packet loss) is generally better than that of competitors. (except Japan, South Korea, Vietnam, Taiwan).
  • Computing power: ECS - the same type of ECS is 15% higher than that of competitors, leading in PPS, container - fast provisioning, performance is 20% higher than open source.
  • Network capability: The intranet bandwidth forwarding efficiency is the highest. ELB billion-level concurrency.
  • Security protection: HUAWEI CLOUD builds a security platform that isolates tenants and provides comprehensive security services to ensure business and data security and protect your games.
  • Simplified operation and maintenance: the operation and maintenance work on the cloud, the platform provides 7*24 hours service for game customers, special guarantee, expert support, to ensure the business stability of major events.
  • High data reliability: Through reasonable commercial and technical efforts, the ECS service promises that the service availability rate of the single-instance dimension per service cycle is not less than 99.975%; the service availability rate of the single-region multi-availability zone dimension is not less than 99.995% per service cycle; Based on a distributed architecture, elastically scalable virtual block storage service has high data reliability and high I/O throughput, which can ensure fast data migration and recovery when any copy fails, and avoid data loss caused by a single hardware failure

3.4 Machine environment preparation

3.4.1 Install docker

After logging in to the machine remotely, switch to the root user and execute the following command to install the docker environment

yum -y install docker

3.4.2 Copy files to target machine

The file list is as follows:

  1. Copy the image file to the local according to the relevant commands in 2.2. If you use a private warehouse, you don't need to perform this step.
  2. Copy the configuration file to the machine, copy all excel configuration files to the machine, and configure the mount in the startup script
  3. Start the script, create and modify the startup script in the planned directory, and set the corresponding parameters.

3.4.3 Script execution

After all the files are ready, switch to the directory where the script is located and start the script directly. Let’s take game as an example

sh start_game.sh

3.4.4 Verify that the server is normal

First check whether there is any error in the logs of all servers, and then log in with a special account to verify that the server functions normally

Verification point:

  1. Can log in normally
  2. can match battle
  3. The http interface is normal
  4. The server is operating normally
  5. The main business logic is normal.

After verifying the above logic, notify the test students to conduct a functional test.

3.4.5 Open server

After the test students pass the test, set the server status to the open server status through gm, and the deployment process ends.

4. Summary

  • Only by not fighting unprepared battles can we be invincible, and we must make a quick start, prepare in advance, and consider everything carefully.
  • A nine-storey platform starts from the ground. A good cloud service provider can make things simpler and easier. Huawei Cloud is worthy of being the first choice.

The HUAWEI CLOUD game cloud deployment solution provides cloud infrastructure covering the world, supports millions of players to run online and stably at the same time, combined with cloud operation and maintenance operations, helps game companies achieve rapid business launch and elastic expansion, and effectively respond to game emergencies The emerging needs and the development needs of game companies going overseas.

Guess you like

Origin blog.csdn.net/perfect2011/article/details/131310050