A method and system for naming distributed high-performance game services without duplication

By using hash functions to locate servers in a distributed system and leveraging bitmaps and Redis storage mechanisms, the performance pressure caused by repeated character name judgment when a new game is launched is resolved, and efficient and unique game character name generation is achieved.

CN115554705BActive Publication Date: 2025-09-19FUJIAN TQ DIGITAL
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211294603.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-21
Publication Date
2025-09-19
Estimated Expiration
2042-10-21

AI Technical Summary

Technical Problem

In a distributed system, when a new game is launched, a large number of players flock in, resulting in repeated judgment of game character names, which puts pressure on server and database performance. Existing technologies make it difficult to achieve high-performance and non-duplicate character name generation.

Method used

Use the hash function to locate the target server, use a bitmap to store the naming information, set up multiple user tables in the target server, and combine with Redis to save the bitmap data, reduce database pressure, and ensure the uniqueness of the game name.

Benefits of technology

Under high concurrency conditions, high-performance generation and uniqueness judgment of game character names are achieved, which reduces the load on the server and database and improves the stability and efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115554705B_ABST
    Figure CN115554705B_ABST
Patent Text Reader

Abstract

The present invention provides a distributed high-performance game service naming method and system with no duplication. The method comprises the following steps: 1. When a player names a game, the client passes the username through a hash function to obtain a hashcode, modulo 10 the hashcode to obtain the target server number n, and initiates a naming request to server n. 2. Upon receiving the username request, the server obtains the hashcode, modulo 10 the length of a bitmap to obtain a value a, checks whether the subscript a in the bitmap in memory is 1, and if so, returns a message indicating that the client's name already exists. If not, the server modulo 10 obtains the number x, accesses the user_x_tb data table to determine whether the username exists. If so, the subscript a in the bitmap is modified to 1, and a message indicating that the client's name already exists is returned. If not, the user name is inserted into the database and the subscript a in the bitmap is modified to 1. 3. The server periodically saves the in-memory bitmap to a Redis key_n every minute. When the server restarts, the server reads the Redis key_n and saves the bitmap data in memory. This ensures high performance of the game naming service and no duplication of game names.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of game development, and in particular to a method and system for naming distributed high-performance game services without duplication. Background Art

[0002] Distributed deployment means deploying different business modules on different servers, or splitting the same business module into multiple sub-businesses and deploying them on different servers to address high concurrency issues. Redis is a commonly used middleware for data caching and is a key-value storage system.

[0003] When a new game is first released, it's often at its peak popularity, with a large number of players flocking to the game server to create their own characters. Because character names cannot be duplicated, character name uniqueness verification requires a database query, which undoubtedly places significant pressure on both server and database performance. Therefore, this patent addresses the issue of creating a high-performance naming service in a distributed system. Summary of the Invention

[0004] In order to overcome the above problems, the purpose of the present invention is to provide a method for naming a distributed high-performance game service without duplication, thereby ensuring the high performance of the game naming service and the non-duplication of game names.

[0005] The present invention is implemented by the following scheme: a method for naming a distributed high-performance game service without duplication, the method comprising the following steps:

[0006] Step S1: When a player chooses a name, the client passes the game name username through a hash function to obtain a hashcode, modulo the number of servers using the hashcode to obtain the target server number n, and initiates a name request to the target server n;

[0007] Step S2: a bitmap with a length of M is set in the target server n to store the user's name;

[0008] Step S3, target server n sets multiple user sub-tables for the database. Target server n receives the name request, obtains a hashcode, uses the hashcode to modulo the length value M to obtain a value a, and determines whether the storage bit corresponding to the bitmap subscript a of the length value M is 1. If it is 1, it returns to the client that the game name exists. If it is 0, the hashcode is modulo the number of user sub-tables to obtain a number x, and the user_x user table is accessed to determine whether the game name username exists. If it exists, the storage bit corresponding to the bitmap subscript a is modified to 1, and the client returns that the game name is repeated. If it does not exist, the game name username is inserted into the corresponding user table user_x_tb in the database, and the storage bit corresponding to the bitmap subscript a is modified to 1.

[0009] Step S4: The server saves the memory bitmap to the value of the key key_n in Redis every minute. When the server is restarted, it reads the key key_n in Redis and saves the bitmap data in the memory.

