API gateway migration verification method and system based on traffic mirroring, medium and equipment

By employing traffic mirroring and eventual consistency verification methods, the stability and security issues of API gateways when migrating to a domestic IT innovation environment are resolved, ensuring that the migrated API gateways operate correctly in the domestic IT innovation environment and improving verification efficiency and system stability.

CN121098728APending Publication Date: 2025-12-09TRAVELSKY TECHNOLOGY LIMITED
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511171584.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-20
Publication Date
2025-12-09

AI Technical Summary

Technical Problem

When migrating API gateways to a domestic IT innovation environment, existing technologies cannot ensure that the migrated API gateways operate correctly, stably, and efficiently. Furthermore, traditional traffic mirroring methods may affect the stability of the production environment and fail to meet high security requirements.

Method used

By employing traffic mirroring and eventual consistency verification, traffic information from the production environment is recorded, categorized, stored, and forwarded to the domestic IT innovation environment via multiple threads. Performance metrics and business consistency are monitored and compared to ensure the correctness of the overall business process at the system level.

Benefits of technology

It enables efficient verification of the API gateway's functionality and performance stability in a domestic IT innovation environment without affecting the existing production environment, identifying potential problems, reducing migration risks, and ensuring business continuity and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121098728A_ABST
    Figure CN121098728A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of gateways, in particular to an API gateway migration verification method and system based on a flow mirror image, a medium and equipment, and the method comprises the steps: recording the flow information of an API gateway called by a production environment; recovering the recorded traffic information to the original traffic; the restored original flow is forwarded to a credential environment in a multi-thread mode; and monitoring and comparing the performance indexes of the API gateway in the creative environment and the original production environment, and comparing the final consistency of each business index of the creative environment and the original production environment under the same flow. According to the method, flow mirroring and final consistency verification are adopted, the existing production environment is not affected, the correctness of the whole business process can be grasped from the system level, the interaction problem between interfaces can be found, the verification efficiency is improved, and the actual requirement of API gateway information creation environment migration verification can be better met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of gateway technology, and in particular to an API gateway migration verification method, system, medium, and device based on traffic mirroring. Background Technology

