A caching method and system based on serverless computing

By setting up independent local caches for each application function in a serverless computing environment and optimizing cache resource allocation using chemical reaction optimization algorithms, the problem of high cache management costs and inability to automatically expand capacity in the existing technology is solved, and a transparent dynamic optimization cache system is realized, which improves the flexibility and efficiency of the system.

CN114281533BActive Publication Date: 2025-03-21SHENZHEN INST OF ADVANCED TECH CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the prior art, cache management is high, the cache layer is opaque, and the capacity cannot be automatically expanded to adapt to changes in data access.

Method used

Design a transparent dynamically optimized cache system based on serverless computing, by splitting the application into multiple fine-grained application functions and setting up independent local caches for each application function. The chemical reaction optimization algorithm is used to optimize cache resource allocation, so that the cache system can transparently manage data at runtime and dynamically expand capacity based on visits.

Benefits of technology

Reduces cache management costs, makes the cache layer more transparent, and can automatically expand capacity to adapt to changes in data access, improving system flexibility and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114281533B_ABST
    Figure CN114281533B_ABST
Patent Text Reader

Abstract

The present invention provides a cache method and system based on serverless computing, the method comprising: running multiple fine-grained application functions obtained by splitting a target application in respective independent containers; allocating local cache resources to each of the application functions through a chemical reaction optimization algorithm; placing each of the application functions and its local cache in the function service runtime, the local cache of each of the application functions can transparently manage the data accessed by the application during the operation, and different application functions can access each other through the local cache. The present invention sets a cache in each application function, which can transparently manage program data during operation and realize mutual access of caches between functions. A serverless cache expansion algorithm based on a chemical reaction optimization algorithm is used to optimize cache resources through a chemical reaction optimization algorithm and factors such as computational effort and cache size are taken into account in the allocation of cache resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of serverless computing, and in particular to a cache method, system, electronic device and readable storage medium based on serverless computing. Background Art

[0002] With the continuous development of cloud computing technology, the concept of serverless has been proposed. As an emerging model for deploying cloud applications, serverless computing splits applications into multiple fine-grained functions and uploads them to the platform. Users only need to care about the business logic of the code and do not need to worry about operation and maintenance issues such as server configuration, maintenance, updates, and expansion. Serverless has the characteristics of low cost, low risk, and flexible scaling, making it gradually become the mainstream architecture for software development.

[0003] Serverless computing divides an application into multiple functions. Since functions cannot communicate directly, when functions need to share data, the function's processed data needs to be written to the remote storage first. During the function execution process, frequent access to the remote storage will reduce bandwidth and increase latency, while increasing management costs and overhead. Considering the above factors, local cache has become a solution to this bottleneck. Local cache speeds up read and write access to remote storage data and speeds up data sharing between functions.

[0004] In most existing technologies, local caches are managed independently of each application. The system contains a local cache, which is shared by multiple applications. The consistency of data is controlled through API interfaces, and information is passed between functions. In most existing cache technologies, fixed-size cache blocks are provided. Some technologies adjust the cache according to the computational load of the cached object, but the cache size is limited.

[0005] However, in the prior art, the cache is managed independently of each application, which results in high management costs and requires changes to the system configuration or application, making the cache layer less transparent. In addition, the cache system statically allocates resources and cannot automatically expand its capacity as the amount of data accessed changes. Summary of the invention

[0006] The purpose of the present invention is to provide a cache method, system, electronic device and readable storage medium based on serverless computing to solve the problems in the prior art of high cache management cost, opaque cache layer, and inability to automatically expand its capacity as the amount of accessed data changes.

[0007] The present invention is achieved in that:

[0008] To achieve the above object, the present invention provides a caching method based on serverless computing, comprising:

[0009] The target application is split into multiple fine-grained application functions and run them in their own independent containers;

[0010] Allocating local cache resources for each of the application functions through a chemical reaction optimization algorithm;

[0011] Each of the application functions and its local cache are placed in the function service runtime. The local cache of each application function can transparently manage the data accessed by the application during the running process, and different application functions can access each other through the local cache.

[0012] Furthermore, the chemical reaction optimization algorithm is used to allocate local cache resources for each of the application functions, including:

