Traffic replication method, component, device and storage medium

CN121664884BActive Publication Date: 2026-10-23中邮消费金融有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511789790.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-01
Publication Date
2026-10-23
Estimated Expiration
2045-12-01

AI Technical Summary

Technical Problem

[0006]本申请实施例的目的是提供一种流量复制方法、一种流量复制组件、一种电子设备以及一种机器可读存储介质,以解决现有技术实现Dubbo流量复制需要的成本较高的问题

Benefits of technology

[0017]本申请提供的流量复制方法、组件、设备及存储介质,在确定客户端发起Dubbo调用请求时,先对Dubbo调用请求进行拦截,然后将Dubbo调用请求的请求信息与客户端配置信息进行匹配,在根据匹配结果确定需要进行流量复制时,根据匹配结果和获取到的服务端配置信息,确定Dubbo调用请求对应的目标正式服务端和目标并行服务端,再向目标正式服务端发送原调用,以获取目标正式服务端响应Dubbo调用请求反馈的第一响应结果,并向目标并行服务端发送并行调用,以获取目标并行服务端响应Dubbo调用请求反馈的第二响应结果。本申请通过将执行流量复制方法的组件嵌入Dubbo客户端的方式实现Dubbo流量复制,不必单独部署执行流量复制的应用,在节省了应用部署资源的同时,降低了应用管理复杂度,保证了对扩展的开放性;由于该组件是基于配置使用的,因此可以简单地迁移到其他系统中进行使用,有效减少了重复开发的工作量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121664884B_ABST
    Figure CN121664884B_ABST
Patent Text Reader

Abstract

The application provides a traffic replication method, component, device and storage medium, relates to the technical field of computers, is applied to a Dubbo-based distributed service system, and the method is executed by a traffic replication component accessed by a client, and the method comprises the following steps: when it is determined that the client initiates a Dubbo calling request, the Dubbo calling request is intercepted, and according to a configuration file of the client, client configuration information is acquired; service side configuration information of a service side is acquired; request information in the Dubbo calling request is matched with the client configuration information, it is determined whether traffic replication is needed, if yes, according to the matching result and the service side configuration information, a target formal service side and a target parallel service side corresponding to the Dubbo calling request are determined; an original call is sent to the target formal service side, so that a first response result fed back by the target formal service side in response to the Dubbo calling request is acquired, and a parallel call is sent to the target parallel service side, so that a second response result fed back by the target parallel service side in response to the Dubbo calling request is acquired.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a traffic replication method, a traffic replication component, an electronic device, and a machine-readable storage medium. Background Technology

[0002] Parallel traffic replication refers to the process in the field of information technology of copying data streams, requests or communications from a network or system to one or more targets in real time. It is often used in scenarios such as testing and verification, monitoring and analysis, fault diagnosis and performance optimization.

[0003] In distributed service systems, most infrastructure components such as API gateways, service proxies, and middleware natively support HTTP protocol traffic replication. However, for high-performance RPC frameworks like Dubbo, these components do not natively support Dubbo protocol traffic replication.

[0004] To achieve Dubbo traffic replication, the following two solutions are typically used: (1) Protocol conversion: Use dedicated tools to convert Dubbo protocol requests into HTTP requests. Although this approach can reuse existing HTTP traffic replication capabilities, it incurs the cost of protocol conversion and the risk of traffic distortion due to the differences in protocol semantics between Dubbo and HTTP.

[0005] (2) Custom code: Developers write custom code to call the parallel service once more while the service consumer calls the official service. Although this solution can ensure the integrity of traffic replication, it has the problems of redundant development and inconsistent code quality, which affects development efficiency and increases maintenance costs. Summary of the Invention

[0006] The purpose of this application is to provide a traffic replication method, a traffic replication component, an electronic device, and a machine-readable storage medium to solve the problem of high cost required for Dubbo traffic replication in the prior art.

[0007] To achieve the above objectives, the first aspect of this application provides a traffic replication method applied to a Dubbo-based distributed service system. The distributed service system includes a client and multiple servers, with the servers divided into formal servers and parallel servers. The method is executed by a traffic replication component accessed by the client, and the method includes: When a client initiates a Dubbo call request, the request is intercepted, and the client configuration information is obtained based on the client's configuration file; the Dubbo call request includes request information. Obtain the server-side configuration information from the server; The request information is matched with the client configuration information to determine whether traffic replication is required. If so, the target production server and target parallel server corresponding to the Dubbo call request are determined based on the matching result and the server configuration information. Send the original call to the target official server to obtain the first response result from the target official server in response to the Dubbo call request, and send the parallel call to the target parallel server to obtain the second response result from the target parallel server in response to the Dubbo call request.

[0008] In this embodiment of the application, the client's configuration file includes client configuration information and asynchronous thread pool configuration information; The client configuration information includes a target server tag value list, a parallel server matching rule list, a parallel call mode, client on / off settings, and call timeout. The target server tag value list includes at least one tag value for a parallel server, and the parallel server matching rule list includes basic parameter information for the target server. This basic parameter information includes the interface class name, method name, version number, and group name. Asynchronous thread pool configuration information includes the core thread count, maximum thread count, and thread rejection policy; The server configuration information for the formal server includes the call timeout; the server configuration information for the parallel server includes the parallel service tag, server on / off switch, and call timeout.

