Cache allocation method, device, equipment, storage medium and program product
By obtaining tenant operation data in real time and determining dynamic expansion or reduction strategies, the problem of resource waste in cache systems in high concurrency scenarios is solved, and efficient resource utilization is achieved.
Patent Information
- Application Number
- CN202210262399.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-16
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2042-03-16
AI Technical Summary
When facing unpredictable and sudden high-concurrency business scenarios, the underlying support platform system, especially the cache system, needs to prepare a large amount of redundant resources, resulting in low resource utilization and wasting resources when the business volume is stable.
By obtaining real-time running data of each tenant regularly, including the average data failure time, memory usage, preset time memory usage and total cluster memory capacity, determine the target difference, expected memory full time, and change trend of memory usage, and then Determines the expansion or reduction strategy to dynamically manage cache resources.
Automatic dynamic allocation of multi-tenant cluster cache is realized, so that in high concurrency scenarios, no need to prepare a large number of redundant resources, which improves resource utilization and avoids resource waste.
Smart Images

Figure CN114968552B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of cloud computing technology, specifically to the field of performance capacity dynamic management technology, and more specifically to a cache allocation method, device, equipment, storage medium and program product. Background Art
[0002] With the development of Internet technology, many traditional businesses have gradually shifted from offline to online, and the number of Internet application users has also increased significantly. The increasing transaction volume brought about by the growth of users has also put higher and higher requirements on the application system to provide fast, efficient and stable responses, especially the pressure on the underlying support platform system. The transaction volume of the business system is usually closely related to the user's business operation behavior, but except for the user behavior of planned shopping activities such as "Double Eleven", which is basically predictable and controllable, other daily user behavior is difficult to predict.
[0003] Therefore, in the actual production environment, in order to cope with unpredictable and sudden high-concurrency business scenarios, the underlying support platform system, especially the cache system, will prepare a large amount of redundant resources to cope with such scenarios. However, when the business volume is stable, the system's resource utilization rate has always been low, which is undoubtedly a huge waste, especially for the memory-based cache system.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] In view of the above problems, the present disclosure provides a cache allocation method, apparatus, device, storage medium and program product.
[0006] According to a first aspect of the present disclosure, a cache allocation method is provided, comprising:
[0007] Regularly obtain the real-time operation data of each tenant, including the average data failure time, memory usage, memory usage within a preset time, and the total cluster memory capacity;
[0008] Determine a target difference, an estimated memory full time, and a memory usage change trend according to the real-time operation data, wherein the target difference is a difference between the average data failure time and the estimated memory full time;
[0009] Determining a capacity expansion or contraction strategy for each tenant according to the target difference, the estimated memory full time, and the memory usage change trend; and
[0010] Execute the expansion or reduction strategy of each tenant to allocate the cache.
[0011] According to an embodiment of the present disclosure, determining the target difference, the estimated memory full time, and the memory usage change trend according to the real-time operation data includes:
[0012] Determine the estimated memory full time according to the preset time memory usage, the memory usage rate and the total cluster memory capacity;
[0013] Determine the target difference according to the mean data failure time and the estimated memory full write time; and
[0014] The memory usage change trend is determined according to the memory usage during the preset time.
[0015] According to an embodiment of the present disclosure, determining the memory usage change trend according to the memory usage in the preset time includes:
[0016] When it is determined that the memory usage increases within the preset time, determining that the memory usage change trend is an upward trend; and
[0017] When it is determined that the memory usage decreases within the preset time, it is determined that the memory usage change trend is a downward trend.
[0018] According to an embodiment of the present disclosure, determining the capacity expansion or contraction strategy for each tenant according to the target difference, the estimated memory full time, and the memory usage change trend includes:
[0019] When the estimated memory full write time is greater than a first preset threshold and less than a second preset threshold, and the target difference within the first preset time is greater than 0, and the memory usage change trend is an upward trend, then executing a capacity expansion strategy for the multi-tenant cluster; and
[0020] When the estimated memory full time is less than the first preset threshold, the capacity expansion strategy is immediately executed for multi-tenant centralization.
[0021] According to an embodiment of the present disclosure, determining the capacity expansion or contraction strategy for each tenant according to the target difference, the estimated memory full time, and the memory usage change trend further includes:
[0022] When the target difference is less than 0 within the second preset time, and the memory usage change trend is a downward trend, a scaling-down strategy is executed on the multi-tenant cluster.
[0023] According to an embodiment of the present disclosure, executing the capacity expansion or contraction strategy of each tenant to allocate cache includes:
[0024] Determine the number of nodes to be expanded based on the rate of change of memory usage;
[0025] Selecting the number of nodes to be expanded from the resource pool to perform expansion operation; and
[0026] Reshard the in-memory data.
[0027] According to an embodiment of the present disclosure, executing the capacity expansion or contraction strategy of each tenant to allocate cache further includes:
[0028] Reshard the data in memory;
[0029] Remove redundant nodes from the cluster; and
[0030] The cluster redundant nodes are initialized and added to the resource pool.
[0031] According to an embodiment of the present disclosure, the method further includes:
[0032] After executing a capacity expansion or reduction policy, the number of cluster nodes used by the tenant is registered to the cluster registration center.
[0033] According to a second aspect of the present disclosure, a cache allocation device is provided, comprising:
[0034] The acquisition module is used to periodically acquire the real-time operation data of each tenant, including the average failure time of data, memory usage rate, memory usage within a preset time, and the total memory capacity of the cluster;
[0035] A first determination module is used to determine a target difference, an estimated memory full time, and a memory usage change trend according to the real-time operation data, wherein the target difference is a difference between the average data failure time and the estimated memory full time;
[0036] A second determination module is used to determine a capacity expansion or contraction strategy for each tenant according to the target difference, the estimated memory full time, and the memory usage change trend; and
[0037] The execution module is used to execute the expansion or reduction strategy of each tenant to allocate the cache.
[0038] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned cache allocation method.
[0039] A fourth aspect of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above-mentioned cache allocation method.
[0040] A fifth aspect of the present disclosure also provides a computer program product, including a computer program, which implements the above cache allocation method when executed by a processor.
[0041] Through the cache allocation method provided by the embodiment of the present disclosure, the target difference, the estimated memory full time and the memory usage change trend are determined according to the real-time operation data of the tenant, and then according to the above data indicators, it is judged whether to perform expansion or reduction of the cluster node, thereby realizing automatic dynamic allocation of multi-tenant cluster cache, so that when facing unpredictable and sudden high-concurrency business scenarios, there is no need to prepare a large amount of redundant resources, thereby improving resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0043] Figure 1 A multi-tenant cluster allocation flow chart according to an embodiment of the present disclosure is schematically shown;
[0044] Figure 2 The application scenarios of the cache allocation method, apparatus, device, storage medium and program product according to the embodiments of the present disclosure are schematically shown;
[0045] Figure 3 A flowchart of a cache allocation method according to an embodiment of the present disclosure is schematically shown;
[0046] Figure 4 A flowchart schematically shows a method for processing real-time operation data according to an embodiment of the present disclosure;
[0047] Figure 5 A flowchart of a method for determining a capacity expansion or capacity reduction strategy according to an embodiment of the present disclosure is schematically shown;
[0048] Figure 6 A flowchart schematically illustrates a method for executing a capacity expansion strategy according to an embodiment of the present disclosure;
[0049] Figure 7 A flowchart schematically shows a method for executing a capacity reduction strategy according to an embodiment of the present disclosure;
[0050] Figure 8a The structure block diagram of the cache allocation device according to the embodiment of the present disclosure is schematically shown;
[0051] Figure 8bThe structure block diagram of the first determination module according to the embodiment of the present disclosure is schematically shown;
[0052] Figure 8c A structural block diagram of a second determination module according to an embodiment of the present disclosure is schematically shown; and
[0053] Fig. 9 A block diagram of an electronic device suitable for implementing a cache allocation method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0054] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0055] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0056] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0057] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0058] First, the terms that appear in the embodiments of the present disclosure are explained:
[0059] Tenant: A tenant is a "user" of a database who rents some of the database's resources.
[0060] Multi-tenancy: In the era of cloud computing, countless separate servers and separate computing resources are brought together to allow all original users to share these computing resources and storage resources on the cloud. Multi-tenancy technology is a software architecture technology that implements how to share the same system or program components in a multi-user environment and ensure the isolation of data between users. For example: running a single application instance on a server to provide services for multiple tenants.
[0061] Redis: Remote Dictionary Server, remote dictionary service, is an open source log-type, Key-Value database written in ANSI C language, supporting the network, based on memory or persistence,
[0062] Redis cluster: Redis cluster realizes the horizontal expansion of Redis, that is, starting N redis nodes, distributing and storing the entire database in these N nodes, and each node stores 1 / N of the total data. Redis cluster provides a certain degree of availability through partitioning.
[0063] Average data expiration time: Each key in Redis has a data expiration time, and the data is automatically deleted once it expires.
[0064] Based on the above technical problems, an embodiment of the present disclosure provides a cache allocation method, which is applied to a multi-tenant cluster, wherein the multi-tenant cluster includes multiple nodes, including: regularly obtaining real-time operation data of each tenant, the real-time operation data including average data failure time, memory usage rate, preset time memory usage and total cluster memory capacity; determining a target difference, an expected memory full time and a memory usage change trend according to the real-time operation data, wherein the target difference is the difference between the average data failure time and the expected memory full time; determining an expansion or reduction strategy for each tenant according to the target difference, the expected memory full time and the memory usage change trend; and executing the expansion or reduction strategy for each tenant to allocate cache.
[0065] Figure 1 The following schematically shows a multi-tenant cluster allocation flow chart according to an embodiment of the present disclosure. Figure 2 The application scenario diagram of the cache allocation method, apparatus, device, storage medium and program product according to the embodiments of the present disclosure is schematically shown.
[0066] like Figure 1As shown, the redis cluster allocation process of the embodiment of the present disclosure includes a statistical analysis module obtaining the source data of the tenant's Redis cluster, and a management and scheduling module judging whether to expand or reduce the capacity of the redis cluster based on the source data of the statistical analysis. After completing an expansion or reduction, the number of nodes of the redis cluster used by the tenant is registered in the cluster registration center, completing a closed loop of redis cluster node allocation.
[0067] like Figure 2 As shown, the application scenario 100 according to this embodiment may include a multi-tenant cluster node allocation scenario. The network 104 is used to provide a medium for a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0068] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0069] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0070] The server 105 may be a server that provides various services, such as a database server that provides data support for websites browsed by users using terminal devices 101, 102, and 103 (for example only). The database server is deployed with a redis cluster, which can process received user data access or write requests, for example, dynamically adjust the number of redis cluster nodes according to user access volume to complete capacity expansion or contraction.
[0071] It should be noted that the cache allocation method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the cache allocation device provided in the embodiment of the present disclosure can generally be set in the server 105. The cache allocation method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the cache allocation device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0072] It should be noted that the cache allocation method and device determined in the present disclosure can be used in the cloud computing technology field and the financial field, and can also be used in any field other than the financial field. The application field of the cache allocation method and device disclosed in the present disclosure is not limited.
[0073] The following will be passed Figure 3 to Figure 7 The cache allocation method of the disclosed embodiment is described in detail.
[0074] Figure 3 The flowchart of a cache allocation method according to an embodiment of the present disclosure is schematically shown. Figure 3 As shown, the cache allocation method of this embodiment includes operations S210 to S240.
[0075] The embodiments of the present disclosure are aimed at processing business scenarios in which a large amount of cache data is written in a short period of time. The principles for processing data invalidation in commonly used cache systems are common. The embodiments of the present disclosure are explained using a redis cluster as an example. The redis cluster includes multiple redis nodes, and tenants are users of the redis cluster.
[0076] The writing of large amounts of data is often difficult to predict and process. If a current limit is set for the cache to protect the cache system, it will cause tremendous pressure on the database and cause cache avalanche. The business scenarios that cause this situation are also diverse and cannot be reflected in the call volume or other system indicators. When there is no other performance, the redis cluster has an alarm that the memory usage has reached the threshold. By the time manual intervention or automatic triggering of expansion occurs, redis OOM errors often occur, causing cache access failures. Therefore, the embodiment of the present disclosure obtains the real-time operation data of the system and compares it with the preset threshold to determine whether the node needs to be expanded or reduced.
[0077] In operation S210, real-time operation data of each tenant is obtained periodically.
[0078] According to an embodiment of the present disclosure, the real-time operation data includes the average failure time of data, memory usage, memory usage within a preset time, and the total capacity of cluster memory.
[0079] In one example, since the data stored in the redis cache is high-frequency hot data, this type of data usually sets an expiration time, that is, the expiration time of the key. Each key corresponds to an expiration time. The average expiration time of the data is determined based on these expiration times, and the detection task is executed regularly to obtain the real-time operation data of each tenant. In the embodiment of the present disclosure, the detection frequency is 1 minute, and the detection frequency can be adjusted according to actual business needs. Specifically, the operating status of redis is obtained through the info command, including the redis cluster status information corresponding to each tenant, such as the expiration time of the key, memory usage, preset time memory usage, and total cluster memory capacity. By obtaining the real-time operation data of each tenant, the operation status of each tenant is monitored so that the tenant's nodes can be dynamically adjusted later.
[0080] In operation S220, a target difference, an estimated memory full time, and a memory usage change trend are determined according to the real-time operation data.
[0081] The real-time operation data obtained by operation S210 is calculated and processed to obtain the target difference, the expected memory full time, and the memory usage change trend, wherein the target difference represents the difference between the average data failure time and the expected memory full time. When the average data failure time is greater than the expected memory full time, it represents an upward trend in the memory usage change trend, that is, corresponding to the business scenario where a large amount of cache data is written, it is necessary to expand the redis cluster and increase the redis nodes to relieve the pressure on the database and avoid cache avalanche causing service unavailability. When the average data failure time is less than the expected memory full time, it represents a downward trend in the memory usage change trend, that is, the current business volume tends to be stable and there are redundant resources. It is necessary to reduce the capacity of the redis cluster, reduce the redis nodes, recycle resources, and avoid waste of resources. The specific method for determining the target difference, the expected memory full time, and the memory usage change trend can be found in Figure 4 Operations S221 to S223 are shown.
[0082] In operation S230, a capacity expansion or contraction strategy for each tenant is determined according to the target difference, the estimated memory full time, and the memory usage change trend. In operation S240, the capacity expansion or contraction strategy for each tenant is executed to allocate cache.
[0083] In one example, after operation S220, the current redis cluster operation status and the operation status of the redis cluster within a preset time are determined according to the target difference, the estimated memory full time, and the memory usage change trend, so as to determine which strategy should be executed, that is, the expansion strategy or the reduction strategy. The process of determining the expansion or reduction strategy can be found in Figure 5Operations S231 to S233 are shown. The execution process of the expansion or reduction strategy can be found in Figure 6 and Figure 7 . I will not go into details here.
[0084] Through the cache allocation method provided by the embodiment of the present disclosure, the operation status of the redis cluster of each tenant is obtained at regular intervals, and whether the redis cluster node needs to be expanded or reduced is determined according to the various values of each tenant, thereby realizing dynamic allocation of the redis cluster nodes, that is, realizing automatic dynamic allocation of multi-tenant cluster cache, so that when facing unpredictable and sudden high-concurrency business scenarios, there is no need to prepare a large amount of redundant resources, thereby improving the reliability of the redis cluster and improving resource utilization.
[0085] Figure 4 The flowchart of the method for processing real-time operation data according to an embodiment of the present disclosure is schematically shown. Figure 4 As shown, operation S220 includes operations S221 to S223.
[0086] In operation S221, the estimated time to fill the memory is determined based on the memory usage at the preset time, the memory usage rate, and the total memory capacity of the cluster. In operation S222, the target difference is determined based on the average data failure time and the estimated time to fill the memory. In operation S223, the memory usage change trend is determined based on the memory usage at the preset time.
[0087] According to an embodiment of the present disclosure, when it is determined that the memory usage increases within a preset time, the memory usage change trend is determined to be an upward trend; and when it is determined that the memory usage decreases within a preset time, the memory usage change trend is determined to be a downward trend.
[0088] In one example, the current redis cluster free memory is determined based on the memory usage rate and the total cluster memory capacity, and the estimated memory full time is determined based on the current redis cluster free memory and the memory usage at the preset time. It should be noted that the estimated memory full time is a value calculated and predicted based on the memory usage in the previous minute, and is not an accurate value. When the memory usage at the preset time increases, it indicates that the business data access volume is increasing, the memory usage change trend is an upward trend, and there may be a business scenario where a large amount of cache data is written; when it is determined that the memory usage at the preset time decreases, it indicates that the current business data access volume is decreasing, the memory usage change trend is a downward trend, and the business is tending to be stable.
[0089] After determining the estimated memory full time, target difference, and memory usage change trend, you need to compare the above indicators with the preset thresholds to further determine whether to implement the expansion or reduction strategy. Figure 5This section describes the process of determining the expansion or reduction strategy.
[0090] Figure 5 The flowchart of the method for determining the expansion or reduction strategy according to the embodiment of the present disclosure is schematically shown. Figure 5 As shown, operation S230 includes operations S231 to S233.
[0091] In operation S231, when the estimated time for the memory to be full is greater than a first preset threshold and less than a second preset threshold, and the target difference within the first preset time is greater than 0, and the memory usage change trend is an upward trend, the capacity expansion strategy is executed for the multi-tenant cluster. In operation S232, when the estimated time for the memory to be full is less than the first preset threshold, the capacity expansion strategy is immediately executed for the multi-tenant cluster.
[0092] In one example, when the estimated time for the memory to be filled is greater than the first preset threshold and less than the second preset threshold, it is determined that the memory is about to be filled, and the redis cluster needs to be expanded. However, in actual business scenarios, since the data request at the next moment is unpredictable and fluctuating, it is also necessary to meet the first preset time target difference is greater than 0, which indicates that the memory usage rate has been on an upward trend for a period of time, that is, the memory usage change trend is an upward trend. In order to ensure the stability of the redis cluster and avoid the problem of service unavailability caused by caching problems, it is necessary to execute an expansion strategy for the redis node. Among them, in order for the first preset threshold, the second preset threshold and the first preset time to be thresholds obtained through stress testing combined with expert experience, they can be adjusted according to actual business scenarios. In this embodiment, as a preferred embodiment, the first preset threshold is 3 minutes, the second preset threshold is 10 minutes, and the first preset time is 3 minutes.
[0093] When the estimated memory full time is less than the first preset threshold, it indicates that the current memory usage is increasing too fast. At this time, the time when the target difference is greater than 0 is no longer a necessary condition, and the redis cluster needs to be expanded immediately to alleviate data access pressure.
[0094] In operation S233, when the target difference is less than 0 within the second preset time and the memory usage change trend is a downward trend, a scaling-down strategy is executed on the multi-tenant cluster.
[0095] In an example, the second preset time may be 10 minutes. When it is determined that the target difference within the current 10 minutes is less than 0, it indicates that the memory usage change trend is a downward trend and the business tends to be stable. In order to avoid resource waste, a scaling-down strategy needs to be implemented for the redis cluster nodes.
[0096] Figure 6 The flowchart of the method for executing the expansion strategy provided in accordance with the embodiment of the present disclosure is schematically shown. Figure 6 As shown, operation S310 to operation S330 are included.
[0097] In operation S310, the number of nodes to be expanded is determined according to the memory usage change rate.
[0098] In an example, there is a certain correspondence between the memory usage change rate and the estimated memory full time. The number of nodes to be expanded can be determined based on the memory usage change rate. The larger the memory usage change rate, for example, greater than a preset threshold, the larger the current business concurrency and the faster the memory usage growth. The number of nodes to be expanded is determined to be 70% of the current number of nodes; otherwise, the number of nodes to be expanded is determined to be 50% of the current number of nodes (rounded up).
[0099] In operation S320, nodes of the number of nodes to be expanded are selected from the resource pool for expansion. In operation S330, the data in the memory is re-sharded.
[0100] In one example, the cluster management scheduling module issues an expansion instruction to the redis cluster used by the tenant, uses the redis source code's built-in script redis-trib.rb to expand the cluster, adds the idle redis nodes determined by operation S310 to the original cluster, reshards the data in the memory, and after completing one expansion, registers the number of redis cluster nodes used by the tenant to the cluster registration center.
[0101] Figure 7 The flowchart of the method for executing the scaling-down strategy provided in accordance with the embodiment of the present disclosure is schematically shown. Figure 7 As shown, operation S410 to operation S430 are included.
[0102] In operation S410, the data in the memory is re-sharded. In operation S420, the cluster redundant node is removed from the cluster. In operation S430, the cluster redundant node is initialized and added to the resource pool.
[0103] In one example, the script redis-trib.rb is used to reshard the data in memory. After the sharding is completed, the redundant nodes in the cluster are removed from the cluster, the nodes are initialized (redundant memory data is cleared, and the redis process is restarted) and added to the redis resource pool. After a reduction is completed, the number of redis cluster nodes used by the tenant is registered to the cluster registration center.
[0104] Based on the above cache allocation method, the present disclosure also provides a cache allocation device. Figure 8a to Figure 8c The device is described in detail.
[0105] Figure 8aThe structure block diagram of the cache allocation device according to the embodiment of the present disclosure is schematically shown. Figure 8b The structural block diagram of the first determination module according to an embodiment of the present disclosure is schematically shown. Figure 8c The structural block diagram of the second determination module according to an embodiment of the present disclosure is schematically shown.
[0106] like Figure 8a As shown, the cache allocation device 800 of this embodiment includes an acquisition module 810 , a first determination module 820 , a second determination module 830 and an execution module 840 .
[0107] The acquisition module 810 is used to periodically acquire the real-time operation data of each tenant, and the real-time operation data includes the average expiration time of the key, the memory usage rate, the memory usage in the preset time, and the total memory capacity of the cluster. In one embodiment, the acquisition module 810 can be used to perform the operation S210 described above, which will not be repeated here.
[0108] The first determination module 820 is used to determine the target difference, the estimated memory full time and the memory usage change trend according to the real-time operation data. In one embodiment, the first determination module 820 can be used to perform the operation S220 described above, which will not be repeated here.
[0109] The second determination module 830 is used to determine the expansion or reduction strategy according to the target difference, the estimated memory full time and the memory usage change trend. In one embodiment, the second determination module 830 can be used to perform the operation S230 described above, which will not be repeated here.
[0110] The execution module 840 is used to execute the expansion or reduction strategy of each tenant to allocate the cache. In one embodiment, the execution module 840 can be used to execute the operation S240 described above, which will not be repeated here.
[0111] like Figure 8b As shown, according to an embodiment of the present disclosure, the first determination module 820 includes a first determination submodule 821 , a second determination submodule 822 and a third determination submodule 823 .
[0112] The first determination submodule 821 is used to determine the estimated memory full time according to the preset time memory usage, the memory usage rate and the cluster memory total capacity. In one embodiment, the first determination submodule 821 can be used to perform the operation S221 described above, which will not be repeated here.
[0113] The second determination submodule 822 is used to determine the target difference according to the average failure time of the key and the estimated full write time of the memory. In one embodiment, the second determination submodule 822 can be used to perform the operation S222 described above, which will not be repeated here.
[0114] The third determination submodule 823 is used to determine the memory usage change trend according to the target difference. In one embodiment, the third determination submodule 823 can be used to perform the operation S223 described above, which will not be described in detail here.
[0115] like Figure 8c As shown, according to an embodiment of the present disclosure, the second determination module 830 includes a first capacity expansion submodule 831 , a second capacity expansion submodule 832 and a capacity reduction submodule 833 .
[0116] The first expansion submodule 831 is used to execute the expansion strategy for the redis cluster when the estimated memory full time is greater than the first preset threshold and less than the second preset threshold, and the target difference within the first preset time is greater than 0, and the memory usage change trend is an upward trend. In one embodiment, the first expansion submodule 831 can be used to execute the operation S231 described above, which will not be repeated here.
[0117] The second expansion submodule 832 is used to immediately execute the expansion strategy for the redis cluster when the estimated full memory time is less than the first preset threshold. In one embodiment, the second expansion submodule 832 can be used to execute the operation S232 described above, which will not be repeated here.
[0118] The shrinking submodule 833 is used to execute the shrinking strategy for the redis cluster when the target difference is less than 0 within the second preset time and the memory usage change trend is a downward trend. In one embodiment, the shrinking submodule 833 can be used to execute the operation S233 described above, which will not be repeated here.
[0119] According to an embodiment of the present disclosure, any multiple modules in the acquisition module 810, the first determination module 820, the second determination module 830 and the execution module 840 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the acquisition module 810, the first determination module 820, the second determination module 830 and the execution module 840 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in a suitable combination of any of them. Alternatively, at least one of the acquisition module 810 , the first determination module 820 , the second determination module 830 , and the execution module 840 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be executed.
[0120] Fig. 9 A block diagram of an electronic device suitable for implementing a cache allocation method according to an embodiment of the present disclosure is schematically shown.
[0121] like Fig. 9 As shown, the electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0122] In RAM 903, various programs and data required for the operation of electronic device 900 are stored. Processor 901, ROM 902 and RAM 903 are connected to each other via bus 904. Processor 901 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 902 and / or RAM 903. It should be noted that the program can also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0123] According to an embodiment of the present disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The electronic device 900 may further include one or more of the following components connected to the I / O interface 905: an input portion 906 including a keyboard, a mouse, etc.; an output portion 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 908 including a hard disk, etc.; and a communication portion 909 including a network interface card such as a LAN card, a modem, etc. The communication portion 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage portion 908 as needed.
[0124] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0125] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.
[0126] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the cache allocation method provided by the embodiment of the present disclosure.
[0127] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 901. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0128] In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of a signal on a network medium, and downloaded and installed through the communication part 909, and / or installed from a removable medium 911. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0129] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0130] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0131] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0132] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0133] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A cache allocation method, applied to a multi-tenant cluster, wherein the multi-tenant cluster includes a plurality of nodes, characterized in that: include: Regularly obtain the real-time operation data of each tenant, including the average data failure time, memory usage, memory usage within a preset time, and the total cluster memory capacity; Determine a target difference, an estimated memory full time, and a memory usage change trend according to the real-time operation data, wherein the target difference is the value of the average data failure time minus the estimated memory full time; Determine a capacity expansion or reduction strategy for each tenant according to the target difference, the estimated memory full time, and the memory usage change trend; as well as Execute the expansion or reduction strategy of each tenant to allocate cache, The determining of the expansion or reduction strategy for each tenant according to the target difference, the estimated memory full time and the memory usage change trend includes: When the estimated memory full write time is greater than a first preset threshold and less than a second preset threshold, and the target difference within the first preset time is greater than 0, and the memory usage change trend is an upward trend, then executing a capacity expansion strategy for the multi-tenant cluster; and When the estimated time for the memory to be full is less than a first preset threshold, the capacity expansion strategy is immediately executed for multi-tenant centralization; or When the target difference is less than 0 within the second preset time, and the memory usage change trend is a downward trend, a scaling-down strategy is executed on the multi-tenant cluster.
2. The method according to claim 1, characterized in that Determining the target difference, the estimated memory full time, and the memory usage change trend according to the real-time operation data includes: Determine the estimated memory full time according to the preset time memory usage, the memory usage rate and the total cluster memory capacity; Determine the target difference according to the mean data failure time and the estimated memory full write time; and The memory usage change trend is determined according to the memory usage during the preset time.
3. The method according to claim 2, characterized in that Determining the memory usage change trend according to the memory usage during the preset time includes: When it is determined that the memory usage increases within the preset time, determining that the memory usage change trend is an upward trend; and When it is determined that the memory usage decreases within the preset time, it is determined that the memory usage change trend is a downward trend.
4. The method according to claim 1, characterized in that: The executing the capacity expansion or contraction strategy of each tenant to allocate cache includes: Determine the number of nodes to be expanded based on the rate of change of memory usage; Selecting the number of nodes to be expanded from the resource pool to perform expansion operation; and Reshard the in-memory data.
5. The method according to claim 1, characterized in that: The executing the capacity expansion or contraction strategy of each tenant to allocate cache also includes: Reshard the data in memory; Remove redundant nodes from the cluster; and The cluster redundant nodes are initialized and added to the resource pool.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: After executing a capacity expansion or reduction policy, the number of cluster nodes used by the tenant is registered to the cluster registration center.
7. A cache allocation device, comprising: The acquisition module is used to periodically acquire the real-time operation data of each tenant, including the average failure time of data, memory usage rate, memory usage within a preset time, and the total memory capacity of the cluster; A first determination module is used to determine a target difference, an estimated memory full time, and a memory usage change trend according to the real-time operation data, wherein the target difference is a value obtained by subtracting the estimated memory full time from the average data failure time; A second determination module is used to determine a capacity expansion or contraction strategy for each tenant according to the target difference, the estimated memory full time and the memory usage change trend; as well as An execution module, used to execute the expansion or reduction strategy of each tenant to allocate cache, The second determination module is further configured to execute a capacity expansion strategy for the multi-tenant cluster when the estimated memory full write time is greater than a first preset threshold and less than a second preset threshold, and the target difference within the first preset time is greater than 0, and the memory usage change trend is an upward trend; When the estimated time for the memory to be full is less than a first preset threshold, the capacity expansion strategy is immediately executed for multi-tenant centralization; The second determination module is further configured to execute a capacity reduction strategy for the multi-tenant cluster when the target difference is less than 0 within a second preset time and the memory usage change trend is a downward trend.
8. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors execute the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method, system and device for carrying out automatic operation and maintenance on cluster
CN111431748A
Redis configuration method and device, storage medium and equipment
CN111459761A