[0013] The problem of optimizing cache resource allocation is transformed into a problem of maximizing the total revenue of the service provider, and the local cache resources are optimally allocated for each of the application functions through a chemical reaction optimization algorithm.

[0014] Furthermore, the chemical reaction optimization algorithm includes an algorithm based on single molecule invalid collision, an algorithm based on decomposition reaction, and an algorithm based on synthesis reaction.

[0015] Furthermore, the method for reading data by any of the application functions is as follows:

[0016] First, the local cache is accessed. If a hit is found, the data is read directly from the local cache. If a hit is not found, the remote storage system is accessed.

[0017] Furthermore, the method further comprises:

[0018] When the local cache memory is used up, the SAIU cache replacement strategy is used to prioritize replacing data blocks with low access rates, large space occupation, and high update frequency. For the replaced data blocks, the data is written back to the remote storage system.

[0019] Furthermore, the SAIU cache replacement strategy applies a benefit function to decide which data block to replace, and the benefit function is:

[0020]

[0021] Among them, g(i) is the benefit function of data block i, L i is the delay time for obtaining data block i, A i is the access time of data block i, U i is the update time of data block i, S i is the size of data i.

[0022] Furthermore, when the target application is deleted, metadata of the cache object is collected, and when the target application is run again, the cache data is preheated using the collected metadata.

[0023] Furthermore, there are three daemons in the local cache of any application function:

[0024] Memory daemon, which monitors memory consumption of application functions and local cache;

[0025] Object daemon, used to determine the data blocks of objects used by the local cache;

[0026] Cache daemon, used to collect cache object metadata and preheat data.

[0027] To achieve the above object, the present invention also provides a cache system based on serverless computing, including: a user front-end control plane, a server platform and a remote storage system, wherein:

[0028] The user front-end control plane is used to split the target application into multiple fine-grained application functions and upload them to the server platform;

[0029] The server platform is used to implement the cache method based on serverless computing as described in any one of the above items;

[0030] The remote storage system is used to store the processing data of each of the application functions.

[0031] To achieve the above objectives, the present invention also provides an electronic device, including a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the serverless computing-based caching method described in any one of the above items is implemented.

[0032] To achieve the above objectives, the present invention further provides a readable storage medium, wherein the readable storage medium stores a computer program, and when the computer program is executed by a processor, the serverless computing-based caching method described in any one of the above items is implemented.

[0033] Compared with the prior art, the present invention has the following beneficial effects:

[0034] (1) The present invention designs a transparent and dynamically optimized serverless computing cache system, which sets a local cache in each application function and associates the local cache with the application function. The local cache can transparently manage program data during runtime, thereby reducing cache management costs;

[0035] (2) The present invention designs a serverless cache expansion algorithm based on a chemical reaction optimization algorithm. By converting the problem of optimizing cache resource allocation into the problem of maximizing the total revenue of the service provider, the cache resources are optimized through the chemical reaction optimization algorithm and factors such as the amount of calculation and cache size are taken into account in the allocation of cache resources. The capacity can be automatically expanded as the amount of accessed data changes;

[0036] (3) In cache replacement, based on the SAIU cache replacement strategy, priority is given to replacing data blocks with low access rate, large space occupation and high update frequency;

[0037] (4) After the application is deleted, metadata about the cached objects is collected. When the application is run again, the cached data is preheated using the collected metadata.

[0038] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for the description. Obviously, the drawings described below are an embodiment of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work:

[0040] Figure 1 is an architecture diagram of a cache system based on serverless computing provided by an embodiment of the present invention;

[0041] Figure 2 is a flow chart of a caching method based on serverless computing provided by an embodiment of the present invention;

[0042] Figure 3 This is a flow chart of cache resource allocation based on a chemical reaction optimization algorithm provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0043] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.

[0044] In order to solve the problems existing in the prior art, the present invention provides a caching method, system, electronic device and readable storage medium based on serverless computing.

[0045] The present invention adopts a transparent dynamically optimized serverless computing cache system design, sets a local cache in each application function, links the local cache with the application function, and the local cache can transparently manage program data during operation.

