How to choose back end service for mobile game development

Time:2020-7-5

[play leancloud] developer contribution sharing:

Author: Zhao Tianze

As a little white who started back-end development through leancloud, I have gained a lot from more than one year of development. Several projects have also made good development under the reliable service support of leancloud. The cloud engine of the project with the largest number of users has about 1.2W requests per minute and 300W + times a day to call the storage service API. In this process, I not only got the guidance of leancloud’s various technical heroes to improve data reliability and optimize logic execution efficiency, but also leancloud The high availability and high efficiency of handling unexpected exceptions also make me have no worries about the operation and maintenance work and service stability. In addition, with the simple and easy-to-use and timely response work order system, it can be said that my work has become beautiful and comfortable.

Leancloud is the most efficient technology support overseas

In fact, before using leancloud, I had been working on IOS applications and mobile game client development. I had no experience in back-end development, nor had I touched JavaScript. Until I participated in the development of several online games, I did not know the general architecture and interface design of the game back-end. Then, our project needs to add network archiving and daily task distribution functions for single player games. However, one of our back-end programmers does not have the ability to build and deploy a set of reliable back-end services from scratch, so the feasible solution is to find a set of ready-made third-party services. At that time, there were many back-end service providers at home and abroad. The final decision of leancloud was mainly based on the following considerations:

Mature and stable overseas nodes and supporting services. Our games are mainly promoted overseas. Although there are many back-end cloud services dedicated to games overseas, we find that their development freedom is not high and can not meet our standards.

Communication efficiency with technical support personnel. Most of the overseas service providers can only communicate through e-mail or forum, which is very inefficient. If there is a problem that can not be solved, it will be very troublesome. The response of leancloud technical support is very fast. Even if we only communicated in QQ group at the beginning, and did not use the work order system, all the replies were not delayed. Of course, the users were happy.

Clear and detailed technical documents. Compared with other service providers, leancloud provides more detailed documents with clear classification, which is very suitable for entry learning.

In addition, we also specially investigated the cloud engine services of leancloud. Because it provides a complete and simple back-end deployment approach and tools to realize one click deployment of online environment, and allows us to arbitrarily develop background logic based on express, we are sure that leancloud is the best choice.

Rest API + cloud function is all-purpose oil

In order to achieve user game data storage and daily task distribution, we first used storage services and cloud engine. However, we did not use the SDK provided by leancloud to directly call the storage services. Instead, we chose to use the leancloud rest API to call the cloud functions in the cloud engine, and then call the storage services through the cloud functions to realize the corresponding logic. The reason for this is that our games are mainly developed using Lua + C + +. Leancloud’s C + + SDK is not maintained continuously, which will bring potential risks; if we use IOS and Android SDK, we have to expose the interface to the script layer, which will lead to an unnecessary program. Based on our previous experience in developing online games, we prefer to provide relevant APIs to the front end according to the functional modules, so that the front-end can post the data to the server through HTTP protocol, and the server will return the part of the data that needs to be updated in the front end after processing.

In practice, we find that it has the advantage of putting the logic of data query, processing and storage in the back end, so that the business adjustment can become very flexible. For example, after users have counted up, it is found that there will be a large number of read and write operations in the daily task table. According to the suggestions of leancloud technical support, we put some hot data into the cloud engine’s cache service leancache In other words, you can search the data in the cache first and then in the storage service if not, which can effectively reduce the query time and improve the efficiency of business processing, while the front-end code does not change.

Cloud caching is fast

Let’s talk about leancache separately. In essence, it is redis, which contributes a lot to improving and improving the performance of our project. At the beginning, we needed to make a regional ranking list. It happened that leancache’s official demo provided the sample code of the ranking list (which helped me to make up the lesson about atomicity, which must be worshipped). Therefore, we implemented our own ranking function on this basis, and put it on the NPM for you to access “leaderboard promise”. Then, we have implemented hot data cache, order system, token verification system and other functions in cloud cache to make full use of the advantages of redis to solve the problems that may cause performance bottlenecks in the business.

Timing push notification across time zones

Our users come from all over the world and have different time zones. We need to get all users to receive a notification at 7:00 p.m. local time. Through the cloud engine and message push service, we only need to add a user’s time zone data under each installation object, and then set a timer task for each on-time trigger in the cloud engine. When the task is triggered, the corresponding time zone information is set in the push condition, which achieves our goal. In addition, it is very convenient to push to specific user groups through cloud engine.

500 lines of code for real-time combat

Recently, our new project hopes to realize reliable room system real-time game playing as soon as possible, so that it can be put into the market quickly to verify whether the game is welcomed by players. It is obviously not wise to develop a real-time combat framework before the user’s approval. So we asked leancloud for help, and we quickly got a set of development suggestions based on the real-time communication module. In this way, through the cloud engine and the real-time communication module, we built a real-time combat framework of room matching configuration in less than 500 lines of code, and then we only needed to gather the actual play method of the game in the project to quickly deploy and go online. Originally thought to want the strength of the famine, but only spent the effort, happiness that is an instant burst.

Perfect live broadcast of technical courses

Let’s pay special tribute to leancloud’s series of live courses. All courses not only involve the basic use of each function of leancloud, but also explain the problems that often need to be faced in the back-end development, such as how to evaluate and optimize the pressure, how to design business processes to ensure the consistency of data, and how to ensure the security of data through authority control. These are useful for back-end developers who don’t use leancloud services.

Finally, I would like to recommend leancloud to two categories of people:

Students who want to learn back-end development, but are scared by the complexity of cloud server procurement, installation and configuration. Leancloud has very efficient development supporting tools, which can quickly realize the required business logic locally and in the cloud. The sense of accomplishment of watching your project go online will certainly encourage you to continue to study deeply, and take leancloud as the starting point to gradually improve the knowledge system of back-end development.

The other is the students who have enough back-end development experience, but they are not supported by the operation and maintenance team for the start-up projects. As we all know, to establish a complete operation and maintenance guarantee system is a matter that requires a lot of resources. Start up projects should put more energy into the actual business logic development, and the trouble of operation and maintenance can be left to leancloud.

Recommended Today

ASP.NET Example of core MVC getting the parameters of the request

preface An HTTP request is a standard IO operation. The request is I, which is the input; the responsive o is the output. Any web development framework is actually doing these two things Accept the request and parse to get the parameters Render according to the parameters and output the response content So let’s learn […]