[0009] In this embodiment of the application, obtaining the server configuration information of the server includes: After the client sends a server information retrieval request to the registry center of the distributed service system, the system receives a full list of servers returned by the registry center. Both the client and the server are connected to the registry center. The full list of servers includes the server configuration information of each server that has completed registration with the registry center.

[0010] In this embodiment of the application, the request information includes parameter information items, which include interface class name, method name, version number, and group name; The request information is matched with the client configuration information to determine whether traffic replication is necessary, including: Determine whether each parameter in the parameter information item is the same as the corresponding parameter in the basic parameter information contained in the parallel server matching rule list. If so, determine that traffic replication is required.

[0011] In this embodiment of the application, the target formal server and target parallel server corresponding to the Dubbo call request are determined based on the matching results and server configuration information, including: The target formal server is identified as a formal server whose server configuration information does not include the parallel service tag. The parallel servers corresponding to each tag value in the target server tag value list are identified as the target parallel servers.

[0012] In this embodiment of the application, before sending a parallel call to the target parallel server to obtain the second response result fed back by the target parallel server in response to the Dubbo call request, the process includes: Determine whether the parallel call mode in the client configuration information is asynchronous. If not, construct an asynchronous thread pool based on the asynchronous thread pool configuration information and adjust the parallel call mode to asynchronous. The asynchronous thread pool is used to execute the operation of sending parallel calls to the target parallel server to obtain the second response result fed back by the target parallel server in response to the Dubbo call request.

[0013] In this embodiment of the application, the method further includes: Obtain the first Kafka message generated by the target official server and the second Kafka message generated by the target parallel server; Generate an association identifier; whereby the association identifier is used to associate the first Kafka message and the second Kafka message; The first Kafka message and the second Kafka message are stored in the database of the distributed service system; wherein, both the first Kafka message and the second Kafka message include an association identifier, request information of the Dubbo request, call duration and response result, and the response result is either the first response result or the second response result.

[0014] A second aspect of this application provides a traffic replication component applied to a Dubbo-based distributed service system. The distributed service system includes a client and multiple servers, with the servers divided into formal servers and parallel servers. The traffic replication component is integrated into the client and includes: The first configuration information acquisition module is used to intercept the Dubbo call request when it is determined that the client initiates the Dubbo call request, and obtain the client configuration information according to the client's configuration file; wherein, the Dubbo call request includes request information; The second configuration information acquisition module is used to acquire the server configuration information of the server. The target server determination module is used to match the request information with the client configuration information to determine whether traffic replication is required. If so, it determines the target formal server and target parallel server corresponding to the Dubbo call request based on the matching result and the server configuration information. The traffic replication module is used to send the original call to the target production server to obtain the first response result of the target production server in response to the Dubbo call request, and to send the parallel call to the target parallel server to obtain the second response result of the target parallel server in response to the Dubbo call request.

[0015] A third aspect of this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the traffic copying method described in the first aspect above.

[0016] A fourth aspect of this application provides a machine-readable storage medium storing instructions that, when executed by a processor, configure the processor to perform the traffic copying method described in the first aspect.

[0017] The traffic replication method, component, device, and storage medium provided in this application, upon determining that a client initiates a Dubbo call request, first intercepts the Dubbo call request, then matches the request information of the Dubbo call request with the client's configuration information. If traffic replication is determined to be necessary based on the matching result, the target primary server and target parallel server corresponding to the Dubbo call request are identified according to the matching result and the obtained server configuration information. The original call is then sent to the target primary server to obtain the first response result from the target primary server in response to the Dubbo call request, and a parallel call is sent to the target parallel server to obtain the second response result from the target parallel server in response to the Dubbo call request. This application implements Dubbo traffic replication by embedding the component executing the traffic replication method into the Dubbo client, eliminating the need for a separate application to perform traffic replication. This saves application deployment resources, reduces application management complexity, and ensures openness to expansion. Since the component is configuration-based, it can be easily migrated to other systems, effectively reducing the workload of redundant development.

[0018] Other features and advantages of the embodiments of this application will be described in detail in the following detailed description section. Attached Figure Description

[0019] The accompanying drawings are provided to further illustrate the embodiments of this application and form part of the specification. They are used together with the following detailed description to explain the embodiments of this application, but do not constitute a limitation on the embodiments of this application. In the drawings: Figure 1 This illustration schematically shows a flowchart of a traffic replication method according to an embodiment of this application; Figure 2This schematically illustrates the process of parallel traffic replication in an embodiment of this application. Figure 1 ; Figure 3 This schematically illustrates the process of parallel traffic replication in an embodiment of this application. Figure 2 ; Figure 4 This schematic diagram illustrates the structural block diagram of a traffic replication component according to an embodiment of this application; Figure 5 The diagram illustrates the internal structure of a computer device according to an embodiment of this application.