[0046] The cache system architecture designed by the present invention based on serverless computing is as follows Figure 1 As shown in the figure, it includes the user front-end control plane, the server platform and the remote storage system. When the user deploys the program code on the user front-end control plane, the application is subdivided into application functions. The server platform uses container technology to deploy each application function. Each application function and local cache are placed in the function service runtime, which can increase the speed, reduce the overhead and reduce the maintenance cost. Each application function has its own local cache, and the local cache of each function can transparently manage the data accessed by the application at runtime. The caches of different application functions can access each other to form a collaborative distributed cache.

[0047] There are three daemons in the local cache. The memory daemon is mainly responsible for monitoring the memory consumption of application functions and local caches. The object daemon is mainly responsible for determining the data blocks of objects used by the local cache. The buffer daemon is mainly responsible for collecting cache object metadata and using them to preheat data. The user front-end control plane is used to control the addition or deletion of function instances.

[0048] like Figure 2 As shown, a caching method based on serverless computing provided by an embodiment of the present invention is applied to a server platform and includes the following steps:

[0049] S100: splitting the target application into multiple fine-grained application functions and running them in their own independent containers;

[0050] S200: Allocating local cache resources for each of the application functions through a chemical reaction optimization algorithm;

[0051] S300: Each of the application functions and its local cache are placed in the function service runtime. The local cache of each application function can transparently manage the data accessed by the application during the running process, and different application functions can access each other through the local cache.

[0052] The function service runtime refers to the environment that the function depends on at runtime, including any libraries, code packages, frameworks, or platforms. "Transparently managing data accessed by applications" means that users do not need to understand the operating mechanism of the local cache, and can interact with the local cache data simply through the storage interface.

[0053] In step S200, the present invention designs a serverless cache expansion algorithm based on a chemical reaction optimization algorithm, which optimizes cache resource allocation by converting the problem of optimizing cache resource allocation into a problem of maximizing the total revenue of a service provider, optimizes cache resources by a chemical reaction optimization algorithm, and takes factors such as computational complexity and cache size into account in the allocation of cache resources. The cache expansion algorithm is specifically as follows:

[0054] The content cache energy cost is the energy consumption caused by content caching and content updating, which is used as a judgment for optimizing cache resources. The cache energy consumption ratio is defined as:

[0055]

[0056] Among them, the M×N two-dimensional matrix Y∈y represents the cache resource allocation state of the application function (the service provider divides the physical network into multiple virtual networks (i.e., network slices), N refers to the number of physical node sets that the service provider can control, and M refers to the number of network slice sets that the service provider can provide), α is the energy consumption value brought by content caching or content updating per unit cache capacity, and v ik Indicates the number of content updates per unit time T, u ik Indicates the number of request queues per unit time T.

[0057] The energy cost of content caching is:

[0058]

[0059] Wherein, ρ is the energy consumption price of content caching or content updating per unit cache capacity.

[0060] The total revenue function of the service provider is defined as U total , which can be expressed as:

[0061] U total =PP cache (3)

[0062] Among them, P is the fee paid by all users to the service provider.

[0063] So the total revenue maximization problem is:

[0064] max{y=ik}U total(Y) (4)

[0065] The chemical reaction optimization algorithm is a molecular behavior in the chemical reaction process, which reaches a stable state through interaction. The entire system platform is regarded as a molecule. The molecular structure represents the solution to the given optimization problem, that is, the cache resource allocation matrix Y. The molecular potential energy is the objective function value, that is, the total revenue of the service provider. The molecular kinetic energy is the molecular tolerance to obtain a higher potential energy state than the existing molecules. The cache resource allocation process based on the chemical reaction optimization algorithm is as follows: Figure 3 As shown, the steps are as follows:

[0066] (1) Initialization, setting initial parameters, and setting the upper limit of kinetic energy loss in single-molecule invalid collision reactions Loss max , the initial value of the molecular kinetic energy E inital , the parameter influencing factor F of the ineffective collision reaction between molecules. The cache resource allocation matrix Y is randomly generated under the constraints.

[0067] (2) Select a chemical reaction optimization algorithm to allocate cache resources. The algorithm may be selected from an algorithm based on single molecule invalid collision, an algorithm based on decomposition reaction, an algorithm based on synthesis reaction, or other chemical reaction optimization algorithms may be used.

