Nodejs service declarative interface performance optimization device and method

The Nodejs service declaration interface optimization system addresses inefficiencies in managing complex business scenarios by optimizing API calls through parallel processing and error handling, improving performance and reducing development costs.

CN119883552APending Publication Date: 2025-04-25CHENGDU NEW HOPE FINANCIAL INFORMATION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411950561.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

Existing interface call technologies in Nodejs services lack the ability to efficiently manage complex and dynamic business scenarios, leading to inefficient performance, high development costs, and poor user experience due to inadequate handling of interdependent and independent interface calls.

Method used

A Nodejs service declaration interface optimization system comprising a declaration schema definition module, schema parser, and API scheduler that analyzes and optimizes API dependencies, performs parallel processing, and ensures error handling to enhance performance and flexibility.

Benefits of technology

The system improves interface call efficiency, reduces development costs, and ensures consistent integration across projects by optimizing API calls through parallel processing and robust error handling, thus enhancing user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883552A_ABST
    Figure CN119883552A_ABST
Patent Text Reader

Abstract

The invention provides a Nodejs service declarative interface performance optimization device and method, relates to the technical field of interface performance optimization, and aims to realize high-efficiency, high-flexibility and high-cost-performance interface services oriented to complex businesses. The device comprises a declarative schema definition module, a schema analyzer and an AP I scheduler; the declarative schema definition module is used for describing a structure and a rule of interface aggregation and defining basic information of the AP I; the schema analyzer is used for analyzing and processing the schema configuration and converting the schema configuration into an executable scheduling instruction, and the analysis and processing of the schema configuration comprises verification of the legality of the schema configuration and analysis of an AP I dependency relationship; and the AP I scheduler is used for executing interface calling and result processing. The method has the advantages of high data acquisition efficiency, fast response and flexible processing of complex tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of interface performance optimization, and in particular to a Nodejs service declarative interface performance optimization device and method. Background Art

[0002] With the rapid development of application software development, application functions are becoming increasingly complex, and the demand for flexible, efficient and personalized business scenarios has led to the widespread use of a large number of interface calls in applications.

[0003] The number of application requests has increased dramatically, and the demand for data interaction is also increasing. The requirements for interface performance optimization and user experience are becoming increasingly stringent. Application development needs to solve the problems of insufficient performance and flexibility caused by a large number of interfaces. For example, in the process of application development, it is necessary to reasonably design interface calls according to business requirements, scenario configuration requirements, etc. For example, an application homepage needs to request product lists, merchant configuration, user information, advertising information, agent tasks, message notifications, data statistics and other interfaces. Some of these interfaces are related and require multiple HTTP requests to complete the complete data acquisition; some are not related and can be completed in a unified concurrent manner. If these situations cannot be balanced well, it will lead to slow page loading, low performance and poor user experience. In the current technical solution, interface call developers classify interfaces and rely on the HTTP client or third-party request library that comes with the client framework for calling. These solutions often only provide basic request capabilities and lack scenario-based dynamic combination capabilities, making it difficult to meet complex and changing business needs. Developers need to write a lot of template code to implement interface aggregation, which increases development costs and maintenance difficulties.

[0004] Therefore, it is necessary to optimize the interface and optimize its performance to achieve high-efficiency, high-flexibility and cost-effective interface services for complex businesses. Summary of the invention

[0005] The purpose of the present invention is to provide a Nodejs service declarative interface performance optimization device and method, which can realize high-efficiency, high-flexibility and high-cost-performance interface services for complex businesses.

[0006] The present invention is achieved through the following technical solutions:

[0007] A Nodejs service declarative interface performance optimization device, comprising a declarative schema definition module, a schema parser and an API scheduler;

[0008] The declarative schema definition module is used to describe the structure and rules of interface aggregation and define the basic information of the API;

[0009] The schema parser is used to parse and process the schema configuration and convert it into executable scheduling instructions. Parsing and processing the schema configuration includes verifying the legitimacy of the schema configuration and parsing the API dependency.