[0020] Explanation of reference numerals in the attached figures A01 - Processor; A02 - Network Interface; A03 - Internal Memory; A04 - Display Screen; A05 - Input Device; A06 - Non-volatile Storage Media; B01 - Operating System; B02 - Computer Program. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only for illustration and explanation of the embodiments of this application and are not intended to limit the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0022] It should be noted that if the embodiments of this application involve directional indicators (such as up, down, left, right, front, back, etc.), the directional indicators are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indicators will also change accordingly.

[0023] Furthermore, if the embodiments of this application involve descriptions such as "first" or "second," these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, features defined with "first" or "second" may explicitly or implicitly include at least one of those features. Additionally, the technical solutions of various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed in this application.

[0024] Dubbo is a high-performance, lightweight Java service governance framework open-sourced by Alibaba. It is primarily used for building distributed service systems. Dubbo uses the RPC (Remote Procedure Call) mechanism to allow service consumers to directly call methods of service providers without needing to concern themselves with the details of network communication.

[0025] Dubbo is an open-source, high-performance Java RPC service framework that enables service input and output through remote procedure calls (RPC). Its core capabilities include interface-oriented remote method invocation, intelligent fault tolerance and load balancing, and automatic service registration and discovery. Dubbo is primarily used to build distributed service systems, allowing service consumers to directly call service provider methods without needing to concern themselves with the details of network communication.

[0026] To ensure the security, stability, and functional availability of systems after deployment, enterprises typically conduct testing and verification before official release. Parallel traffic replication technology utilizes real-world production traffic for system verification, enabling the early detection of potential errors, performance issues, and security risks. Below is an introduction to some existing traffic replication technologies: Network-level traffic replication: Network devices such as switches, routers, and load balancers typically support port mirroring or SPAN (Switched Port Analyzer) functions, which can send copies of HTTP network traffic to monitoring devices, such as Intrusion Detection Systems (IDS) and network performance monitoring tools. However, they do not support the replication of Dubbo traffic. Specifically, network-level traffic replication mainly focuses on network layer traffic and cannot directly capture and replicate Dubbo's RPC requests because these requests are usually encapsulated in application layer protocols, such as TCP connection packets.

[0027] Application-level replication: At the application level, API gateways, service proxies, and middleware can be configured to replicate or mirror requests. While they don't inherently support Dubbo-type traffic replication, this can be achieved by using Higress, a product that uses protocol conversion to transform Dubbo requests into HTTP requests. However, this requires using a paid product, significantly increasing enterprise costs. Furthermore, maintaining traffic replication configurations in external systems greatly increases the complexity of system maintenance and troubleshooting.

[0028] Custom code: Developers can write custom code to make an additional parallel call to the service while calling the production service, thus achieving traffic replication. However, implementing traffic replication through custom code leads to a lot of repetitive development of similar content, which is detrimental to work efficiency. Furthermore, the code written by developers varies in efficiency and security, which can introduce more potential risks.

[0029] In view of the high cost required to implement Dubbo traffic replication in related technologies, this application provides a traffic replication method, component, device and storage medium. The traffic replication method, component, device and storage medium provided in this application will be described in detail below with reference to the accompanying drawings and specific embodiments and implementation methods.

[0030] Figure 1 A schematic flowchart illustrating the traffic replication method according to an embodiment of this application is shown. Figure 1 As shown in one embodiment of this application, a traffic replication method is provided, applied to a Dubbo-based distributed service system. The distributed service system includes clients (applications that call Dubbo services) and multiple servers (applications that provide Dubbo services). The servers are divided into formal servers and parallel servers. The method is executed by a traffic replication component accessed by the client, and the method may include the following steps.

[0031] Step 200: When it is determined that the client initiates a Dubbo call request, the Dubbo call request is intercepted, and the client configuration information is obtained according to the client's configuration file.

[0032] In this embodiment, the Dubbo call request includes request information. This request information includes parameter information items, which include the interface class name, method name, version number, and group name.

[0033] Specifically, when a client connected to the traffic replication component initiates a Dubbo call, the traffic replication component will intercept it. In a specific example, step 200 implements the interception based on Dubbo's native InvokerCluster extension.

[0034] In this embodiment, the client's configuration file (a Properties configuration file) includes client configuration information and asynchronous thread pool configuration information.

[0035] The client configuration information includes a list of target server tag values, a list of parallel server matching rules, a parallel call mode (synchronous or asynchronous call), client on / off switches and call timeout (configured by overriding the server call timeout), and whether the original call response needs to be extracted and placed in the parallel call request header.

[0036] The target server tag value list includes tag values ​​for at least one parallel server, and the parallel server matching rule list includes basic parameter information for the target server. This basic parameter information includes the interface class name, method name, version number, and group name. It is worth noting that the target server mentioned in this embodiment refers to the parallel server in the distributed service system.

[0037] The asynchronous thread pool configuration information includes the core thread count, maximum thread count, thread rejection policy, buffer queue size, and thread pool name prefix.

[0038] Step 400: Obtain the server configuration information.

[0039] In this embodiment, the server-side configuration information is configured in the server's Properties configuration file. The server-side configuration information of the formal server includes the call timeout, and the server-side configuration information of the parallel server includes the parallel service tag, server switch, and call timeout.