[0010] Furthermore, step S3 is further specified as follows: after the target server n receives the naming request, it obtains the game name username, obtains the hash value hashcode through the same hash function as step S1, sets the length of the bitmap bitmap to 800 million in order to reduce the database pressure, and obtains the value a after taking the modulus of the 800 million value M with the hashcode, determines whether the storage bit corresponding to the bitmap subscript a in the server memory is 1, and if it is 1, returns to the client that the game name already exists; if it is 0, it indicates that the game name is available, sets 10 user tables to store the created game names, obtains the number x by taking the modulus of 10 with the hashcode, reads the user table user_x to determine whether the username exists, and if it exists, modifies the storage bit corresponding to the subscript a in the bitmap to 1, and returns to the client that the game name is repeated; if the username does not exist in the user table user_x, inserts the username into the database, and modifies the storage bit corresponding to the memory bitmap subscript a to 1, and returns to the client that the creation is successful.

[0011] Furthermore, the step S4 is further specified as follows: the server stores the user naming situation in the memory bitmap to the value of the redis key key_n every minute. This is used when the server is restarted. The server can use its own server number n to read the naming situation of this service from redis, read the redis key key key_n and save the bitmap data in the memory for fast duplicate detection in the memory when the user names.

[0012] The present invention also provides a distributed high-performance game service naming system without duplication, the system comprising: a target server positioning module, a bitmap creation module, a game name duplication processing module, and a data reading module;

[0013] The target server location module, when the player names the game username, passes the hash function to obtain the hashcode, uses the hashcode to modulo the number of servers to obtain the target server number n, and initiates a naming request to the target server n;

[0014] The bitmap creation module sets a bitmap with a length value of M in the target server n to store the user's naming situation;

[0015] The game name duplication processing module sets multiple user sub-tables for the database through the target server n. The target server n receives a name request, obtains a hashcode, uses the hashcode to modulo the length value M to obtain a value a, and determines whether the storage bit corresponding to the bitmap subscript a of the length value M is 1. If it is 1, it returns to the client that the game name exists. If it is 0, the hashcode is modulo the number of user sub-tables to obtain a number x, accesses the user_x user table to determine whether the game name username exists. If it exists, the storage bit corresponding to the bitmap subscript a is modified to 1, and the game name is returned to the client that the game name is repeated. If it does not exist, the game name username is inserted into the user table user_x corresponding to the database, and the storage bit corresponding to the bitmap subscript a is modified to 1;

[0016] The data reading module saves the memory bitmap to the value of redis with the key key_n every minute through the server timing. When the server is restarted, the key key of redis is read as key_n to save the bitmap data in the memory.

[0017] Furthermore, the implementation of the game name duplication processing module is further specifically as follows: after the target server n receives the naming request, it obtains the game name username, obtains the hash value hashcode through the same hash function as step S1, sets the length of the bitmap bitmap to 800 million in order to reduce the database pressure, obtains the value a after taking the modulus of the 800 million value M with the hashcode, determines whether the storage bit corresponding to the bitmap subscript a in the server memory is 1, and if it is 1, returns to the client that the game name already exists; if it is 0, it indicates that the game name is available, sets 10 user tables to store the created game names, obtains the number x by taking the hashcode modulo 10, reads the user table user_x to determine whether the username exists, and if it exists, modifies the storage bit corresponding to the subscript a in the bitmap to 1, and returns to the client that the game name is duplicated; if the username does not exist in the user table user_x, inserts the username into the database, modifies the storage bit corresponding to the memory bitmap subscript a to 1, and returns to the client that the creation is successful.

[0018] Furthermore, the implementation method of the data reading module is further specified as follows: the server stores the user naming information in the memory bitmap to the redis key with the key key_n value every minute. This is used when the server is restarted. You can use your own server number n to read the naming information of this service from redis, read the redis key key_n and save the bitmap data in the memory for fast duplicate detection in memory when the user names.

[0019] The beneficial effects of the present invention are: locating the request for game naming in the server, setting a bitmap in the server, storing the game names through the bitmap, and deleting the duplicate game names, thereby ensuring the high performance of the server's naming service and the non-duplicate game names in the early stage of the game's launch. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It is a schematic flow chart of the method of the present invention.

[0021] Figure 2 It is a block diagram of the working principle of the present invention. DETAILED DESCRIPTION

