Trial calculation service interface optimization method and system based on synchronous and asynchronous mixed calling
By building an effect prediction model and dynamically adjusting the asynchronous proportions, and optimizing the task scheduling parameters, the resource blocking problem of trial computing service interfaces when load changes is solved, the system's adaptive optimization is realized, and the response speed and throughput rate are improved.
Patent Information
- Application Number
- CN202511073632.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-01
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2045-08-01
AI Technical Summary
The existing trial computing service interface is not asynchronously processed in time when the load is low, and blocking resources are synchronously called when the load is high, resulting in low system throughput and response efficiency, and it is impossible to dynamically select the optimal calling method.
By building an effect prediction model based on gradient enhancement tree, combining system strategies and key performance indicators, dynamically adjusting the asynchronous proportion and task priority, optimizing the combination of task scheduling parameters, and realizing dynamic selection of synchronous and asynchronous mixed calls.
It improves the system's response speed and throughput, improves user experience and service quality, solves the problems of resource blocking and inefficiency, and realizes adaptive optimization of task calling methods.
Smart Images

Figure CN120578480A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method and system for optimizing a trial calculation service interface based on synchronous and asynchronous mixed calls. Background Art
[0002] The trial calculation service interface is one of the core modules commonly used in modern information systems to execute specific calculation logic, such as financial trial calculations, tax assessments, insurance policy calculations, and risk control simulations. With the continuous growth of business complexity and data processing requirements, the performance of the trial calculation interface in terms of service response speed, resource scheduling efficiency, and system stability directly affects the user experience and operational efficiency of the overall business system.
[0003] Currently, trial calculation service interfaces are primarily categorized into synchronous and asynchronous call methods. In practice, system architects typically select either synchronous or asynchronous as a fixed call mode during the initial interface design phase. However, due to the uncertainty of workloads and the diversity of trial calculation tasks, fixed call paths often fail to balance response efficiency and system stability. For example, during peak hours, services that originally used synchronous calls may experience thread blocking, leading to a request backlog. Furthermore, for time-sensitive tasks, the asynchronous mode may not be able to meet the real-time demands of the business.
[0004] The Chinese patent application with publication number CN118227508A discloses a service interface testing method, apparatus, computer equipment and storage medium, including: obtaining a service interface sequence corresponding to a target service, and determining the interface parameters corresponding to each service interface in the service interface sequence; constructing a request parameter set corresponding to each interface parameter, wherein the request parameters in the request parameter set are determined according to the interface parameters to which they belong and the abnormal values corresponding to the interface parameters; generating a test request corresponding to the service interface based on the request parameters in the request parameter set; testing the service interfaces in the service interface sequence in sequence based on the test request to obtain the target test result corresponding to each service interface. This application uses abnormal values to construct a request parameter set, which can simulate the operation of the interface under different parameter values, thereby discovering potential problems and abnormal handling capabilities of the interface. By generating test requests and testing the interface, problems and abnormal situations can be discovered in a timely manner, and problem analysis and improvement and optimization can be carried out.
[0005] Existing trial calculation service interfaces generally use a fixed calling mode and are unable to dynamically select the optimal calling method. This results in asynchronous processing not being timely enough when the load is low and synchronous calls blocking resources when the load is high, seriously affecting the system throughput and response efficiency. Summary of the Invention
[0006] This application aims to solve at least one of the technical problems in the related art to a certain extent. To this end, one purpose of this application is to propose a method and system for optimizing the trial calculation service interface based on synchronous and asynchronous hybrid calls, thereby realizing dynamic selection of the optimal calling method.
[0007] One aspect of the present application provides a method for optimizing a trial calculation service interface based on a hybrid synchronous and asynchronous call, including:
[0008] Step S100: Collect task execution data to predict the execution effects of synchronous and asynchronous execution, calculate the comprehensive cost based on the system strategy, preliminarily select the execution path based on the comprehensive cost, and calculate the initial asynchronous ratio;
[0009] Step S200: Calculating a comprehensive load index based on the key performance indicators, and adjusting the initial asynchronization ratio to an adjusted asynchronization ratio according to the comprehensive load index;
[0010] Step S300: constructing a time efficiency prediction model based on task information and task execution data, and allocating task execution paths based on the predicted priority index under the constraint of the adjusted asynchronization ratio;
[0011] Step S400: Divide the asynchronously executed tasks into task mode categories according to process data, and optimize the task scheduling parameter combination of each task mode category;
[0012] The prediction method of the execution effect is:
[0013] Step S110: Collect historical task execution data and execution results, including time consumption data and resource consumption of synchronous or asynchronous execution; build an effect prediction model, the basic model of which is a gradient boosting tree, which is composed of a decision tree. The input data is task execution data, and the output data is the execution results of synchronous and asynchronous execution.
[0014] Step S120: defining mean square error as the loss function of the effect prediction model, and using the gradient descent method to train the effect prediction model, with minimizing the loss function as the training goal;
[0015] Step S130: When the loss function converges to a minimum, the training ends and a trained effect prediction model is obtained;
[0016] Step S140: For the current task execution data, use the trained effect prediction model to predict the execution effects of synchronous execution and asynchronous execution;
[0017] The specific method of calculating the comprehensive cost by combining the system strategy, preliminarily selecting the execution path based on the comprehensive cost, and calculating the initial asynchronization ratio is as follows:
[0018] Step S150: Preset the benchmark weights of time consumption data and resource consumption, and dynamically adjust the benchmark weights based on the current system policy to obtain normalized weight coefficients of real-time time consumption data and resource consumption;
[0019] Step S160: Calculating the comprehensive cost of synchronous execution and the comprehensive cost of asynchronous execution by weighted summation based on the normalized weight coefficient, the predicted time consumption data and resource consumption of synchronous execution, and the time consumption data and resource consumption of asynchronous execution;
[0020] Step S170: Select the execution path with the lowest comprehensive cost. If the comprehensive cost of synchronous execution is smaller, then synchronous execution is selected; otherwise, asynchronous execution is selected.
[0021] Step S180: Count the number of asynchronously executed tasks and calculate the ratio of the number of asynchronously executed tasks to the total number of tasks to obtain an initial asynchronous ratio.
[0022] The specific method of calculating the comprehensive load index based on the key performance indicators and adjusting the initial asynchronization ratio to the adjusted asynchronization ratio according to the comprehensive load index is as follows:
[0023] Step S210: Real-time monitoring of key performance indicators of the system;
[0024] Step S220: performing weighted summation on each key performance indicator to calculate the real-time comprehensive load index of the system;
[0025] Step S230: defining a linear model between the comprehensive load index and the asynchronization ratio, dynamically adjusting the initial asynchronization ratio according to the comprehensive load index, and constraining it to obtain an adjusted asynchronization ratio;
[0026] The method for obtaining the adjusted asynchronization ratio is:
[0027] Step S231: defining the comprehensive load index as the system state and the asynchronization ratio as the control variable;
[0028] Step S232: defining a linear model between the asynchronization ratio and the comprehensive load index, and using the recursive least squares method to estimate the proportional coefficient and bias term of the linear model;
[0029] Step S233: using the least squares method to update the proportional coefficient and bias term of the linear model in real time;
[0030] Step S234: Calculate the control amount based on the estimated proportional coefficient and bias term to obtain the real-time asynchronization ratio;
[0031] Step S235: constraining the real-time asynchronous ratio to be between 0 and 1 to obtain an adjusted asynchronous ratio;
[0032] The specific method of constructing a time efficiency prediction model based on task information and task execution data and allocating task execution paths based on the predicted priority index under the constraint of the adjusted asynchronization ratio is as follows:
[0033] Step S310: Collect the user's historical task information and corresponding task execution data; the task information includes user ID, task content, and request timestamp; the task execution data includes task type, task complexity, and task completion time;
[0034] Step S320: Extract key features of user tasks based on historical task execution data and task information. The key features include task request frequency, task type distribution, time sensitivity, and resource consumption. Use the key features and corresponding time sensitivity labels to build a timeliness prediction model.
[0035] Step S330: Predicting the sensitivity of the current task to timeliness based on the timeliness prediction model, and using the sensitivity as the priority index of the task;
[0036] Step S340: Preset a priority threshold, compare the priority index with the priority threshold, and classify all tasks into high priority and normal priority;
[0037] Step S350: Under the constraint of the adjusted asynchronization ratio, high-priority tasks are preferentially assigned to the synchronous execution path, and normal-priority tasks are preferentially assigned to the asynchronous execution path;
[0038] The construction method of the aging prediction model is:
[0039] Step S321: extract key features from historical task information and task execution data;
[0040] Step S322: Select tasks whose response time is less than or equal to the median response time, and use their corresponding key features as positive samples; select tasks whose response time is greater than the median response time and their corresponding key features as negative samples;
[0041] Step S323: labeling the positive and negative samples based on their sensitivity to timeliness, setting the label of the positive sample to 1 and the label of the negative sample to 0;
[0042] Step S324: The labeled positive and negative samples are combined into a sample set, and the key features are used as input and the corresponding sensitivity to timeliness is used as output to construct training samples;
[0043] Step S325: Using the logistic regression model as the initial model, the logistic regression model is trained based on the training samples. The loss function is defined as the mean square error. The model parameters are updated using the gradient descent algorithm to minimize the loss function on the training samples. When the loss function converges, the training is completed, and a trained time-efficiency prediction model is obtained.
[0044] The optimization method of the task scheduling parameter combination is:
[0045] Step S410: Track and record the asynchronous execution process of the task, and obtain the process data of the asynchronous execution of the task;
[0046] Step S420: clustering the asynchronously executed tasks according to the task execution process data, and dividing the asynchronously executed tasks into different task mode categories;
[0047] Step S430: For each task mode category, define the optimization goal as minimizing the average execution time and minimizing resource consumption, define the optimization variable as the task scheduling parameter, and find the optimal task scheduling parameter combination;
[0048] The method for finding the optimal task scheduling parameter combination is:
[0049] Step S431: define the task scheduling parameter combination x that needs to be optimized, including concurrency, timeout period, and number of retries, determine the value range of each task scheduling parameter, and form a parameter space;
[0050] Step S432: taking the average execution time and resource consumption as the objective function, and minimizing the objective function as the optimization goal;
[0051] Step S433: Using a genetic algorithm to search the parameter space, search for a task scheduling parameter combination that minimizes the objective function, and use it as the optimal task scheduling parameter combination.
[0052] One aspect of the present application provides a system for optimizing a trial calculation service interface based on synchronous and asynchronous hybrid calls, including:
[0053] The initial asynchronous calculation module is used to collect task execution data to predict the execution effects of synchronous and asynchronous execution, calculate the comprehensive cost based on the system strategy, preliminarily select the execution path based on the comprehensive cost, and calculate the initial asynchronous ratio;
[0054] an asynchronous ratio adjustment module, configured to calculate a comprehensive load index based on key performance indicators, and adjust an initial asynchronous ratio to an adjusted asynchronous ratio according to the comprehensive load index;
[0055] The priority prediction constraint module is used to build a timeliness prediction model based on task information and task execution data. Based on the predicted priority index, it allocates task execution paths under the constraint of the adjusted asynchronization ratio.
[0056] The scheduling parameter optimization module is used to divide the asynchronously executed tasks into task mode categories according to process data and optimize the task scheduling parameter combination of each task mode category.
[0057] The method and system for optimizing the trial calculation service interface based on synchronous and asynchronous hybrid calls proposed in this application have the following advantages over the existing technology:
[0058] This application dynamically selects the optimal synchronous or asynchronous execution path based on system load and task characteristics, which can process asynchronous tasks in a timely manner when the load is low and improve response speed; when the load is high, it avoids synchronous calls blocking resources and improves system throughput.
[0059] This application monitors system performance indicators and task execution results in real time, dynamically adjusts the asynchronization ratio and task priority, and can adaptively optimize the task calling method according to the system status and task characteristics, always maintaining the optimal calling strategy.
[0060] This application predicts the timeliness sensitivity of tasks and uses synchronous execution for high-priority tasks to improve the response speed and user experience of critical tasks; it uses asynchronous execution for ordinary tasks to smooth the load and improve service quality.
[0061] By clustering asynchronous tasks and optimizing scheduling parameters, this application can adopt the optimal scheduling strategy for different task mode categories, minimize the execution time and resource consumption of tasks, and improve the execution efficiency of asynchronous tasks.
[0062] This application is based on the synergistic technical effects of multiple technical means such as effect prediction, load perception, timeliness prediction, task clustering and parameter optimization. From multiple dimensions such as task execution effect prediction, system load perception, task priority prediction, and asynchronous task optimization, it realizes dynamic selection and adaptive optimization of task calling methods, effectively solving the resource congestion and inefficiency problems caused by the solidification of calling modes in existing solutions, and significantly improving the system's throughput, response efficiency, user experience and service quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 A flowchart of the method for optimizing the trial calculation service interface based on synchronous and asynchronous mixed calls provided by this application;
[0064] Figure 2 Flowchart of the method for obtaining the initial asynchronization ratio provided by this application;
[0065] Figure 3 Flowchart of the method for allocating task execution paths provided by this application;
[0066] Figure 4 This is a functional module diagram of the trial calculation service interface optimization system based on synchronous and asynchronous mixed calls provided in this application. DETAILED DESCRIPTION
[0067] To better understand the present application, various aspects of the present application will be described in more detail with reference to the accompanying drawings. It should be understood that these detailed descriptions are merely descriptions of exemplary embodiments of the present application and are not intended to limit the scope of the present application in any way. Throughout the specification, the same reference numerals refer to the same elements. The expression "and / or" includes any and all combinations of one or more of the associated listed items.
[0068] In the accompanying drawings, the size, dimensions, and shapes of the elements have been slightly adjusted for ease of illustration. The accompanying drawings are for illustration only and are not drawn strictly to scale. As used herein, the terms "substantially," "approximately," and similar terms are used to indicate approximate values, not degrees, and are intended to illustrate inherent deviations in measurements or calculations that would be recognized by a person of ordinary skill in the art. In addition, in this application, the order in which the steps are described does not necessarily represent the order in which these steps would occur in actual operation, unless otherwise specified or inferred from the context.
[0069] It should also be understood that expressions such as "including", "comprising", "having", "containing" and / or "comprising" are open rather than closed expressions in this specification, which indicate the presence of the stated features, elements and / or components, but do not exclude the presence of one or more other features, elements, components and / or combinations thereof. In addition, when expressions such as "at least one of..." appear after a list of listed features, they modify the entire list of features rather than just the individual elements in the list. In addition, when describing embodiments of the present application, "may" is used to mean "one or more embodiments of the present application". And, the term "exemplary" is intended to refer to an example or illustration.
[0070] Unless otherwise defined, all terms used herein (including engineering and scientific terms) have the same meaning as commonly understood by those skilled in the art to which this application belongs. It should also be understood that, unless otherwise specified in this application, words defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant technology, and should not be interpreted in an idealized or overly formal sense.
[0071] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0072] Example 1
[0073] like Figure 1 As shown, the trial calculation service interface optimization method based on synchronous and asynchronous mixed calls provided by this application includes:
[0074] Step S100: Collect task execution data to predict the execution effects of synchronous and asynchronous execution, calculate the comprehensive cost based on the system strategy, preliminarily select the execution path based on the comprehensive cost, and calculate the initial asynchronous ratio;
[0075] The prediction method of the execution effect is:
[0076] Step S110: Collect historical task execution data and execution results, including time consumption data and resource consumption of synchronous or asynchronous execution; construct an effect prediction model, the basic model of which is a gradient boosting tree, which is obtained by constructing A decision trees. The input data is task execution data, and the output data is the execution results of synchronous and asynchronous execution.
[0077] The gradient boosting tree consists of A decision trees, each of which learns the residual of the previous decision tree, and the final prediction result is the sum of the prediction values of all decision trees;
[0078] Specifically, let the prediction function of the a-th decision tree be , then the function expression of the prediction function of the gradient boosting tree is: , where a is the number index of the decision tree, A is the total number of decision trees, a=1,2,...,A;
[0079] Step S120: defining mean square error as the loss function of the effect prediction model, and using the gradient descent method to train the effect prediction model, with minimizing the loss function as the training goal;
[0080] The calculation formula of the loss function of the effect prediction model is: ; Among them, y is the actual execution effect, The execution effect predicted by the effect prediction model;
[0081] Step S130: When the loss function converges to a minimum, the training ends and a trained effect prediction model is obtained;
[0082] Furthermore, during training, a training set, a test set, and a validation set are set, the training set is used to train the effect prediction model, the test set is used to evaluate the performance of the effect prediction model, and the validation set is used to verify the performance of the effect prediction model;
[0083] The number of iterations is set by those skilled in the art based on experience;
[0084] Step S140: For the current task execution data, use the trained effect prediction model to predict the execution effects of synchronous execution and asynchronous execution; the task execution data includes task type and task complexity;
[0085] like Figure 2 As shown in FIG, a flow chart of the method for obtaining the initial asynchronization ratio provided by this application is provided. The specific method of calculating the comprehensive cost by combining the system strategy, preliminarily selecting the execution path according to the comprehensive cost, and calculating the initial asynchronization ratio is as follows:
[0086] Step S150: Preset the benchmark weights of time consumption data and resource consumption, and dynamically adjust the benchmark weights based on the current system policy to obtain normalized weight coefficients of real-time time consumption data and resource consumption;
[0087] The normalized weight coefficients of the time-consuming data and resource consumption are set based on the current system strategy; specifically, a set of benchmark weights are pre-set according to the business characteristics of the system. and ; For example, if the system is sensitive to response time, the default is 0.8, The average response time and resource utilization rate are collected in real time through the monitoring system as quantitative system optimization indicators. An optimization target value is set for each optimization indicator. The deviation of each optimization indicator is calculated in real time. The deviation of each optimization indicator is normalized. Based on the normalized deviation, the dynamic adjustment value of the weight coefficient is calculated. The baseline weight and the dynamic adjustment value are added to obtain the weight coefficient and normalized to obtain the normalized weight coefficient of time-consuming data and resource consumption.
[0088] The deviation of the optimization index is the absolute value of the difference between the actual value of the optimization index and the optimization target value;
[0089] The calculation formula of the dynamic adjustment value of the weight coefficient is: , ,in, is the normalized deviation of the average response time, is the normalized deviation of resource utilization, 、 is the sensitivity coefficient;
[0090] The sensitivity coefficient is used to control the adjustment range of the weight coefficient;
[0091] The calculation formula for the weight coefficient of time-consuming data is: ;in, is the weight coefficient of time-consuming data;
[0092] The calculation formula of the weight coefficient of resource consumption is: ;in, is the weight coefficient of resource consumption;
[0093] The calculation formula of the normalized weight coefficient of the time-consuming data is: ;
[0094] The calculation formula of the normalized weight coefficient of resource consumption is: ;
[0095] Step S160: Calculating the comprehensive cost of synchronous execution and the comprehensive cost of asynchronous execution by weighted summation based on the normalized weight coefficient, the predicted time consumption data and resource consumption of synchronous execution, and the time consumption data and resource consumption of asynchronous execution;
[0096] The time-consuming data includes the task response time and the start and end time of each link;
[0097] The calculation formula for the comprehensive cost of the synchronous execution is: ,in, 、 are the normalized weight coefficients of time-consuming data and resource consumption, 、 They are the time-consuming data and resource consumption of synchronous execution respectively;
[0098] The calculation formula for the comprehensive cost of asynchronous execution is: ,in, 、 They are the time-consuming data and resource consumption of asynchronous execution respectively;
[0099] Furthermore, in order to avoid the inability to perform weighted calculations due to different dimensions in the calculation of the comprehensive cost, this application de-dimensionalizes the time-consuming data and resource consumption in the synchronous and asynchronous execution processes to ensure their additivity.
[0100] Step S170: Select the execution path with the lowest comprehensive cost. If the comprehensive cost of synchronous execution is smaller, then synchronous execution is selected; otherwise, asynchronous execution is selected.
[0101] Step S180: Count the number of asynchronously executed tasks and calculate the ratio of the number of asynchronously executed tasks to the total number of tasks to obtain an initial asynchronous ratio.
[0102] Actively making an initial routing allocation decision based on task execution data combined with comprehensive costs, wherein the initial asynchronization ratio is obtained by statistically analyzing the allocation decision;
[0103] For example, the system currently receives three trial calculation tasks, A, B, and C. Task A is a pricing trial calculation with complex parameters and a long historical execution time; Task B is a batch trial calculation with relatively simple parameters and a medium historical execution time; Task C is a single trial calculation with very simple parameters and a short historical execution time. Based on the characteristics of Tasks A, B, and C, their response times under synchronous execution and asynchronous execution times, as well as the resource consumption of asynchronous execution, are predicted. By comprehensively considering the corresponding time consumption data and resource consumption, the initial asynchronous execution ratio can be obtained.
[0104] The purpose of the above steps is to predict the performance of tasks under both synchronous and asynchronous execution paths based on the relevant data of the task, and select the execution path with the best performance as the initial routing decision, indicating the proportion of tasks that the system tends to route to the asynchronous channel. This allows for accurate prediction of task execution results, dynamic balance between the time and resource costs of tasks, and preliminary optimization of task calling methods.
[0105] Step S200: Calculating a comprehensive load index based on the key performance indicators, and adjusting the initial asynchronization ratio to an adjusted asynchronization ratio according to the comprehensive load index;
[0106] The specific method of calculating the comprehensive load index based on the key performance indicators and adjusting the initial asynchronization ratio to the adjusted asynchronization ratio according to the comprehensive load index is as follows:
[0107] Step S210: Real-time monitoring of key performance indicators of the system;
[0108] The key performance indicators include CPU usage, task queue length, average response time and resource consumption, which are collected in real time through the server-side performance monitoring system at one-second intervals;
[0109] Step S220: performing weighted summation on each key performance indicator to calculate the real-time comprehensive load index of the system;
[0110] Step S230: defining a linear model between the comprehensive load index and the asynchronization ratio, dynamically adjusting the initial asynchronization ratio according to the comprehensive load index, and constraining it to obtain an adjusted asynchronization ratio;
[0111] The method for obtaining the adjusted asynchronization ratio is:
[0112] Step S231: defining the comprehensive load index as the system state and the asynchronization ratio as the control variable;
[0113] Step S232: defining a linear model between the asynchronization ratio and the comprehensive load index, and using the recursive least squares method to estimate the proportional coefficient and bias term of the linear model;
[0114] The calculation formula of the linear model is: , where k is the proportional coefficient and b is the bias term. is the comprehensive load index, is the asynchronization ratio;
[0115] Specifically, assuming the current time is t, the comprehensive load index at the current time is , the asynchronous ratio is , construct a cost function and take minimizing the cost function as the goal of system identification;
[0116] The calculation formula of the cost function is: ; where i is the time index, i=1,2,...,t, 、 They represent the asynchronization ratio and comprehensive load index at the i-th moment respectively;
[0117] Step S233: using the least squares method to update the proportional coefficient and bias term of the linear model in real time;
[0118] The initial values of the proportional coefficient and the bias term can be set as empirical constants, or the sliding window mean can be used for initial value estimation;
[0119] Step S234: Calculate the control amount based on the estimated proportional coefficient and bias term to obtain the real-time asynchronization ratio;
[0120] The calculation formula of the real-time asynchronous ratio is: ;in, 、 Represent the proportional coefficient and bias term at the current time t respectively;
[0121] Step S235: constraining the real-time asynchronous ratio to be between 0 and 1 to obtain an adjusted asynchronous ratio;
[0122] Furthermore, steps S231 to S235 are repeated to achieve dynamic adaptive adjustment of the asynchronization ratio;
[0123] For example, assume the initial asynchronization ratio is 60%, meaning 60% of tasks are routed to asynchronous channels. The system's CPU utilization, task queue length, average response time, and resource consumption are monitored to calculate the system's comprehensive load index. Assume the real-time comprehensive load index is 0.7. Based on the comprehensive load index and the initial asynchronization ratio, the linear model is used to adjust the initial asynchronization ratio to 0.8, meaning 80% of tasks are routed to asynchronous channels to alleviate system load.
[0124] The above steps are based on the initial asynchronization ratio, and the initial asynchronization ratio is dynamically adjusted in combination with the real-time load of the system to obtain the adjusted asynchronization ratio. This balances the system load and performance at the global level. When the system load is high, the asynchronization ratio is increased to reduce the pressure of synchronous execution; when the system load is low, the asynchronization ratio is reduced to improve the real-time processing capability of tasks. This realizes the real-time quantitative evaluation of the system load and establishes an adaptive adjustment mechanism between the load and the asynchronization ratio. According to the real-time load status of the system, the distribution ratio of asynchronous tasks can be dynamically optimized, reducing asynchronous tasks under high load and increasing asynchronous tasks under low load to achieve adaptive load balancing.
[0125] Step S300: constructing a time efficiency prediction model based on task information and task execution data, and allocating task execution paths based on the predicted priority index under the constraint of the adjusted asynchronization ratio;
[0126] like Figure 3 As shown in FIG, a flow chart of the method for allocating task execution paths provided by the present application is provided. The method for constructing a time efficiency prediction model based on task information and task execution data and allocating task execution paths based on the predicted priority index under the constraint of the adjusted asynchronization ratio is as follows:
[0127] Step S310: Collect the user's historical task information and corresponding task execution data;
[0128] The task information includes user ID, task content, and request timestamp;
[0129] The task execution data includes task type, task complexity, and task completion time;
[0130] Step S320: Extract key features of user tasks based on historical task execution data and task information. The key features include task request frequency, task type distribution, time sensitivity, and resource consumption. Use the key features and corresponding time sensitivity labels to build a timeliness prediction model.
[0131] The task request frequency extraction method is as follows: based on the task information of the historical time and the time span of the task execution data, the request timestamp is divided into multiple time windows, and the time window can be daily, hourly or minutely; the request timestamps in each time window are grouped according to the user ID, and the number of requests of each user in the time window is calculated to obtain the task request frequency;
[0132] The task type distribution extraction method is as follows: encoding the task type in the task execution data and converting the string type into a digital code; grouping each user's task execution data and task information by task type, calculating the number of requests for each task type, and obtaining the task type distribution of each user;
[0133] The time sensitivity extraction method is as follows: for each task, based on its request timestamp and task completion time, the response time is calculated, i.e., the difference between the task completion time and the request timestamp, and the average response time is calculated. The median response time is used as the user's sensitivity index to timeliness. The timeliness sensitivity indexes of different users are normalized and discretized to convert them into discrete time sensitivities.
[0134] The resource consumption extraction method is as follows: selecting resource consumption indicators related to user task requests based on the system's resource types and monitoring indicators;
[0135] The construction method of the aging prediction model is:
[0136] Step S321: extract key features from historical task information and task execution data;
[0137] The task request frequency is the average frequency of task requests initiated by users, reflecting the user's activity level; the task type distribution refers to the proportion of task types in user task requests, reflecting the user's business preferences; the time sensitivity refers to the user's tolerance for the average response time of tasks, reflecting the user's requirements for timeliness; the resource consumption refers to the average resource consumption of user task requests, reflecting the computing intensity of task requests;
[0138] Step S322: Select tasks whose response time is less than or equal to the median response time, and use their corresponding key features as positive samples; select tasks whose response time is greater than the median response time and their corresponding key features as negative samples;
[0139] Step S323: labeling the positive and negative samples based on their sensitivity to timeliness, setting the label of the positive sample to 1 and the label of the negative sample to 0;
[0140] Step S324: The labeled positive and negative samples are combined into a sample set, and the key features are used as input and the corresponding sensitivity to timeliness is used as output to construct training samples;
[0141] Step S325: Using the logistic regression model as the initial model, the logistic regression model is trained based on the training samples. The loss function is defined as the mean square error. The model parameters are updated using the gradient descent algorithm to minimize the loss function on the training samples. When the loss function converges, the training is completed, and a trained time-efficiency prediction model is obtained.
[0142] Step S330: Predicting the sensitivity of the current task to timeliness based on the timeliness prediction model, and using the sensitivity as the priority index of the task;
[0143] Specifically, a timeliness prediction model is used to input the key features of the current task and output the sensitivity of the current task to timeliness. The sensitivity output by the timeliness prediction model is a continuous sensitivity prediction value in the range of 0 to 1. The closer the sensitivity is to 1, the more sensitive the current task is to timeliness, and the higher the priority index is. The closer the sensitivity is to 0, the less sensitive the current task is to timeliness, and the lower the priority index is.
[0144] Step S340: Preset a priority threshold, compare the priority index with the priority threshold, and classify all tasks into high priority and normal priority;
[0145] Specifically, the priority threshold is preset as follows: based on the priority index distribution of historical tasks, the value of the priority index of the first 20% quantile of the priority index distribution is taken as the priority threshold, and tasks corresponding to priority indices greater than or equal to the priority threshold are classified as high priority, otherwise they are classified as normal priority;
[0146] Step S350: Under the constraint of the adjusted asynchronization ratio, high-priority tasks are preferentially assigned to the synchronous execution path, and normal-priority tasks are preferentially assigned to the asynchronous execution path;
[0147] The above steps introduce the concepts of timeliness prediction model and task priority to further optimize task routing decisions. First, the task priority is predicted based on the timeliness prediction model. By predicting the task's sensitivity to timeliness, synchronous execution is prioritized for highly sensitive tasks to improve the response speed of critical tasks. Asynchronous execution is prioritized for less sensitive tasks to smooth the load while ensuring the asynchronous ratio.
[0148] Step S400: Divide the asynchronously executed tasks into task mode categories according to process data, and optimize the task scheduling parameter combination of each task mode category;
[0149] The optimization method of the task scheduling parameter combination is:
[0150] Step S410: Track and record the asynchronous execution process of the task, and obtain the process data of the asynchronous execution of the task;
[0151] The process data includes the task submission time, execution start time, time consumption data, and resource consumption;
[0152] Step S420: clustering the asynchronously executed tasks according to the task execution process data, and dividing the asynchronously executed tasks into different task mode categories;
[0153] Specifically, the method for clustering the asynchronously executed tasks according to the process data of task execution and dividing the asynchronously executed tasks into different task pattern categories is as follows: extracting features from the process data of the asynchronously executed tasks to obtain feature vectors of the process data; based on the feature vectors of the process data, randomly selecting K feature vectors as initial clustering centers, clustering the asynchronously executed tasks based on the K-means clustering algorithm, calculating the Euclidean distance between the feature vector of each asynchronously executed task and the cluster center, and dividing each feature vector into the task pattern category where the cluster center closest to it is located; when all feature vectors are divided, recalculating the mean feature vector of each task pattern category as a new cluster center; repeating the above steps until the cluster center of each task pattern category no longer changes, thereby obtaining K different task pattern categories;
[0154] The clustering of asynchronously executed tasks can be expressed as follows: ;in, is the ki-th cluster center, is the feature vector of the nth task, K is the number of task mode categories, and N is the total number of asynchronously executed tasks;
[0155] Step S430: For each task mode category, define the optimization goal as minimizing the average execution time and minimizing resource consumption, define the optimization variable as the task scheduling parameter, and find the optimal task scheduling parameter combination;
[0156] The method for finding the optimal task scheduling parameter combination is:
[0157] Step S431: define the task scheduling parameter combination x that needs to be optimized, including concurrency, timeout period, and number of retries, determine the value range of each task scheduling parameter, and form a parameter space;
[0158] The task scheduling parameter combination x can be expressed as: , where m is the concurrency, c is the timeout period, and r is the number of retries;
[0159] Specifically, the value range of each task scheduling parameter is , the parameter space is formed by the value space of each task scheduling parameter ;
[0160] Step S432: taking the average execution time and resource consumption as the objective function, and minimizing the objective function as the optimization goal;
[0161] The average execution time can be expressed as: , where N is the total number of asynchronously executed tasks, The execution time of the nth asynchronously executed task;
[0162] The resource consumption can be expressed as: , where J is the number of resource types, For the Class resource consumption;
[0163] The objective function can be expressed as: ;
[0164] The optimization goal is to use the task scheduling parameter combination as the optimization variable and search for the best optimization variable so that the optimization goal can achieve the goal of minimizing the average execution time and minimizing resource consumption;
[0165] Step S433: Using a genetic algorithm to search the parameter space, searching for a task scheduling parameter combination that minimizes the objective function, and taking it as the optimal task scheduling parameter combination;
[0166] This application uses a genetic algorithm to replace the traditional grid search method, which reduces the cost of searching the space and can significantly improve the computational efficiency and system adaptability of parameter optimization while maintaining the accuracy of the optimal solution.
[0167] The above steps achieve adaptive optimization of task scheduling by adjusting the task scheduling parameter combination. By finding the optimal parameter combination as the benchmark configuration for scheduling, the optimal scheduling strategy is adopted for asynchronous tasks of different modes to improve the execution efficiency of asynchronous tasks. The optimal scheduling parameter combination is found for each type of task, minimizing the average execution time and resource consumption, thereby improving the performance and efficiency of asynchronous task execution.
[0168] Example 2
[0169] like Figure 4 As shown, the trial calculation service interface optimization system based on synchronous and asynchronous mixed calls provided by this application includes:
[0170] The initial asynchronous calculation module is used to collect task execution data to predict the execution effects of synchronous and asynchronous execution, calculate the comprehensive cost based on the system strategy, preliminarily select the execution path based on the comprehensive cost, and calculate the initial asynchronous ratio;
[0171] an asynchronous ratio adjustment module, configured to calculate a comprehensive load index based on key performance indicators, and adjust an initial asynchronous ratio to an adjusted asynchronous ratio according to the comprehensive load index;
[0172] The priority prediction constraint module is used to build a timeliness prediction model based on task information and task execution data. Based on the predicted priority index, it allocates task execution paths under the constraint of the adjusted asynchronization ratio.
[0173] The scheduling parameter optimization module is used to divide the asynchronously executed tasks into task mode categories according to process data and optimize the task scheduling parameter combination of each task mode category.
[0174] In addition, the parts of the above technical solutions provided in the embodiments of the present application that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive redundancy.
[0175] The above-described specific embodiments further illustrate the objectives, technical solutions, and beneficial effects of the present invention. It should be understood that the above description is merely a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A method for optimizing the trial calculation service interface based on synchronous and asynchronous mixed calls, characterized in that: include: Collect task execution data to predict the performance of synchronous and asynchronous execution, calculate the comprehensive cost based on system strategy, preliminarily select the execution path based on the comprehensive cost, and calculate the initial asynchronous ratio; Calculate a comprehensive load index based on key performance indicators, and adjust the initial asynchronization ratio to the adjusted asynchronization ratio based on the comprehensive load index; A timeliness prediction model is built based on task information and task execution data. Based on the predicted priority index, task execution paths are assigned under the constraint of the adjusted asynchronization ratio. The asynchronously executed tasks are divided into task mode categories according to process data, and the task scheduling parameter combination of each task mode category is optimized.
2. The method for optimizing the computation service interface based on synchronous and asynchronous mixed calls according to claim 1, wherein: The prediction method of the execution effect is: Collect historical task execution data and execution results, including time consumption data and resource consumption of synchronous or asynchronous execution; build an effect prediction model, the basic model of which is a gradient boosting tree, which is composed of a decision tree. The input data is task execution data, and the output data is the execution results of synchronous and asynchronous execution; Define mean square error as the loss function of the effect prediction model, use gradient descent method to train the effect prediction model, and minimize the loss function as the training goal; When the loss function converges to the minimum, the training ends and the trained effect prediction model is obtained; For the current task execution data, the trained effect prediction model is used to predict the execution effects of synchronous execution and asynchronous execution.
3. The method for optimizing the computation service interface based on synchronous and asynchronous mixed calls according to claim 2, wherein: The specific method of calculating the comprehensive cost by combining the system strategy, preliminarily selecting the execution path based on the comprehensive cost, and calculating the initial asynchronization ratio is as follows: Preset the baseline weights for time consumption data and resource consumption, and dynamically adjust the baseline weights based on the current system policy to obtain the normalized weight coefficients for real-time time consumption data and resource consumption; Calculate the comprehensive cost of synchronous execution and the comprehensive cost of asynchronous execution by weighted summation based on the normalized weight coefficient, the predicted time consumption data and resource consumption of synchronous execution, and the time consumption data and resource consumption of asynchronous execution; Select the execution path with the lowest overall cost. If the overall cost of synchronous execution is lower, then choose synchronous execution; otherwise, choose asynchronous execution. Count the number of tasks executed asynchronously, calculate its ratio to the total number of tasks, and get the initial asynchronization ratio.
4. The method for optimizing the computation service interface based on synchronous and asynchronous mixed calls according to claim 3, wherein: The specific method for calculating the comprehensive load index based on the key performance indicators and adjusting the initial asynchronization ratio to the adjusted asynchronization ratio according to the comprehensive load index is as follows: real-time monitoring of the key performance indicators of the system; performing weighted summation of the key performance indicators to calculate the real-time comprehensive load index of the system; defining a linear model between the comprehensive load index and the asynchronization ratio, dynamically adjusting the initial asynchronization ratio according to the comprehensive load index, and constraining it to obtain the adjusted asynchronization ratio.
5. The method for optimizing the calculation service interface based on synchronous and asynchronous mixed calls according to claim 4, characterized in that: The method for obtaining the adjusted asynchronization ratio is as follows: defining a comprehensive load index as a system state and defining the asynchronization ratio as a control variable; defining a linear model between the asynchronization ratio and the comprehensive load index, and estimating a proportional coefficient and a bias term of the linear model using a recursive least squares method; and updating the proportional coefficient and the bias term of the linear model in real time using the least squares method; According to the estimated proportional coefficient and bias term, the control amount is calculated to obtain the real-time asynchronous ratio; The real-time asynchronization ratio is constrained to be between 0 and 1 to obtain the adjusted asynchronization ratio.
6. The method for optimizing the computation service interface based on synchronous and asynchronous mixed calls according to claim 5, wherein: The specific method of constructing a time efficiency prediction model based on task information and task execution data and allocating task execution paths based on the predicted priority index under the constraint of the adjusted asynchronization ratio is as follows: Collect user's historical task information and corresponding task execution data; the task information includes user ID, task content, and request timestamp; the task execution data includes task type, task complexity, and task completion time; Extract key features of user tasks based on historical task execution data and task information. The key features include task request frequency, task type distribution, time sensitivity, and resource consumption. Use the key features and corresponding time sensitivity labels to build a timeliness prediction model. Predict the sensitivity of the current task to timeliness based on the timeliness prediction model, and use the sensitivity as the priority index of the task; Preset the priority threshold, compare the priority index with the priority threshold, and divide all tasks into high priority and normal priority; Under the constraint of the adjusted asynchronization ratio, high-priority tasks are assigned to the synchronous execution path first, and normal-priority tasks are assigned to the asynchronous execution path first.
7. The method for optimizing the computation service interface based on synchronous and asynchronous mixed calls according to claim 6, wherein: The construction method of the aging prediction model is: Extract key features from historical task information and task execution data; Select tasks with response time less than or equal to the median response time and use their corresponding key features as positive samples, and use the key features corresponding to tasks with response time greater than the median response time as negative samples; Based on the sensitivity of positive and negative samples to timeliness, the labels of positive samples are set to 1 and the labels of negative samples are set to 0; The labeled positive and negative samples are used to form a sample set, with key features as input and the corresponding sensitivity to timeliness as output to construct training samples; The logistic regression model is used as the initial model and trained based on the training samples. The loss function is defined as the mean square error. The gradient descent algorithm is used to update the model parameters so that the loss function on the training samples is minimized. When the loss function converges, the training is completed and a trained time-sensitive prediction model is obtained.
8. The method for optimizing the computation service interface based on synchronous and asynchronous mixed calls according to claim 7, wherein: The optimization method of the task scheduling parameter combination is: Track and record the asynchronous execution process of the task and obtain the process data of the asynchronous execution of the task; Clustering asynchronously executed tasks according to the process data of task execution, and dividing asynchronously executed tasks into different task mode categories; For each task mode category, the optimization goal is defined as minimizing the average execution time and minimizing resource consumption, the optimization variables are defined as task scheduling parameters, and the optimal task scheduling parameter combination is found.
9. The method for optimizing the computation service interface based on synchronous and asynchronous mixed calls according to claim 8, wherein: The method for finding the optimal task scheduling parameter combination is: Define the task scheduling parameter combination x that needs to be optimized, including concurrency, timeout, and number of retries, and determine the value range of each task scheduling parameter to form a parameter space; The average execution time and resource consumption are used as the objective function, and minimizing the objective function is used as the optimization goal; A genetic algorithm is used to search the parameter space and search for the task scheduling parameter combination that minimizes the objective function, which is taken as the optimal task scheduling parameter combination.
10. A system for optimizing a trial calculation service interface based on a combination of synchronous and asynchronous calls, which is used to implement the method for optimizing a trial calculation service interface based on a combination of synchronous and asynchronous calls as claimed in any one of claims 1 to 9, characterized in that: include: The initial asynchronous calculation module is used to collect task execution data to predict the execution effects of synchronous and asynchronous execution, calculate the comprehensive cost based on the system strategy, preliminarily select the execution path based on the comprehensive cost, and calculate the initial asynchronous ratio; an asynchronous ratio adjustment module, configured to calculate a comprehensive load index based on key performance indicators, and adjust an initial asynchronous ratio to an adjusted asynchronous ratio according to the comprehensive load index; The priority prediction constraint module is used to build a timeliness prediction model based on task information and task execution data. Based on the predicted priority index, it allocates task execution paths under the constraint of the adjusted asynchronization ratio. The scheduling parameter optimization module is used to divide the asynchronously executed tasks into task mode categories according to process data and optimize the task scheduling parameter combination of each task mode category.
Citation Information
Patent Citations
Cross-domain computing task scheduling method and system based on intelligent perception
CN109960573A
Multi-terminal cooperation-oriented digital intelligent screen station interaction scene scheduling method and system
CN119862043A
Multi-queue multi-cluster task scheduling method and system
US20220269536A1
Task scheduling service system and method
WO2014173339A1
Cited By
Intelligent data processing method for public facility design
CN121833085A