[0040] In this embodiment, step 400 includes the following steps.

[0041] Step 410: Obtain the full list of servers returned by the registration center after the client sends a server information retrieval request to the registration center of the distributed service system.

[0042] Both the client and server are connected to the registry center, and the full list of servers includes the server configuration information of each server that has been registered in the registry center.

[0043] It should be understood that, in this embodiment, in order to ensure that the distributed service system can achieve traffic replication, both the client and the server in the distributed service system will register with the registration center of the distributed service system when they start up, so that the registered client can obtain the server configuration information of each server in the distributed service system.

[0044] Figure 2 and Figure 3 The flowchart of parallel traffic replication in an embodiment of this application is illustrated schematically, such as... Figure 2 As shown, this embodiment can use ZooKeeper as the registry center, which can store relevant information about the registered clients and servers.

[0045] The Dubbo server (i.e., the server mentioned above) provides Dubbo services for Dubbo clients (i.e., the clients mentioned above) to call. When a parallel server connected to the traffic replication component completes its server configuration and registers its service in the registry, it will include an additional tag, such as `dubbo.tag=DUBBO-PARALLEL-TAG`, so that the client can find the target service during traffic replication, i.e., determine the target parallel server. In other words, the server with the tag is the parallel server (corresponding to the parallel service in the diagram), and the server without the tag is the official server (corresponding to the original service in the diagram).

[0046] The Dubbo client can call services from the Dubbo server. The Dubbo client can obtain relevant information about all Dubbo servers (including tagged parallel servers and untagged formal servers) from the registry center.

[0047] Understandably, this embodiment supports service discovery using a registry center, enabling dynamic scaling of the server without specifying the server's IP address when making calls.

[0048] Step 600: Match the request information with the client configuration information to determine whether traffic replication is required. If so, determine the target production server and target parallel server corresponding to the Dubbo call request based on the matching result and the server configuration information.

[0049] In this embodiment, step 600 matches the request information with the client configuration information to determine whether traffic replication is required, including the following steps.

[0050] Step 610: Determine whether each parameter in the parameter information item is the same as the corresponding parameter in the basic parameter information contained in the parallel server matching rule list. If so, determine that traffic replication is required.

[0051] It is important to understand that clients accessing the traffic replication component need to configure a list of parallel server matching rules to determine whether a Dubbo call needs to be performed in parallel, i.e., whether parallel traffic replication should be performed. Furthermore, by configuring parallel service tags (corresponding to a list of target server tag values), parallel calls will be made to the Dubbo servers with tags in the distributed service system's parallel server pool when it is determined that a parallel call is to be performed.

[0052] When a client initiates a Dubbo call request, the traffic replication component will match the request according to the client configuration. The matching content specifically includes the request's interface name, method name, version number, and group name.

[0053] When at least one parameter in the parameter information item is inconsistent with the corresponding parameter in the basic parameter information contained in the parallel server matching rule list, it indicates that the Dubbo call request does not meet the parallel call conditions. The traffic replication component will not perform traffic replication. At this time, only the normal Dubbo service is called, that is, only the formal server is called, and the response result returned by the formal server in response to the Dubbo call request is obtained.

[0054] In this embodiment, step 600 determines the target formal server and target parallel server corresponding to the Dubbo call request based on the matching result and server configuration information, including the following steps.

[0055] Step 620: Identify a formal server whose server configuration information does not include the parallel service label as the target formal server; identify the parallel server corresponding to each label value in the target server label value list as the target parallel server.

[0056] It is important to understand that when step 600 determines that traffic replication is necessary, the traffic replication component will replicate traffic based on the target server tag value list in the client configuration. If the target server tag value list contains multiple tag values, the Dubbo call request will be sent to the parallel server corresponding to each tag value in the target server tag value list, thus achieving multiple replications of traffic.

[0057] Understandably, this embodiment achieves flexible and precise traffic replication control through parallel configuration. Only Dubbo call requests that match exactly will have their traffic replicated, and it supports sending traffic to different servers to replicate multiple copies of the traffic.

[0058] Step 800: Send the original call to the target formal server to obtain the first response result of the target formal server in response to the Dubbo call request, and send the parallel call to the target parallel server to obtain the second response result of the target parallel server in response to the Dubbo call request.

[0059] As can be seen, the traffic replication method provided in this application embodiment achieves traffic replication through a flexible, configurable, customizable target server Dubbo parallel traffic replication component that requires no additional system deployment, and has the following advantages: It fills the gap in the original API gateway's ability to only support HTTP request traffic replication; Based on configuration, it is simple and quick to integrate and use, avoiding repetitive code development; By implementing Dubbo traffic replication by embedding it into the caller system (i.e., the client), there is no need to deploy a separate application to perform traffic replication. This saves application deployment resources, reduces application management complexity, and ensures openness to expansion. When traffic increases, there is no need to modify the code; simply increasing the thread pool configuration for traffic replication is sufficient to meet scalability requirements. By replicating traffic in parallel and using real online traffic for testing, the system's performance in actual operation is more accurately reflected, improving the effectiveness and reliability of the test.

