A user information management method and system

By determining the user's home cluster and data table in the database cluster, and generating user ID based on cluster ID, data table ID and global ID, the mapping relationship confusion caused by changes in the database server is solved, and the stability and efficiency of data access are achieved.

CN112905703BActive Publication Date: 2025-05-16BEIJING GRELA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110270546.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-12
Publication Date
2025-05-16
Estimated Expiration
2041-03-12

AI Technical Summary

Technical Problem

When the database server changes, the mapping relationship between the user ID and the database server is disordered, which in turn affects the efficiency of data storage and access.

Method used

By determining the home cluster and data table of the current user in all clusters and generating user ID based on the cluster ID, data table ID, and global ID, ensure that the mapping relationship between the user ID and the corresponding cluster and data table is always consistent.

Benefits of technology

It avoids mapping relationship disorders caused by changes in the number of database servers, ensures the stability and efficiency of data access, and reduces the cost of cluster maintenance and data migration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112905703B_ABST
    Figure CN112905703B_ABST
Patent Text Reader

Abstract

The present disclosure provides a user information management method and system, the method comprising: determining a first cluster as a belonging cluster of a current user in all clusters; determining a first data table in the first cluster to store user information of the current user; allocating a global ID to the current user, and determining the user ID of the current user based on the cluster ID of the first cluster, the data table ID of the first data table, and the global ID; and storing the user ID as a keyword of the current user in the first data table. The present disclosure adjusts the generation method of the user ID, associates the user ID with the corresponding cluster and data table, so that the mapping relationship between the user ID and the corresponding cluster and data table will not change according to the adjustment of the number of clusters, thereby avoiding the problem of data information call failure.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of data management, and in particular to a method and system for managing user information. Background Art

[0002] Data is the support of the game, and data storage is a very important part of the game. On the one hand, it can provide players with a continuous and accumulative gaming experience, and on the other hand, it can also provide an important reference for analyzing and improving game design. The current common data storage methods can be divided into cluster mode and non-cluster mode, both of which have their own advantages and disadvantages.

[0003] 1) Non-cluster mode, also known as stand-alone mode, stores all data in a single database server. Its advantages are simple design and relatively low maintenance costs; its disadvantages are that it is difficult to support the storage and access of large amounts of data, and does not support dynamic data expansion; it is suitable for scenarios with relatively small amounts of data.

[0004] 2) Cluster mode, also known as multi-server mode, distributes a large amount of data to multiple database servers to support the storage and access of a large amount of data. Its advantages are that it can meet the needs of large-scale data storage and access, and can also support the dynamic data growth of the business; its disadvantages are that the design is relatively complex and the maintenance cost is relatively high; it is suitable for scenarios with large amounts of data or large amounts of data that are expected to grow in the future.

[0005] With the continuous development of computer technology and the continuous increase in data volume, the industry usually uses cluster mode for data storage. Different from the single-machine method, the cluster-based method usually needs to divide the data to be stored so that it can be stored in different database servers to achieve relatively balanced and efficient storage and access. Generally speaking, a common method is to use a globally unique user ID as the basis for storage and access, such as generating a global user ID through a snowflake algorithm, a database self-increment unique ID, etc., and then mapping the user ID to different database servers by modulo or hashing. However, in this case, if the number of database servers changes, such as when a new database server is added, the mapping relationship between the user ID and the database server will change when performing a modulo or hash operation, resulting in confusion in the original mapping relationship. According to the original mapping relationship, the newly added user cannot be stored in the newly added database server, and adjusting the mapping relationship will cause the original data to appear based on the mapping The database is different from the original stored database when accessing, and the corresponding data information cannot be called. Summary of the invention

[0006] The purpose of the embodiments of the present disclosure is to provide a user information management method and system to solve the problem of mapping relationship confusion caused by changes in the database server in the prior art.

[0007] The embodiment of the present disclosure adopts the following technical solution: a method for managing user information, comprising: determining a first cluster as a belonging cluster of a current user among all clusters; determining a first data table in the first cluster to store user information of the current user; assigning a global ID to the current user, and determining a user ID of the current user based on the cluster ID of the first cluster, a data table ID of the first data table, and the global ID; and storing the user ID as a keyword of the current user in the first data table.

[0008] Further, determining the first cluster among all clusters as the belonging cluster of the current user includes: determining the first cluster in one of the following ways: randomly selecting a cluster among all clusters as the first cluster; selecting a cluster with the lowest utilization rate among all clusters as the first cluster; selecting a currently designated cluster among all clusters as the first cluster, wherein the currently designated cluster is switched once every first preset period; based on the network belonging information of the user, determining among all clusters that the cluster corresponding to the network belonging information is the first cluster.