[0010] The API scheduler is used to execute interface calls and result processing.

[0011] Preferably, the basic information of the API includes API name, interface parameters, dependencies, aggregation logic, concurrency configuration, and data conversion rules.

[0012] Preferably, parsing the API dependency relationship includes analyzing the API relationship, deduplicating and merging the APIs, and calculating the key execution path.

[0013] Preferably, the method for analyzing API relationships is:

[0014] Verify the validity of the parameters declared in the schema. If a parameter is missing, an exception is returned.

[0015] If the schema declaration is correct, declare each API dependency es in a loop to generate two relationship trees: an API dependency tree and an API non-dependency tree;

[0016] The API deduplication and merging are performed while looping the declaration.

[0017] Preferably, the method for performing API deduplication and merging is:

[0018] Get the API_ID of all APIs;

[0019] According to the uniqueness of API_ID, check whether there are repeated API declarations through the API_IDs of all APIs, and remove duplicates if there are duplicates.

[0020] Preferably, the method for calculating the critical execution path is:

[0021] According to the dependent API tree and the independent API tree, API parallel groups are allocated and request task groups are generated.

[0022] Preferably, the method for executing interface call and result processing is:

[0023] Create a request task according to the scheduling instruction generated by the Schema parser;

[0024] Make concurrent requests to APIs in batches and handle the aggregation logic of API dependencies;

[0025] Execute data conversion rules according to responseMapp ing configuration rules, unify error handling mechanisms, and assemble final response results.

[0026] In order to solve the above problems, the present invention also provides a Nodejs service declarative interface performance optimization method, which is applied to the above-mentioned Nodejs service declarative interface performance optimization device, and includes the following steps:

[0027] Design interface schema configuration according to business scenarios;

[0028] The client applies the interface Schema and defines the basic information of the API through the declarative schema definition module;

[0029] The client initiates a request, and the Nodejs service declarative interface performance optimization device receives the request Schema;

[0030] Read the schema configuration in the request schema through the schema resolver, verify the legitimacy of the schema configuration, and resolve the API dependency;

[0031] The Schema parser calculates the execution order to achieve API deduplication and concurrent grouping;

[0032] Execute interface calls, create request task queues, perform batch concurrent requests, and obtain API response data according to the execution order and the concurrent grouping results through the API scheduler;

[0033] Execute data conversion rules, process response results, unify error handling, and assemble final data;

[0034] Return the final data to the client.

[0035] The technical solution of the present invention has at least the following advantages and beneficial effects:

[0036] The present invention can analyze the dependency relationships among multiple APIs, perform concurrent processing on the APIs that can be requested concurrently, and optimize service performance by performing batch concurrent requests based on the API relationships, thereby improving interface request efficiency and reducing time consumption.

[0037] The interface combination capability of the present invention is flexible, can adapt to dynamically changing business scenarios, and has a unified interface aggregation specification, so the implementation methods of accessing different projects are more consistent;

[0038] The present invention can improve the error handling and fault tolerance mechanism to ensure business stability;

[0039] The interface parsing and optimization capabilities of the present invention are strong, which helps to fully utilize the concurrent processing capabilities of the server, thereby improving processing efficiency;

[0040] The present invention is reasonably designed, easy to deploy to various application scenarios requiring interface services, and has high cost performance and flexibility. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 A schematic diagram of the structure of a Nodejs service declarative interface performance optimization device provided in Example 1 of the present invention;

[0042] Figure 2 This is a diagram showing the analytical effect provided by Example 1 of the present invention;

[0043] Figure 3 A flow chart of the Nodejs service declarative interface performance optimization method provided in Example 2 of the present invention. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0045] Example 1

[0046] This embodiment provides a Nodejs service declarative interface performance optimization device, see Figure 1 , which communicates with the client and the API service, including a declarative schema definition module, a schema parser, and an API scheduler;