[0060] In one embodiment, before step 800 sends a parallel call to the target parallel server to obtain a second response result from the target parallel server in response to the Dubbo call request, the method further includes the following steps.

[0061] Step 700: Determine whether the parallel call mode in the client configuration information is asynchronous call. If not, construct an asynchronous thread pool based on the asynchronous thread pool configuration information and adjust the parallel call mode to asynchronous call. The asynchronous thread pool is used to execute the operation of sending a parallel call to the target parallel server to obtain the second response result fed back by the target parallel server in response to the Dubbo call request.

[0062] It should be understood that by executing step 700, this embodiment enables the traffic replication operation to be performed in a separate thread. Apart from the request matching logic mentioned above, the original call will not add any processing logic, so the processing time added to the original call is almost negligible.

[0063] When performing traffic replication to the target parallel server, the traffic replication component sets the parallel call mode of the Dubbo call to asynchronous. This means that after initiating the Dubbo call request, the call ends immediately without waiting for a response, thus quickly reclaiming the threads executing the parallel call and reducing resource consumption. Furthermore, during serial calls, by supporting the extraction of parameters from the original request's response and placing them into the request header of the parallel call, the parallel call can be associated with specific information from the original request's response.

[0064] Additionally, it is important to understand that the traffic replication component performs traffic replication operations in a separate thread pool (i.e., provides exception isolation). Even if an exception occurs during traffic replication, only an error log will be printed, without affecting the original calls in the production environment.

[0065] Understandably, during the traffic replication process, parallel calls are made based on an asynchronous thread pool, and the call mode is switched to asynchronous mode, which ensures that the system in the production environment can run normally with almost no impact on performance, thus ensuring the continuity and stability of business.

[0066] In one embodiment, the client configuration information may further include the JsonPath rule for extracting the original call response, the Kafka reporting address, and the topic. JsonPath is a tool for extracting fields from JSON messages. It's important to understand that if the function to extract the original call response is enabled, parameters will be extracted from the original call response according to the JsonPath rule and placed into the Attachment of the parallel call.

[0067] In this embodiment, the method further includes the following steps.

[0068] Step 910: Obtain the first Kafka message generated by the target official server and the second Kafka message generated by the target parallel server.

[0069] Step 920: Generate the associated identifier.

[0070] The association identifier is used to associate the first Kafka message with the second Kafka message.

[0071] Step 940: Store the first Kafka message and the second Kafka message in the database of the distributed service system.

[0072] Both the first and second Kafka messages include an association identifier, Dubbo request information, call duration, and response result, with the response result being either the first response result or the second response result.

[0073] Specifically, before the original call completes the Dubbo call and returns the first response result, it reports the request information, response message (i.e., response result), and response time (i.e., call duration) of this call to the specified topic in the form of a Kafka message. Similarly, before the parallel call completes the Dubbo call and returns the second response result, it also reports the request information, response message, and response time of this call to the specified topic in the form of a Kafka message. These two Kafka messages are associated with a randomly generated batchId (i.e., association identifier) ​​to facilitate comparison by result comparison applications.

[0074] like Figure 2 and Figure 3As shown in the example, the Dubbo client connected to the traffic replication component is configured with a Kafka broker and topic. After determining that traffic replication is needed, a server without a tag is selected from the entire service list (which can be obtained directly from the registry center) and invoked (i.e., the original call). The result is then reported, including the Dubbo request body, response result, call duration, batchId (random number), and type "original call". Simultaneously, a separate thread selects a Dubbo server with a specified parallel service tag from the entire service list and invokes it in parallel. The result is also reported, including the Dubbo request body, response result, call duration, batchId (random number, consistent with the original call), and type "parallel call".

[0075] In this example, after completing a Dubbo call, the client sends a Kafka message. The traffic replication component listens to these messages and parses out the request information, response message, response time, and batchId, storing this information in the raw data table of the distributed service system's database. Subsequently, the batchId can be used to query the information of the original call and the parallel call, and then the response messages can be compared to determine if both calls return the same response, thus completing a functional comparison of the interfaces. By comparing the response times, the response efficiency of the old and new interfaces can be determined, thus completing a performance comparison of the interfaces. Finally, the compared interfaces are displayed on the relevant pages of the distributed service system for developers to view.

[0076] Specifically, the steps for comparing and displaying Kafka messages include: first, retrieving data from the original data table in the database based on the batchId, using the data with type=original call as the baseline, and comparing other data with this baseline data: comparing whether the response results are consistent and whether the call time is longer or shorter than the baseline data. Then, summarizing these two comparison results, inserting them into the comparison result table, and displaying them.

[0077] Understandably, this embodiment collects the results and sends Kafka messages to report them during parallel traffic replication. The results are then stored and analyzed by a separate comparison application, which can clearly compare the differences in the results and response times between the original call and the parallel call.

[0078] In one embodiment, before step 800 sends the parallel call to the target parallel server, the method may further include the following steps.

[0079] The request is formatted and saved to the database of the distributed service system.

