A dynamic interface calling method and storage medium
Through dynamic interface call methods and intelligent resource scheduling, the problem of frequent interface transformation in software system iterative updates is solved, efficient interface matching and resource optimization is achieved, and the automation and stability of the system is improved.
Patent Information
- Application Number
- CN202111638110.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2041-12-29
AI Technical Summary
During the iterative and updating of software systems, interfaces need to be continuously re-transformed and upgraded due to changes in functions, business requirements and scenarios, and it is difficult for existing technology to achieve efficient and automated interface calls.
Provide a dynamic interface call method, which realizes intelligent interface matching and resource scheduling by receiving requests, generating request information lists, classifying requests, obtaining environmental monitoring data and computing resource allocation.
It improves the level of automatic matching of interface requests, saves manpower and debugging costs, realizes intelligence of interface call process and dynamic resource adjustment, and improves the stability and efficiency of the system.
Smart Images

Figure CN114443732B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of system communications, and in particular to a method and storage medium capable of automatically and dynamically calling an interface. Background Art
[0002] As software systems continue to iterate and update, and businesses and business systems connect through interfaces, changes in functionality, business needs, and scenarios often necessitate the redesign, upgrade, and development of new and old interface modules. To address this constant need to switch interfaces between iterations, a new interface access method is needed. Summary of the Invention
[0003] Therefore, it is necessary to provide an automated interface calling method that can meet the problem of request adaptation interface under the ever-changing business demand scenarios.
[0004] To achieve the above object, the present invention provides a dynamic interface calling method, comprising the following steps:
[0005] Receive the first request from the initiator, obtain the target address of the receiver and the parameter content of the transmission according to the received first request,
[0006] Store the request of each call in the database, collect statistics on the stored requests, generate a request information list, and divide the stored requests into several request categories according to the similarity of the items in the list.
[0007] Compare the first request of the initiator with the request information list and classify the first request,
[0008] The first request is assigned to the generated first interface for calling according to the classification result.
[0009] Some embodiments of the present application also include a step of obtaining current environmental monitoring data, wherein the environmental monitoring data includes operating indicator data of the processing unit, intermediate node, database, and Java application, and generating timing data of different interface calls based on the operating indicator data.
[0010] Some embodiments of the present application further include a step of calculating, based on the received first request, the expected changes in operating indicator data that may be brought about by accessing the first request, and dynamically allocating resources to different interfaces based on the expected results.
[0011] In some embodiments of the present application, the operating indicator data also includes the CPU usage, memory usage, disk usage of the processing unit, stack memory usage of the intermediate node, response time, or the number of active threads.
[0012] In some embodiments of the present application, the request information list includes an interface address, interface parameters, time distribution of interface calls, or interface response status.
[0013] A dynamic interface calling storage medium stores a computer program, which, when executed, performs the following steps:
[0014] Receive the first request from the initiator, obtain the target address of the receiver and the parameter content of the transmission according to the received first request,
[0015] Store the request of each call in the database, collect statistics on the stored requests, generate a request information list, and divide the stored requests into several request categories according to the similarity of the items in the list.
[0016] Compare the first request of the initiator with the request information list and classify the first request,
[0017] The first request is assigned to the generated first interface for calling according to the classification result.
[0018] In some embodiments of the present application, the computer program also executes steps including obtaining current environmental monitoring data when being run, wherein the environmental monitoring data includes operating indicator data of the processing unit, intermediate node, database, and Java application, and generating timing data of different interface calls based on the operating indicator data.
[0019] In some embodiments of the present application, the computer program, when being executed, further executes steps including calculating, based on the received first request, the expected changes in operating indicator data that may be brought about by accessing the first request, and dynamically allocating resources to different interfaces based on the expected results.
[0020] In some embodiments of the present application, the operating indicator data also includes the CPU usage, memory usage, disk usage of the processing unit, stack memory usage of the intermediate node, response time, or the number of active threads.
[0021] In some embodiments of the present application, the request information list includes an interface address, interface parameters, time distribution of interface calls, or interface response status.
[0022] Different from the existing technology, the above solution can intelligently compare the received first request with the stored request information list, thereby classifying and distinguishing the first request from the closest request information, thereby matching the most suitable generated interface, and calling the first request through the generated first interface, thereby solving the problem of new business requests constantly changing or generating. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 This is a flow chart of the dynamic interface calling method described in the specific implementation method;
[0024] Figure 2 A diagram of a method for generating time series data according to a specific embodiment;
[0025] Figure 3 This is a flow chart of the method for dynamically allocating resources according to a specific implementation method;
[0026] Figure 4 A diagram of a dynamic interface calling and resource allocation method described in a specific implementation manner;
[0027] Figure 5 It is the dynamic interface calling storage medium described in the specific implementation method. DETAILED DESCRIPTION
[0028] In order to explain the technical content, structural features, achieved objectives and effects of the technical solution in detail, the following is a detailed description in conjunction with specific embodiments and accompanying drawings.
[0029] In some embodiments of this solution, HTTP can be used for communication and interaction, enabling the transmission of both unformatted and formatted data. Within the RPC framework, relevant interface calls can be made. The RPC framework principle, in simple terms, consists of a three-party model: consumer (user or initiator), registration center, and service provider (recipient). Building a service center is the core of this model.
[0030] In such Figure 1 In the embodiment shown, the scheme introduces a dynamic interface calling method, which can be executed in a service center and includes the following steps:
[0031] S1 receives the first request from the initiator, obtains the target address of the receiver and the parameters of the transmission according to the received first request,
[0032] S2 stores each call request in the database, collects statistics on the stored requests, generates a request information list, and divides the stored requests into several request categories according to the similarity of the items in the list.
[0033] S3 compares the initiator's first request with the request information list and classifies the first request.
[0034] S4 allocates the first request to the generated first interface for calling according to the classification result.
[0035] In certain specific embodiments, upon receiving a service request, such as the first request, through the HTTP protocol framework, filtering and interception can be used to parse the initiator's access to the recipient's information. This information includes specific interface information, including the interface address (URI), interface parameters, and the interface return type (JSON or XML). These three elements are stored in an interface information table in the database. The interface information table stores specific interface information, such as the interface address, interface parameters, interface return type, interface type (new, deleted, changed, etc.), and other business fields. The receiving system automatically creates and generates interfaces based on this information. The system periodically extracts information from the interface information table and notifies the registration center of different interface types (new, deleted, changed, etc.) for publication, update, or cancellation. The registration center receives the notification and displays the generated interface on the system front-end. The front-end configures the interface in a canvas by pulling components. The interface's IP and port are fixed at service startup and require no configuration. The interface URI, request header parameters, and request parameters are all automatically generated.
[0036] In some specific cases, the first request will often be changed according to the needs of the initiator's testing and debugging. Under the traditional technical solution, the only way to complete the relevant interface calling solution is to coordinate the receiver to analyze the first request and write an interface based on the first request. In an embodiment of the present application, the requests that have been connected to the interface can be recorded through the request information table. When a new first request is received, the closest allocated request to the first request can be judged through various information dimensions, and thus classified into the closest request category. The most suitable generated interface can be directly and intelligently matched, and the fastest call can be made in the relevant generated interface solution, thereby improving the level of automatic matching of interface requests and saving labor costs and debugging costs.
[0037] In order to better monitor the interface environment, Figure 2In the illustrated embodiment, the solution further includes step S5 of obtaining current environmental monitoring data. The environmental monitoring data includes operational indicator data for processing units, intermediate nodes, databases, and Java applications, and generating time series data for different interface calls based on the operational indicator data. The processing units herein include hosts and master servers, and the operational indicator data also includes CPU usage, memory usage, or disk usage of the processing units. The intermediate nodes may include intermediate stacks, and the operational indicator data also includes stack memory usage, response time, or the number of active threads of the intermediate nodes. A database is a data storage repository managed and controlled by a data structure. The operational indicator data may also include the total number of database threads, number of concurrent connections, current number of connections, maximum number of connections, and empty response time. The operational environment data may also include various other indicator data such as the CPU usage of Java application processes, GC execution efficiency, and heap memory usage. System APM business monitoring data, such as request chains, exceptions, and data, may also be collected. Selecting the aforementioned operational environment data can effectively reflect the operational status of the device. Acquiring environmental monitoring data allows for better real-time detection and acquisition of the operational status of the interfaces.
[0038] In other embodiments of this application, please refer to Figure 3 , further comprising step S6 of calculating, based on the received first request, the expected change in operating indicator data that may result from receiving the first request, and dynamically allocating resources to different interfaces based on the expected result. Dynamically here means that after the first request is automatically allocated to the preset, already created first interface, the change in operating indicator data is automatically calculated, and based on the allocation result, the corresponding resource allocation method after receiving the first request is immediately found, thereby achieving the technical effect of timely adjusting system resource allocation and improving the practicality of intelligent matching interfaces.
[0039] In some embodiments of the present application, the request information list includes the interface address, interface parameters, time distribution of interface calls, or interface response status. The request information is information that may be included in the business request, and the above request information can better characterize the type of the first request. It provides a basis for the classification of the first request. In a specific embodiment, the back-end service will regularly perform merge statistics based on this data, and the statistical results will form a request information list. The information in the list includes: interface address, interface parameters, number of interface appearances, time distribution of interface calls, interface response status (delay, timeout, exception), etc., and finally compared with the interface information table in the database. Through similarity or equality calculations, the recommended results of a certain type of request are obtained: error request, change request, security attack, etc. If an initiator subsequently initiates a request to the system, the system will first call the statistical results for comparison. The comparison here has three aspects: similarity comparison of interface addresses, integrity comparison of parameters, etc., to roughly obtain which type of interface this type belongs to.
[0040] For other comprehensive examples, see Figure 4 A dynamic interface calling method can be executed in a service center and includes the following steps:
[0041] S1 receives the first request from the initiator, obtains the target address of the receiver and the parameters of the transmission according to the received first request,
[0042] S2 stores each call request in the database, collects statistics on the stored requests, generates a request information list, and divides the stored requests into several request categories according to the similarity of the items in the list.
[0043] S3 compares the initiator's first request with the request information list and classifies the first request.
[0044] S4 allocates the first request to the generated first interface for calling according to the classification result.
[0045] S5 obtains current environment monitoring data, which includes operation index data of processing units, intermediate nodes, databases, and Java applications, and generates time series data of different interface calls based on the operation index data.
[0046] S6 calculates, based on the received first request, the expected changes in operating indicator data that may be caused by accessing the first request, and dynamically allocates resources to different interfaces based on the expected results.
[0047] The above method can intelligently and immediately allocate a first interface to connect with a newly received first request based on the first request. Furthermore, it can calculate the expected changes in operating indicator data after the first request is received, and promptly adjust and allocate system resources. This can achieve the technical effect of better debugging of business requests.
[0048] In other comprehensive embodiments, the HTTP protocol framework, after filtering and interception, can specifically parse the relevant information related to the initiator's access to the recipient. This information includes specific interface information, which includes the interface address URI, interface parameters, and the interface return type (JSON or XML). These three elements are stored in an interface information table in the database. The interface information table stores specific interface information, such as the interface address, interface parameters, interface return type, interface type (new, deleted, changed, etc.), and other business fields. The receiving system automatically creates and generates interfaces based on this information. The system periodically extracts information from the interface information table and notifies the registration center of different interface types (new, deleted, changed, etc.) for publication, update, or cancellation. The registration center then receives the notification. The created interface is displayed on the system front end, configured in a canvas by pulling components. The interface IP and port are fixed at service startup and require no configuration. The interface URI, request header parameters, and request parameters are all automatically generated. Simply configure the interface and execute the service according to your needs. Based on the business execution results, the service center converts them into the appropriate format (XML or JSON) and returns them to the initiator. After the interface is created, the front-end needs to configure the corresponding data flow. The process execution process is the actual business processing. After the process is completed, the data is returned to the interface side, and the interface side pushes the returned content to the caller. The data format for the interface to connect with the business process is specified as {code, msg, data}, where code is the identifier, msg is the description, and data is the data content. The interface retrieves the content and returns it based on the identifier. If the business requires a specific return format, configure the corresponding logic class to implement it.
[0049] When the same interface is accessed, the service center uses big data from previous calls to determine whether the current request is an error or a change. It then updates the interface and displays the results on the front-end, allowing users to make adjustments based on the actual situation. The system first stores each request in a big data ElasticSearch repository. The back-end service periodically aggregates and compiles statistics based on this data, generating a request information list. This list includes information such as the interface address, interface parameters, number of interface occurrences, call time distribution, and response status (latency, timeout, and exceptions). This list is then compared with the interface information table in the database, and similarity or equality calculations are used to determine recommended results for specific request types: error request, change request, security attack, and so on. If a subsequent initiator initiates a request to the system, the system first compares the statistical results. This comparison involves three aspects: interface address similarity and parameter integrity, to roughly determine the type of interface. The service center plays a bridging role, not only receiving access to various requests but also ensuring interoperability between interfaces. In addition to these functions, it also incorporates intelligent analysis mechanisms that combine time-series data from interface calls for trend analysis. The intelligent analysis mechanism leverages big data from both software and hardware. The system regularly collects operational monitoring data from the current environment, including metrics for hosts or services (CPU, memory, and disk usage), middleware (current stack memory usage, response time, and number of active threads), databases (total number of threads, concurrent connections, current number of connections, maximum number of connections, and empty response time), and Java applications (process CPU usage, GC efficiency, and heap memory usage). System APM (APM) monitoring data (request chain, exceptions, and concurrency) is also collected. Combining this monitoring data, the system regularly generates a time series data list for interface calls. The list details the usage of various metrics within the current timeframe, such as high CPU and memory usage, excessive database concurrent connections, and high request concurrency. Time series data analysis identifies resource usage levels for each time period, such as high, medium, or low. Trend analysis predicts the level of request access to the interface at a specific point in time, and then optimizes scheduling at the software level based on these levels. Intelligently allocates resources to frequently used interfaces, those with high processing volume and high response time requirements, and freezes or disables low-utilization interfaces to ensure high performance and stability. Intelligent analysis determines whether an interface's resource usage is high or low during the current time period.Under stressful circumstances, the system will allocate more threads at the software level to handle current transactions, tighten CPU scheduling, allocate more memory for processing, and ensure service stability and improve response time through service timeouts, circuit breakers, degradation, current limiting and other measures. At the same time, through dynamic control of local and global variables, local cache or distributed cache can be used (such as setting storage timeouts for hot and cold data, improving cache hits, etc., which can improve response time), and the priority of the data processing queue is improved; in idle situations, multi-threaded processing is switched to single-threaded processing, and the service policy does not set timeouts, circuit breakers, current limiting, etc., so the database can create connections more freely and allocate them on demand.
[0050] The system will store the data of each interface request in the big data ElasticSearch library. The back-end service will regularly classify and count these data by interface, calculate the concurrency, request volume, response time, resource usage, etc. of each interface in each time period, and form a time list. Based on these time series data, trend analysis is used to determine whether the current interface request is in a time period with high concurrency, large processing volume, and tight resource utilization. The above-mentioned comprehensive embodiment can achieve the technical effect of adapting the created interface according to different business needs, adjusting resource allocation in a timely manner, and improving testing efficiency.
[0051] In such Figure 5 In the embodiment shown, a dynamic interface calling storage medium 500 is shown, which stores a computer program. When the computer program is executed, the following steps are performed:
[0052] Receive the first request of the initiator, obtain the target address of the receiver and the parameter content of the transmission based on the received first request, store the request of each call in a database, count the stored requests, generate a request information list, divide the stored requests into several request categories according to the similarity of the items in the list, compare the first request of the initiator with the request information list, classify the first request, and assign the first request to the generated first interface for calling according to the classification result.
[0053] The above-mentioned storage medium can record the requests that have been connected to the interface through the request information table. When a new first request is received, it can judge the closest allocated request to the first request through various information dimensions, and thus classify it into the closest request category, directly and intelligently match the most suitable generated interface, and can make the fastest call in the relevant generated interface solution, thereby improving the level of automatic matching of interface requests and saving labor costs and debugging costs.
[0054] In some embodiments of the present application, the computer program also executes steps including obtaining current environmental monitoring data when being run, wherein the environmental monitoring data includes operating indicator data of the processing unit, intermediate node, database, and Java application, and generating timing data of different interface calls based on the operating indicator data.
[0055] In some embodiments of the present application, the computer program, when being executed, further executes steps including calculating, based on the received first request, the expected changes in operating indicator data that may be brought about by accessing the first request, and dynamically allocating resources to different interfaces based on the expected results.
[0056] In some embodiments of the present application, the operating indicator data also includes the CPU usage, memory usage, disk usage of the processing unit, stack memory usage of the intermediate node, response time, or the number of active threads.
[0057] In some embodiments of the present application, the request information list includes an interface address, interface parameters, time distribution of interface calls, or interface response status.
[0058] The above solution can intelligently and immediately allocate a first interface to connect to a newly received first request based on the first request. Furthermore, it can calculate the expected changes in operating indicator data after the first request is received, and promptly adjust and allocate system resources. This can achieve the technical effect of better debugging of business requests.
[0059] It should be noted that although the above embodiments have been described herein, this does not limit the scope of patent protection of the present invention. Therefore, based on the innovative concept of the present invention, changes and modifications to the embodiments described herein, or equivalent structural or equivalent process transformations made using the contents of the present invention's specification and drawings, and direct or indirect application of the above technical solutions to other related technical fields, are all included in the scope of patent protection of the present invention.
Claims
1. A dynamic interface calling method, characterized in that: The following steps are included: Receive the first request from the initiator, obtain the target address of the receiver and the parameter content of the transmission according to the received first request, Store the request of each call in the database, collect statistics on the stored requests, generate a request information list, and divide the stored requests into several request categories according to the similarity of the items in the list. Compare the first request of the initiator with the request information list and classify the first request, Allocating the first request to the generated first interface for calling according to the classification result; The request information list includes the interface address, interface parameters, time distribution of interface calls, or interface response status; The method also includes the steps of obtaining current environmental monitoring data, wherein the environmental monitoring data includes operating indicator data of the processing unit, intermediate node, database, and Java application, and generating time series data of different interface calls based on the operating indicator data; The operation indicator data also includes the CPU usage, memory usage, disk usage of the processing unit, stack memory usage of the intermediate node, response time, or number of active threads; The method further includes the steps of calculating, based on the received first request, the expected changes in operating indicator data that may be brought about by accessing the first request, and dynamically allocating resources to different interfaces based on the expected results.
2. A dynamic interface calling storage medium, characterized in that: A computer program is stored, and when the computer program is run, the steps include: Receive the first request from the initiator, obtain the target address of the receiver and the parameter content of the transmission according to the received first request, Store the request of each call in the database, collect statistics on the stored requests, generate a request information list, and divide the stored requests into several request categories according to the similarity of the items in the list. Compare the first request of the initiator with the request information list and classify the first request, Allocating the first request to the generated first interface for calling according to the classification result; The request information list includes the interface address, interface parameters, time distribution of interface calls, or interface response status; When the computer program is executed, the computer program further performs the steps of obtaining current environmental monitoring data, the environmental monitoring data including operating indicator data of the processing unit, the intermediate node, the database, and the Java application, and generating time series data of different interface calls based on the operating indicator data; The operation indicator data also includes the CPU usage, memory usage, disk usage of the processing unit, stack memory usage of the intermediate node, response time, or number of active threads; When the computer program is executed, the computer program further executes the steps of calculating, based on the received first request, the expected changes in operating indicator data that may be caused by accessing the first request, and dynamically allocating resources to different interfaces based on the expected results.
Citation Information
Patent Citations
Service interface monitoring method and device, electronic equipment and storage medium
CN111324520A
Interface call management method and device under micro-service architecture, server and medium
CN112199426A
Interface access method and device, equipment and medium
CN113656473A