[0022] The present invention will be further described below with reference to the accompanying drawings.

[0023] See also Figure 1 As shown, a method for naming a distributed high-performance game service without duplication of the present invention comprises the following steps:

[0024] Step S1: When a player chooses a name, the client passes the game name username through a hash function to obtain a hashcode, modulo the number of servers using the hashcode to obtain the target server number n, and initiates a name request to the target server n;

[0025] Step S2: a bitmap with a length of M is set in the target server n to store the user's name;

[0026] Step S3, target server n sets multiple user sub-tables for the database. Target server n receives the name request, obtains a hashcode, uses the hashcode to modulo the length value M to obtain the value a, and determines whether the storage bit corresponding to the bitmap subscript a of the length value M is 1. If it is 1, it returns to the client that the game name exists. If it is 0, the hashcode is modulo the number of user sub-tables to obtain the number x (the user table needs to set multiple user sub-tables, so there are multiple user tables, user_0_tb, user_1_tb, user_2_tb...user_x_tb. x represents the number x modulo the number of user sub-tables, which means the number of the sub-table). The user_x user table is accessed to determine whether the game name username exists. If so, the storage bit corresponding to the bitmap subscript a is modified to 1, and the client returns that the game name is repeated. If not, the game name username is inserted into the user table user_x corresponding to the database, and the storage bit corresponding to the bitmap subscript a is modified to 1.

[0027] Step S4: The server saves the memory bitmap to the value of the key key_n in Redis every minute. When the server is restarted, it reads the key key_n in Redis and saves the bitmap data in the memory.

[0028] The present invention will be further described below with reference to a specific embodiment:

[0029] A method for naming distributed high-performance game services without duplication, the method comprising:

[0030] Step 1: When the player is naming, the client passes the game name username through the hash function to obtain the hashcode, uses the hashcode modulo 10 of the server number to obtain the target server number n, and initiates a naming username request to server n.

[0031] In order to cope with the high concurrency of naming requests in the early days of the game, suppose there are 10 naming servers. When a player logs in to the game client to name the game, the client will first pass the username through the hash function to obtain the hash value hashcode, use the hashcode modulo 10 of the number of servers to obtain the target server number n, and send the player's naming request to server n.

[0032] Step 2: Server n receives the username request, obtains the hashcode, modulo the 800 million value to obtain the value a, and determines whether the storage bit corresponding to subscript a in the bitmap with a length of 800 million in memory is 1. If it is 1, it returns that the client game name already exists. If it is 0, the hashcode is modulo the number of user tables 10 to obtain the number x, and the user_x_tb user table is accessed to determine whether the username exists. If it exists, the storage bit corresponding to subscript a in the bitmap is modified to 1, and the client game name is returned that it is repeated. If it does not exist, the username is inserted into the database, and the storage bit corresponding to subscript a in the bitmap is modified to 1.

[0033] The target server n sets up multiple user tables in the database. After receiving the naming request, the server obtains the username and obtains the hashcode through the same hash function as step 1. In order to reduce the pressure on the database, the system uses bitmap to store the user's naming situation. Due to the small memory usage of bitmap, 1M=1024*1024*8=about 8 million, so a bitmap of 800 million length only requires a capacity of about 1000MB. After taking the modulus of 800 million with hashcode, the value a is obtained to determine whether the storage bit value corresponding to the bitmap subscript a in the server memory is 1. If it is 1, it means that the username may exist, and the client's game name is returned to be repeated.

[0034] If it is 0, it means the game name is available. The system uses 10 user tables to store the created game names. The number x is obtained by taking the hashcode modulo 10 (the number of 10 user tables). The data table user_x_tb is read to determine whether the username exists. If it exists, the storage bit corresponding to the subscript a in the bitmap is modified to 1, and the client is returned that the game name is duplicated.

[0035] If username does not exist in the data table user_x_tb, then username is inserted into the corresponding user table user_x_tb in the database, and the value of the storage bit corresponding to the memory bitmap index a is modified to 1, and a successful creation is returned to the client.

[0036] Step 3: The server saves the in-memory bitmap to the Redis key key=key_n value every minute. When the server restarts, it reads the Redis key key=key_n and saves the bitmap data in memory.

[0037] The server stores the user naming information in the memory bitmap to the value of the redis key key = key_n every minute. This is used when the server is restarted. You can use your own server number n to read the naming information of this service from redis, read the key_n of redis, and save the bitmap data internally for fast duplicate detection in memory when the user names are entered.