[0080] It should be understood that this embodiment adds a request storage mechanism so that if a request needs to be reproduced in the future, the request content can be retrieved directly from the database, enabling the request to be quickly reassembled and the call initiated.

[0081] The following specific example illustrates the traffic replication method provided in the embodiments of this application.

[0082] A company is optimizing its existing business processes (based on Dubbo calls), requiring the switching of business requests to a new processing flow. Although the new flow has been tested in the test environment, it cannot fully cover production conditions. Switching directly in production could lead to unforeseen problems, requiring version rollbacks, bug fixes, and repeated deployments. This not only reduces development efficiency but also negatively impacts the correctness and stability of the business logic. Furthermore, even if the switch to the new flow is successful, the lack of a comparison between the old and new processes makes it impossible to verify whether there has been an actual improvement in processing efficiency.

[0083] After conducting research, the company found that there was no good solution in the industry. The gateway itself does not support the processing of Dubbo requests, and the existing canary deployment solution only supports the distribution of Dubbo requests, which will still affect some requests. Moreover, the number of distributed requests is small and cannot expose the potential problems under high concurrency.

[0084] Based on this, the company has effectively solved the existing problems through the Dubbo parallel traffic replication component (hereinafter referred to as the component) provided in the above embodiments. The corresponding operation implementation includes the following aspects.

[0085] Before deploying the new process, integrate the component into the client and server applications that make Dubbo calls. Define the Dubbo interfaces that need to be executed in parallel in the client application configuration, and deploy multiple parallel server applications. Specifically, configure the class name, method name, version number, group name, parallel server tag (multiple are allowed), and component client switch for the interface in the calling system (i.e., the client application). Deploy multiple server systems (i.e., server applications) for the Dubbo interface, including the production system and multiple parallel test systems. Do not add a parallel flag in the production system, but add the corresponding parallel flag (each system has its own parallel flag) and component server switch in the parallel test systems.

[0086] In the test environment, Dubbo calls were initiated from the client application to confirm that both the production and parallel server applications received the same request, verifying that parallel traffic replication was indeed effective. Furthermore, in the test environment, a stress test was first performed on the target Dubbo interface. Then, the component switches for both the client application and the parallel server application were turned off, and another stress test was conducted to verify that under high concurrency conditions, the call efficiency of the Dubbo interface was not significantly affected, and that both the production and parallel server applications received requests normally. Finally, the applications were compared to examine the functionality and performance of the original and parallel calls, and optimizations were made to the new version of the interface.

[0087] After deployment, when client applications call the interfaces defined by the component, the component automatically replicates the request to the parallel server application, achieving full request replication. If problems arise in the new process, only the parallel server application needs to be fixed and deployed, without affecting existing business requests, thus improving the stability of existing business operations. Furthermore, since both the old and new Dubbo interfaces are called simultaneously, the processing efficiency of the two can be directly compared, and the new process can be further optimized and modified as needed.

[0088] The integrated components can identify potential problems and risks before new features or systems go live, reducing the probability of failures after deployment. From a reusability perspective, the integrated components are configuration-based, allowing for easy migration to other systems and reducing redundant development work. These features significantly improve application development and operational efficiency.

[0089] It is easy to see that the traffic replication method provided in this application embodiment can be based on a non-blocking asynchronous framework. Traffic replication rules can be defined through the Properties configuration file. When the original call is initiated, it can automatically determine whether traffic replication is needed, whether there is one or multiple target servers for traffic replication, and whether the replication process is synchronous or asynchronous, based on the defined rules. This effectively solves the problem of high cost required for Dubbo traffic replication in the prior art.

[0090] Figure 1 This is a flowchart illustrating a traffic replication method in one embodiment. It should be understood that, although... Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise explicitly stated herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 1At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.

[0091] Figure 4 A schematic block diagram illustrating the structure of a traffic replication component according to an embodiment of this application is shown. Figure 4 As shown in one embodiment of this application, a traffic replication component is provided, which is applied to a Dubbo-based distributed service system. The distributed service system includes a client and multiple servers. The servers are divided into formal servers and parallel servers. The traffic replication component is connected to the client. The traffic replication component may include the following functional modules.

[0092] The first configuration information acquisition module is used to intercept a Dubbo call request when it is determined that the client has initiated such a request, and to obtain the client's configuration information based on the client's configuration file. The Dubbo call request includes request information.

[0093] The second configuration information acquisition module is used to acquire the server configuration information of the server.

[0094] The target server determination module is used to match the request information with the client configuration information to determine whether traffic replication is required. If so, it determines the target official server and target parallel server corresponding to the Dubbo call request based on the matching result and the server configuration information.

[0095] The traffic replication module is used to send the original call to the target production server to obtain the first response result of the target production server in response to the Dubbo call request, and to send the parallel call to the target parallel server to obtain the second response result of the target parallel server in response to the Dubbo call request.

[0096] In one embodiment, the client's configuration file includes client configuration information and asynchronous thread pool configuration information.

[0097] The client configuration information includes a list of target server label values, a list of parallel server matching rules, a parallel call mode, client on / off settings, and call timeout. The target server label value list includes label values ​​for at least one parallel server, and the parallel server matching rule list includes basic parameter information for the target server; this basic parameter information includes the interface class name, method name, version number, and group name.

