Business data processing method, apparatus, device, and storage medium
By allocating specific hash slots to new application services in the Redis database cluster and migrating the data, the problem of messy business data in the Redis database cluster is solved, and convenient data management and statistical analysis are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MIGU CO LTD
- Filing Date
- 2022-03-22
- Publication Date
- 2026-04-14
AI Technical Summary
When storing business data from different application services, existing Redis database clusters often result in disorganized data that is difficult to clean up or analyze in a targeted manner, making management inconvenient.
When a new application service is connected, the hash slot allocation information of the Redis database cluster is obtained. Based on the allocation information, a second hash slot is allocated to the new application service. The data is sorted and migrated according to factors such as data storage volume and activity level to ensure that the data is stored in the specified hash slot.
It enables accurate storage and management of business data in a Redis database cluster, facilitating cleanup and statistical analysis, and improving management convenience.
Smart Images

Figure CN114676196B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a business data processing method, apparatus, device and storage medium. Background Technology
[0002] Currently, Redis database clusters store business data for different application services randomly in arbitrary hash slots. This makes it difficult to manage and clean up Redis data or analyze the data storage volume of a particular application service when different application services need to do so. The random storage of business data in hash slots results in a chaotic and unmanageable business data within the Redis database cluster. This makes it very difficult to target specific application services for cleaning or to analyze the data storage volume of a particular application service, making business data management extremely inconvenient. Summary of the Invention
[0003] The main purpose of this application is to provide a business data processing method, apparatus, device and storage medium, which aims to solve the problem that existing technologies are not convenient enough in managing business data.
[0004] To achieve the above objectives, this application provides a business data processing method, the method comprising:
[0005] Upon detecting the access of a new application service, the allocation information of the first hash slot of the already accessed application service in the Redis database cluster is obtained; the first hash slot is used to store the business data of the already accessed application service.
[0006] Based on the allocation information, a second hash slot is allocated to the new application service;
[0007] When it is necessary to process the first business data of the new application service, process the business data in the second hash slot.
[0008] For example, the allocation information characterizes the application service affiliation of each hash slot in the Redis database cluster, and the allocation of a second hash slot to the new application service based on the allocation information includes:
[0009] Iterate through the data storage volume of each hash slot in the Redis database cluster; and determine the application service affiliation of each hash slot;
[0010] Based on the data storage volume and the application service affiliation, the data size of each hash slot in each application service is sorted to obtain the data storage volume sorting result.
[0011] Based on the data storage volume sorting result, a second hash slot is allocated to the new application service.
[0012] For example, allocating a second hash slot to the new application service based on the data storage sorting result includes:
[0013] Based on the data storage volume sorting result, the third hash slot is extracted from each hash slot of each application service in ascending order of data storage volume to obtain the second hash slot, and the second hash slot is allocated to the new application service.
[0014] For example, after allocating a second hash slot to the new application service based on the allocation information, the process includes:
[0015] Migrate the second business data in the third hash slot to other hash slots, wherein the other hash slots are hash slots other than the third hash slot in the application service corresponding to the third hash slot;
[0016] Update the mapping relationship between the third hash slot and the application service so that when each application service needs to access business data, it can accurately access the hash slot corresponding to the application service.
[0017] For example, migrating the second business data in the third hash slot to other hash slots includes:
[0018] Calculate the data activity of the second business data in each of the third hash slots;
[0019] Based on the data activity level, the target hash slot is determined from other hash slots;
[0020] Migrate the second business data to the target hash slot.
[0021] For example, determining the target hash slot from other hash slots based on the data activity includes:
[0022] Based on the data activity level, the data reading speed requirement for the second business data is determined;
[0023] From the other hash slots, determine the target hash slot that can meet the data read speed requirement.
[0024] For example, when it is necessary to process the first business data of the new application service, processing the business data in the second hash slot includes:
[0025] Determine the storage key based on the preset data key;
[0026] Based on the storage key, determine the mapping character;
[0027] Based on the mapped character, the business data in the second hash slot is processed.
[0028] Furthermore, to achieve the above objectives, this application also provides a business data processing apparatus, the apparatus comprising:
[0029] The acquisition module is used to detect the access of new application services and acquire the allocation information of the first hash slot of the accessed application service in the Redis database cluster; the first hash slot is used to store the business data of the accessed application service.
[0030] An allocation module is used to allocate a second hash slot to the new application service based on the allocation information;
[0031] The processing module is used to process the business data in the second hash slot when it is necessary to process the first business data of the new application service.
[0032] In addition, to achieve the above objectives, this application also provides a business data processing device, which includes a memory, a processor, and a business data processing program stored in the memory and executable on the processor. When the business data processing program is executed by the processor, it implements the steps of the business data processing method described above.
[0033] In addition, to achieve the above objectives, this application also provides a computer-readable storage medium storing a business data processing program, which, when executed by a processor, implements the steps of the business data processing method described above.
[0034] Compared to existing technologies, which struggle to target and clean up the business data of a specific application service or to statistically analyze its data storage volume, leading to significant inconvenience in business data management, this application addresses this issue by obtaining the hash slot allocation information of the Redis database cluster when a new application service is integrated. This allocation information is then used to determine the hash slot for the new application service. In other words, each application service has a designated hash slot in the Redis database cluster, ensuring that the hash slot for the application service can be accurately located when processing its business data. It's important to understand that this application does not randomly store business data across all hash slots; instead, it stores it in the hash slot corresponding to the application service. Therefore, existing technologies often store business data haphazardly in hash slots, while this application provides a structured approach, facilitating the determination of the business data's storage location within the Redis database cluster. This makes it easier to clean up or statistically analyze the data storage volume of a specific application service, thereby improving the convenience of business data management. Attached Figure Description
[0035] Figure 1 This is a flowchart illustrating the first embodiment of the business data processing method of this application;
[0036] Figure 2 This is a schematic diagram of a typical deployment method of the Redis database cluster involved in the business data processing method of this application;
[0037] Figure 3 This is a schematic diagram of the hardware operating environment involved in the embodiments of this application.
[0038] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0039] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0040] This application provides a business data processing method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the business data processing method of this application.
[0041] This application provides embodiments of a business data processing method. It should be noted that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here. The business data processing method is applied to a business system. For ease of description, the execution entities describing the various steps of the business data processing method are omitted below. The business data processing method includes:
[0042] Step S10: Detect the access of a new application service and obtain the allocation information of the first hash slot of the accessed application service in the Redis database cluster; the first hash slot is used to store the business data of the accessed application service.
[0043] In this embodiment, business data is stored in a Redis database cluster, which is an in-memory database. Its data storage format is key-value, meaning that the key is used to operate on the value.
[0044] The Redis database cluster has a certain number of hash slots (e.g., 16384) built-in. Business data is stored in hash slots. When a new application service is connected, it is necessary to determine the usage of the first hash slot allocated to the connected application service.
[0045] For example, refer to Figure 2 , Figure 2This diagram illustrates a typical deployment of a Redis database cluster, which includes nodes A, B, and C, each corresponding to a Redis database instance. Node A covers hash slots numbered 0-5460, node B covers hash slots numbered 5461-10922, and node C covers hash slots numbered 10923-16383. It's important to note that the number of nodes and the distribution of hash slots can be freely adjusted according to business needs. Specifically, hash slots numbered 0-16383 can be configured on any node (for example, hash slots numbered 3, 6000, and 13000 can be configured on node C), as long as the total number of hash slots is the same across all nodes.
[0046] When storing and retrieving business data from a Redis database cluster, it is based on a preset business key. A service interface is generated by calling the data key corresponding to the preset business key. This service interface retrieves the storage key of the business data, and finally, the data is retrieved from the Redis database cluster using this storage key. The preset business key and the hash slot have a corresponding relationship, ensuring that the application service can accurately locate the target hash slot and store the data there, avoiding the problem of randomly storing data in any hash slot.
[0047] Application services are services provided to applications for data management. In a business system (a system that provides services to applications), there may be one or more application services.
[0048] For example, after an application is connected to a business system, it will assign an ID (e.g., application service ID is application service A, application service B, etc.) or name it (e.g., application service name is user management, order management, etc.) to facilitate data management services for the application. This embodiment takes assigning an ID to an application service as an example. The embodiment of naming an application service is basically the same as the embodiment of assigning an ID to an application service, and will not be described again here.
[0049] For example, the allocation information reflects the allocation of hash slots for application services. For instance, the application services include application service A and application service B, and the Redis database cluster includes hash slots numbered 0-16383. Application service A is allocated hash slots numbered 0-8000, and application service B is allocated hash slots numbered 8001-16383.
[0050] For example, business data refers to data generated by the application at runtime. For instance, if the application generates an order at runtime, the business data includes order information; or if the application requires user registration at runtime, the business data includes user information.
[0051] Step S20: Based on the allocation information, allocate a second hash slot to the new application service.
[0052] The second hash slot allocated to the new application service is called from the hash slots allocated to the already connected application service. The allocation status of the current hash slot is determined based on the allocation information, and the second hash slot is determined based on the allocation status.
[0053] For example, the allocation information characterizes the application service affiliation of each hash slot in the Redis database cluster, and the allocation of a second hash slot to the new application service based on the allocation information includes:
[0054] Step a: Iterate through the data storage volume of each hash slot in the Redis database cluster; and determine the application service affiliation of each hash slot.
[0055] Based on the hash slot number, the data storage volume of each hash slot in the Redis database cluster is obtained sequentially, and the application service to which each hash slot belongs is determined sequentially, thus obtaining the application service affiliation.
[0056] For example, data storage capacity includes quantities that can characterize data size, such as the number of data entries (each data entry has a similar byte size) and the number of data bytes.
[0057] Step b: Based on the data storage volume and the application service affiliation, sort the data size of each hash slot in each application service to obtain the data storage volume sorting result.
[0058] When sorting data by size for each hash slot, the sorting is not done on a Redis database cluster basis, but on an application service basis. That is, after determining the application service to which the hash slot belongs, the hash slots in each application service are sorted separately.
[0059] It can be understood that the data storage volume sorting result is the sorting result of the hash slot number corresponding to each application service. For example, if the hash slot numbers corresponding to application service A are 1, 2, and 3, where the data storage volume of hash slot 2 is greater than that of hash slot 1, and the data storage volume of hash slot 1 is greater than that of hash slot 3, then the sorting result obtained by ordering the data storage volume from largest to smallest is 2, 1, 3, while the sorting result obtained by ordering the data storage volume from smallest to largest is 3, 1, 2.
[0060] The reason for sorting the hash slots in each application service is understandable. It's necessary to allocate a portion of the hash slots from each application service to new application services, rather than simply allocating hash slots from a single application service. This ensures a more balanced distribution of hash slots across all application services, preventing situations where one application service lacks sufficient hash slots while another has a surplus, thus improving the rationality of hash slot allocation.
[0061] Step c: Based on the data storage sorting result, allocate a second hash slot to the new application service.
[0062] For example, allocating a second hash slot to the new application service based on the data storage sorting result includes:
[0063] Step c1: Based on the data storage volume sorting result, extract the third hash slot from each hash slot of each application service in ascending order of data storage volume to obtain the second hash slot, and allocate the second hash slot to the new application service.
[0064] The methods for allocating a second hash slot to a new application service include determining the number of second hash slots based on the amount of business data corresponding to the application service already connected, and equally distributing the hash slots in the Redis database cluster based on the number of application services to determine the number of second hash slots.
[0065] It is understandable that each application service has its corresponding number of third hash slots.
[0066] The number of second hash slots is determined based on the total amount of business data corresponding to the connected application services. The number of hash slots for each application service may not be equal; it depends on the actual data storage situation. Therefore, it can be understood that the number of hash slots required by the connected application services is inversely proportional to the total amount of their business data. The formula for calculating the number of hash slots required by each application service is as follows:
[0067] N X提供 =N X已分配 -(N 总 -N 新 )*D X / D 总
[0068] Where, N X提供 N is the number of hash slots required for application service X. X已分配 N represents the current number of hash slots for application service X. 总 N represents the total number of hash slots in the Redis database cluster. 新 D represents the number of the second hash slots.X D represents the total data storage capacity of application service X. 总 This represents the total data storage volume in the Redis database cluster.
[0069] For example, the existing application services include application service A and application service B. Application service A is currently allocated hash slots numbered 0-8191, and application service B is currently allocated hash slots numbered 8192-16383. Now, a new application service—application service C—needs to be integrated into the business system. Based on the number of application services after integration, 33% of the total hash slots need to be allocated to application service C for storage, i.e., 16384 / 3. Here, we assume that application service A has a total data storage capacity of 1 million records, and application service B has a total… If the data storage volume is 2 million, then using the formula for calculating the number of hash slots required by each application service, the number of hash slots required by application service A can be calculated as: 8192 - (16384 - 16384 / 3) * 100 / (100 + 200) ≈ 4551. Correspondingly, using the same formula, the number of hash slots required by application service B can be calculated as: 3641. The calculation process is basically the same as that for application service A and will not be repeated here. Therefore, the second hash slot includes 4551 third hash slots extracted from the hash slots of application service A in ascending order of data storage volume, and 3641 third hash slots extracted from the hash slots of application service B in ascending order of data storage volume.
[0070] To determine the number of second hash slots by evenly distributing hash slots in a Redis database cluster based on the number of application services, this method can be determined by the total number of hash slots in the Redis database cluster and the number of all application services in the business system. For example, if the total number of hash slots is 16384, and after the new application service is added, the total number of application services is 4, namely application service A, application service B, application service C, and the new application service. Among them, the hash slots currently allocated to application service A are numbered 0-6000, the hash slots currently allocated to application service B are numbered 6001-12000, and the hash slots currently allocated to application service C are numbered 12001-16384. Then the number of second hash slots is 16384 / 4 = 4096. Therefore, the second hash slot includes (6001-4096 / 3) third hash slots extracted from the hash slots of application service A in ascending order of data storage size, (6000-4096 / 3) third hash slots extracted from the hash slots of application service B in ascending order of data storage size, and (4384-4096 / 3) third hash slots extracted from the hash slots of application service C in ascending order of data storage size.
[0071] For example, after allocating a second hash slot to the new application service based on the allocation information, the process includes:
[0072] Step d: Migrate the second business data in the third hash slot to other hash slots, where the other hash slots are hash slots other than the third hash slot in the application service corresponding to the third hash slot.
[0073] To avoid storing business data from different application services in the same hash slot, which would make the business data look messy and difficult to manage, it is necessary to migrate the business data in the hash slots of the new application service that have been connected to the application service to hash slots that have not been assigned to the new application service, i.e., other hash slots.
[0074] For example, if hash slot number 5 is assigned to the new application service, while hash slots numbered 6 and 7 are not assigned to the new application service, then the business data in hash slot 5 will be migrated to hash slot 6 or 7.
[0075] For example, the target hash slot for business data migration can be determined by data activity. Specifically, migrating the second business data in the third hash slot to other hash slots includes:
[0076] Step d1: Calculate the data activity of the second business data in each of the third hash slots;
[0077] Step d2: Based on the data activity, determine the target hash slot from other hash slots;
[0078] Step d3: Migrate the second business data to the target hash slot.
[0079] Data activity H is calculated using the following formula:
[0080] H = (1-a)HT1 + a(Q + ZHT2)
[0081] Where a is a constant, an empirical value; HT1 is the estimated data activity level of the business system's server based on the data type of the second business data, determined through historical data; HT2 is the estimated data activity level of the business system's server based on the data type of the second business data, determined through historical data; Z is the discount function; and Q is the priority of the application service.
[0082] If H is greater than the data activity threshold Y, the second business data is determined to be business data with high activity; if H is less than the data activity threshold Y, the second business data is determined to be business data with low activity.
[0083] For example, determining the target hash slot from other hash slots based on the data activity includes:
[0084] Step d21: Based on the data activity level, determine the data reading speed requirement for the second business data;
[0085] Step d22: Determine the target hash slot from the other hash slots that can meet the data read speed requirements.
[0086] Higher data activity levels result in higher read / write frequencies, while lower data activity levels result in lower read / write frequencies. Therefore, to rationally allocate data partitions to business data with different levels of activity, allocation can be based on data activity. It can be understood that data activity is positively correlated with read / write speed, and the purpose of determining data activity is to improve the read / write efficiency of business data.
[0087] For example, the determination of the target hash slot requires a two-level judgment, with the aforementioned data activity level serving as the basis for the two-level judgment. The first-level judgment is for data with high data activity, determined by the data volume of each piece of data in the second business data. Specifically, if the data volume is large, it needs to be stored in the fast read / write area; if the data volume is small, it needs to be stored in the slow read / write area. The second-level judgment is for data with low data activity, determined by whether the second business data is data from an active time period. Specifically, if the data volume is large and it is from an active time period, it needs to be stored in the fast read / write area; otherwise, it is stored in the slow read / write area.
[0088] It is understandable that the data reading speed requirement is the requirement for fast read / write speed and the requirement for slow read / write speed.
[0089] For example, whether a time period is active can be determined by dividing the 24 time periods into three categories: morning, noon, and evening, each containing eight time periods. Time periods in the evening are identified as active time periods, while time periods in the morning or noon are identified as inactive time periods.
[0090] Step e: Update the mapping relationship between the third hash slot and the application service so that when each application service needs to access business data, it can accurately access the hash slot corresponding to the application service.
[0091] After migrating the business data, it's necessary to redetermine the storage key for the second business data. Specifically, the difference between the storage key and the data key is that the storage key also includes a mapping character. This mapping character is used in the routing mechanism of the Redis database cluster; that is, the hash slot can be uniquely identified through the mapping character. After determining the target hash slot, the old mapping character of the third hash slot for the second business data needs to be updated to the new mapping character. This ensures that when each application service needs to access business data, it can accurately access the hash slot corresponding to the application service. It can be understood that the mapping relationship between the third hash slot and the application service is the same as the mapping relationship between the mapping character and the data key.
[0092] For example, when it is necessary to process the first business data of the new application service, processing the business data in the second hash slot includes:
[0093] Step f: Determine the storage key based on the preset data key;
[0094] Step g: Determine the mapping character based on the storage key;
[0095] Step h: Based on the mapped character, process the business data in the second hash slot.
[0096] Storing and retrieving data in a specified hash slot is achieved using a storage key. The storage key is calculated using the CRC16 algorithm and contains a mapping character. This mapping character is obtained by calculating the data key using the CRC16 algorithm and then assigning it a slot number. There is a mapping relationship between the mapping character and the hash slot; each hash slot has a corresponding mapping character. Generally, the maximum slot number is directly consistent with the number of hash slots. Specifically, after calculating the data key 'y' using the CRC16 algorithm, the remainder of 'y' is calculated against the total number of hash slots in the Redis database cluster. The mapping character is determined based on the remainder, and the data is stored in the hash slot corresponding to that mapping character. For example, if the remainder is 5, the mapping character corresponding to 5 is obtained, and the data is stored in the hash slot corresponding to that mapping character.
[0097] For example, if the data key is redisValueKey, and the mapping character obtained after the above calculation is XXXX, then the storage key is {XXXX}:redisValueKey.
[0098] For example, mapping characters need to be pre-configured to provide the corresponding functionality. The number of hash slots in the Redis database cluster is the same as the number of mapping characters. Mapping characters are configured once and do not need to be adjusted later. When using the Redis database cluster to access business data, the Redis database cluster uses mapping characters to determine the hash slots. It should be noted that mapping characters can be configured in the configuration file of the data management service (a service provided by the business system to provide business data access services for application services). When the data management service starts, the JVM cache preloads the mapping characters for the hash slots. When the data management service makes a call, it directly retrieves the mapping characters from the JVM cache without needing to re-parse the configuration file.
[0099] Compared to existing technologies, which struggle to target and clean up the business data of a specific application service or to statistically analyze its data storage volume, leading to significant inconvenience in business data management, this application addresses this issue by obtaining the hash slot allocation information of the Redis database cluster when a new application service is integrated. This allocation information is then used to determine the hash slot for the new application service. In other words, each application service has a designated hash slot in the Redis database cluster, ensuring that the hash slot for the application service can be accurately located when processing its business data. It's important to understand that this application does not randomly store business data across all hash slots; instead, it stores it in the hash slot corresponding to the application service. Therefore, existing technologies often store business data haphazardly in hash slots, while this application provides a structured approach, facilitating the determination of the business data's storage location within the Redis database cluster. This makes it easier to clean up or statistically analyze the data storage volume of a specific application service, thereby improving the convenience of business data management.
[0100] In addition, this application also provides a business data processing apparatus, referring to Figure 2 The business data processing device includes:
[0101] The acquisition module is used to detect the access of new application services and acquire the allocation information of the first hash slot of the accessed application service in the Redis database cluster; the first hash slot is used to store the business data of the accessed application service.
[0102] An allocation module is used to allocate a second hash slot to the new application service based on the allocation information;
[0103] The processing module is used to process the business data in the second hash slot when it is necessary to process the first business data of the new application service.
[0104] For example, the allocation information represents the application service affiliation of each hash slot in the Redis database cluster, and the allocation module is specifically used for:
[0105] Iterate through the data storage volume of each hash slot in the Redis database cluster; and determine the application service affiliation of each hash slot;
[0106] Based on the data storage volume and the application service affiliation, the data size of each hash slot in each application service is sorted to obtain the data storage volume sorting result.
[0107] Based on the data storage volume sorting result, a second hash slot is allocated to the new application service.
[0108] For example, the allocation module is further configured to:
[0109] Based on the data storage volume sorting result, the third hash slot is extracted from each hash slot of each application service in ascending order of data storage volume to obtain the second hash slot, and the second hash slot is allocated to the new application service.
[0110] For example, the business data processing apparatus further includes:
[0111] The migration module is used to migrate the second business data in the third hash slot to other hash slots, wherein the other hash slots are hash slots other than the third hash slot in the application service corresponding to the third hash slot;
[0112] The update module is used to update the mapping relationship between the third hash slot and the application service, so that when each application service needs to access business data, it can accurately access the hash slot corresponding to the application service.
[0113] For example, the migration module is specifically used for:
[0114] Calculate the data activity of the second business data in each of the third hash slots;
[0115] Based on the data activity level, the target hash slot is determined from other hash slots;
[0116] Migrate the second business data to the target hash slot.
[0117] For example, the migration module is further configured to:
[0118] Based on the data activity level, the data reading speed requirement for the second business data is determined;
[0119] From the other hash slots, determine the target hash slot that can meet the data read speed requirement.
[0120] For example, the processing module is specifically used for:
[0121] Determine the storage key based on the preset data key;
[0122] Based on the storage key, determine the mapping character;
[0123] Based on the mapped character, the business data in the second hash slot is processed.
[0124] The specific implementation of the business data processing device in this application is basically the same as the embodiments of the business data processing method described above, and will not be repeated here.
[0125] In addition, this application also provides a business data processing device. For example... Figure 3 As shown, Figure 3 This is a schematic diagram of the hardware operating environment involved in the embodiments of this application.
[0126] It should be noted that, Figure 3 This can be a schematic diagram of the hardware operating environment of the business data processing equipment.
[0127] like Figure 3 As shown, the business data processing device may include: a processor 3001, such as a CPU; a memory 3005; a user interface 3003; a network interface 3004; and a communication bus 3002. The communication bus 3002 is used to enable communication between these components. The user interface 3003 may include a display screen and an input unit such as a keyboard. Optionally, the user interface 3003 may also include a standard wired interface or a wireless interface. The network interface 3004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 3005 may be high-speed RAM or non-volatile memory, such as a disk drive. Optionally, the memory 3005 may also be a storage device independent of the aforementioned processor 3001.
[0128] Optionally, the business data processing equipment may also include RF (Radio Frequency) circuits, sensors, audio circuits, WiFi modules, etc.
[0129] Those skilled in the art will understand that Figure 3 The business data processing equipment structure shown does not constitute a limitation on the business data processing equipment. It may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0130] like Figure 3As shown, the memory 3005, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a business data processing program. The operating system is a program that manages and controls the hardware and software resources of the business data processing device, supporting the operation of the business data processing program and other software or programs.
[0131] exist Figure 3 In the business data processing device shown, the user interface 3003 is mainly used to connect to the terminal and communicate with the terminal, such as receiving user signaling data sent by the terminal; the network interface 3004 is mainly used for the backend server and communicates with the backend server; the processor 3001 can be used to call the business data processing program stored in the memory 3005 and execute the steps of the business data processing method described above.
[0132] The specific implementation of the business data processing device in this application is basically the same as the embodiments of the business data processing method described above, and will not be repeated here.
[0133] Furthermore, embodiments of this application also propose a computer-readable storage medium storing a business data processing program, which, when executed by a processor, implements the steps of the business data processing method described above.
[0134] The specific implementation of the computer-readable storage medium in this application is basically the same as the embodiments of the above-described business data processing method, and will not be repeated here.
[0135] In addition, to achieve the above objectives, this application also provides a computer program product, comprising: a computer program, which, when executed by a processor, implements the steps of the business data processing method described above.
[0136] The specific implementation method of the computer program product in this application is basically the same as the embodiments of the above-mentioned business data processing method, and will not be described again here.
[0137] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0138] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0139] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes: several instructions to cause a terminal device (which may be a mobile phone, computer, server, device, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0140] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A business data processing method, characterized in that, The method includes: Upon detecting the access of a new application service, the allocation information of the first hash slot of the already accessed application service in the Redis database cluster is obtained; the first hash slot is used to store the business data of the already accessed application service. Based on the allocation information, a second hash slot is allocated to the new application service; When it is necessary to process the first business data of the new application service, process the business data in the second hash slot; The step of processing the business data in the second hash slot includes: Based on a preset data key and the CRC16 algorithm, a mapping character is determined, and the second hash slot is directly determined through the mapping character to process the business data in the second hash slot. The mapping character corresponds to the slot number of the second hash slot. The allocation information characterizes the application service affiliation of each hash slot in the Redis database cluster. The allocation of a second hash slot to the new application service based on the allocation information includes: Iterate through the data storage volume of each hash slot in the Redis database cluster; and determine the application service affiliation of each hash slot; Based on the data storage volume and the application service affiliation, the data size of each hash slot in each application service is sorted to obtain the data storage volume sorting result. Based on the data storage volume sorting result, a second hash slot is allocated to the new application service.
2. The method as described in claim 1, characterized in that, The process of allocating a second hash slot to the new application service based on the data storage sorting result includes: Based on the data storage volume sorting result, the third hash slot is extracted from each hash slot of each application service in ascending order of data storage volume to obtain the second hash slot, and the second hash slot is allocated to the new application service.
3. The method as described in claim 2, characterized in that, After allocating a second hash slot to the new application service based on the allocation information, the process includes: Migrate the second business data in the third hash slot to other hash slots, wherein the other hash slots are hash slots other than the third hash slot in the application service corresponding to the third hash slot; Update the mapping relationship between the third hash slot and the application service so that when each application service needs to access business data, it can accurately access the hash slot corresponding to the application service.
4. The method as described in claim 3, characterized in that, The migration of the second business data in the third hash slot to other hash slots includes: Calculate the data activity of the second business data in each of the third hash slots; Based on the data activity level, the target hash slot is determined from other hash slots; Migrate the second business data to the target hash slot.
5. The method as described in claim 4, characterized in that, The step of determining the target hash slot from other hash slots based on the data activity includes: Based on the data activity level, the data reading speed requirement for the second business data is determined; From the other hash slots, determine the target hash slot that can meet the data read speed requirement.
6. The method as described in claim 1, characterized in that, When it is necessary to process the first business data of the new application service, processing the business data in the second hash slot includes: Determine the storage key based on the preset data key; Based on the storage key, determine the mapping character; Based on the mapped character, the business data in the second hash slot is processed.
7. A business data processing device, characterized in that, The device includes: The acquisition module is used to detect the access of new application services and acquire the allocation information of the first hash slot of the accessed application service in the Redis database cluster; the first hash slot is used to store the business data of the accessed application service. An allocation module is used to allocate a second hash slot to the new application service based on the allocation information; The processing module is used to process the business data in the second hash slot when it is necessary to process the first business data of the new application service. The processing module can be used to implement: Based on a preset data key and the CRC16 algorithm, a mapping character is determined, and the second hash slot is directly determined through the mapping character to process the business data in the second hash slot. The mapping character corresponds to the slot number of the second hash slot. The allocation information represents the application service affiliation of each hash slot in the Redis database cluster, and the allocation module can be used to implement: Iterate through the data storage volume of each hash slot in the Redis database cluster; and determine the application service affiliation of each hash slot; Based on the data storage volume and the application service affiliation, the data size of each hash slot in each application service is sorted to obtain the data storage volume sorting result. Based on the data storage volume sorting result, a second hash slot is allocated to the new application service.
8. A business data processing device, characterized in that, The business data processing device includes a memory, a processor, and a business data processing program stored in the memory and executable on the processor. When executed by the processor, the business data processing program implements the steps of the business data processing method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a business data processing program, which, when executed by a processor, implements the steps of the business data processing method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Data distributing method and device and computer storage medium
CN107832009A
Database processing method and device, computer equipment and storage medium
CN112541039A