[0009] Further, determining a first data table in the first cluster to store user information of the current user includes: determining the first data table in one of the following ways: randomly selecting a data table from all data tables in the first cluster as the first data table; selecting a data table with the lowest usage rate from all data tables in the first cluster as the first data table; selecting a data table from all data tables in the first cluster in a predetermined order as the first data table.

[0010] Furthermore, the method further includes: determining the cluster to which the current user belongs and a data table storing user information of the current user based on the user ID of the current user; and determining the user information of the current user based on the user ID in the data table.

[0011] Furthermore, the format of the user ID is: the cluster ID in the first digit, the data table ID in the second digit, and the global ID in the third digit.

[0012] An embodiment of the present disclosure also provides a user information management system, including: a logical server, used to manage user information according to the above-mentioned management method; at least one cluster, each of the clusters includes at least a preset number of data tables, each data table is used to store user information of the user, wherein the cluster is composed of multiple database servers.

[0013] Furthermore, the logic server is further configured to: determine the cluster to which the current user belongs and a data table storing user information of the current user based on the user ID of the current user; and determine the user information of the current user based on the user ID in the data table.

[0014] Furthermore, each of the clusters includes at least a master database and a slave database, and both the master database and the slave database contain the preset number of data tables, and each of the data tables in the master database has a corresponding data table in the slave database.

[0015] Furthermore, the logic server stores the user information through the master database and queries the user information through the slave database.

[0016] Furthermore, data synchronization is performed between the master database and the slave database at intervals of a second preset period.

[0017] The beneficial effect of the embodiment of the present disclosure is that by adjusting the method of generating user IDs, user IDs are associated with corresponding clusters and data tables, so that the mapping relationship between user IDs and corresponding clusters and data tables will not change according to the adjustment of the number of clusters, thereby avoiding the problem of data information call failure. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0019] Figure 1 It is a flowchart of the method for managing user information in the first embodiment of the present disclosure;

[0020] Figure 2 Schematic diagram of the architecture of the user information management system in the second embodiment of the present disclosure. DETAILED DESCRIPTION

[0021] Various aspects and features of the present disclosure are described herein with reference to the drawings.

[0022] It should be understood that various modifications may be made to the embodiments of the present application. Therefore, the above description should not be considered as limiting, but only as an example of an embodiment. Other modifications within the scope and spirit of the present disclosure will occur to those skilled in the art.

[0023] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the general description of the present disclosure given above and the detailed description of the embodiments given below, serve to explain the principles of the present disclosure.

[0024] These and other characteristics of the present disclosure will become apparent from the following description of a preferred form of embodiment given as a non-limiting example, with reference to the attached drawings.

[0025] It should also be understood that, although the present disclosure has been described with reference to some specific examples, those skilled in the art will be able to realize many other equivalent forms of the present disclosure that have the features of the claims and are therefore within the scope of protection defined thereby.

[0026] The above and other aspects, features and advantages of the present disclosure will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings.

[0027] Specific embodiments of the present disclosure are described hereinafter with reference to the accompanying drawings; however, it should be understood that the embodiments claimed are merely examples of the present disclosure, which may be implemented in a variety of ways. Well-known and / or repeated functions and structures are not described in detail to avoid obscuring the present disclosure with unnecessary or redundant details. Therefore, the specific structural and functional details claimed herein are not intended to be limiting, but merely serve as a basis and representative basis for the claims to teach those skilled in the art to use the present disclosure in a variety of ways with substantially any suitable detailed structure.

[0028] This specification may use the phrases "in one embodiment," "in another embodiment," "in a further embodiment," or "in other embodiments," all of which may refer to one or more of the same or different embodiments according to the present disclosure.

[0029] In order to solve the problems existing in the prior art, the first embodiment of the present disclosure provides a method for managing user information, which is suitable for allocating IDs and managing corresponding user information for users with large amounts of data. Figure 1 As shown, steps S101 to S104 are mainly disclosed:

[0030] S101: Determine a first cluster among all clusters as a home cluster of a current user.

[0031] In this embodiment, the cluster mainly refers to a database cluster composed of one or more database servers for storing user data. For an application or game with a large number of users, it usually has at least one database cluster for maintaining user data, each cluster has a globally unique cluster ID, and as the number of users increases due to the long-term operation of the application or game, the number of database clusters will be adjusted accordingly.