[0098] The configuration information for asynchronous thread pools includes the core number of threads, the maximum number of threads, and the thread rejection policy.

[0099] The server-side configuration information for the official server includes the call timeout period.

[0100] The server configuration information for the parallel server includes the parallel service label, server switch, and call timeout.

[0101] In one embodiment, the second configuration information acquisition module is specifically used for: After the client sends a server information retrieval request to the registry center of the distributed service system, the system retrieves a full list of servers returned by the registry center. Both the client and the server are connected to the registry center; the full list of servers includes the server configuration information of each server that has already registered with the registry center.

[0102] In one embodiment, the request information includes parameter information items, which include interface class name, method name, version number, and group name.

[0103] In one embodiment, the target server determination module includes: The judgment unit is used to determine whether each parameter in the parameter information item is the same as the corresponding parameter in the basic parameter information contained in the parallel server matching rule list. If so, it is determined that traffic replication is required.

[0104] In one embodiment, the target server determination module includes: The first server determination unit is used to determine a formal server whose server configuration information does not include the parallel service label as the target formal server.

[0105] The second server determination unit is used to determine the parallel server corresponding to each tag value in the target server tag value list as the target parallel server.

[0106] In one embodiment, the traffic replication component may further include the following functional modules.

[0107] The call mode management module determines whether the parallel call mode in the client configuration information is asynchronous. If not, it constructs an asynchronous thread pool based on the asynchronous thread pool configuration information and adjusts the parallel call mode to asynchronous. The asynchronous thread pool is used to send parallel calls to the target parallel server to obtain the second response result from the target parallel server's response to the Dubbo call request.

[0108] In one embodiment, the traffic replication component may further include a packet entry module, which may include the following functional modules.

[0109] The first message generation unit is used to obtain the first Kafka message generated by the target official server.

[0110] The second message generation unit is used to generate the second Kafka message corresponding to the target parallel server after obtaining the second response result.

[0111] The identifier generation unit is used to generate association identifiers. These association identifiers are used to associate the first Kafka message with the second Kafka message.

[0112] The message storage unit is used to store the first Kafka message and the second Kafka message into the database of the distributed service system. Both the first and second Kafka messages include an association identifier, Dubbo request information, call duration, and response result, where the response result is either a first response result or a second response result.

[0113] Since the traffic replication component provided in this application is a virtual device corresponding to the traffic replication method in the above embodiments, the component provides Dubbo parallel traffic replication function, which can be called through the Dubbo native ClusterInvoker extension, and can also solve the problem of high cost required to implement Dubbo traffic replication in the prior art.

[0114] This application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the traffic replication method described in the above embodiments.

[0115] The electronic device provided in this application embodiment includes a processor capable of running the traffic replication method of the aforementioned embodiment, thus also solving the problem of high cost required for Dubbo traffic replication in the prior art.

[0116] This application provides a machine-readable storage medium storing instructions that, when executed by a processor, configure the processor to perform the traffic replication method described in the above embodiments.

[0117] The machine-readable storage medium provided in this application embodiment stores instructions for causing the machine to execute the traffic replication method of the above embodiment, thus also solving the problem of high cost required for Dubbo traffic replication in the prior art.

[0118] Figure 5 The diagram schematically illustrates the internal structure of a computer device according to an embodiment of this application. Figure 5As shown in one embodiment of this application, a computer device is provided, which can be a terminal. The computer device includes a processor A01, a network interface A02, a display screen A04, an input device A05, and a memory (not shown) connected via a system bus. The processor A01 provides computing and control capabilities. The memory includes internal memory A03 and a non-volatile storage medium A06. The non-volatile storage medium A06 stores an operating system B01 and a computer program B02. The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 stored in the non-volatile storage medium A06. The network interface A02 is used to communicate with an external terminal via a network connection. When the computer program B02 is executed by the processor A01, it implements a traffic replication method. The display screen A04 of the computer device can be an LCD screen or an e-ink screen. The input device A05 of the computer device can be a touch layer covering the display screen A04, or a button, trackball, or touchpad set on the computer device casing, or an external keyboard, touchpad, or mouse, etc.

[0119] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0120] In one embodiment, the traffic replication component provided in this application can be implemented as a computer program, which can be implemented in the form of, for example... Figure 5 The computer device shown operates on the network. The memory of the computer device can store various program modules that make up the traffic replication component, and the computer program composed of the various program modules causes the processor A01 to execute the steps in the traffic replication methods of the various embodiments of this application described in this specification.

[0121] Figure 5 The computer device shown can be used as follows Figure 4 The first configuration information acquisition module in the traffic replication component shown executes step 200, the second configuration information acquisition module executes step 400, the target server determination module executes step 600, and the traffic replication module executes step 800.