[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.

[0003] The information technology application innovation industry refers to the industry that, through independent research and development and innovation in the field of information technology, establishes a domestic information technology software and hardware underlying architecture system and a full-cycle ecosystem, so as to achieve controllability, researchability, developmentability and productionability in the field of information technology, and aims to achieve independent controllability in the field of information technology and safeguard national information security.

[0004] API gateways, as a key component connecting clients and backend services, play a central role in modern application architectures. They provide a unified access point for numerous microservices and undertake critical responsibilities such as traffic management, security authentication, and service routing. When migrating API gateways to a domestically developed IT environment, the significant differences in hardware, operating systems, databases, and other infrastructure between the domestic and traditional environments present considerable challenges during migration and verification. API stands for Application Programming Interface, which enables communication between computer software.

[0005] Ensuring the correct, stable, and efficient operation of the migrated API gateway to meet diverse business needs has become a pressing issue when migrating to a domestically developed IT environment. Traffic mirroring, in essence, is a technology that can accurately copy specific network traffic and forward it to a designated target location without interfering with the normal transmission and processing of the original business traffic.

[0006] In terms of implementation, traffic mirroring can be achieved through various technical means, from the underlying hardware to the application software. At the network device level, many network switches support traffic mirroring, which can be implemented by configuring port mirroring. At the application level, taking the common Nginx service as an example, traffic forwarding rules and target addresses can be specified through configuration files. However, all of the above methods require modification of the original environment, whether hardware or software, which may compromise the stability of the original environment and is not suitable for use cases requiring extremely high security. Summary of the Invention

[0007] To overcome the shortcomings of the prior art, this invention provides an API gateway migration verification method, system, medium, and device based on traffic mirroring. It adopts traffic mirroring and eventual consistency verification, which not only does not affect the existing production environment, but also grasps the correctness of the overall business process at the system level, discovers interaction problems between interfaces, and improves verification efficiency. It can better meet the actual needs of API gateway migration verification in the domestic IT innovation environment.

[0008] To achieve the above objectives, the present invention provides the following technical solution: Firstly, a method for verifying API gateway migration based on traffic mirroring is provided, the method comprising: Record traffic information from the production environment calling the API gateway; Restore the recorded traffic information to the original traffic; The restored original traffic is forwarded to the domestic IT innovation environment via multiple threads; Monitor and compare the performance metrics of the API gateway in the domestic IT innovation environment and the original production environment, and compare the final consistency of various business metrics in the domestic IT innovation environment and the original production environment under the same traffic.

[0009] Furthermore, Before recording traffic information from API gateway calls in the production environment, offline knowledge preparation is also included, which includes: Record the traffic within the first preset time period, extract the structure of the interface request message, and combine it with the interface name to form a vocabulary field; Clustering algorithms are used to cluster the vocabulary fields; If the number of clusters of an interface is less than N and the number of calls is greater than K, then the interface is classified as a type A interface; otherwise, the interface is classified as a non-type A interface. Here, N and K are both natural numbers. The interface name, vocabulary ID, and vocabulary fields are combined to form a vocabulary and saved to the database.

[0010] Furthermore, The recorded traffic information of the production environment calling the API gateway includes: Record basic information about request traffic within a second preset time period using a message middleware; Record the request message portion corresponding to the request within the second preset time period using the caching middleware.

[0011] Furthermore, The recording of traffic information from the production environment calling the API gateway also includes: The traffic basic information within the second preset time period is obtained by querying the message middleware. The traffic basic information includes transaction number, interface name, user authentication related information, request time, and request header information. Based on the queried traffic information, obtain the corresponding request message, and then prepare and classify the request information corresponding to the request message according to offline knowledge.

[0012] Furthermore, The step of obtaining the corresponding request message based on the queried traffic basic information includes: Use the transaction number of the traffic obtained from querying basic traffic information as a unique identifier to retrieve the request message corresponding to the transaction number.

[0013] Furthermore, The step of preparing the corresponding request information for the classified storage request message based on offline knowledge includes: Based on offline knowledge, the corresponding interfaces for request messages are classified. Based on the classification results of the interface, the corresponding request information of the request message is stored in categories.

[0014] Furthermore, The process of classifying and storing the corresponding request information of the request message according to the classification result of the interface includes: If the interface belongs to type A, then store the transaction number, vocabulary ID, and corresponding values ​​of the vocabulary fields in the cache middleware; If the interface is not a type A interface, then store the transaction number and the original request message in the cache middleware.

[0015] Furthermore, The process of restoring the recorded traffic information to the original traffic includes: Basic traffic information for the second preset time period is obtained by querying the message middleware; Based on the transaction number of the traffic obtained from the basic traffic information, the stored request information is retrieved from the cache middleware and restored to the original traffic.

[0016] Furthermore, The monitoring compares the performance metrics of the API gateway in the domestic IT innovation environment and the original production environment, and compares the final consistency of various business metrics between the domestic IT innovation environment and the original production environment under the same traffic, including: Obtain the hardware and software metrics of the API gateway in the domestic IT innovation environment and the original production environment, and perform real-time monitoring and comparison. Organize the business data and status information of the domestic IT innovation environment and the original production environment under the same traffic, and compare them for eventual consistency.

[0017] Secondly, a migration verification system for an API gateway in a domestic IT innovation environment based on traffic mirroring is also provided, characterized in that the system includes: The traffic recording module is used to record traffic information of API gateway calls in the production environment; The traffic integration module is used to restore the recorded traffic information to the original traffic. The traffic forwarding module is used to forward the restored original traffic to the domestic IT innovation environment in a multi-threaded manner. The monitoring and comparison module is used to monitor and compare the performance indicators of the API gateway in the domestic IT innovation environment and the original production environment, and to compare the final consistency of various business indicators between the domestic IT innovation environment and the original production environment under the same traffic.

[0018] Based on the same inventive concept, the present invention also provides a computer-readable storage medium storing one or more programs, which, when executed, can realize the API gateway migration verification method based on traffic mirroring as described above.

[0019] Based on the same inventive concept, the present invention also provides an electronic device, including a processor, a communication interface, a computer-readable storage medium as described above, and a communication bus; wherein the processor, the communication interface, and the computer-readable storage medium communicate with each other through the communication bus; the processor is used to execute a program stored in the computer-readable storage medium.

[0020] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. Based on traffic mirroring, the traffic of the production environment is replicated without affecting the existing production environment. It is suitable for environments with high security requirements and adopts eventual consistency verification. Compared with verifying each interface one by one, the eventual consistency verification verifies whether the final results generated by the two environments (i.e., the domestic innovation environment and the original production environment) are consistent under the same traffic. It can grasp the correctness of the overall business process at the system level, discover the interaction problems between interfaces, and improve the verification efficiency. Therefore, it can better meet the actual needs of API gateway migration verification in the domestic innovation environment. 2. Using categorized interface storage improves verification efficiency. Categorized storage can classify requests based on the characteristics of different interfaces using clustering algorithms, reducing the storage of duplicate request messages and improving query efficiency. 3. Using multi-threaded forwarding can handle multiple traffic forwarding tasks simultaneously, and while waiting for network data transmission, threads can execute other tasks, thereby improving the overall performance of the system.

[0021] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures pointed out in the description, claims and drawings.

[0022] The invention will now be further described with reference to the accompanying drawings. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 This is a flowchart illustrating an embodiment of the API gateway migration verification method based on traffic mirroring according to the present invention. Figure 2 This is a schematic diagram of the overall structure of an API gateway migration verification system based on traffic mirroring according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0025] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0026] like Figure 1 As shown, the first embodiment of the present invention provides an API gateway migration verification method based on traffic mirroring, the method comprising the following steps: S1. Record traffic information for API gateway calls in the production environment; S2. Restore the recorded traffic information to the original traffic; S3. Forward the restored original traffic to the domestic IT innovation environment via multiple threads; S4. Monitor and compare the performance indicators of the API gateway in the domestic IT innovation environment and the original production environment, and compare the final consistency of various business indicators between the domestic IT innovation environment and the original production environment under the same traffic.