[0032] When a new user registers, a globally unique user ID needs to be assigned to the user, and all user information of the user (such as personal information, settings, game archives, etc.) is associated with the user ID and needs to be queried and retrieved in the cluster through the user ID. Therefore, when a new user registers, it is necessary to first assign the user a cluster to which he belongs, and determine a first cluster from all clusters as the cluster to which the current user belongs. The first cluster can be any cluster among all clusters.

[0033] Specifically, the first cluster may be determined from among all clusters in any of the following ways:

[0034] (1) Randomly select a cluster from all clusters as the first cluster;

[0035] Whenever a new user registers, a cluster is randomly selected from all clusters as the home cluster of the new user (ie, the first cluster). In general, the random allocation method can basically ensure that the number of users stored in all clusters remains the same.

[0036] (2) Select the cluster with the lowest utilization rate among all clusters as the first cluster;

[0037] The utilization rate refers to the ratio of the number of users saved in the current cluster to the maximum number of users that the cluster can save. The higher the utilization rate, the more users are saved in the cluster. In order to achieve an average number of users, the cluster with the lowest current utilization rate (i.e., the cluster with the least number of users currently saved) can be used as the first cluster when a new user registers.

[0038] (3) selecting a currently designated cluster from among all clusters as a first cluster, wherein the currently designated cluster is switched once every first preset period;

[0039] When the game or application is actually running, one cluster can be designated among all clusters as the cluster to which all new users registered within a certain period of time belong, and the designated cluster is switched after a first preset period. For example, the first preset period is one week. In the first week of January, the designated cluster is cluster A, and all new users registered in the first week of January belong to cluster A. In the second week of January, the designated cluster is switched to cluster B, and all new users registered in the second week of January belong to cluster B, and so on.

[0040] (4) Based on the network belonging information of the user, determine, from among all clusters, a cluster corresponding to the network belonging information as the first cluster.

[0041] The network belonging information in this embodiment may be the operator of the network used by the user, or the current location of the user. Different network operators correspond to different clusters, for example, mobile users correspond to cluster A, Unicom users correspond to cluster B, Telecom users correspond to cluster C, and other users correspond to cluster D. When determining the first cluster, the corresponding cluster is determined as the first cluster based on the operator of the current user; or, users in Northeast China and North China correspond to cluster A, users in Central China and South China correspond to cluster B, and users in Northwest China and Southwest China correspond to cluster C. When determining the first cluster, the corresponding cluster is determined as the first cluster based on the location of the current user.

[0042] It should be noted that the several methods for determining the first cluster disclosed in this embodiment are only several preferred implementation methods that may exist in actual use. The above methods can be switched according to actual needs, and maintenance personnel can also use other methods of allocating clusters according to actual conditions. This embodiment does not limit this.

[0043] S102: Determine a first data table in a first cluster to store user information of a current user.

[0044] In this embodiment, each database cluster stores user information in the form of a data table, and the data table in a single cluster is split horizontally into multiple data tables to reduce the number of data entries in each data table, ensuring that when obtaining corresponding user information based on the user ID, the time for traversing data can be reduced and the data search efficiency can be improved. In this embodiment, it is preferred to split the data table in a single cluster horizontally with the user ID as the key value, and the number of splits is 200. After the split, the data entries that can be stored in each table are in the tens of millions. In other words, the number of users that can be stored in a single cluster is 2 billion, which can basically meet the usage requirements of large applications or games. In addition, each data table in a single cluster has a unique data table ID, and data tables in different clusters may have the same data table ID.

[0045] When a new user registers, the cluster to which the user belongs is first determined, and then a first data table is selected in the cluster to store the user information of the user. The first data table may be any data table in the first cluster, and may be determined in the first cluster in any of the following ways:

[0046] (1) randomly selecting a data table from among all the data tables in the first cluster as the first data table;

[0047] Whenever a new user registers and is assigned to the first cluster, a data table is randomly selected in the first cluster as the first data table. In general, the random assignment method can basically ensure that the number of users stored in all data tables in the first cluster remains the same.

[0048] (2) selecting the data table with the lowest usage rate among all the data tables in the first cluster as the first data table;

[0049] The utilization rate here refers to the ratio of the number of users saved in the current data table to the maximum number of users that the data table can save. The higher the utilization rate, the more users are saved in the data table. In order to achieve an average number of users, the data table with the lowest current utilization rate (i.e., the data table with the least number of users currently saved) can be used as the first data table when a new user registers.

[0050] (3) Selecting a data table from among all the data tables of the first cluster in a predetermined order as the first data table.