[0068] The idea of ​​cache resource allocation based on single-molecule invalid collision reaction is to randomly select a row in the cache resource allocation matrix Y, randomly reallocate cache resources under constraints, and then obtain a new cache resource allocation matrix Y′;

[0069] The idea of ​​cache resource allocation based on decomposition reaction is to randomly select a row in the cache allocation resource matrix Y and randomly allocate it to the corresponding row in Y1′ or Y2′ until every row in the matrix Y is allocated, and then randomly allocate positive numbers to the unallocated rows in Y1′ and Y2′;

[0070] Cache resource allocation based on synthetic reaction. Randomly create cache resource allocation matrices Y1 and Y2, and randomly select non-overlapping rows in matrices Y1 and Y2 and assign their corresponding values ​​to the corresponding positions in the cache resource allocation matrix Y′ until every row of matrix Y′ is allocated, that is, a new cache allocation matrix Y′ is generated;

[0071] The specific calculation processes of the above-mentioned algorithm based on single molecule invalid collision, algorithm based on decomposition reaction, and algorithm based on synthesis reaction can be referred to the prior art and will not be described in detail here.

[0072] (3) Calculate the total revenue U of the current service provider according to formula (3): total , and determine whether the obtained solution satisfies the constraints of formula (4).

[0073] (4) Stop criterion. Set the loop coefficient t. When the number of loops reaches t, stop the iteration. Otherwise, continue the iteration. If the exit condition is met, exit and determine the size of allocated resources. If not, continue the iteration. After the iteration stops, output the molecular potential energy and molecular structure, that is, the objective function and the solution to the given problem.

[0074] Furthermore, when the application function reads data, it first accesses the local cache. If the data hits, it directly reads the data from the local cache. If the data misses, it continues to access the remote storage system. There are three situations for reading data:

[0075] (1) Local hit, that is, the data to be read is found in the local cache;

[0076] (2) Local miss and remote hit, that is, the data to be read cannot be found in the local cache, but can be found in the remote storage system;

[0077] (3) Neither the local nor the remote cache hits the data, that is, the data to be read cannot be found in the local cache, and then it is searched in the remote storage system, but it is still not found.

[0078] Furthermore, when the local cache memory is used up, the SAIU cache replacement strategy gives priority to replacing data blocks with low access rates, large space usage, and high update frequency. For the replaced data blocks, the data needs to be written back to the remote storage system.

[0079] In the SAIU cache replacement strategy, a benefit function is applied to decide which data block to replace. The benefit function is:

[0080]

[0081] Among them, g(i) is the benefit function of data block i, L i is the delay time for obtaining data block i, A i is the access time of data block i, U i is the update time of data block i, S i is the size of data i.

[0082] That is, calculate the benefit function corresponding to each data block, and select the data block with the smallest benefit function value to replace it.

[0083] A write-back strategy is adopted for data writing. When a data block in the cache is replaced, the content of the data block is written back to the remote storage system. A "dirty bit" is set in the data block, that is, a flag is set to indicate whether the data block has been modified. 0 means it has not been modified, and 1 means it has been modified.

[0084] Furthermore, when the target application is deleted, the local cache will also be uninstalled. At this time, metadata about cache objects will be collected, and when the application is reloaded, the objects frequently accessed by the metadata will be used to preheat the cache.

[0085] In summary, compared with the prior art, the present invention sets a local cache in each application function, can transparently manage program data at runtime, and realize mutual access of caches between application functions. The serverless cache expansion algorithm based on the chemical reaction optimization algorithm is used to optimize cache resources through the chemical reaction optimization algorithm and take factors such as computational load and cache size into account in the allocation of cache resources.

[0086] Based on the same inventive concept, the present invention also provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and when the processor executes the computer program, the caching method based on serverless computing as described above is implemented.

[0087] The processor may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor is generally used to control the overall operation of the electronic device. In this embodiment, the processor is used to run the program code stored in the memory or process data, such as running the program code of the cache method based on serverless computing.

[0088] The memory includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. In other embodiments, the memory may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. equipped on the electronic device. Of course, the memory may also include both the internal storage unit of the electronic device and its external storage device. In this embodiment, the memory is generally used to store the operating method and various application software installed in the electronic device, such as the program code of the cache method based on serverless computing, etc. In addition, the memory may also be used to temporarily store various types of data that have been output or are to be output.