[0122] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0123] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0124] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0125] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0126] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0127] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0128] Computer-readable media include both permanent and non-permanent, removable and non-removable media, which can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0129] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0130] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A traffic replication method, characterized in that, This method is applied to a Dubbo-based distributed service system, which includes a client and multiple servers. The servers are divided into main servers and parallel servers. The method is executed by a traffic replication component accessed by the client and includes: When a client initiates a Dubbo call request, the request is intercepted, and the client configuration information is obtained based on the client's configuration file. The Dubbo call request includes request information, and the client configuration file includes client configuration information and asynchronous thread pool configuration information. The client configuration information includes a target server tag value list, a parallel server matching rule list, parallel call mode, client on / off status, and call timeout. The target server tag value list includes at least one tag value for a parallel server. The parallel server matching rule list includes basic parameter information for the target server, including the interface class name, method name, version number, and group name. The asynchronous thread pool configuration information includes the core thread count, maximum thread count, and thread rejection policy. Obtain the server configuration information of the server; the server configuration information of the formal server includes the call timeout, and the server configuration information of the parallel server includes the parallel service tag, server switch, and call timeout. The request information is matched with the client configuration information to determine whether traffic replication is required. If so, the target production server and target parallel server corresponding to the Dubbo call request are determined based on the matching result and the server configuration information. Send the original call to the target official server to obtain the first response result from the target official server in response to the Dubbo call request, and send the parallel call to the target parallel server to obtain the second response result from the target parallel server in response to the Dubbo call request.

2. The traffic replication method according to claim 1, characterized in that, Obtain the server-side configuration information, including: After the client sends a server information retrieval request to the registry center of the distributed service system, the system receives a full list of servers returned by the registry center. Both the client and the server are connected to the registry center. The full list of servers includes the server configuration information of each server that has completed registration with the registry center.

3. The traffic replication method according to claim 1, characterized in that, The request information includes parameter information items, which include the interface class name, method name, version number, and group name; The request information is matched with the client configuration information to determine whether traffic replication is necessary, including: Determine whether each parameter in the parameter information item is the same as the corresponding parameter in the basic parameter information contained in the parallel server matching rule list. If so, determine that traffic replication is required.

4. The traffic replication method according to claim 1, characterized in that, Based on the matching results and server configuration information, determine the target production server and target parallel server corresponding to the Dubbo call request, including: The target formal server is identified as a formal server whose server configuration information does not include the parallel service tag. The parallel servers corresponding to each tag value in the target server tag value list are identified as the target parallel servers.

5. The traffic replication method according to claim 1, characterized in that, Before sending a parallel call to the target parallel server to obtain the second response result from the target parallel server in response to the Dubbo call request, the process includes: Determine whether the parallel call mode in the client configuration information is asynchronous. If not, construct an asynchronous thread pool based on the asynchronous thread pool configuration information and adjust the parallel call mode to asynchronous. The asynchronous thread pool is used to execute the operation of sending parallel calls to the target parallel server to obtain the second response result fed back by the target parallel server in response to the Dubbo call request.

6. The traffic replication method according to any one of claims 1 to 5, characterized in that, The method further includes: Obtain the first Kafka message generated by the target official server and the second Kafka message generated by the target parallel server; Generate an association identifier; whereby the association identifier is used to associate the first Kafka message and the second Kafka message; The first Kafka message and the second Kafka message are stored in the database of the distributed service system; wherein, both the first Kafka message and the second Kafka message include an association identifier, request information of the Dubbo request, call duration and response result, and the response result is either the first response result or the second response result.

7. A traffic replication component, characterized in that, This is applied to a Dubbo-based distributed service system, which includes a client and multiple servers. The servers are divided into production servers and parallel servers. The traffic replication component is integrated into the client and includes: The first configuration information acquisition module is used to intercept a Dubbo call request when it is determined that the client has initiated such a request, and to obtain the client configuration information based on the client's configuration file. The Dubbo call request includes request information, and the client's configuration file includes client configuration information and asynchronous thread pool configuration information. The client configuration information includes a target server tag value list, a parallel server matching rule list, a parallel call mode, client on / off settings, and call timeout. The target server tag value list includes at least one tag value for a parallel server, and the parallel server matching rule list includes basic parameter information for the target server, including the interface class name, method name, version number, and group name. The asynchronous thread pool configuration information includes the core thread count, maximum thread count, and thread rejection policy. The second configuration information acquisition module is used to acquire the server configuration information of the server; wherein, the server configuration information of the formal server includes the call timeout, and the server configuration information of the parallel server includes the parallel service tag, server switch and call timeout. The target server determination module is used to match the request information with the client configuration information to determine whether traffic replication is required. If so, it determines the target formal server and target parallel server corresponding to the Dubbo call request based on the matching result and the server configuration information. The traffic replication module is used to send the original call to the target production server to obtain the first response result of the target production server in response to the Dubbo call request, and to send the parallel call to the target parallel server to obtain the second response result of the target parallel server in response to the Dubbo call request.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the traffic replication method according to any one of claims 1 to 6.

9. A machine-readable storage medium storing instructions thereon, characterized in that, When executed by a processor, this instruction causes the processor to be configured to perform the traffic replication method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Multi-tenant service gray release method and device, computer equipment and storage medium

    CN112118565A

  • Server gray release method, device, equipment and medium

    CN120201071A