[0047] The declarative schema definition module is used to describe the structure and rules of interface aggregation and define the basic information of the API;

[0048] The schema parser is used to parse and process the schema configuration and convert it into executable scheduling instructions, wherein parsing and processing the schema configuration includes verifying the legitimacy of the schema configuration and parsing the API dependency;

[0049] The API scheduler is used to execute interface calls and result processing.

[0050] The Nodejs service declarative interface performance optimization device of this embodiment can perform relationship analysis on multiple APIs, merge and process the original multiple interfaces, and improve service performance and response speed and reduce operation and maintenance costs through optimal execution order calculation, concurrent requests, optimized cache, etc.

[0051] In this embodiment, the basic information of the API includes the API name, interface parameters, dependencies, aggregation logic, concurrency configuration, and data conversion rules.

[0052] Generally speaking, the API in the shema generally includes the following information:

[0053] API_ID, unique ID of the API, used to retrieve and use the API;

[0054] params, request parameters;

[0055] dependencies, API dependency declaration, including the API_ID that A depends on and the corresponding API parameters;

[0056] responseMapp i ng, mapping rules for response data.

[0057] As a preferred solution of this embodiment, the parsing of API dependency relationships preferably includes analyzing API relationships, performing API deduplication and merging, and calculating key execution paths.

[0058] In other words, the schema parser can mainly verify the legitimacy of the schema configuration, analyze API dependencies, determine the execution order, split API concurrent groups, implement request deduplication and merging, and generate standardized scheduling instructions for the API scheduler.

[0059] Wherein, the method for analyzing API relationship is preferably:

[0060] Verify the validity of the parameters declared in the schema. If a parameter is missing, return an exception. The parameters can include the information that the API generally includes, such as API_ID, params, and responseMapping.

[0061] If the schema declaration is correct, declare each API dependency es in a loop to generate two relationship trees: an API dependency tree and an API non-dependency tree;

[0062] The API deduplication and merging are performed while looping the declaration.

[0063] Next, the method for performing API deduplication and merging is preferably:

[0064] Get the API_ID of all APIs;

[0065] According to the uniqueness of the API_ID, it is confirmed whether there is a duplicate API declaration through the API_ID of all APIs, and if there is a duplicate, it is removed. That is to say, in this embodiment, only one request is made to the API declared duplicated.

[0066] Then, the method for calculating the critical execution path may be:

[0067] According to the dependent API tree and the non-dependent API tree, API parallel groups are allocated and request task groups are generated, wherein the dependent API tree is a dependency tree between dependent APIs, and the non-dependent API tree is an independent API without internal dependencies.

[0068] See also Figure 2 The following figure shows the parsing effect. By performing dependency analysis and concurrent grouping on the API, the request steps can be reduced and the execution efficiency can be improved.

[0069] Finally, the method for executing the interface call and result processing is:

[0070] Create a request task according to the scheduling instruction generated by the Schema parser;

[0071] Make concurrent requests to APIs in batches and handle the aggregation logic of API dependencies;

[0072] Execute data conversion rules according to responseMapp ing configuration rules, unify error handling mechanisms, and assemble final response results.

[0073] In other words, the API scheduler is responsible for the actual execution of interface calls and result processing, creating request tasks according to the instructions parsed by the Schema parser, implementing efficient concurrency control, batching concurrent API requests, processing the aggregation logic of API dependencies, handling request timeouts and retries, executing data conversion rules according to responseMapping configuration rules, unifying the error handling mechanism, and assembling the final response results.

[0074] Example 2

[0075] This embodiment provides a Nodejs service declarative interface performance optimization method, which is applied to a Nodejs service declarative interface performance optimization device in the above embodiment. Figure 3 , including the following steps:

[0076] Design interface schema configuration according to business scenarios;

[0077] The client applies the interface Schema and defines the basic information of the API through the declarative schema definition module;

