Memory management method, system, device and memory database server for memory database
By obtaining memory usage information and using the release time prediction model to dynamically calculate the memory release time, the delay glitch and memory bloating problems of the memory database are solved, and the stability and performance balance of memory resources are achieved.
Patent Information
- Application Number
- CN202510734593.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2045-06-04
AI Technical Summary
Existing memory databases have delay glitches and memory bloat problems after memory is full, affecting performance and resource stability.
By obtaining memory usage information, calculating memory release information, and using the release time prediction model to dynamically calculate memory release time, balancing data writing and elimination processing, avoiding memory bloat and delay glitches.
It realizes smooth data elimination of memory databases in different scenarios, ensures the stability and performance of memory resources, and avoids memory bloat problems and delay glitches.
Smart Images

Figure CN120276682B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of database technology, and in particular to a memory management method, system, device, and memory database server for an in-memory database. Background Art
[0002] With the development of computer and internet technologies, the application of in-memory databases has laid the foundation for efficient data processing. By configuring memory management and data eviction policies, in-memory databases address the conflict between large amounts of data written and limited memory resources. Once the memory reaches a preset threshold, users can evict data from the in-memory database according to different policies, ensuring efficient and controllable memory usage. Existing technologies typically configure eviction policies for in-memory databases to achieve these goals. However, the configuration of eviction policies varies depending on the scenario, and latency and memory bloat issues still exist. Latency glitch occurs when eviction occurs after the memory is full. If the amount of data evicted at this time is too large, users must wait for data eviction to complete before continuing to write. This can lead to a significant drop in QPS and a rapid increase in latency, impacting performance. Memory bloat occurs when eviction occurs after the memory is full. To avoid latency glitch, a fixed wait delay is set. The server evicts data within this delay, and new commands are executed after this delay. If the write rate exceeds the eviction rate at this time, the user's running memory usage will continue to increase, causing memory bloat. Therefore, an effective solution is urgently needed to address these issues. Summary of the Invention
[0003] In light of this, embodiments of this specification provide a memory management method for an in-memory database. One or more embodiments of this specification also relate to a memory management system for an in-memory database, an in-memory database server, a memory management apparatus for an in-memory database, a computing device, a computer-readable storage medium, and a computer program product to address technical deficiencies in the prior art.
[0004] According to a first aspect of an embodiment of this specification, a memory management method for an in-memory database is provided, comprising:
[0005] In response to an operation instruction submitted to a memory database, obtaining memory usage information of the memory database;
[0006] When it is determined according to the memory usage information that the memory database meets the memory release condition, calculating the memory release information of the memory database according to the memory usage information;
[0007] Inputting the memory release information into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time according to gain information corresponding to the memory release information;
[0008] Redundant data is released from the memory database according to the memory release time, and the operation instruction of writing data to the memory database is executed according to the data release result.
[0009] According to a second aspect of an embodiment of this specification, a memory management system for an in-memory database is provided, comprising a server and a client, including:
[0010] The client is configured to receive an operation instruction submitted for a target service item and submit the operation instruction to the server;
[0011] The server is configured to obtain memory usage information of the memory database in response to an operation instruction submitted to the memory database; calculate memory release information of the memory database based on the memory usage information when determining that the memory database meets a memory release condition based on the memory usage information; input the memory release information into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time based on gain information corresponding to the memory release information; release redundant data for the memory database according to the memory release time, and execute the operation instruction to write data to the memory database based on the data release result; and feed back data operation information to the client based on the data write result.
[0012] According to a third aspect of an embodiment of this specification, there is provided an in-memory database server, comprising:
[0013] in-memory databases, storage, and processors;
[0014] The memory is used to store memory management instructions for managing the memory database, and the processor is used to execute the memory management instructions. The memory management instructions are executed by the processor to implement the steps of the memory management method for the memory database when managing the memory database.
[0015] According to a fourth aspect of an embodiment of this specification, a memory management device for an in-memory database is provided, comprising:
[0016] an acquisition module, configured to acquire memory usage information of the memory database in response to an operation instruction submitted to the memory database;
[0017] a calculation module configured to calculate memory release information of the memory database according to the memory usage information when determining that the memory database meets the memory release condition according to the memory usage information;
[0018] a processing module configured to input the memory release information into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time according to gain information corresponding to the memory release information;
[0019] The release module is configured to release redundant data from the memory database according to the memory release time, and execute the operation instruction of writing data to the memory database according to the data release result.
[0020] According to a fifth aspect of the embodiments of this specification, there is provided a computing device, including:
[0021] memory and processor;
[0022] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the memory management method of the in-memory database are implemented.
[0023] According to a sixth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the memory management method of the above-mentioned memory database are implemented.
[0024] According to a seventh aspect of the embodiments of this specification, a computer program product is provided, comprising a computer program or instructions, which, when executed by a processor, implement the steps of the above-mentioned memory management method for the in-memory database.
[0025] The memory management method for the memory database provided in this embodiment can solve the problems of latency glitches and memory expansion. After receiving an operation instruction submitted to the memory database, the memory usage information of the memory database can be first obtained. If it is determined that the memory database meets the memory release conditions based on the memory usage information, it indicates that data elimination can be performed at this time. In order to achieve a dynamic balance between writing and eliminating data, the memory release information of the memory database can be calculated based on the memory usage information. At this time, the memory release information is input into the release time prediction model for processing to obtain the memory release time, wherein the release time prediction model predicts the memory release time according to the gain information corresponding to the memory release information. Then, the memory release time corresponding to different stages is dynamically calculated to balance the writing and elimination of data, thereby avoiding the occurrence of memory expansion and latency glitches. Finally, redundant data can be released according to the memory release time for the memory database, and the operation instruction to write data to the memory database is executed according to the data release result. By dynamically calculating the memory release time, the memory database can smoothly eliminate data and effectively control memory expansion, thereby ensuring the stability of the memory resources provided by the memory database in different scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 This is a flowchart of a memory management method for an in-memory database provided by one embodiment of this specification;
[0027] Figure 2a This is a schematic diagram of threshold setting in a memory management method for an in-memory database provided by one embodiment of this specification;
[0028] Figure 2b This is a schematic diagram of membership division in a memory management method for a memory database provided by one embodiment of this specification;
[0029] Figure 3 This is a flowchart of a processing process of a memory management method for an in-memory database provided by one embodiment of this specification;
[0030] Figure 4 This is a schematic diagram of the structure of a memory management system for an in-memory database provided by one embodiment of this specification;
[0031] Figure 5 This is a schematic diagram of the structure of a memory management device for an in-memory database provided by one embodiment of this specification;
[0032] Figure 6 This is a structural block diagram of a computing device provided by one embodiment of this specification. DETAILED DESCRIPTION
[0033] The following description sets forth many specific details to facilitate a thorough understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0034] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a," "the," and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0035] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0036] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0037] First, the terms involved in one or more embodiments of this specification are explained.
[0038] Redis (Remote Dictionary Server) is an open-source, in-memory data structure storage system that can be used as a database, cache, and messaging middleware. Redis supports a variety of data structures, such as strings, hashes, lists, sets, and sorted sets, and provides a rich set of operations to efficiently manage and query these data structures.
[0039] Data eviction: When the in-memory database is full, data eviction is triggered, and some data is evicted from the database to make way for new data. This can be controlled by setting eviction policies such as "random eviction," "eviction of infrequently used data," and "no eviction."
[0040] Elimination latency: In some in-memory databases, if the memory capacity is full, new write commands need to wait for the database to eliminate some data before writing new ones. This waiting time is called elimination latency.
[0041] Latency glitch: The time from command execution to command return is the command latency. If this latency increases suddenly over a short period of time, it is called a latency glitch.
[0042] PID: The PID controller (Proportional-Integral-Derivative Controller) is a closed-loop control algorithm widely used in industrial control and automation. It continuously adjusts the system output to make the actual output as close as possible to the set reference input (target value).
[0043] This specification provides a memory management method for an in-memory database. One or more embodiments of this specification also relate to a memory management system for an in-memory database, an in-memory database server, a memory management apparatus for an in-memory database, a computing device, a computer-readable storage medium, and a computer program product, each of which is described in detail in the following embodiments.
[0044] See also Figure 1 , Figure 1 A flowchart of a memory management method for an in-memory database provided according to an embodiment of the present specification is shown, which specifically includes the following steps.
[0045] Step S102 : In response to an operation instruction submitted to the memory database, memory usage information of the memory database is obtained.
[0046] The memory management method for an in-memory database provided in this embodiment can be applied to any in-memory database, such as Redis, Memcached, Aerospike, VoltDB, etc., and is used to dynamically calculate memory release time, so that the in-memory database can smoothly eliminate data and effectively control memory expansion, thereby ensuring the stability of memory resources provided by the in-memory database in different scenarios.
[0047] This embodiment uses Redis as an example to illustrate the memory management method of the memory database. For the memory management method of the memory database in other scenarios, refer to the same or corresponding description in this embodiment, and this embodiment will not be described in detail.
[0048] Among them, the operation instruction specifically refers to the instruction for the user to submit operation data when using the target service project. The instruction is used to trigger the writing of data to the memory database so that the data can be read from the memory database later to execute the target service project. Correspondingly, the memory usage information specifically refers to the amount of memory space that has been used in the memory database at the current moment when the operation instruction is received, which provides a basis for subsequent judgment on whether to eliminate data.
[0049] Based on this, in order to solve the problems of latency glitches and memory expansion, after receiving the operation instructions submitted to the memory database, the memory usage information of the memory database can be obtained first; then, if it is determined based on the memory usage information that the memory database meets the memory release conditions, it means that data elimination can be performed at this time. In order to achieve a dynamic balance between writing and eliminating data, the memory release information of the memory database can be calculated based on the memory usage information; at this time, the memory release information is input into the release time prediction model for processing to obtain the memory release time, wherein the release time prediction model predicts the memory release time according to the gain information corresponding to the memory release information; and then the memory release time corresponding to different stages is dynamically calculated to balance the writing and elimination of data, thereby avoiding the occurrence of memory expansion and latency glitches. Finally, redundant data can be released for the memory database according to the memory release time, and the operation instructions for writing data to the memory database are executed according to the data release results. By dynamically calculating the memory release time, the memory database can smoothly eliminate data and effectively control memory expansion, thereby ensuring the stability of the memory resources provided by the memory database in different scenarios.
[0050] Step S104 : when it is determined according to the memory usage information that the memory database meets a memory release condition, memory release information of the memory database is calculated according to the memory usage information.
[0051] Specifically, after determining the memory usage information of the memory database at the current moment according to the operation instruction, it is further possible to detect whether the memory database needs to undergo data elimination processing based on the memory usage information. If it is determined based on the memory usage information that the memory database meets the memory release conditions, it means that the remaining memory resources of the memory database at this time are insufficient to complete the data writing operation corresponding to the operation instruction, and therefore data elimination processing is required. In order to dynamically balance data elimination and writing, the memory release information of the memory database can be first calculated based on the memory usage information, so that the memory release time can be calculated in combination with the memory release information to ensure that the memory release time calculated at each stage meets the current data elimination requirements, that is, it will not generate a large number of delay glitches and will not cause memory expansion.
[0052] Among them, the memory release condition specifically refers to the condition for judging whether it is necessary to execute the data elimination mechanism for the data stored in the memory database at the current moment, which can be constructed by setting the memory elimination threshold; correspondingly, the memory release information specifically refers to the information on the size of memory space that needs to be released by the memory database after calculation based on the memory usage information, which is used for subsequent calculation of the memory release time.
[0053] Furthermore, when determining whether the in-memory database needs to eliminate data, this can be achieved by comparing the set threshold. In this embodiment, the specific implementation is as follows:
[0054] Determine an early release threshold and a delayed release threshold of the memory database, and compare the memory usage information with the early release threshold and the delayed release threshold; when the memory usage information is greater than the early release threshold and less than the delayed release threshold, determine that the memory database meets the memory release condition, and execute the step of calculating memory release information of the memory database based on the memory usage information; wherein, the early release threshold is less than the memory capacity of the memory database, and the delayed release threshold is greater than the memory capacity.
[0055] Specifically, the early release threshold refers to the threshold set for the memory database at which the data elimination mechanism can be executed in advance, which is smaller than the memory capacity of the memory database; the delayed release threshold refers to the threshold set for the memory database at which the operation instructions can be blocked and only data elimination can be performed, which is larger than the content capacity of the memory database.
[0056] Based on this, before determining whether it is necessary to calculate the memory release time based on the current memory usage information, the early release threshold and the delayed release threshold of the memory database can be determined first. At this time, the memory usage information can be compared with the early release threshold and the delayed release threshold. When the memory usage information is greater than the early release threshold and less than the delayed release threshold, it means that the usage of the memory database is about to reach the maximum memory capacity. If the operation command is continued to be executed, it will cause operation instruction congestion, and then only data elimination will be performed. However, only data elimination will cause subsequent operation commands to be congested, which may not meet user needs. Therefore, when the memory usage information is greater than the early release threshold and less than the delayed release threshold, it can be determined that the memory database meets the memory release conditions. At this time, the step of calculating the memory release information of the memory database based on the memory usage information can be executed.
[0057] In summary, by setting the early release threshold and the delayed release threshold, the execution of the elimination mechanism can be dynamically controlled, thereby ensuring that different elimination mechanisms are selected for data elimination according to different memory usage conditions, thereby improving load balancing capabilities.
[0058] In addition, if the memory usage information is not between the early release threshold and the delayed release threshold, it is necessary to use other strategies to execute the operation instruction. In this embodiment, the specific implementation method is as follows:
[0059] When the memory usage information is less than or equal to the early release threshold, the operation instruction of writing data to the memory database is executed; when the memory usage information is greater than or equal to the delayed release threshold, the redundant data is released according to the set memory release time, and the operation instruction of writing data to the memory database is executed according to the data release result.
[0060] Specifically, setting the memory release time specifically refers to the time for directly blocking the operation instruction and only performing data elimination when the memory usage information is greater than or equal to the delayed release threshold.
[0061] Based on this, when the memory usage information is less than or equal to the early release threshold, it means that the memory database still has a lot of memory resources available, so there is no need to eliminate data, and the operation instruction to write data to the memory database can be directly executed. When the memory usage information is greater than or equal to the delayed release threshold, it means that the memory database usage has exceeded the maximum content capacity of the memory database. If the data writing operation is still carried out according to the original plan, the waiting time of the operation instruction may increase indefinitely. Therefore, to avoid this problem, redundant data can be released according to the set memory release time. After the set memory release time ends, the operation instruction to write data to the memory database can be executed according to the data release result.
[0062] In summary, by setting early release thresholds and delayed release thresholds, different elimination strategies can be selected under different memory usage conditions, thereby effectively improving the memory resource utilization of the in-memory database.
[0063] Furthermore, the memory release information can be calculated by combining the memory capacity information and the memory usage information. In this embodiment, the specific implementation is as follows:
[0064] Memory capacity information corresponding to the memory database is determined, and memory release information of the memory database is calculated according to the memory capacity information and the memory usage information.
[0065] Specifically, the memory capacity information refers to the maximum memory capacity of the in-memory database. Based on this, when determining that data in the in-memory database requires data elimination, the corresponding memory capacity information of the in-memory database can be determined first. Then, the memory release information of the in-memory database can be calculated based on the memory capacity information and memory usage information, which can be used to calculate the memory release time.
[0066] For example, after the user submits a write command to Redis, Figure 2a As shown, Redis has a maximum memory capacity of 1GB, an early elimination threshold of 0.8GB, and a delayed elimination threshold of 1.2GB. Based on this, we can determine that Redis's current memory value is 0.9GB. Comparison shows that the current memory value of 0.9GB is greater than the early elimination threshold of 0.8GB and less than the delayed elimination threshold of 1.2GB. This further demonstrates that Redis can dynamically calculate the elimination time to avoid excessive latency glitches and memory bloat at the current moment. Furthermore, the memory value to be eliminated can be calculated based on the aforementioned memory value. The calculation determines that the memory occupied by the data to be eliminated is 0.1GB, denoted as e(t). Subsequent elimination time calculations can be performed based on the memory value to be eliminated, e(t) = 0.1GB.
[0067] In addition, if the memory usage value of Redis at the current moment is 0.5GB, and it is determined through comparison that the memory value at the current moment is less than the early elimination threshold of 0.8GB, the write command can be directly executed to write data to Redis; if the memory usage value of Redis at the current moment is 1.5GB, and it is determined through comparison that the memory value at the current moment is greater than the delayed elimination threshold of 1.2GB, then if data elimination is not performed in time, memory expansion may be caused, and the write command waiting time is too long. Therefore, the write command can be congested, and the set elimination time can be determined to be 100ms. After that, data elimination can be performed on Redis for 100ms, and after the data elimination is completed, it can be determined that the memory space of Redis is released, and then the congested write command can continue to be executed.
[0068] Step S106: input the memory release information into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time according to gain information corresponding to the memory release information.
[0069] Specifically, after obtaining the memory release information described above, to avoid latency glitches and memory bloat, the current memory release information can be combined with the release time prediction model to calculate the most appropriate memory release time for the current moment. This allows subsequent redundant data release operations to be completed according to the dynamically calculated memory release time. Furthermore, the release time prediction model predicts the memory release time by inputting the memory release information and combining it with the corresponding gain information. This ensures that the memory release time calculated at each stage closely matches the release requirements of the current scenario, preventing excessively long or short release times from impacting normal service operations.
[0070] Among them, the release time prediction model specifically refers to a model that inputs memory release information and combines its corresponding gain information to calculate the memory release time; accordingly, the memory release time specifically refers to the duration required for the memory database to eliminate data at the current moment. It can be calculated to different durations at different stages, thereby achieving the purpose of flexible data elimination.
[0071] On the one hand, when calculating the memory release time based on the memory release information, a PID model can be used to dynamically adjust each delay when triggering elimination. In this embodiment, the specific implementation method is as follows:
[0072] When the operation instruction corresponds to a first data release scenario, a release time prediction model associated with the first data release scenario is selected, and the memory release information is input into the release time prediction model; the first error ratio, the first error integral and the first error differential term are calculated using the release time prediction model according to the gain information corresponding to the memory release information; and the memory release time is determined based on the first error ratio, the first error differential and the first error differential term.
[0073] Specifically, the first data release scenario refers to the default data writing scenario of the memory database. The operation instructions in this scenario have no special instructions. The memory release time can be directly calculated in combination with its corresponding release time prediction model.
[0074] Based on this, when the operation instruction corresponds to the first data release scenario, it means that the memory database deployment scenario at this time is not loaded and will not be affected by parameters of other dimensions. Therefore, the release time prediction model associated with the first data release scenario can be directly selected, and the memory release information can be input into the release time prediction model; thereafter, the release time prediction model can be used to calculate the first error ratio, the first error integral and the first error differential term according to the gain information corresponding to the memory release information; and the memory release time can be determined based on the first error ratio, the first error differential and the first error differential term.
[0075] In actual applications, when it is determined that data needs to be eliminated for the in-memory database, the user needs to wait until all redundant data has been evicted before continuing to write. This will cause the QPS to drop to zero instantly, the command latency to increase significantly, and a large number of latency glitches to occur, affecting the user experience. If data is released according to a fixed elimination time, if the write speed is greater than the elimination speed, it will cause memory to increase. Therefore, in order to balance the elimination speed and command latency, the memory release time can be calculated in combination with the memory release information in the first data release scenario. In this way, when the memory increases quickly, the delay of each access command can be increased, the data elimination time can be longer, and the memory increase speed can be controlled. If the memory increases slowly, the delay of each access command can be reduced, and the data elimination time can be shorter.
[0076] Based on this, according to the above description logic, the classic PID (differential, integral, difference) model (release time prediction model) in the control field can be used to dynamically adjust the delay of each trigger elimination, that is, the memory release time, which can be expressed by the following formula (1):
[0077] (1)
[0078] Among them, K p Represents the proportional gain, K i Indicates the integral gain, K d represents the differential gain, e represents the error, which is equal to the set value (SP) minus the recovery value (PV), t represents the target time, u represents the state input, e(t) represents the difference between the instance memory and the actual memory, and u(t) represents the elimination time of each access, that is, the memory release time.
[0079] It can be understood that when e(t) fluctuates rapidly, it is possible to adjust K p , K i and K d Parameters are used to make u(t) quickly and smoothly reach a stable value, thereby releasing redundant data according to the calculated memory release time, which can balance the elimination speed and command latency.
[0080] Continuing with the above example, when the memory value to be eliminated is determined to be e(t) = 0.1GB, the proportional, integral, and differential terms corresponding to e(t) can be calculated using the above formula (1). Then, by summing them, the elimination time u(t) = 50ms corresponding to the current moment can be obtained. Subsequently, the redundant data in Redis can be eliminated according to u(t) = 50ms.
[0081] In summary, by using the PID model combined with memory release information to calculate the memory release time, it can be ensured that the calculated memory release time is more in line with the current scenario requirements, thereby avoiding the memory expansion problem caused by setting a fixed release time.
[0082] On the other hand, in the face of complex data elimination scenarios, in order to make the calculation of memory release time more interpretable and adapt to more complex scenarios, the calculation of memory release time can be completed by calculating the memory change rate. In this embodiment, the specific implementation method is as follows:
[0083] When the operation instruction corresponds to a second data release scenario, a release time prediction model associated with the second data release scenario is selected, and the memory release information is input into the release time prediction model; the memory change rate corresponding to the memory release information is calculated using the release time prediction model, and the gain information corresponding to the memory release information is determined based on the memory change rate and the memory release information; the second error proportion, the second error integral and the second error differential term are calculated based on the gain information, and the memory release time is determined based on the second error proportion, the second error differential and the second error differential term.
[0084] Specifically, in complex data elimination scenarios like the second data release scenario, calculating the memory release time directly based on memory release information can lead to inaccurate calculations due to load conditions. Therefore, a release time prediction model associated with the second data release scenario can be used to calculate the memory release time. Accordingly, the memory change rate specifically refers to the probability of change corresponding to the memory release information.
[0085] Based on this, when the operation instruction corresponds to the second data release scenario, it means that it is necessary to select the release time prediction model associated with the second data release scenario to calculate the memory release time, so as to ensure the accuracy of the calculation. Therefore, the memory release information can be input into the release time prediction model; the release time prediction model is used to calculate the memory change rate corresponding to the memory release information, and on this basis, the gain information corresponding to the memory release information is determined according to the memory change rate and the memory release information; the second error ratio, the second error integral and the second error differential term are calculated according to the gain information, and then the memory release time can be determined based on the second error ratio, the second error differential and the second error differential term, so that the redundant data can be released subsequently.
[0086] In summary, for complex scenarios, the release time prediction model corresponding to the second data release scenario is used to predict memory release information, which can ensure the calculation accuracy of memory release time in complex scenarios. Releasing memory in this way can avoid generating a large number of glitches and avoid memory expansion, thereby balancing data elimination and data writing.
[0087] In this process, determining gain information corresponding to the memory release information according to the memory change rate and the memory release information includes:
[0088] The memory change rate and the memory release information are mapped to a target domain according to a linear mapping algorithm; a first membership corresponding to the memory change rate and a second membership corresponding to the memory release information are calculated according to the mapping result; the first membership and the second membership are converted, and the gain information corresponding to the memory release information is calculated according to the membership conversion result.
[0089] Specifically, the linear mapping algorithm refers to an algorithm for mapping memory change rates and memory release information. The target domain refers to the domain of fuzzy sets corresponding to the memory change rates and memory release information. The first membership degree refers to the membership degree corresponding to the memory change rate, and the second membership degree refers to the membership degree corresponding to the memory release information.
[0090] Based on this, when calculating the gain information, the memory change rate and memory release information can be mapped to the target domain according to the linear mapping algorithm; thereafter, the first membership corresponding to the memory change rate and the second membership corresponding to the memory release information can be calculated according to the mapping results; based on this, the first membership and the second membership are converted, so as to calculate the gain information corresponding to the memory release information according to the membership conversion result.
[0091] In summary, by calculating the membership degree to determine the gain information, it can ensure that the subsequent memory release time prediction results are more accurate.
[0092] Furthermore, converting the first membership degree and the second membership degree, and calculating gain information corresponding to the memory release information according to the membership conversion result, includes:
[0093] The proportional rule table, integral rule table and differential item rule table are queried according to the first membership and the second membership; the proportional membership, integral membership and differential item membership are determined according to the query results, and initial gain information is calculated according to the proportional membership, the integral membership and the differential item membership; the initial gain information is updated to obtain gain information corresponding to the memory release information.
[0094] Specifically, the proportion rule table specifically refers to a data table recording proportion-related membership, the integral rule table specifically refers to a data table recording integral-related membership, and the differential item rule table specifically refers to a data table recording differential item-related membership.
[0095] Based on this, when calculating the gain information based on the first membership and the second membership, the proportional rule table, the integral rule table and the differential item rule table can be queried based on the first membership and the second membership; thereby, the proportional membership, the integral membership and the differential item membership are determined based on the query results, and on this basis, the initial gain information is calculated based on the proportional membership, the integral membership and the differential item membership; based on this, the initial gain information is updated to obtain the gain information corresponding to the memory release information, which is used for calculating the memory release time to ensure the calculation accuracy.
[0096] In practical applications, in the second data release scenario, the release time prediction model corresponding to this scenario can be configured to improve the prediction accuracy of memory release time. Specifically, when predicting memory release time, the input can be fuzzified first. Combined with fuzzy control methods, the fuzzy set of the input error variable e(t) and the error variable change value ec(t) can be set to {negative, negative medium, negative small, zero, positive small, positive medium, positive large}, and abbreviated as {NB, NM, NS, ZO, PS, PM, PB}. The domain of the fuzzy set is set to {-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6}. The maximum and minimum values of e(t) and ec(t) can be obtained through actual stress testing results, denoted as Emin, Emax, ECmin, and ECmax. Then, the values of e(t) and ec(t) can be mapped to the interval range [-6, 6] of the fuzzy subset domain through linear mapping. This can be achieved using the following formula (2):
[0097] (2)
[0098] Furthermore, the membership of the above input variables to the fuzzy set can be calculated through the membership function / membership graph. In this case, a triangular narrow membership function can be used (for example, the two sides of the triangle with NM as the vertex belong to NM), and the corresponding values of f(e) and f(ce) can be mapped to the corresponding membership. Figure 2b As shown in the schematic diagram, if the calculated value of f(e) is -3, the corresponding membership degree to NM is 0.5, and the corresponding membership degree to NS is also 0.5.
[0099] Furthermore, after the fuzzification is completed, fuzzy control rules can be established for fuzzy reasoning. That is, the membership of the input variable is changed through certain conditional rules to obtain the membership of the output variable. This process involves K p , K i , K d The parameters of the three variables need to be adjusted, so the three variables △K need to be set p , △K i , △K d The fuzzy rule table of the fuzzy set is also defined as {negative, negative medium, negative small, zero, positive small, positive medium, positive large}, and abbreviated as {NB, NM, NS, ZO, PS, PM, PB}. The domain of the fuzzy set is {-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6}. p The fuzzy rule table is as follows Table 1, △K i The fuzzy rule table is as follows Table 2, △K d The fuzzy rule table is as follows Table 3:
[0100]
[0101] Table 1
[0102]
[0103] Table 2
[0104]
[0105] Table 3
[0106] For example, the membership of f(e) is 0.4NM+0.6NS, and the membership of f(ec) is 0.3PS+0.7PM. Then, after querying the above fuzzy rule table, the membership output is:
[0107] △K p = 0.4*0.3 PS + 0.4*0.7 ZO + 0.6*0.3ZO+0.6*0.7NS = 0.12PS+0.46ZO+0.42NS
[0108] △K i = 0.4*0.3 NS + 0.4*0.7 ZO + 0.6*0.3ZO+0.6*0.7PS = 0.12NS+0.46ZO+0.42PS
[0109] △K d = 0.4*0.3NM + 0.4*0.7NS + 0.6*0.3NS+0.6*0.7NS = 0.12NM + 0.88NS
[0110] The output value △K is obtained above p , △K i , △K d After the membership value is obtained, the defuzzification output can be performed. At this time, the centroid method can be used to calculate the output quantization value, which can be achieved by the following formula (3):
[0111] (3)
[0112] Among them, Mi is the membership value, and Fi is the fuzzy value (such as NM=-4).
[0113] Continuing with the previous example, after obtaining the membership determined by the lookup table, we can further calculate the membership values of the proportional, integral, and differential terms:
[0114] △K p= 0.12PS+0.46ZO+0.42NS = 0.12*2+0.46*0+0.42*-2 = -0.6
[0115] △K i = 0.12NS+0.46ZO+0.42PS = 0.12*-2+0.46*0+0.42*2 = 0.6
[0116] △K d = 0.12NM + 0.88NS = 0.12*-4+0.88*-2= -1.28
[0117] After obtaining the quantized value of the defuzzified output, the change range can be adjusted by setting the coefficient, which can be achieved by the following formula (4):
[0118] (4)
[0119] Among them, K represents the PID coefficient K p , K i , K d , α represents the coefficient of variation of △K.
[0120] That is to say, based on the fuzzy rule table, the input error variables e(t) and ec(t) can not only adjust the change of the input quantity u(t), but also adjust the PID parameters in the process, thereby improving the stability of the dynamic change of the delay under different data elimination scenarios. It can be expressed by the following formula (5):
[0121] (5)
[0122] Among them, K p , K i , K d The value of is affected by the changes of e(t) and ec(t) during the input process.
[0123] It can be understood that when e(t) fluctuates rapidly, it is possible to adjust K p , K i and K d Parameters are used to make u(t) quickly and smoothly reach a stable value, thereby releasing redundant data according to the calculated memory release time, which can balance the elimination speed and command latency.
[0124] Continuing with the above example, when the memory value to be eliminated is determined to be e(t) = 0.1GB, we can first calculate the change rate ec(t) corresponding to e(t), and then combine the above formulas (2) to (5) to calculate the updated value K of the PID parameter through e(t) and ec(t). p (t), Ki (t) and K d (t), based on the updated K p (t), K i (t) and K d (t) can be used to calculate the proportional, integral, and differential terms of the corresponding error. Then, by summing them up, we can get the elimination time u(t) = 25ms corresponding to the current moment. Subsequently, the redundant data in Redis can be eliminated according to u(t) = 25ms.
[0125] In summary, by querying rule tables of different dimensions to determine the membership and using it to predict memory release time, the calculation accuracy and efficiency can be effectively improved.
[0126] Step S108 : releasing redundant data from the memory database according to the memory release time, and executing the operation instruction of writing data to the memory database according to the data release result.
[0127] Specifically, after calculating the memory release time corresponding to the current moment using the release time prediction model, redundant data can be released from the in-memory database according to the memory release time. After the memory release time expires, the operation instruction to write data to the in-memory database can be executed based on the data release result, completing the operation process of writing the data corresponding to the operation instruction to the in-memory database. Redundant data specifically refers to data in the in-memory database that can be deleted at the current moment, such as data that has been stored for a long time or that occupies a large amount of memory space.
[0128] Furthermore, in order to ensure that the released redundant data does not affect the running target service project, the redundant data can be determined according to the set strategy. In this embodiment, the specific implementation is as follows:
[0129] Redundant data is determined in the memory database according to a set release policy, the redundant data is released according to the memory release time, and the operation instruction of writing data to the memory database is executed according to the data release result.
[0130] Specifically, setting a release strategy refers to determining a strategy for redundant data. For example, you can sort the storage time of each piece of data and select the data with the longest storage time as redundant data. You can also compare the space occupied by each piece of data and select the data with a space greater than a set threshold as redundant data.
[0131] Based on this, after determining the memory release time, redundant data can be determined in the memory database according to the set release policy, and then the redundant data can be released according to the memory release time, and the operation instruction of writing data to the memory database can be executed according to the data release result.
[0132] Continuing with the previous example, after determining the elimination time u(t) = 50ms, the redundant data that needs to be deleted can be determined in Redis. For example, n redundant data that has been stored for too long can be determined based on the storage time. At this time, these n redundant data can be deleted and the deletion process will continue for 50ms. After the elimination time is over, the data corresponding to the write command can be written to Redis, thereby ensuring the normal operation of the target service project.
[0133] The memory management method for the memory database provided in this embodiment can solve the problems of latency glitches and memory expansion. After receiving an operation instruction submitted to the memory database, the memory usage information of the memory database can be first obtained. If it is determined that the memory database meets the memory release conditions based on the memory usage information, it indicates that data elimination can be performed at this time. In order to achieve a dynamic balance between writing and eliminating data, the memory release information of the memory database can be calculated based on the memory usage information. At this time, the memory release information is input into the release time prediction model for processing to obtain the memory release time, wherein the release time prediction model predicts the memory release time according to the gain information corresponding to the memory release information. Then, the memory release time corresponding to different stages is dynamically calculated to balance the writing and elimination of data, thereby avoiding the occurrence of memory expansion and latency glitches. Finally, redundant data can be released according to the memory release time for the memory database, and the operation instruction to write data to the memory database is executed according to the data release result. By dynamically calculating the memory release time, the memory database can smoothly eliminate data and effectively control memory expansion, thereby ensuring the stability of the memory resources provided by the memory database in different scenarios.
[0134] The above is a schematic diagram of a memory management system for an in-memory database according to this embodiment. It should be noted that the technical solution of the in-memory database memory management system and the technical solution of the in-memory database memory management method described above are based on the same concept. For details not described in detail in the technical solution of the in-memory database memory management system, please refer to the description of the technical solution of the in-memory database memory management method described above.
[0135] The following combined Figure 3 , taking the application of the memory management method of the memory database provided in this specification in the memory database data elimination scenario as an example, the memory management method of the memory database is further explained. Figure 3 A flowchart of a processing process of a memory management method of an in-memory database provided by an embodiment of this specification is shown, which specifically includes the following steps.
[0136] Step S302 : In response to the operation instruction submitted to the memory database, memory usage information of the memory database is obtained.
[0137] Step S304: determining an early release threshold and a late release threshold of the memory database, and comparing the memory usage information with the early release threshold and the late release threshold.
[0138] Step S306 : When the memory usage information is greater than the early release threshold and less than the delayed release threshold, it is determined that the memory database meets the memory release condition.
[0139] Step S308: determining memory capacity information corresponding to the memory database, and calculating memory release information of the memory database according to the memory capacity information and the memory usage information.
[0140] In step S310 , the memory release information is input into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time according to gain information corresponding to the memory release information.
[0141] An optional processing method, when the operation instruction corresponds to a first data release scenario, select a release time prediction model associated with the first data release scenario, and input the memory release information into the release time prediction model; use the release time prediction model to calculate the first error ratio, the first error integral and the first error differential term according to the gain information corresponding to the memory release information; determine the memory release time based on the first error ratio, the first error differential and the first error differential term.
[0142] Another optional processing method is to select a release time prediction model associated with the second data release scenario when the operation instruction corresponds to a second data release scenario, and input the memory release information into the release time prediction model; use the release time prediction model to calculate the memory change rate corresponding to the memory release information, and map the memory change rate and the memory release information to the target domain according to a linear mapping algorithm; calculate the first membership corresponding to the memory change rate and the second membership corresponding to the memory release information according to the mapping result; query the proportion rule table, the integral rule table and the differential item rule table according to the first membership and the second membership; determine the proportion membership, the integral membership and the differential item membership according to the query result, and calculate the initial gain information according to the proportion membership, the integral membership and the differential item membership; update the initial gain information to obtain the gain information corresponding to the memory release information, calculate the second error proportion, the second error integral and the second error differential item according to the gain information, and determine the memory release time based on the second error proportion, the second error differential and the second error differential item.
[0143] Step S312: determining redundant data in the memory database according to the set release policy, and releasing the redundant data according to the memory release time.
[0144] Step S314: executing an operation instruction to write data into the memory database according to the data release result.
[0145] In summary, in order to resolve latency glitches and memory bloat, after receiving an operation instruction submitted to the memory database, the memory usage information of the memory database can be first obtained. If the memory usage information determines that the memory database meets the memory release conditions, data elimination can be performed. To achieve a dynamic balance between writing and eliminating data, the memory release information of the memory database can be calculated based on the memory usage information. The memory release information is then input into a release time prediction model for processing to obtain a memory release time. The release time prediction model predicts the memory release time based on the gain information corresponding to the memory release information. The memory release time corresponding to different stages is then dynamically calculated to balance data writing and elimination, thereby avoiding memory bloat and latency glitches. Finally, redundant data can be released from the memory database according to the memory release time, and the operation instruction to write data to the memory database is executed based on the data release result. By dynamically calculating the memory release time, the memory database can smoothly eliminate data and effectively control memory bloat, thereby ensuring the stability of the memory resources provided by the memory database in different scenarios.
[0146] Corresponding to the above method embodiment, this specification also provides an embodiment of a memory management system for an in-memory database. Figure 4 FIG1 shows a schematic diagram of a memory management system for a memory database provided by an embodiment of this specification. Figure 4 As shown, the memory management system 400 of the memory database includes a server 420 and a client 410, including:
[0147] The client 410 is configured to receive an operation instruction submitted for a target service item and submit the operation instruction to the server;
[0148] The server 420 is configured to obtain memory usage information of the memory database in response to an operation instruction submitted to the memory database; calculate memory release information of the memory database based on the memory usage information when determining that the memory database meets a memory release condition based on the memory usage information; input the memory release information into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time based on gain information corresponding to the memory release information; release redundant data for the memory database according to the memory release time, and execute the operation instruction to write data to the memory database based on the data release result; and feed back data operation information to the client based on the data write result.
[0149] In an optional embodiment, the server 420 is further used to determine the early release threshold and the delayed release threshold of the memory database, and compare the memory usage information with the early release threshold and the delayed release threshold; when the memory usage information is greater than the early release threshold and less than the delayed release threshold, it is determined that the memory database meets the memory release condition, and the step of calculating the memory release information of the memory database based on the memory usage information is executed; wherein, the early release threshold is less than the memory capacity of the memory database, and the delayed release threshold is greater than the memory capacity.
[0150] In an optional embodiment, the server 420 is further used to determine the memory capacity information corresponding to the memory database, and calculate the memory release information of the memory database based on the memory capacity information and the memory usage information; wherein, the redundant data for the memory database is released according to the memory release time, and the operation instruction of writing data to the memory database is executed according to the data release result, including: determining the redundant data in the memory database according to the set release policy, releasing the redundant data according to the memory release time, and executing the operation instruction of writing data to the memory database according to the data release result.
[0151] In an optional embodiment, the server 420 is further used to select a release time prediction model associated with a first data release scenario when the operation instruction corresponds to the first data release scenario, and input the memory release information into the release time prediction model; use the release time prediction model to calculate the first error ratio, the first error integral and the first error differential term according to the gain information corresponding to the memory release information; and determine the memory release time based on the first error ratio, the first error differential and the first error differential term.
[0152] In an optional embodiment, the server 420 is further used to select a release time prediction model associated with a second data release scenario when the operation instruction corresponds to a second data release scenario, and input the memory release information into the release time prediction model; use the release time prediction model to calculate the memory change rate corresponding to the memory release information, and determine the gain information corresponding to the memory release information based on the memory change rate and the memory release information; calculate the second error ratio, the second error integral and the second error differential term based on the gain information, and determine the memory release time based on the second error ratio, the second error differential and the second error differential term.
[0153] In an optional embodiment, the server 420 is also used to map the memory change rate and the memory release information to the target domain according to a linear mapping algorithm; calculate the first membership corresponding to the memory change rate and the second membership corresponding to the memory release information according to the mapping result; convert the first membership and the second membership, and calculate the gain information corresponding to the memory release information according to the membership conversion result.
[0154] In an optional embodiment, the server 420 is further used to query the proportional rule table, integral rule table and differential item rule table based on the first membership and the second membership; determine the proportional membership, integral membership and differential item membership based on the query results, and calculate the initial gain information based on the proportional membership, the integral membership and the differential item membership; update the initial gain information to obtain the gain information corresponding to the memory release information.
[0155] In an optional embodiment, the server 420 is also used to execute the operation instruction to write data to the memory database when the memory usage information is less than or equal to the early release threshold; when the memory usage information is greater than or equal to the delayed release threshold, release the redundant data according to the set memory release time, and execute the operation instruction to write data to the memory database based on the data release result.
[0156] The memory management system of the memory database provided in this embodiment can solve the problems of latency glitches and memory expansion. After receiving the operation instruction submitted to the memory database, the memory usage information of the memory database can be obtained first. If it is determined that the memory database meets the memory release conditions based on the memory usage information, it means that data elimination can be performed at this time. In order to achieve a dynamic balance between writing and eliminating data, the memory release information of the memory database can be calculated based on the memory usage information. At this time, the memory release information is input into the release time prediction model for processing to obtain the memory release time, wherein the release time prediction model predicts the memory release time according to the gain information corresponding to the memory release information. Then, the memory release time corresponding to different stages is dynamically calculated to balance the writing and elimination of data, thereby avoiding the occurrence of memory expansion and latency glitches. Finally, redundant data can be released according to the memory release time for the memory database, and the operation instruction of writing data to the memory database is executed according to the data release result. By dynamically calculating the memory release time, the memory database can be smoothly eliminated and memory expansion can be effectively controlled, thereby ensuring the stability of the memory resources provided by the memory database in different scenarios.
[0157] Corresponding to the above method embodiment, this specification also provides an embodiment of a memory management device for an in-memory database. Figure 5 FIG1 shows a schematic diagram of a memory management device for a memory database provided by an embodiment of the present specification. Figure 5 As shown, the device includes:
[0158] An acquisition module 502 is configured to acquire memory usage information of the memory database in response to an operation instruction submitted to the memory database;
[0159] A calculation module 504 is configured to calculate memory release information of the memory database according to the memory usage information when it is determined that the memory database meets the memory release condition according to the memory usage information;
[0160] The processing module 506 is configured to input the memory release information into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time according to gain information corresponding to the memory release information;
[0161] The release module 508 is configured to release redundant data from the memory database according to the memory release time, and execute the operation instruction of writing data to the memory database according to the data release result.
[0162] In an optional embodiment, when determining, based on the memory usage information, that the memory database meets the memory release condition, calculating the memory release information of the memory database based on the memory usage information includes:
[0163] Determine an early release threshold and a delayed release threshold of the memory database, and compare the memory usage information with the early release threshold and the delayed release threshold; when the memory usage information is greater than the early release threshold and less than the delayed release threshold, determine that the memory database meets the memory release condition, and execute the step of calculating memory release information of the memory database based on the memory usage information; wherein, the early release threshold is less than the memory capacity of the memory database, and the delayed release threshold is greater than the memory capacity.
[0164] In an optional embodiment, the calculating the memory release information of the memory database according to the memory usage information includes:
[0165] Determine memory capacity information corresponding to the memory database, and calculate memory release information of the memory database based on the memory capacity information and the memory usage information; wherein, releasing redundant data for the memory database according to the memory release time, and executing the operation instruction of writing data to the memory database according to the data release result, includes: determining redundant data in the memory database according to a set release policy, releasing the redundant data according to the memory release time, and executing the operation instruction of writing data to the memory database according to the data release result.
[0166] In an optional embodiment, inputting the memory release information into a release time prediction model for processing to obtain the memory release time includes:
[0167] When the operation instruction corresponds to a first data release scenario, a release time prediction model associated with the first data release scenario is selected, and the memory release information is input into the release time prediction model; the first error ratio, the first error integral and the first error differential term are calculated using the release time prediction model according to the gain information corresponding to the memory release information; and the memory release time is determined based on the first error ratio, the first error differential and the first error differential term.
[0168] In an optional embodiment, inputting the memory release information into a release time prediction model for processing to obtain the memory release time includes:
[0169] When the operation instruction corresponds to a second data release scenario, a release time prediction model associated with the second data release scenario is selected, and the memory release information is input into the release time prediction model; the memory change rate corresponding to the memory release information is calculated using the release time prediction model, and the gain information corresponding to the memory release information is determined based on the memory change rate and the memory release information; the second error proportion, the second error integral and the second error differential term are calculated based on the gain information, and the memory release time is determined based on the second error proportion, the second error differential and the second error differential term.
[0170] In an optional embodiment, determining the gain information corresponding to the memory release information according to the memory change rate and the memory release information includes:
[0171] The memory change rate and the memory release information are mapped to a target domain according to a linear mapping algorithm; a first membership corresponding to the memory change rate and a second membership corresponding to the memory release information are calculated according to the mapping result; the first membership and the second membership are converted, and the gain information corresponding to the memory release information is calculated according to the membership conversion result.
[0172] In an optional embodiment, converting the first membership and the second membership, and calculating the gain information corresponding to the memory release information according to the membership conversion result, includes:
[0173] The proportional rule table, integral rule table and differential item rule table are queried according to the first membership and the second membership; the proportional membership, integral membership and differential item membership are determined according to the query results, and initial gain information is calculated according to the proportional membership, the integral membership and the differential item membership; the initial gain information is updated to obtain gain information corresponding to the memory release information.
[0174] In an optional embodiment, after the step of comparing the memory usage information with the early release threshold and the delayed release threshold is performed, the method further includes:
[0175] When the memory usage information is less than or equal to the early release threshold, the operation instruction of writing data to the memory database is executed; when the memory usage information is greater than or equal to the delayed release threshold, the redundant data is released according to the set memory release time, and the operation instruction of writing data to the memory database is executed according to the data release result.
[0176] The memory management device for the in-memory database provided in this embodiment can, in order to solve the problems of latency glitches and memory expansion, first obtain the memory usage information of the in-memory database after receiving an operation instruction submitted to the in-memory database. Then, if it is determined based on the memory usage information that the in-memory database meets the memory release conditions, it indicates that data elimination can be performed at this time. In order to achieve a dynamic balance between writing and eliminating data, the memory release information of the in-memory database can be calculated based on the memory usage information. At this time, the memory release information is input into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time based on the gain information corresponding to the memory release information. Then, the memory release time corresponding to different stages is dynamically calculated to balance the writing and elimination of data, thereby avoiding the occurrence of memory expansion and latency glitches. Finally, redundant data can be released from the in-memory database according to the memory release time, and the operation instruction to write data to the in-memory database is executed based on the data release result. By dynamically calculating the memory release time, the in-memory database can smoothly eliminate data and effectively control memory expansion, thereby ensuring the stability of the memory resources provided by the in-memory database in different scenarios.
[0177] The above is a schematic diagram of a memory management device for an in-memory database according to this embodiment. It should be noted that the technical solution of the memory management device for an in-memory database and the technical solution of the memory management method for an in-memory database are based on the same concept. For details not described in detail in the technical solution of the memory management device for an in-memory database, please refer to the description of the technical solution of the memory management method for an in-memory database.
[0178] An embodiment of the present specification provides an in-memory database server, comprising: an in-memory database, a memory, and a processor;
[0179] The memory is used to store memory management instructions for managing the memory database, and the processor is used to execute the memory management instructions. The memory management instructions are executed by the processor to implement the steps of the memory management method for the memory database when managing the memory database.
[0180] The above is a schematic diagram of an in-memory database server according to this embodiment. It should be noted that the technical solution of this in-memory database server and the technical solution of the in-memory database memory management method described above share the same concept. For details not described in detail in the technical solution of the in-memory database server, please refer to the description of the technical solution of the in-memory database memory management method described above.
[0181] Figure 66 shows a block diagram of a computing device 600 according to one embodiment of the present disclosure. Components of the computing device 600 include, but are not limited to, a memory 610 and a processor 620. The processor 620 is connected to the memory 610 via a bus 630, and a database 650 is used to store data.
[0182] Computing device 600 also includes an access device 640 that enables computing device 600 to communicate via one or more networks 660. Examples of such networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. Access device 640 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, or a near field communication (NFC) interface.
[0183] In one embodiment of the present specification, the above components of the computing device 600 and Figure 6 Other components not shown in the figure may also be connected to each other, for example, via a bus. Figure 6 The computing device structure block diagram shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art may add or replace other components as needed.
[0184] Computing device 600 can be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, personal digital assistant, laptop computer, notebook computer, netbook computer, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or personal computer (PC). Computing device 600 can also be a mobile or stationary server.
[0185] The processor 620 is configured to execute the following computer executable instructions, which, when executed by the processor, implement the steps of the memory management method for the memory database.
[0186] The above is a schematic diagram of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the memory management method for the in-memory database described above are based on the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the memory management method for the in-memory database described above.
[0187] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the above-mentioned memory management method for the memory database.
[0188] The above is a schematic diagram of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium is based on the same concept as the technical solution of the memory management method for the in-memory database described above. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the memory management method for the in-memory database described above.
[0189] An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned memory management method for the memory database.
[0190] The above is an illustrative solution of a computer program according to this embodiment. It should be noted that the technical solution of this computer program and the technical solution of the memory management method for the in-memory database described above are based on the same concept. For details not described in detail in the technical solution of the computer program, please refer to the description of the technical solution of the memory management method for the in-memory database described above.
[0191] An embodiment of the present specification further provides a computer program product, including a computer program or instructions, which implements the steps of the above-mentioned memory management method for the in-memory database when executed by a processor.
[0192] The above is an illustrative embodiment of a computer program product. It should be noted that the technical solution of this computer program product is based on the same concept as the technical solution of the memory management method for an in-memory database described above. For details not described in detail in the technical solution of the computer program product, please refer to the description of the technical solution of the memory management method for an in-memory database described above.
[0193] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0194] The computer instructions include computer program code, which may be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium may include any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content of the computer-readable medium may be appropriately increased or decreased based on the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media does not include electric carrier signals and telecommunication signals.
[0195] It should be noted that for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0196] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0197] The preferred embodiments disclosed above are intended only to help illustrate this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made based on the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A memory management method for an in-memory database, comprising: In response to an operation instruction submitted to a memory database, obtaining memory usage information of the memory database; comparing the memory usage information with an early release threshold and a delayed release threshold of the memory database, determining that the memory database meets a memory release condition if the memory usage information is greater than the early release threshold and less than the delayed release threshold, and calculating memory release information of the memory database based on the memory usage information; Inputting the memory release information into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time according to gain information corresponding to the memory release information; Redundant data is released from the memory database according to the memory release time, and the operation instruction of writing data to the memory database is executed according to the data release result. 2 . The memory management method for an in-memory database according to claim 1 , wherein the early release threshold is smaller than a memory capacity of the in-memory database, and the delayed release threshold is larger than the memory capacity.
3. The memory management method for an in-memory database according to claim 1 , wherein the step of calculating the memory release information of the in-memory database based on the memory usage information comprises: Determining memory capacity information corresponding to the memory database, and calculating memory release information of the memory database based on the memory capacity information and the memory usage information; The step of releasing redundant data from the memory database according to the memory release time and executing the operation instruction of writing data to the memory database according to the data release result includes: Redundant data is determined in the memory database according to a set release policy, the redundant data is released according to the memory release time, and the operation instruction of writing data to the memory database is executed according to the data release result.
4. The memory management method for an in-memory database according to any one of claims 1 to 3, wherein the inputting the memory release information into a release time prediction model for processing to obtain the memory release time comprises: In a case where the operation instruction corresponds to a first data release scenario, selecting a release time prediction model associated with the first data release scenario, and inputting the memory release information into the release time prediction model; Calculating a first error ratio, a first error integral, and a first error differential term according to the gain information corresponding to the memory release information using the release time prediction model; A memory release time is determined based on the first error ratio, the first error differential, and the first error differential term.
5. The memory management method of an in-memory database according to any one of claims 1 to 3, wherein the step of inputting the memory release information into a release time prediction model for processing to obtain the memory release time comprises: In a case where the operation instruction corresponds to a second data release scenario, selecting a release time prediction model associated with the second data release scenario, and inputting the memory release information into the release time prediction model; Calculating a memory change rate corresponding to the memory release information using the release time prediction model, and determining gain information corresponding to the memory release information according to the memory change rate and the memory release information; A second error proportion, a second error integral, and a second error differential term are calculated according to the gain information, and a memory release time is determined based on the second error proportion, the second error differential, and the second error differential term.
6. The memory management method of an in-memory database according to claim 5, wherein determining the gain information corresponding to the memory release information according to the memory change rate and the memory release information comprises: Mapping the memory change rate and the memory release information to a target domain according to a linear mapping algorithm; Calculating a first degree of membership corresponding to the memory change rate and a second degree of membership corresponding to the memory release information according to the mapping result; The first membership degree and the second membership degree are converted, and gain information corresponding to the memory release information is calculated according to the membership conversion result.
7. The memory management method for an in-memory database according to claim 6, wherein the converting the first membership and the second membership, and calculating the gain information corresponding to the memory release information according to the membership conversion result, comprises: querying a proportion rule table, an integral rule table, and a differential term rule table according to the first membership degree and the second membership degree; Determining proportional membership, integral membership, and differential term membership according to the query result, and calculating initial gain information according to the proportional membership, the integral membership, and the differential term membership; The initial gain information is updated to obtain gain information corresponding to the memory release information.
8. The memory management method for an in-memory database according to claim 2, further comprising: after the step of comparing the memory usage information with the early release threshold and the late release threshold of the in-memory database is performed: When the memory usage information is less than or equal to the early release threshold, executing the operation instruction to write data to the memory database; When the memory usage information is greater than or equal to the delayed release threshold, the redundant data is released according to the set memory release time, and the operation instruction of writing data to the memory database is executed according to the data release result.
9. A memory management system for an in-memory database, comprising a server and a client, including: The client is configured to receive an operation instruction submitted for a target service item and submit the operation instruction to the server; The server is configured to obtain memory usage information of the memory database in response to an operation instruction submitted to the memory database; comparing the memory usage information with an early release threshold and a delayed release threshold of the memory database, determining that the memory database meets a memory release condition if the memory usage information is greater than the early release threshold and less than the delayed release threshold, and calculating memory release information of the memory database based on the memory usage information; Inputting the memory release information into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time according to gain information corresponding to the memory release information; Redundant data is released from the memory database according to the memory release time, and the operation instruction of writing data to the memory database is executed according to the data release result; and data operation information is fed back to the client according to the data writing result.
10. An in-memory database server, comprising: in-memory databases, storage, and processors; The memory is used to store memory management instructions for managing the memory database, and the processor is used to execute the memory management instructions. When the memory management instructions are executed by the processor to manage the memory database, the steps of the method according to any one of claims 1 to 8 are implemented.
11. A memory management device for an in-memory database, comprising: an acquisition module, configured to acquire memory usage information of the memory database in response to an operation instruction submitted to the memory database; a calculation module configured to compare the memory usage information with an early release threshold and a delayed release threshold of the memory database, determine that the memory database meets a memory release condition if the memory usage information is greater than the early release threshold and less than the delayed release threshold, and calculate memory release information of the memory database based on the memory usage information; a processing module configured to input the memory release information into a release time prediction model for processing to obtain a memory release time, wherein the release time prediction model predicts the memory release time according to gain information corresponding to the memory release information; The release module is configured to release redundant data from the memory database according to the memory release time, and execute the operation instruction of writing data to the memory database according to the data release result.
12. A computing device comprising: memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the method according to any one of claims 1 to 8 are implemented.
13. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the steps of the method according to any one of claims 1 to 8.
14. A computer program product comprising a computer program or instructions, which implement the steps of the method according to any one of claims 1 to 8 when executed by a processor.
Citation Information
Patent Citations
Memory database management method and device and storage medium
CN116560848A
Memory equalization method and system based on edge computing, medium and program product
CN119512767A