[0051] The predetermined order can be adjusted according to the number of data tables or actual needs. For example, when determining the first data table of the current user, first obtain the data table ID corresponding to the previous user of the current user when registering, and add 1 to the previous data table ID. The data table corresponding to the data table ID obtained at this time is the first data table.

[0052] It should be noted that the several methods of determining the first data table disclosed in this embodiment are only several preferred implementation methods that may exist in actual use. The above methods can be switched according to actual needs, and maintenance personnel can also use other methods of allocating data tables according to actual conditions. This embodiment does not limit this.

[0053] S103: Allocate a global ID for the current user, and determine a user ID of the current user based on the cluster ID of the first cluster, the data table ID of the first data table, and the global ID.

[0054] The global ID refers to the unique ID of the user stored in all clusters in the current application or game. The global ID of any user does not have the same global ID as other users in the current application or game, thereby further distinguishing between users. When a new user registers, an addition operation can be performed on the basis of the global ID of the last registered user to determine the global ID of the current user, or other methods can be used to allocate the global ID, which is not limited in this embodiment. After the global ID is determined, the user ID of the user is generated based on the cluster ID of the first cluster assigned to the current user, the data table ID of the first data table, and the global ID. Specifically, the generated user ID can be composed of the cluster ID of the first digit, the data table ID of the second digit, and the global ID of the third digit, wherein the specific values ​​of the first digit, the second digit, and the third digit can be determined according to the number of clusters, the number of data tables, and the estimated number of users. For example, in this embodiment, the user ID can be preferably set to a 64-bit unsigned string (usually in digital form), wherein the cluster ID is 8 bits, the data table ID is 16 bits, and the remaining 40 bits are the global ID.

[0055] S104: Store the user ID as a keyword of the current user in the first data table.

[0056] After the user ID is determined, it is used as the keyword (key) of the current user and stored in the first data table, and all user information and related data generated by the user in the process of running the application or game are stored in the first data table as the value (value) corresponding to the keyword.

[0057] During the actual operation of an application or game, a new user usually sets a personalized user name and password when registering, and associates it with the user ID generated by the background during the registration process. After the user logs in, the user's personal settings, operation records, etc. are stored as user information in the corresponding first data table. When the user logs in or performs a user information query operation, the cluster to which the user belongs is first determined based on the cluster ID in the user ID, and then the data table in the cluster that stores the corresponding user information is determined by the data table ID. Finally, all data entries in the data table are traversed using the user ID as the query condition to find and obtain the user information corresponding to the user ID.

[0058] This embodiment adjusts the user ID generation method to associate the user ID with the corresponding cluster and data table. Even if the number of clusters is adjusted, the mapping relationship between the current existing users and their corresponding clusters and data tables will not change, and there will be no data access failures caused by the adjustment of the mapping relationship. At the same time, when a new cluster needs to be added, there is no need to adjust any user ID generation logic or perform data migration. When generating a new user's user ID, the corresponding cluster can be configured as the newly added cluster, which reduces the cost of cluster maintenance and data migration, while avoiding operations such as service suspension or interruption, ensuring the long-term stable operation of the product and bringing a better user experience to users.

[0059] The second embodiment of the present disclosure provides a user information management system, which can be used as a background server of an application or game, and is mainly used to implement user information management, assign user IDs to new users during operation, and perform operations such as user information storage, query or reading. Figure 2 The schematic diagram of the architecture of the user information management system is shown, which mainly includes a logic server 10 and at least one cluster 20, wherein the cluster 20 is composed of multiple database servers.

[0060] The logical server 10 mainly manages user information through the user information management method in the first embodiment of the present disclosure. The specific operation or execution principle implemented has been described in detail in the first embodiment, and will not be repeated in this embodiment. In addition, the number of logical servers 10 is not limited to one. Figure 2 That is, the case of having two logical servers 10 is shown, as long as each logical server 10 is connected to each cluster 20. When a new user registers, the logical server 10 configures a belonging cluster and a data table for the new user according to the method of generating the user ID disclosed in the first embodiment; when querying user information, the logical server 10 determines the cluster to which the current user belongs and the data table storing the user information of the current user based on the user ID of the user, and then determines the user information of the current user in the data table based on the user ID.

[0061] The cluster 20 is composed of multiple database servers, the number of which can be set according to actual conditions and can be added in the later operation. Figure 2 Only the case of two clusters is shown. Each cluster 20 has an independent cluster ID, and each cluster 20 includes at least a preset number of data tables 30, and mainly stores user information through the data tables 30.