[0027] In the above technical solution, the recorded traffic information is restored to the original traffic, i.e., mirrored traffic. Multi-threaded forwarding allows for the simultaneous handling of multiple traffic forwarding tasks, while threads execute other tasks while waiting for network data transmission, thereby improving overall system performance. This technical solution replicates production environment traffic using traffic mirroring, without affecting the existing production environment. It is suitable for environments with high security requirements and employs eventual consistency verification. Compared to comparing and verifying each interface individually, eventual consistency verification verifies whether the final results generated by the two environments (i.e., the domestically developed environment and the original production environment) are consistent under the same traffic. This allows for a system-level understanding of the correctness of the overall business process, the identification of inter-interface interaction issues, and improved verification efficiency. Therefore, it better meets the actual needs of API gateway migration verification in domestically developed environments.

[0028] In this embodiment, the multi-threaded forwarding of raw traffic to the domestic IT innovation environment is mainly based on the multi-threading characteristics of the JAVA language and the non-blocking function of NIO. On a high-performance multi-core CPU server, mirrored HTTP requests are forwarded to the gateway entry point of the domestic IT innovation environment. Java is an object-oriented programming language, and NIO is JAVA's network communication library, providing non-blocking I / O operations that can efficiently handle a large number of concurrent connections.

[0029] This embodiment employs traffic mirroring, the core purpose of which is to provide traffic data completely consistent with the actual production environment for subsequent analysis, testing, and monitoring operations. This helps technical personnel better understand the system's operation under real business loads, enabling relevant personnel to conduct comprehensive and in-depth testing of the migrated API gateway and related upstream and downstream links in a simulated real business scenario. By comparing the final results after the tests are completed, not only can the functional correctness of the API gateway in the domestic IT innovation environment be verified, but its performance, stability, and security can also be comprehensively evaluated. Potential problems can be identified and resolved in advance, thereby greatly reducing the risks of domestic IT innovation migration and ensuring business continuity and stability.

[0030] This embodiment does not focus on the differences and testing of individual interfaces, but mainly on whether the changes in the overall system caused by the overall traffic are the same. When migrating an API gateway to a domestically developed environment, the hardware, operating system, database, and other infrastructure in the domestically developed environment differ significantly from the traditional environment, posing a challenge to functional consistency during migration verification. As a unified entry point, the gateway has many users, many usage scenarios, many published interfaces, and many types of request messages. Current interface testing and verification are based on individual interfaces, using manual or automated batch testing schemes to verify partial product functions of individual interfaces. During the migration process, it is necessary to ensure business continuity and data consistency. However, the above tests are difficult to achieve the effect of verifying overall functional consistency. Therefore, this embodiment adopts eventual consistency verification, which can effectively verify overall functional consistency.

[0031] As a preferred technical solution, before recording the traffic information of the API gateway calls in the production environment, offline knowledge preparation is also included. The offline knowledge preparation includes: recording the traffic within a first preset time period, extracting the interface request message structure and forming a vocabulary field with the interface name; using a clustering algorithm to cluster the vocabulary field; if the clustering categories of the interface are less than N and the call volume is greater than K, then the interface is classified as a category A interface; otherwise, the interface is classified as a non-category A interface, where N and K are both natural numbers; and forming a vocabulary with the interface name, vocabulary ID, and vocabulary field and saving it to the database.