[0078] The client initiates a request, and the Nodejs service declarative interface performance optimization device receives the request Schema;

[0079] Read the schema configuration in the request schema through the schema resolver, verify the legitimacy of the schema configuration, and resolve the API dependency;

[0080] The Schema parser calculates the execution order to achieve API deduplication and concurrent grouping;

[0081] Execute interface calls, create request task queues, perform batch concurrent requests, and obtain API response data according to the execution order and the concurrent grouping results through the API scheduler;

[0082] Execute data conversion rules, process response results, unify error handling, and assemble final data;

[0083] Return the final data to the client.

[0084] Based on the above scheme, this embodiment implements the client specifying the required data through declarative interface combination configuration, without obtaining redundant or unnecessary information, improving the efficiency of data acquisition and reducing the overhead of data transmission; it also optimizes service performance and reduces response time through concurrency control and scheduling mechanisms, batches concurrent requests according to API relationships; it can also improve error handling and fault tolerance mechanisms to ensure business stability.

[0085] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A Nodejs service declarative interface performance optimization device, characterized in that: Includes declarative schema definition module, schema parser and API scheduler; The declarative schema definition module is used to describe the structure and rules of interface aggregation and define basic information of the API; The schema parser is used to parse and process the schema configuration and convert it into executable scheduling instructions. Parsing and processing the schema configuration includes verifying the legitimacy of the schema configuration and parsing API dependencies. The API scheduler is used to execute interface calls and result processing.

2. A Nodejs service declarative interface performance optimization device according to claim 1, characterized in that: The basic information of the API includes API name, interface parameters, dependencies, aggregation logic, concurrency configuration, and data conversion rules.

3. A Nodejs service declarative interface performance optimization device according to claim 1, characterized in that: The parsing of API dependencies includes analyzing API relationships, deduplicating and merging APIs, and calculating key execution paths.

4. A Nodejs service declarative interface performance optimization device according to claim 3, characterized in that: The method for analyzing API relationships is: Verify the validity of the parameters declared in the schema. If a parameter is missing, an exception is returned. If the schema declaration is correct, declare each API dependency in a loop to generate two relationship trees: a dependent API tree and an independent API tree; The API deduplication and merging are performed while looping the declaration.

5. A Nodejs service declarative interface performance optimization device according to claim 4, characterized in that: The method for deduplication and merging of APIs is as follows: Get the API_ID of all APIs; Based on the uniqueness of API_ID, check whether there are duplicate API declarations through the API_ID of all APIs, and remove duplicates if there are any.

6. A Nodejs service declarative interface performance optimization device according to claim 5, characterized in that: The method for calculating the critical execution path is: According to the dependent API tree and the independent API tree, API parallel groups are allocated and request task groups are generated.

7. A Nodejs service declarative interface performance optimization device according to claim 1, characterized in that: The method for executing interface call and result processing is: Create a request task according to the scheduling instruction generated by the Schema parser; Make concurrent requests to the API in batches and handle the aggregation logic of API dependencies; Execute data conversion rules according to responseMapping configuration rules, unify error handling mechanisms, and assemble final response results.

8. A Nodejs service declarative interface performance optimization method according to claim 1, applied to a Nodejs service declarative interface performance optimization device according to any one of claims 1-7, characterized in that: The following steps are involved: Design interface schema configuration according to business scenarios; The client applies the interface Schema and defines basic information of the API through the declarative schema definition module; The client initiates a request, and the Nodejs service declarative interface performance optimization device receives the request Schema; Read the schema configuration in the request schema through the schema resolver, verify the legitimacy of the schema configuration, and resolve API dependencies; The execution order is calculated by the Schema parser to achieve API deduplication and concurrent grouping; Execute interface calls, create request task queues, perform batch concurrent requests, and obtain API response data through the API scheduler according to the execution order and the concurrent grouping results; Execute data conversion rules, process response results, unify error handling, and assemble final data; Return the final data to the client.