[0062] Furthermore, each cluster 20 includes at least one master database 201 and one slave database 202. The slave database 202 is actually a backup of the master database 201. The master database 201 and the slave database 202 contain the same number of data tables, and each data table in the master database 201 has a corresponding data table with the same data table ID in the slave database 202, and the user information stored in the two is also the same. In actual use, the logic server 10 is connected to the master database 201 and the slave database 202 in each cluster 20. The master database 201 is mainly used to implement data writing operations, that is, the logic server 10 writes the corresponding data into the data table of the master database 201 when generating a user ID and saving user information; the slave database 202 is mainly used to implement data reading operations, that is, the logic server 10 obtains user information by querying the data in the slave database 202. It should be understood that in order to ensure that the data between the master database 201 and the slave database 202 are the same, the master database 201 and the slave database 202 in each cluster 20 can synchronize data once every second preset period. The second preset period is preferably 10 milliseconds to 200 milliseconds, and can be adjusted according to the new data addition or database performance.

[0063] This embodiment associates the user ID with the physical cluster 20 through the setting of the logical server 10 and the cluster 20. Even if the number of clusters is adjusted, the mapping relationship between the current existing users and their corresponding clusters and data tables will not change, and there will be no data access failures caused by the adjustment of the mapping relationship. At the same time, the cluster implements the read operation by setting up a slave database, which reduces the read pressure of the master database, thereby improving the overall performance of the database, reducing the delay of data storage or reading, and optimizing the actual user experience.

[0064] Multiple embodiments of the present disclosure are described in detail above, but the present disclosure is not limited to these specific embodiments. Those skilled in the art can make various variations and modifications to the embodiments based on the concepts of the present disclosure, and these variations and modifications should all fall within the scope of protection required by the present disclosure.

Claims

1. A method for managing user information, characterized in that: include: Determine a first cluster as a home cluster of the current user from among all clusters including the newly added cluster. In the case of a newly added cluster, the first cluster is determined from the newly added cluster; Determine a first data table in the first cluster to store user information of the current user; Allocating a global ID for the current user, and determining a user ID of the current user based on the cluster ID of the first cluster, the data table ID of the first data table, and the global ID; The user ID is stored in the first data table as a keyword of the current user, wherein the first data table is horizontally split into multiple data tables with the user ID as a key value.

2. The management method according to claim 1, characterized in that: The step of determining the first cluster among all clusters as the home cluster of the current user includes: The first cluster is determined in one of the following ways: Randomly select one cluster from all clusters as the first cluster; Selecting a cluster with the lowest utilization rate among all clusters as the first cluster; Selecting a currently designated cluster from among all clusters as the first cluster, wherein the currently designated cluster is switched once every first preset period; Based on the network belonging information of the user, it is determined that the cluster corresponding to the network belonging information is the first cluster among all clusters.

3. The management method according to claim 1, characterized in that: The determining a first data table in the first cluster to store the user information of the current user includes: The first data table is determined in one of the following ways: Randomly select a data table from all the data tables of the first cluster as the first data table; Selecting a data table with the lowest usage rate from among all data tables of the first cluster as a first data table; A data table is selected from all the data tables of the first cluster in a predetermined order as a first data table.

4. The management method according to any one of claims 1 to 3, characterized in that: Also includes: Based on the user ID of the current user, determine the cluster to which the current user belongs and the data table storing the user information of the current user; The user information of the current user is determined in the data table based on the user ID.

5. The management method according to any one of claims 1 to 3, characterized in that: The format of the user ID is: the cluster ID in the first digit, the data table ID in the second digit, and the global ID in the third digit.

6. A user information management system, characterized in that: include: A logic server, configured to manage user information according to the management method described in any one of claims 1 to 5; At least one cluster, each of the clusters includes at least a preset number of data tables, each data table is used to store user information of a user, wherein the cluster is composed of a plurality of database servers.

7. The management system according to claim 6, characterized in that: The logic server is further used for: Based on the user ID of the current user, determine the cluster to which the current user belongs and the data table storing the user information of the current user; The user information of the current user is determined in the data table based on the user ID.

8. The management system according to claim 6, characterized in that: Each of the clusters includes at least a master database and a slave database. Both the master database and the slave database contain the preset number of data tables. Each of the data tables in the master database has a corresponding data table in the slave database.

9. The management system according to claim 8, characterized in that: The logic server stores the user information through the master database, and queries the user information through the slave database.

10. The management system according to claim 8, characterized in that: The master database and the slave database perform data synchronization once every second preset period.

Citation Information

Patent Citations

  • Method and device for generating unique identifier

    CN110928912A

  • Global primary key generation method and device

    CN111708831A