A method for building an artificial intelligence model management application based on serverless architecture
By preheating function instances in the serverless architecture, delaying the loading of resources and adopting insulation mechanisms, the problems of function instance startup delay and resource waste in the serverless architecture are solved, and more efficient performance and cost efficiency are achieved.
Patent Information
- Application Number
- CN202410477147.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-19
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-04-19
AI Technical Summary
In serverless architecture, the initialization and startup delay of function instances leads to real-time application impact on instant responses, and the traditional serviceless architecture platform loads all models and resources when function initialization, resulting in waste of resources and increased startup time.
By extracting historical function instance creation requests, obtain the importance level of different function instance categories, and obtain the warm-up strategy in advance based on the importance level to realize the preheating of function instances; use a delay loading mechanism when initializing the function to load only some of the necessary resources; at the same time, the insulation mechanism is used to temporarily remain active after execution, so that the function instance can be reused.
Reduces startup latency for serverless architecture applications, reduces resource consumption and costs, and improves overall performance and cost efficiency of applications.
Smart Images

Figure CN118535236B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of serverless architecture, and specifically to a method for constructing an artificial intelligence model management application based on a serverless architecture. Background Art
[0002] Traditional Internet applications mainly use a client-server architecture. The server needs to maintain a business process for a long time to handle client requests and call code logic to complete the request response process.
[0003] Serverless architecture is the latest emerging architecture model. The underlying server host and other aspects of the system architecture of serverless architecture are managed by the service provider rather than the customer. The customer can write source code that is unrelated to the system architecture and compile it to generate target code that can be executed on any serverless architecture. Configuration tasks such as load balancing and expansion can be provided by the service provider on the backend without the need for customer configuration.
[0004] Comparative document CN112214293A "A method for business deployment under a serverless architecture and a function management platform" establishes a function executor in a tenant resource pool. Since the resource pools of different tenants are isolated from each other, the function executors of different tenants run in isolated resource pools, thereby improving the security of the system. At the same time, a two-level resource elasticity control method for the function executor and the function execution host is disclosed. When the business is at a peak, the host is expanded (including the number or specification); when the business is reduced, the host is reduced (including the number or specification);
[0005] Comparative document CN113687989A "A method and system for detecting anomalies in IoT data based on serverless architecture" combines the traditional IoT cloud platform with the emerging serverless architecture. It uses the traditional IoT cloud platform as the device access terminal to reduce the cost of device access and management, and builds an anomaly detection terminal through the serverless architecture to significantly reduce the deployment and operation costs of the system.
[0006] Serverless applications are executed based on event triggers. Events can be requests from users, timer triggers, messages from message queues, etc. When an event is triggered, the serverless platform will try to start a function instance for the event to handle the request. When the event is triggered, if there is no function instance already in running state, the serverless platform will start a new function instance, which involves creating a container or virtual machine, loading the function code, and configuring and preparing the running environment for the function. The entire initialization process takes a certain amount of time, usually between a few hundred milliseconds and a few seconds, depending on factors such as the size of the function code, the complexity of the environment configuration, and the availability of resources. Since these operations take a certain amount of time, they have a certain impact on real-time applications that require instant response. How to reasonably build and optimize serverless architecture applications is a problem that we urgently need to solve. This paper provides a method for building an artificial intelligence model management application based on a serverless architecture. Summary of the invention
[0007] In order to solve the above technical problems, the purpose of the present invention is to provide a method for building an artificial intelligence model management application based on a serverless architecture, comprising the following steps:
[0008] Step S1: extracting historical function instance creation requests of the logged-in user, obtaining importance levels of different function instance categories according to the historical function instance creation requests, and pre-obtaining a preheating strategy for each function instance category according to the importance levels;
[0009] Step S2: receiving the application function code sent by the logged-in user, obtaining the execution process sequence of the application function code, extracting the logical function of each execution process in the execution process sequence, segmenting the execution process sequence according to the logical function of the execution process, and matching the function instance according to the logical function of the segmented execution process sequence;
[0010] Step S3: Obtain the function instance timing sequence of the execution process sequence, delay the function initialization loading process according to the function instance timing sequence, and after the loaded function instance completes the logical function required by the execution process sequence, determine whether the function instance meets the execution insulation strategy standard.
[0011] Furthermore, the process of extracting historical function instance creation requests of the logged-in user and obtaining importance levels of different function instance categories according to the historical function instance creation requests includes:
[0012] Obtain the historical call frequency, average response time, peak concurrent request volume, and resource cost consumption of different function instance categories based on historical function instance creation requests;
[0013] The historical call frequency, average response time, peak request concurrency and resource cost consumption of each function instance are used as evaluation indicators. The indicator weights of the evaluation indicators are set, and the importance levels are preset. The membership matrix of each function instance for the preset importance level is judged through fuzzy comprehensive evaluation. The importance level of each function instance category is obtained according to the membership matrix and indicator weights.
[0014] Furthermore, the process of pre-acquiring the preheating strategy of each function instance category according to the importance level includes:
[0015] Set an importance level threshold, compare the importance level of the function instance category with the importance level threshold, and implement a preheating strategy for the function instance category whose importance level is greater than or equal to the importance level threshold;
[0016] According to the importance level of the function instance category that meets the preheating strategy, the trigger interval time, activation duration and the number N of function instance triggers corresponding to the function instance category are obtained, and periodic activation requests are sent to the N function instances of the function instance category according to the trigger interval time and activation duration.
[0017] Furthermore, the trigger interval time represents the interval time for sending the periodic activation request, and the activation duration time represents the time for which the function instance remains activated after receiving the periodic activation request.
[0018] Furthermore, the process of matching the function instance according to the logical function of the segmented execution process sequence includes:
[0019] After the execution process sequence is divided into a plurality of execution process subsequences, the logical function execution order and the logical function execution relationship of each execution process subsequence in the execution process sequence are obtained, and a logical directed graph is constructed through each execution process subsequence and the logical function execution order and the logical function execution relationship of each execution process subsequence;
[0020] The execution process subsequences are taken as nodes of the logical directed graph, the logical function execution order and logical function execution relationship of each execution process subsequence are taken as the connection relationship between the nodes, and the function instances matching the logical functions of each execution process subsequence are taken as the supplementary nodes of the nodes.
[0021] Furthermore, the process of obtaining the function instance timing sequence of the execution process sequence includes:
[0022] According to the start timestamp of each execution process subsequence in the logical directed graph, the triggering time point of the function instance corresponding to each execution process subsequence is used, and the function instance timing sequence of the execution process sequence is obtained according to the triggering time point of the function instance corresponding to each execution process subsequence.
[0023] Furthermore, the process of delaying the function initialization loading process according to the function instance timing sequence includes:
[0024] Set an initialization loading quota, obtain the trigger time point of each function instance through the function instance timing sequence, sort the function instances in reverse order according to the trigger time point, select the function instances with the initialization loading quota quantity for loading according to the sorting result, and mark the loading process as the first batch initialization process;
[0025] After all function instances in the first batch of initialization processes have completed the loading process, the remaining function instances of the initialization loading quota are selected for loading according to the sorting results, and the loading process is marked as the second batch of initialization processes, and so on, until the initialization loading process of all function instances is completed.
[0026] Furthermore, after the loaded function instance completes the logical function required by the execution process sequence, the process of determining whether the function instance meets the execution insulation strategy standard includes:
[0027] Determine whether there are other execution flow subsequences in the logic directed graph that are consistent with the function instance category of the function instance that has completed execution. If not, the function instance does not meet the execution insulation strategy standard;
[0028] If it exists, the function instance meets the execution insulation strategy standard, and obtains the maximum deviation value between the triggering time point of the function instance corresponding to other execution process subsequences and the triggering time point of the function instance that has completed execution;
[0029] A deviation threshold interval is preset, and a threshold point is selected within the deviation threshold interval to divide the sub-intervals into different insulation levels, and the sub-interval where the maximum deviation value is located is obtained, and the insulation level of the executed function instance is obtained according to the sub-interval, and the insulation time of the executed function instance is determined according to the insulation level.
[0030] Compared with the prior art, the present invention has the following beneficial effects:
[0031] 1. The present invention implements preheating of function instances by periodically sending recovery requests. When a new execution process is triggered, an initialized function instance is available without starting a new instance, thereby quickly responding to requests and reducing the startup delay of serverless architecture application building.
[0032] 2. Traditional serverless architecture platforms load all models and resources immediately when functions are initialized, which will occupy more memory and computing resources, and these resources may not be needed immediately during the function execution process. Especially when facing large-scale requests, the startup time and resource usage of function instances are greatly increased, resulting in useless costs and waste of resources, and limiting the scalability of serverless architecture platforms. The present invention uses delayed loading to load only the necessary parts when functions are initialized, thereby reducing the time and resource consumption of function initialization, and improving the overall performance and cost efficiency of serverless architecture application construction;
[0033] 3. The insulation mechanism allows the function instance to remain activated temporarily after execution so that it can be reused within a period of time. When a new trigger event arrives, it can be immediately routed to the insulation function instance without starting a new function instance, reducing the startup delay of serverless architecture application building. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 This is a schematic diagram of a method for building an artificial intelligence model management application based on a serverless architecture according to an embodiment of the present application. DETAILED DESCRIPTION
[0035] The following is a clear and complete description of the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0036] like Figure 1 As shown, a method for building an artificial intelligence model management application based on a serverless architecture includes the following steps:
[0037] Step S1: extracting historical function instance creation requests of the logged-in user, obtaining importance levels of different function instance categories according to the historical function instance creation requests, and pre-obtaining a preheating strategy for each function instance category according to the importance levels;
[0038] Step S2: receiving the application function code sent by the logged-in user, obtaining the execution process sequence of the application function code, extracting the logical function of each execution process in the execution process sequence, segmenting the execution process sequence according to the logical function of the execution process, and matching the function instance according to the logical function of the segmented execution process sequence;
[0039] Step S3: Obtain the function instance timing sequence of the execution process sequence, and delay the function initialization loading process according to the function instance timing sequence; after the loaded function instance is executed, obtain the insulation strategy of the executed function instance according to the execution process sequence.
[0040] It should be further explained that, in a specific implementation process, the process of extracting the historical function instance creation requests of the logged-in user and obtaining the importance levels of different function instance categories according to the historical function instance creation requests includes:
[0041] Obtain the historical call frequency, average response time, peak concurrent request volume, and resource cost consumption of different function instance categories based on historical function instance creation requests;
[0042] The historical call frequency, average response time, peak request concurrency and resource cost consumption of each function instance are used as evaluation indicators. The indicator weights of the evaluation indicators are set, and the importance levels are preset. The membership matrix of each function instance for the preset importance level is judged through fuzzy comprehensive evaluation. The importance level of each function instance category is obtained according to the membership matrix and indicator weights.
[0043] It should be further explained that, in a specific implementation process, the process of pre-acquiring the preheating strategy of each function instance category according to the importance level includes:
[0044] Set an importance level threshold, compare the importance level of the function instance category with the importance level threshold, and implement a preheating strategy for the function instance category whose importance level is greater than or equal to the importance level threshold;
[0045] According to the importance level of the function instance category that meets the preheating strategy, the trigger interval time, activation duration and the number N of function instance triggers corresponding to the function instance category are obtained, and periodic activation requests are sent to the N function instances of the function instance category according to the trigger interval time and activation duration.
[0046] It should be further explained that, in the specific implementation process, the trigger interval time represents the interval time for sending periodic activation requests, and the activation duration time represents the time that the function instance remains activated after receiving the periodic activation request. The higher the importance level of the function instance, the shorter the trigger interval time of the function instance and the longer the activation duration time.
[0047] In this embodiment, the function instance is preheated in advance by periodically sending recovery requests. In this way, when a new execution process is triggered, an initialized function instance is available without starting a new instance, thereby quickly responding to requests and reducing startup delays.
[0048] It should be further explained that, in the specific implementation process, the function instance categories of this embodiment include but are not limited to:
[0049] Request response function, used to process requests and return responses. When a request triggers a function, the function will execute the corresponding logic and return the processing result to the caller. For example, the function that processes HTTP requests belongs to the request response function category;
[0050] Scheduled trigger functions are used to trigger execution at scheduled time intervals or specified time points. Users can configure functions to perform specific tasks at specific times or time intervals, such as generating reports, cleaning up temporary data, etc.
[0051] Asynchronous event processing function, used to process asynchronous events, such as new messages from the message queue. When an event is published to the message queue, the function will be triggered to execute the corresponding event processing logic, decoupling the communication and processing between different components or services;
[0052] Data processing functions are used to handle data conversion, calculation, and processing. For example, users can write functions to process and convert large amounts of data, such as image processing, text analysis, data cleaning, etc.
[0053] Batch processing functions: This type of function instance is used to process large batches of data. The function will process the batch data according to preset rules, such as batch report generation, batch data import, etc.
[0054] It should be further explained that, in the specific implementation process, the process of obtaining the importance level of each function instance according to the membership matrix and the indicator weight includes:
[0055] The weight matrix B and the membership matrix M are fused by the following formula to obtain the fuzzy comprehensive evaluation matrix L of each function instance, thereby obtaining the fuzzy comprehensive evaluation result vector corresponding to each function instance in the fuzzy comprehensive evaluation matrix L, and obtaining the importance level corresponding to each function instance according to the fuzzy comprehensive evaluation result vector;
[0056] Wherein, the formula is:
[0057] L = a 1 B+a 2 M;
[0058] Among them, "+" represents the addition of the elements at the corresponding positions of the weight matrix and the membership matrix, a 1 and a 2 It is a weighting parameter used to control the balance between the weight matrix and the membership matrix in the fuzzy comprehensive evaluation matrix of each function instance.
[0059] It should be further explained that, in the specific implementation process, the process of matching the function instance according to the logical function of the segmented execution process sequence includes:
[0060] After the execution process sequence is divided into a plurality of execution process subsequences, the logical function execution order and the logical function execution relationship of each execution process subsequence in the execution process sequence are obtained, and a logical directed graph is constructed through each execution process subsequence and the logical function execution order and the logical function execution relationship of each execution process subsequence;
[0061] The execution process subsequences are taken as nodes of the logical directed graph, the logical function execution order and logical function execution relationship of each execution process subsequence are taken as the connection relationship between the nodes, and the function instances matching the logical functions of each execution process subsequence are taken as the supplementary nodes of the nodes.
[0062] It should be further explained that, in a specific implementation process, the process of obtaining the function instance timing sequence of the execution process sequence includes:
[0063] According to the start timestamp of each execution process subsequence in the logical directed graph, the triggering time point of the function instance corresponding to each execution process subsequence is used, and the function instance timing sequence of the execution process sequence is obtained according to the triggering time point of the function instance corresponding to each execution process subsequence.
[0064] It should be further explained that, in a specific implementation process, the process of delaying the function initialization loading process according to the function instance timing sequence includes:
[0065] Set an initialization loading quota, obtain the trigger time point of each function instance through the function instance timing sequence, sort the function instances in reverse order according to the trigger time point, select the function instances with the initialization loading quota quantity for loading according to the sorting result, and mark the loading process as the first batch initialization process;
[0066] After all function instances in the first batch of initialization processes have completed the loading process, the remaining function instances of the initialization loading quota are selected for loading according to the sorting results, and the loading process is marked as the second batch of initialization processes, and so on, until the initialization loading process of all function instances is completed.
[0067] Traditional serverless architecture platforms immediately load all models and resources when functions are initialized, which will take up more memory and computing resources, and these resources may not be immediately needed during the function execution process. Especially when facing large-scale requests, the startup time and resource usage of function instances are greatly increased, resulting in useless costs and waste of resources, and limiting the scalability of the serverless architecture platform. The present invention uses delayed loading to load only the necessary parts when functions are initialized, thereby reducing the time and resource consumption of function initialization, and improving the overall performance and cost efficiency of building serverless architecture applications.
[0068] It should be further explained that, in the specific implementation process, it is characterized in that after the loaded function instance completes the logical function required by the execution process sequence, the process of judging whether the function instance meets the execution insulation strategy standard includes:
[0069] Determine whether there are other execution flow subsequences in the logic directed graph that are consistent with the function instance category of the function instance that has completed execution. If not, the function instance does not meet the execution insulation strategy standard;
[0070] If it exists, the function instance meets the execution insulation strategy standard, and obtains the maximum deviation value between the triggering time point of the function instance corresponding to other execution process subsequences and the triggering time point of the function instance that has completed execution;
[0071] A deviation threshold interval is preset, and a threshold point is selected within the deviation threshold interval to divide the sub-intervals into different insulation levels, and the sub-interval where the maximum deviation value is located is obtained, and the insulation level of the executed function instance is obtained according to the sub-interval, and the insulation time of the executed function instance is determined according to the insulation level.
[0072] The insulation mechanism allows the function instance to remain activated temporarily after execution so that it can be reused within a period of time. When a new trigger event arrives, it can be immediately routed to the insulation function instance without starting a new function instance, reducing startup delays.
[0073] The above embodiments are only used to illustrate the technical method of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical method of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical method of the present invention.
Claims
1. A method for constructing an artificial intelligence model management application based on a serverless architecture, characterized in that: The following steps are involved: Step S1: extracting historical function instance creation requests of the logged-in user, obtaining importance levels of different function instance categories according to the historical function instance creation requests, and pre-obtaining a preheating strategy for each function instance category according to the importance levels; Step S2: receiving the application function code sent by the logged-in user, obtaining the execution process sequence of the application function code, extracting the logical function of each execution process in the execution process sequence, segmenting the execution process sequence according to the logical function of the execution process, and matching the function instance according to the logical function of the segmented execution process sequence; The process of matching function instances according to the logical functions of the segmented execution process sequence includes: After the execution process sequence is divided into a plurality of execution process subsequences, the logical function execution order and the logical function execution relationship of each execution process subsequence in the execution process sequence are obtained, and a logical directed graph is constructed through each execution process subsequence and the logical function execution order and the logical function execution relationship of each execution process subsequence; The execution process subsequences are taken as nodes of the logical directed graph, the logical function execution order and logical function execution relationship of each execution process subsequence are taken as the connection relationship between the nodes, and the function instances matching the logical functions of each execution process subsequence are taken as the supplementary nodes of the nodes; Step S3: Obtain the function instance timing sequence of the execution process sequence, perform delayed loading on the function initialization loading process according to the function instance timing sequence, and after the loaded function instance completes the logical function required by the execution process sequence, determine whether the function instance meets the execution insulation strategy standard; The process of obtaining the function instance timing sequence of the execution process sequence includes: According to the start timestamp of each execution process subsequence in the logical directed graph as the triggering time point of the function instance corresponding to each execution process subsequence, the function instance timing sequence of the execution process sequence is obtained according to the triggering time point of the function instance corresponding to each execution process subsequence; The process of delaying the function initialization loading process according to the function instance timing sequence includes: Set an initialization loading quota, obtain the trigger time point of each function instance through the function instance timing sequence, sort the function instances in reverse order according to the trigger time point, select the function instances with the initialization loading quota quantity for loading according to the sorting result, and mark the loading process as the first batch initialization process; When all function instances in the first batch initialization process complete the loading process, select the remaining function instances of the initialization loading quota according to the sorting result for loading, and mark the loading process as the second batch initialization process, and so on, until the initialization loading process of all function instances is completed; After the loaded function instance completes the logical function required by the execution process sequence, the process of determining whether the function instance meets the execution insulation strategy standard includes: Determine whether there are other execution flow subsequences in the logic directed graph that are consistent with the function instance category of the function instance that has completed execution. If not, the function instance does not meet the execution insulation strategy standard; If it exists, the function instance meets the execution insulation strategy standard, and obtains the maximum deviation value between the triggering time point of the function instance corresponding to other execution process subsequences and the triggering time point of the function instance that has completed execution; A deviation threshold interval is preset, and a threshold point is selected within the deviation threshold interval to divide the sub-intervals into different insulation levels, and the sub-interval where the maximum deviation value is located is obtained, and the insulation level of the executed function instance is obtained according to the sub-interval, and the insulation time of the executed function instance is determined according to the insulation level.
2. According to claim 1, a method for constructing an artificial intelligence model management application based on a serverless architecture is characterized in that: The process of extracting historical function instance creation requests of the logged-in user and obtaining importance levels of different function instance categories according to the historical function instance creation requests includes: Obtain the historical call frequency, average response time, peak concurrent request volume, and resource cost consumption of different function instance categories based on historical function instance creation requests; The historical call frequency, average response time, peak request concurrency and resource cost consumption of each function instance are used as evaluation indicators. The indicator weights of the evaluation indicators are set, and the importance levels are preset. The membership matrix of each function instance for the preset importance level is judged through fuzzy comprehensive evaluation. The importance level of each function instance category is obtained according to the membership matrix and indicator weights.
3. The method for constructing an artificial intelligence model management application based on a serverless architecture according to claim 2, characterized in that: The process of pre-acquiring a preheating strategy for each function instance category according to the importance level includes: Set an importance level threshold, compare the importance level of the function instance category with the importance level threshold, and implement a preheating strategy for the function instance category whose importance level is greater than or equal to the importance level threshold; According to the importance level of the function instance category that meets the preheating strategy, the trigger interval time, activation duration and the number N of function instance triggers corresponding to the function instance category are obtained, and periodic activation requests are sent to the N function instances of the function instance category according to the trigger interval time and activation duration.
4. The method for constructing an artificial intelligence model management application based on a serverless architecture according to claim 3, characterized in that: The trigger interval represents the interval for sending a periodic activation request, and the activation duration represents the time that the function instance remains activated after receiving the periodic activation request.
Citation Information
Patent Citations
Service deployment method under server-free architecture and function management platform
CN112214293A
Internet of Things data anomaly detection method and system based on server-free architecture
CN113687989A
Container preheating and keep-alive method and device for edge device and storage medium
CN117742833A