[0032] As a preferred technical solution, the recording of traffic information of the production environment calling the API gateway includes: recording the basic information of request traffic calls within a second preset time period through a message middleware; and recording the request message portion corresponding to the request within the second preset time period through a caching middleware.

[0033] As a preferred technical solution, the recording of traffic information of the production environment calling the API gateway further includes: obtaining basic traffic information within a second preset time period by querying the message middleware, wherein the basic traffic information includes transaction number, interface name, user authentication related information, request time, and request header information; obtaining the corresponding request message based on the queried basic traffic information, and then preparing and classifying the request information corresponding to the request message based on offline knowledge.

[0034] As a preferred technical solution, the step of obtaining the corresponding request message based on the queried traffic basic information includes: using the transaction number of the traffic obtained from the queried traffic basic information as a unique identifier to obtain the request message corresponding to the transaction number.

[0035] As a preferred technical solution, the step of preparing and classifying the request information corresponding to the request message based on offline knowledge includes: classifying the interface corresponding to the request message based on offline knowledge; and classifying and storing the request information corresponding to the request message based on the classification results of the interface.

[0036] As a preferred technical solution, the step of classifying and storing the corresponding request information of the request message according to the classification result of the interface includes: if the interface belongs to type A interface, then the transaction number, vocabulary ID, and corresponding values ​​of vocabulary fields are stored in the cache middleware; if the interface belongs to a non-type A interface, then the transaction number and the original request message are stored in the cache middleware.

[0037] To make the process of recording production environment traffic (i.e., recording traffic information of production environment calling API gateway) clearer in the embodiments of the present invention, the following further explains the recording of production environment calling API gateway traffic information in conjunction with the above-mentioned preferred technical solutions.