[0038] See also Figure 2 As shown, the present invention also provides a distributed high-performance game service naming system without duplication, the system comprising: a target server positioning module, a bitmap creation module, a game name duplication processing module, and a data reading module;

[0039] The target server location module, when the player names the game username, passes the hash function to obtain the hashcode, uses the hashcode to modulo the number of servers to obtain the target server number n, and initiates a naming request to the target server n;

[0040] In order to cope with the high concurrency of naming requests in the early days of the game, suppose there are 10 naming servers. When a player logs in to the game client to name the game, the client will first pass the username through the hash function to obtain the hash value hashcode, use the hashcode modulo 10 of the number of servers to obtain the target server number n, and send the player's naming request to server n.

[0041] The bitmap creation module sets a bitmap with a length value of M in the target server n to store the user's naming situation;

[0042] The game name duplication processing module sets multiple user sub-tables for the database through the target server n, receives a naming request on the target server n, obtains a hashcode, uses the hashcode to modulo the length value M to obtain a value a, determines whether the storage bit corresponding to the bitmap subscript a of the length value M is 1, and returns to the client that the game name exists if it is 1; if it is 0, the hashcode is modulo the number of user sub-tables (i.e., the number of user sub-tables set in the database) to obtain a number x, accesses the user_x user table to determine whether the game name username exists; if it exists, modifies the storage bit corresponding to the bitmap subscript a to 1, and returns to the client that the game name is repeated; if it does not exist, inserts the game name username into the corresponding user table user_x in the database, and modifies the storage bit corresponding to the bitmap subscript a to 1;

[0043] The implementation method of the game name duplication processing module is further specifically as follows: after the target server n receives the naming request, it obtains the game name username, obtains the hash value hashcode through the same hash function as step S1, sets the length of the bitmap bitmap to 800 million to reduce the database pressure, uses the hashcode to modulo the 800 million value M to obtain the value a, determines whether the storage bit corresponding to the bitmap subscript a in the server memory is 1, and if it is 1, returns to the client that the game name already exists; if it is 0, it indicates that the game name is available, sets 10 user tables to store the created game names, obtains the number x through the hashcode modulo 10, reads the user table user_x_tb to determine whether username exists, and if so, modifies the storage bit corresponding to the subscript a in the bitmap to 1, and returns to the client that the game name is duplicated; if username does not exist in the user table user_x_tb, inserts username into the corresponding user table user_x_tb in the database, modifies the storage bit corresponding to the memory bitmap subscript a to 1, and returns to the client that the creation is successful.

[0044] The data reading module saves the memory bitmap to the value of redis with the key key_n every minute through the server timing. When the server is restarted, the key key of redis is read as key_n to save the bitmap data in the memory.

[0045] The implementation method of the data reading module is further specified as follows: the server stores the user naming information in the memory bitmap to the value of the redis key key_n every minute. This is used when the server is restarted. You can use your own server number n to read the naming information of this service from redis, read the redis key key_n, and save the bitmap data in the memory for fast duplicate detection in memory when the user names.

[0046] In summary, the present invention locates the request for game naming in the server, sets a bitmap in the server, stores the game names through the bitmap, and deletes the duplicate game names, thereby ensuring the high performance of the server's naming service and the non-duplicate game names in the initial stage of the game's launch.

[0047] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.

Claims

1. A method for naming distributed high-performance game services without duplication, characterized by: The method comprises the following steps: Step S1: When a player chooses a name, the client passes the game name username through a hash function to obtain a hashcode, modulo the number of servers using the hashcode to obtain the target server number n, and initiates a name request to the target server n; Step S2: a bitmap with a length of M is set in the target server n to store the user's name; Step S3, target server n sets multiple user sub-tables for the database. Target server n receives the name request, obtains a hashcode, uses the hashcode to modulo the length value M to obtain a value a, and determines whether the storage bit corresponding to the bitmap subscript a of the length value M is 1. If it is 1, it returns to the client that the game name exists. If it is 0, the hashcode is modulo the number of user sub-tables to obtain a number x, and the user_x user table is accessed to determine whether the game name username exists. If it exists, the storage bit corresponding to the bitmap subscript a is modified to 1, and the client returns that the game name is repeated. If it does not exist, the game name username is inserted into the corresponding user table user_x in the database, and the storage bit corresponding to the bitmap subscript a is modified to 1. Step S4: The server saves the memory bitmap to the value of key_n in Redis every minute. When the server is restarted, it reads the key key_n in Redis and saves the bitmap data in memory. The step S4 is further specified as follows: the server stores the user naming information in the memory bitmap to the value of the key key key_n in redis every minute. This is used when the server is restarted. The server can use its own server number n to read the naming information of this service from redis, read the key key key_n from redis, and save the bitmap data in the memory for fast duplicate detection in the memory when the user names.