[0089] Based on the same inventive concept, the present invention also provides a readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the caching method based on serverless computing as described above is implemented.

[0090] In summary, the cache method, system, electronic device and readable storage medium based on serverless computing provided by the present invention have the following advantages and positive effects:

[0091] (1) The present invention designs a transparent and dynamically optimized serverless computing cache system, which sets a local cache in each application function and associates the local cache with the application function. The local cache can transparently manage program data during operation, thereby reducing management costs.

[0092] (2) The present invention designs a serverless cache expansion algorithm based on a chemical reaction optimization algorithm. By converting the problem of optimizing cache resource allocation into the problem of maximizing the total revenue of the service provider, the cache resources are optimized through the chemical reaction optimization algorithm and factors such as the amount of calculation and cache size are taken into account in the allocation of cache resources. The capacity can be automatically expanded as the amount of accessed data changes;

[0093] (3) In cache replacement, based on the SAIU cache replacement strategy, priority is given to replacing data blocks with low access rate, large space occupation and high update frequency;

[0094] (4) After the application is deleted, metadata about the cached objects is collected. When the application is run again, the cached data is preheated using the collected metadata.

[0095] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.

[0096] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0097] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0098] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0099] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A caching method based on serverless computing, characterized in that: include: The target application is split into multiple fine-grained application functions and run them in their own independent containers; Allocating local cache resources for each of the application functions through a chemical reaction optimization algorithm; The method of allocating local cache resources for each of the application functions by using a chemical reaction optimization algorithm includes: The problem of optimizing cache resource allocation is transformed into a problem of maximizing the total revenue of the service provider, and the local cache resource is optimally allocated for each of the application functions through a chemical reaction optimization algorithm; And factor the computational effort and cache size into the allocation of cache resources; Each of the application functions and its local cache are placed in the function service runtime. The local cache of each application function can transparently manage the data accessed by the application during the running process, and different application functions can access each other through the local cache.

2. The caching method based on serverless computing according to claim 1, characterized in that: The chemical reaction optimization algorithm includes an algorithm based on single molecule invalid collision, an algorithm based on decomposition reaction, and an algorithm based on synthesis reaction.

3. The caching method based on serverless computing according to claim 1, characterized in that: The method for reading data by any of the application functions is as follows: First, the local cache is accessed. If a hit is found, the data is read directly from the local cache. If a hit is not found, the remote storage system is accessed.

4. The caching method based on serverless computing according to claim 1, characterized in that: The method further comprises: When the local cache memory is used up, the SAIU cache replacement strategy is used to prioritize replacing data blocks with low access rates, large space occupation, and high update frequency. For the replaced data blocks, the data is written back to the remote storage system.

5. The caching method based on serverless computing according to claim 4, characterized in that: The SAIU cache replacement strategy uses a benefit function to decide which data block to replace. The benefit function is: ; in, is the benefit function of data block i, is the delay time for obtaining data block i, is the access time of data block i, is the update time of data block i, is the size of data i.

6. The caching method based on serverless computing according to claim 1, characterized in that: When the target application is deleted, metadata of the cached object is collected, and when the target application is run again, the cached data is preheated using the collected metadata.

7. The caching method based on serverless computing according to claim 1, characterized in that: There are three daemons in the local cache of any application function: Memory daemon, which monitors memory consumption of application functions and local cache; Object daemon, used to determine the data blocks of objects used by the local cache; Cache daemon, used to collect cache object metadata and preheat data.

8. A cache system based on serverless computing, characterized in that: include: User front-end control plane, server platform and remote storage system, among which, The user front-end control plane is used to split the target application into multiple fine-grained application functions and upload them to the server platform; The server platform is used to implement the caching method based on serverless computing as described in any one of claims 1 to 7; The remote storage system is used to store the processing data of each of the application functions.

9. An electronic device, characterized in that: It comprises a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the cache method based on serverless computing described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Cache resource allocation method and apparatus

    CN106412040A

  • Processing method for multi-physical coupling application, device, computer equipment and storage medium

    CN110246549A