[0038] Gateway interfaces can be categorized into query interfaces and non-query interfaces based on the nature of their business operations. Query interfaces are primarily used to retrieve various types of data from the system. Users provide input parameters, and the interface retrieves specific data from databases, caches, or other data storage media, returning the results to the caller. Query interfaces are typically idempotent, meaning that multiple calls to the same query interface will return consistent results if the data remains unchanged. These interfaces generally have a fixed request message structure, with only the input parameters differing. Parameters are usually simple key-value pairs, and parameter values ​​are typically text or numbers, used to specify query conditions such as filtering and sorting. Non-query interfaces are used to perform operations other than querying, such as data creation, updating, and deletion. These operations alter the data state in the system. These operations are generally performed after the user has defined their requirements. The request message structure for these interfaces is diverse and may contain complex data structures, such as nested objects or arrays. Based on this interface classification, storing request messages can be done by categorizing them to reduce storage size, improve storage efficiency, and increase recording efficiency. The specific operation steps are as follows: 1. Offline knowledge preparation process: Recording (t) i-k ,t n-k Traffic within a given time period (i.e., the first preset time period) is processed using recursive traversal to extract the structure of the API request messages. The following example uses a request message from an API named testAPI: { "userInfo": { "name": "Test", "age": 25, "contact": { "phone": "1234567890", "email": "Test@example.com" } } } The extracted structure consists of `$userInfo`, `$userInfo.name`, `$userInfo.age`, `$userInfo.contact`, `$userInfo.contact.phone`, and `$userInfo.contact.email`. These, along with the interface name, form a vocabulary field, such as `[testAPI,$userInfo, $userInfo.name,$userInfo.age,$userInfo.contact,$userInfo.contact.phone, $userInfo.contact.email]`. A clustering algorithm is used to cluster these vocabulary fields. Interfaces with a cluster type less than N and a call volume greater than K (where N and K are natural numbers and can be defined based on the overall gateway call situation) are classified as type A interfaces. The interface name, vocabulary ID, and vocabulary fields are combined to form a vocabulary (i.e., `[vocabulary ID, interface name, [testAPI, $userInfo, $userInfo.name,$userInfo.age,$userInfo.contact,$userInfo.contact.phone ... $userInfo.contact.email]]) and persist (i.e., save to a permanent storage medium, here referring to saving to a database) for classification during traffic recording.

[0039] (t i-k ,t n-k The time period (i.e., the first preset time period) refers to a pre-recorded period of time. This time length may differ from the time length of (ti, tn) (i.e., the second preset time period). The first preset time period is before the second preset time period. (t i-k ,t n-k The recording of the specified time period is used as offline knowledge to classify interface types. During actual recording, this result (i.e., offline knowledge) is used to differentiate between types. The offline knowledge is prepared in advance by querying the production traffic within a certain period (the first preset time period in this embodiment) to classify the interfaces. This way, the offline knowledge can be directly used for classification during actual recording.

[0040] Clustering algorithms include, but are not limited to, the K-means algorithm and the DBScan algorithm. The K-means algorithm and the DBScan algorithm are existing technologies and will not be elaborated here.

[0041] In some embodiments, the K-means algorithm and the DBScan algorithm are combined to cluster the vocabulary fields and count the differences between the interface name and message vocabulary. For query-type interfaces (i.e., type A interfaces), the request messages are generally more consistent, and the extracted vocabulary will cluster together; for change-type interfaces (i.e., non-type A interfaces), the request message structures are generally more different, and the clustering results may show multiple clusters.

[0042] In this embodiment, the vocabulary ID uses UUID (Universally Unique Identifier), which can be used as a unique identifier.

[0043] Generally, query interfaces account for a large proportion of traffic in an API gateway, exceeding 90%, making them relatively easy to distinguish. Therefore, this embodiment categorizes interfaces into Type A interfaces and Non-Type A interfaces. Type A interfaces (i.e., query interfaces) only store field values, while Non-Type A interfaces (i.e., non-query interfaces, mainly those involving changes in request types) store the original request text. By classifying interfaces, cache storage can be reduced, and message recovery efficiency can be improved.

[0044] 2. Query basic information about message middleware traffic: Query the traffic information in the message middleware (t i ,t n Within a time range (i.e., the second preset time period, representing the actual recording and comparison period), the system obtains basic traffic information, excluding the request message, necessary for traffic recovery. This primarily includes the transaction number, interface name, user authentication information, request time, and request header information. Message middleware is a software component used in distributed systems for message delivery. It enables asynchronous communication between different applications, services, or systems, decoupling senders and receivers and ensuring reliable message delivery. Common message middleware includes open-source tools such as RabbitMQ and Kafka. Message middleware generally provides full field lookup, making it slightly slower than caching middleware. However, pushing all original messages to message middleware would result in a massive data volume, potentially reaching hundreds of gigabytes per day. Therefore, pushing original messages is not currently used in production. The purpose of obtaining basic traffic information in this embodiment is primarily to acquire the transaction number and interface name, which are then used to map the request message stored for that transaction number in the caching middleware.

[0045] 3. Store the request message in the cache middleware: Download (t i ,t nLog files that have changed within a time range (i.e., the second preset time period) are downloaded to a unified server. The purpose of downloading log files here is mainly to obtain the original logs without affecting the existing production environment. Similarly, logs can be obtained from trace tapes, but this embodiment uses the log download method, which is more convenient to implement. Based on the aforementioned offline knowledge preparation, interfaces are classified according to the basic information of the interface calls obtained by the query message middleware. If the called interface belongs to type A, the transaction number, vocabulary ID, and corresponding vocabulary field values ​​are stored in the cache middleware; otherwise, the transaction number and the original request message are stored in the cache middleware. Specifically, the transaction number of the traffic obtained by the query middleware is used as a unique identifier. The request message with the corresponding transaction number is obtained by the Linux commands grep and zgrep. According to the rules in the aforementioned offline knowledge preparation process, the interface corresponding to the request message is classified. If the interface belongs to type A, [transaction number, vocabulary ID, vocabulary field] is stored; otherwise, [transaction number, original request message] is stored.

[0046] The caching middleware used is Redis (Remote Dictionary Server), an open-source, in-memory data structure storage system that can be used as a database, cache, and message middleware. This embodiment uses Redis as the caching middleware because Redis is inherently highly efficient for simple key-value queries due to its in-memory operation, quickly locating and returning results. While Elasticsearch can also provide results quickly in simple query scenarios, compared to Redis, its index structure and query parsing process introduce some latency, and it cannot categorize and store request messages, leading to a large amount of redundant storage. Therefore, this embodiment uses Redis, which effectively improves the storage efficiency of the migration verification method in this embodiment.

[0047] Using physical hardware or Nginx Lua scripts requires modifying the original production environment, which is intrusive and may compromise the stability of the original environment. In contrast, this method uses middleware (i.e., message middleware, caching middleware) to mirror traffic (copy traffic), which has no intrusive impact on Nginx and does not affect the existing production environment. It is suitable for environments with high security requirements.

[0048] The categorized interface storage method in this invention improves verification efficiency. This method uses clustering algorithms to classify requests based on the characteristics of different interfaces, reducing the storage of duplicate request messages. Leveraging Redis's high-performance memory caching in key-value query scenarios significantly improves the efficiency of recorded traffic recovery.

[0049] Therefore, the embodiments of the present invention are actually a method for verifying the migration of domestically developed API gateways based on traffic mirroring, which utilizes middleware (i.e., message middleware and cache middleware). This method classifies and stores interfaces, and the use of cache middleware effectively improves the efficiency of traffic recovery.

[0050] As a preferred technical solution, restoring the recorded traffic information to the original traffic includes: The system retrieves basic traffic information for a second preset time period by querying the message middleware; based on the transaction number of the traffic obtained from the basic traffic information, it retrieves the stored request information from the cache middleware and restores it to the original traffic.

[0051] This embodiment restores traffic based on rules (offline knowledge preparation + categorized storage). Specifically, it queries the message middleware (t... i ,t n Within a time range (i.e., the second preset time period), traffic is processed to obtain basic information, and request message information in the cached middleware is queried based on the transaction number. If it belongs to interface type A, the original request storage structure is queried based on [transaction number, vocabulary ID, corresponding vocabulary field value] and the message is restored. Taking the testAPI interface (belonging to interface type A) as an example, the storage structure in the cached middleware is [transaction number, vocabulary ID, ["Test", 25, "1234567890", "Test@example.com"]], and the specific vocabulary is [vocabulary ID, interface name, [testAPI, $userInfo, $userInfo.name, $userInfo.age, $userInfo.contact, $userInfo.contact.phone, $userInfo.contact.email]]. The original request message is restored using these two records. If it does not belong to interface type A, the original request message is queried based on [transaction number, original request message]. Basic information obtained from the message middleware + original request restored according to the rules = mirrored traffic.

[0052] As a preferred technical solution, the monitoring and comparison of the API gateway's performance indicators in the domestic IT innovation environment and the original production environment, and the comparison of the final consistency of various business indicators in the domestic IT innovation environment and the original production environment under the same traffic, includes: obtaining the hardware and software indicators of the API gateway in the domestic IT innovation environment and the original production environment, and performing real-time monitoring and comparison; organizing the business data and status information of the domestic IT innovation environment and the original production environment under the same traffic, and comparing the final consistency.

[0053] This embodiment monitors the domestic IT innovation environment and compares it with the original production environment. Further explanation follows.

[0054] 1. Performance Metrics: Acquire and monitor various performance test metrics and their changes, performing real-time monitoring and comparison. Examples include hardware metrics such as server CPU utilization, memory utilization, and network bandwidth; and software metrics such as response time and throughput. Compare performance metrics to determine if there are significant differences and whether these differences meet expected targets.

[0055] Response time refers to the time interval from when the client sends a request to when it receives a response from the API gateway. It directly reflects the processing speed and efficiency of the API gateway. By statistically analyzing response times, we can understand the performance of the API gateway under different load conditions and determine whether it can meet the real-time requirements of the business. Throughput refers to the number of requests that the API gateway can process per unit of time.

[0056] When migrating to a domestic IT innovation environment, API gateways face performance challenges during migration verification. Gateways typically have high traffic and are deployed in a distributed manner. Since the hardware performance and software optimization level of the domestic IT innovation environment may differ from those of the traditional environment, API gateways need to be well compatible and adapted to these new domestic IT innovation components to maintain efficient and stable operation in the new environment and meet the business requirements for high concurrency and low latency. Therefore, the performance indicators monitored and compared in this embodiment include the aforementioned hardware and software indicators.

[0057] 2. Business Metrics: Organize the changes in gateway and backend application results and compare them for eventual consistency. The analyzable changes are as follows: (1) Business data: refers to business data and related data that are relevant to specific business functions. For example, (t i ,t n The final change in order volume within the time frame includes the username, contact information, and the associated order number, including order time, flight number, and cargo space information.

[0058] (2) State information: refers to the state changes of the system after the interface performs an operation, such as (t i ,t n Within a certain time frame, an order is in a state of pending payment, paid, or pending check-in.

[0059] Among these, business data and status information of the domestic IT innovation environment and the original production environment under the same traffic can be obtained by looking at cache, databases, etc.

[0060] Compared to verifying each interface individually, this embodiment compares the final results generated by all interfaces (i.e., uses eventual consistency verification). 1. Take a holistic approach: Verifying each interface individually focuses on the independence of each interface's function, while comparing the final results of all interfaces allows for a system-wide understanding of the correctness of the overall business process. For example, in an e-commerce system, from the product display interface, the add-to-cart interface, the order placement interface to the payment interface, verifying each individual interface can ensure that each step is working correctly. However, only by comparing the final order status, inventory changes, and other results can we ensure that the data flow and business logic of the entire shopping process are correct.

[0061] 2. Identify Inter-Interface Interaction Issues: Interfaces may have data transfer and dependency relationships, which may be difficult to detect through individual interface verification. By comparing the final results of all interfaces, inconsistencies caused by interface interactions can be identified. For example, if the order generation interface depends on data from the product inventory interface, and the inventory interface returns incorrect data or the order generation interface processes inventory data improperly, verifying each interface individually may not reveal the problem. However, comparing the final order status with the actual inventory changes will uncover the issue.

[0062] 3. Improve efficiency: For complex business scenarios with multiple interconnected interfaces, verifying each interface individually may require repeatedly setting preconditions and simulating data. However, by comparing the final results, only one check is needed after the business process has been fully executed, reducing verification steps and improving verification efficiency.

[0063] The API gateway migration verification method based on traffic mirroring in the above embodiments can be well applied to civil aviation managed service gateways. like Figure 2 As shown, the second embodiment of the present invention provides an API gateway migration verification system for a domestic IT innovation environment based on traffic mirroring. The system includes: The traffic recording module is used to record traffic information of API gateway calls in the production environment; The traffic integration module is used to restore the recorded traffic information to the original traffic. The traffic forwarding module is used to forward the restored original traffic to the domestic IT innovation environment in a multi-threaded manner. The monitoring and comparison module is used to monitor and compare the performance indicators of the API gateway in the domestic IT innovation environment and the original production environment, and to compare the final consistency of various business indicators between the domestic IT innovation environment and the original production environment under the same traffic.

[0064] The traffic recording module is the starting point of the entire API gateway migration verification method based on traffic mirroring in the domestic IT innovation environment. It is responsible for recording traffic information of the production environment calling the gateway. Using message middleware to push the current production environment operation status can be well used for business traffic monitoring and subsequent analysis functions. This module records basic information of request traffic calls through message middleware, mainly including transaction number, interface name, user authentication information, request time, request header information, etc.; and records the corresponding request message part through cache middleware, which is used to classify and store the messages.

[0065] The traffic integration module is responsible for restoring the recorded and stored content to its original traffic. The specified recording time range is (t...). i ,t n (i.e., the second preset time period) First, query the message middleware to obtain the basic information of the gateway call traffic within this time range. Then, retrieve the stored request information from the cache middleware through the transaction number and restore it to the original traffic, i.e., mirrored traffic, according to the rules.

[0066] The traffic forwarding module is responsible for forwarding the restored traffic to the domestically developed environment. Utilizing Java multithreading technology, the module forwards the restored original traffic to the domestically developed environment. This is primarily based on the multithreading capabilities of the Java language and the non-blocking functionality of NIO, enabling it to handle multiple traffic forwarding tasks simultaneously. Furthermore, while waiting for network data transmission, threads can execute other tasks, thereby improving the overall performance of the system.

[0067] The monitoring and comparison module is responsible for monitoring (t) i ,t n Within a given time frame, performance metrics (including hardware and software metrics) are calculated. Changes in various performance test metrics of the production environment and backend applications requiring joint debugging are provided during this time frame. After traffic mirroring and forwarding are completed, various business metrics of the two environments (i.e., the domestic IT innovation environment and the original production environment) are compared.

[0068] Regarding the system in the above embodiments, the specific manner in which each unit module performs operations has been described in detail in the embodiments related to the method, and will not be repeated here.

[0069] Based on the same inventive concept, the present invention also provides a computer-readable storage medium storing one or more programs, which, when executed, can realize the API gateway migration verification method based on traffic mirroring as described above.

[0070] Based on the same inventive concept, the present invention also provides an electronic device, such as... Figure 3As shown, it includes a processor, a communication interface, a computer-readable storage medium as described above, and a communication bus; wherein the processor, the communication interface, and the computer-readable storage medium communicate with each other via the communication bus; the processor is used to execute a program stored in the computer-readable storage medium.

[0071] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between systems or modules may be electrical, mechanical, or other forms.

[0072] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, the functional modules in the various embodiments of this invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0073] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0074] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0075] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0076] The parts not mentioned in the above embodiments are the same as or can be implemented using existing technologies, and will not be further described here.

[0077] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for verifying API gateway migration based on traffic mirroring, characterized in that, The method includes: Record traffic information from the production environment calling the API gateway; Restore the recorded traffic information to the original traffic; The restored original traffic is forwarded to the domestic IT innovation environment via multiple threads; Monitor and compare the performance metrics of the API gateway in the domestic IT innovation environment and the original production environment, and compare the final consistency of various business metrics in the domestic IT innovation environment and the original production environment under the same traffic.

2. The API gateway migration verification method based on traffic mirroring according to claim 1, characterized in that, Before recording traffic information from API gateway calls in the production environment, offline knowledge preparation is also included, which includes: Record the traffic within the first preset time period, extract the structure of the interface request message, and combine it with the interface name to form a vocabulary field; Clustering algorithms are used to cluster the vocabulary fields; If the number of clusters of an interface is less than N and the number of calls is greater than K, then the interface is classified as a type A interface; otherwise, the interface is classified as a non-type A interface. Here, N and K are both natural numbers. The interface name, vocabulary ID, and vocabulary fields are combined to form a vocabulary and saved to the database.

3. The API gateway migration verification method based on traffic mirroring according to claim 2, characterized in that, The recorded traffic information of the production environment calling the API gateway includes: Record basic information about request traffic within a second preset time period using a message middleware; Record the request message portion corresponding to the request within the second preset time period using the caching middleware.

4. The API gateway migration verification method based on traffic mirroring according to claim 3, characterized in that, The recording of traffic information from the production environment calling the API gateway also includes: The traffic basic information within the second preset time period is obtained by querying the message middleware. The traffic basic information includes transaction number, interface name, user authentication related information, request time, and request header information. Based on the queried traffic information, obtain the corresponding request message, and then prepare and classify the request information corresponding to the request message according to offline knowledge.

5. The API gateway migration verification method based on traffic mirroring according to claim 4, characterized in that, The step of obtaining the corresponding request message based on the queried traffic basic information includes: Use the transaction number of the traffic obtained from querying basic traffic information as a unique identifier to retrieve the request message corresponding to the transaction number.

6. The API gateway migration verification method based on traffic mirroring according to claim 4, characterized in that, The step of preparing the corresponding request information for the classified storage request message based on offline knowledge includes: Based on offline knowledge, the corresponding interfaces for request messages are classified. Based on the classification results of the interface, the corresponding request information of the request message is stored in categories.

7. The API gateway migration verification method based on traffic mirroring according to claim 6, characterized in that, The process of classifying and storing the corresponding request information of the request message according to the classification result of the interface includes: If the interface belongs to type A, then store the transaction number, vocabulary ID, and corresponding values ​​of the vocabulary fields in the cache middleware; If the interface is not a type A interface, then store the transaction number and the original request message in the cache middleware.

8. The API gateway migration verification method based on traffic mirroring according to claim 4, characterized in that, The process of restoring the recorded traffic information to the original traffic includes: Basic traffic information for the second preset time period is obtained by querying the message middleware; Based on the transaction number of the traffic obtained from the basic traffic information, the stored request information is retrieved from the cache middleware and restored to the original traffic.

9. The API gateway migration verification method based on traffic mirroring according to claim 1, characterized in that, The monitoring compares the performance metrics of the API gateway in the domestic IT innovation environment and the original production environment, and compares the final consistency of various business metrics between the domestic IT innovation environment and the original production environment under the same traffic, including: Obtain the hardware and software metrics of the API gateway in the domestic IT innovation environment and the original production environment, and perform real-time monitoring and comparison. Organize the business data and status information of the domestic IT innovation environment and the original production environment under the same traffic, and compare them for eventual consistency.

10. A migration verification system for API gateways in a domestic IT innovation environment based on traffic mirroring, characterized in that, The system includes: The traffic recording module is used to record traffic information of API gateway calls in the production environment; The traffic integration module is used to restore the recorded traffic information to the original traffic. The traffic forwarding module is used to forward the restored original traffic to the domestic IT innovation environment in a multi-threaded manner. The monitoring and comparison module is used to monitor and compare the performance indicators of the API gateway in the domestic IT innovation environment and the original production environment, and to compare the final consistency of various business indicators between the domestic IT innovation environment and the original production environment under the same traffic.

11. A computer-readable storage medium storing one or more programs, characterized in that, When one or more of these programs are executed, the API gateway migration verification method based on traffic mirroring as described in any one of claims 1-9 can be implemented.

12. An electronic device comprising a processor, a communication interface, a computer-readable storage medium as described in claim 11, and a communication bus; wherein, The processor, communication interface, and computer-readable storage medium communicate with each other via a communication bus; Its features are, The processor is used to execute programs stored in a computer-readable storage medium.