2. The method for naming a distributed high-performance game service without duplication according to claim 1, characterized in that: The step S3 is further specifically as follows: after the target server n receives the naming request, it obtains the game name username, obtains the hash value hashcode through the same hash function as step S1, sets the length of the bitmap bitmap to 800 million to reduce the database pressure, and obtains the value a after taking the hashcode modulo the 800 million value M, determines whether the storage bit corresponding to the bitmap subscript a in the server memory is 1, and if it is 1, returns to the client that the game name already exists; if it is 0, it indicates that the game name is available, sets 10 user tables to store the created game names, obtains the number x through hashcode modulo 10, reads the user table user_x to determine whether the username exists, and if it exists, modifies the storage bit corresponding to the subscript a in the bitmap to 1, and returns to the client that the game name is duplicated; if the username does not exist in the user table user_x, inserts the username into the database, modifies the storage bit corresponding to the memory bitmap subscript a to 1, and returns to the client that the creation is successful.

3. A system for distributing high-performance game services with unique naming, characterized by: The system includes: a target server positioning module, a bitmap creation module, a game name duplication processing module, and a data reading module; The target server location module, when the player names the game username, passes the hash function to obtain the hashcode, uses the hashcode to modulo the number of servers to obtain the target server number n, and initiates a naming request to the target server n; The bitmap creation module sets a bitmap with a length value of M in the target server n to store the user's naming situation; The game name duplication processing module sets multiple user sub-tables for the database through the target server n. The target server n receives a name request, obtains a hashcode, uses the hashcode to modulo the length value M to obtain a value a, and determines whether the storage bit corresponding to the bitmap subscript a of the length value M is 1. If it is 1, it returns to the client that the game name exists. If it is 0, the hashcode is modulo the number of user sub-tables to obtain a number x, accesses the user_x user table to determine whether the game name username exists. If it exists, the storage bit corresponding to the bitmap subscript a is modified to 1, and the game name is returned to the client that the game name is repeated. If it does not exist, the game name username is inserted into the user table user_x corresponding to the database, and the storage bit corresponding to the bitmap subscript a is modified to 1; The data reading module saves the memory bitmap to the value of key_n in redis every minute through the server timing. When the server is restarted, the key key_n in redis is read to save the bitmap data in the memory; The implementation method of the data reading module is further specified as follows: the server stores the user naming information in the memory bitmap to the value of the redis key key_n every minute. This is used when the server is restarted. The server can use its own server number n to read the naming information of this service from redis, read the redis key key_n and save the bitmap data in the memory for fast duplicate detection in the memory when the user names.

4. The system for distributing high-performance game services with unique naming according to claim 3, characterized in that: The implementation method of the game name duplication processing module is further specifically as follows: after the target server n receives the naming request, it obtains the game name username, obtains the hash value hashcode through the same hash function as step S1, sets the length of the bitmap bitmap to 800 million to reduce the database pressure, uses the hashcode to modulo the 800 million value M to obtain the value a, determines whether the storage bit corresponding to the bitmap subscript a in the server memory is 1, and if it is 1, returns to the client that the game name already exists; if it is 0, it indicates that the game name is available, sets 10 user tables to store the created game names, obtains the number x through the hashcode modulo 10, reads the user table user_x to determine whether username exists, and if it exists, modifies the storage bit corresponding to the subscript a in the bitmap to 1, and returns to the client that the game name is duplicated; if username does not exist in the user table user_x, inserts username into the database, modifies the storage bit corresponding to the memory bitmap subscript a to 1, and returns to the client that the game name is duplicated;

Citation Information

Patent Citations

  • Method and equipment for identifying repeated information

    CN102541918A

  • Game server data storage, read method and system based on redis

    CN106031827A