A traffic dyeing method and device in a Dubbo framework
By introducing traffic coloring functionality into the cluster layer of the Dubbo framework, the problem that filter coloring tags could not be used in the cluster layer and subsequent hierarchical structures was solved, enabling the wide utilization of coloring tags in multiple hierarchical structures and improving utilization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NETSUNION CLEARING CORP
- Filing Date
- 2024-11-29
- Publication Date
- 2026-06-05
AI Technical Summary
In existing technologies, when using filters to color traffic in the Dubbo framework, the coloring markers can only be used after the protocol layer, resulting in low utilization and ineffective use in the cluster layer and subsequent hierarchical structures.
By introducing a predefined traffic coloring function into the cluster layer of the Dubbo framework, and coloring requests by extending fault tolerance capabilities, the coloring tags can be used in the cluster layer and subsequent hierarchical structures, thus expanding the scope of application of coloring tags.
It improves the utilization of coloring tags, enabling them to be used effectively in the cluster layer, routing, load balancing, monitoring, and protocol layers, thus enhancing the scalability and practicality of traffic coloring.
Smart Images

Figure CN122160283A_ABST
Abstract
Description
Technical Field
[0001] This article relates to data processing techniques, particularly a flow coloring method and apparatus within the Dubbo framework. Background Technology
[0002] Traffic coloring refers to setting corresponding traffic coloring rules according to the traffic protocol, marking specific traffic with color, and carrying this mark throughout the call chain. By coloring traffic, specific traffic can be tracked and routed.
[0003] In related technologies, filters are often used to color the flow rate.
[0004] However, since the filter is located at the protocol layer, the staining marks formed by this method can only be used after the protocol layer, resulting in low utilization of the staining marks. Summary of the Invention
[0005] This application provides a flow coloring method and apparatus in the Dubbo framework, which can expand the application scope of coloring markers and improve the utilization rate of coloring markers.
[0006] On the one hand, this application provides a traffic coloring method in the Dubbo framework, including:
[0007] Introduce a predefined traffic coloring feature in the cluster layer of the Dubbo framework;
[0008] Before a request reaches the cluster layer in the Dubbo framework for fault tolerance, the introduced traffic coloring feature is used to color the request.
[0009] On the other hand, this application provides a traffic coloring device in the Dubbo framework, including: a memory and a processor, wherein the memory is used to store an executable program;
[0010] The processor is used to read and execute the executable program to implement the traffic coloring method in the Dubbo framework described above.
[0011] Compared with related technologies, this application introduces a predefined traffic coloring function into the cluster layer of the Dubbo framework. Before a request reaches the cluster layer of the Dubbo framework for fault tolerance, the introduced traffic coloring function is used to color the request. Therefore, the coloring marks formed after coloring can be used in the cluster layer and subsequent hierarchical structures of the Dubbo framework, thereby expanding the scope of use of coloring marks and improving the utilization rate of coloring marks.
[0012] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the application. Other advantages of this application can be realized and obtained by means of the solutions described in the description and the accompanying drawings. Attached Figure Description
[0013] The accompanying drawings are used to provide an understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.
[0014] Figure 1 A flowchart illustrating a flow coloring method in the Dubbo framework provided in this application embodiment;
[0015] Figure 2 This is a schematic diagram of a Dubbo framework based on existing technology.
[0016] Figure 3 This is a schematic diagram of a flow coloring process using a filter in the prior art;
[0017] Figure 4 This is a flowchart illustrating a traffic coloring method in the Dubbo framework provided in an embodiment of this application. Detailed Implementation
[0018] This application describes several embodiments, but these descriptions are exemplary and not restrictive, and it will be apparent to those skilled in the art that many more embodiments and implementations are possible within the scope of the embodiments described herein. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with, or may replace, any feature or element of any other embodiment.
[0019] This application includes and contemplates combinations of features and elements known to those skilled in the art. The embodiments, features, and elements disclosed in this application may also be combined with any conventional features or elements to form a unique inventive scheme as defined by the claims. Any feature or element of any embodiment may also be combined with features or elements from other inventive schemes to form another unique inventive scheme as defined by the claims. Therefore, it should be understood that any feature shown and / or discussed in this application may be implemented individually or in any suitable combination. Therefore, the embodiments are not limited except by the limitations imposed by the appended claims and their equivalents. Furthermore, various modifications and changes may be made within the scope of the appended claims.
[0020] Furthermore, in describing representative embodiments, the specification may have presented methods and / or processes as a specific sequence of steps. However, the method or process should not be limited to the specific order of steps described herein, to the extent that it does not depend on such a specific order. As will be understood by those skilled in the art, other sequences of steps are also possible. Therefore, the specific order of steps set forth in the specification should not be construed as a limitation of the claims. Moreover, the claims concerning the method and / or process should not be limited to the steps performed in the written order, and those skilled in the art will readily understand that these orders can be varied and still remain within the spirit and scope of the embodiments of this application.
[0021] This application provides a traffic coloring method in the Dubbo framework, such as... Figure 1 As shown, it includes:
[0022] Step 101: Introduce a predefined traffic coloring function in the cluster layer of the Dubbo framework;
[0023] Step 102: Before the request reaches the cluster layer in the Dubbo framework for fault tolerance, the introduced traffic coloring function is used to color the request.
[0024] For example, the request could specifically be an RPC request.
[0025] In one exemplary instance, the fault tolerance function includes: routing function and load balancing function.
[0026] Cluster fault tolerance implementations all include service directory lookup, routing, and load balancing, and their execution order is fixed. However, routing and load balancing require coloring, so it is sufficient to ensure that traffic coloring is performed before the router to meet the design requirements.
[0027] In related technologies, a schematic diagram of the Dubbo framework is shown below. Figure 2 As shown, the Dubbo framework is abstracted into 10 layers, which, in order of execution, include: Service interface layer, Config layer, Proxy layer, Registry layer, Cluster layer, Monitor layer, Protocol layer, Exchange layer, Transport layer, and Serialize layer. Dubbo cluster fault tolerance refers to the handling scheme when exceptions occur during consumer calls to the provider cluster. The framework itself provides multiple strategies (Failover, Failfast, Failback, etc.), and custom extended strategies can also be selected.
[0028] Traffic coloring refers to setting corresponding traffic coloring rules according to traffic protocols, marking specific traffic with a color, and carrying this mark throughout the entire call chain. Colored traffic allows for the tracking and routing of specific traffic. It enables end-to-end request tracing. In a microservice architecture, the system is divided into numerous services based on business scale and boundaries. External requests flow between services within the system according to business needs. To track the execution of individual business requests, traffic coloring technology can assign a unique mark to each request, which each system records to achieve traffic tracking. Another use case for traffic coloring is as a basis for routing. By classifying and labeling traffic according to business needs, the system can route traffic to its respective resource pool by recognizing the traffic mark, reducing mutual interference between different services. Common use cases include canary releases and end-to-end load testing. During canary releases, experimental traffic is routed to canary machines to verify new features; during end-to-end load testing, load testing traffic is colored, and each service can route it to the load testing environment to achieve load testing isolation.
[0029] Traffic coloring in a microservice architecture typically requires implementing both tag delivery and traffic tagging functionality. Tag delivery involves passing tags along with requests during cross-service Remote Procedure Calls (RPCs). In the Dubbo framework, a common solution is to use RpcContext (request context), which includes implicit parameter passing during RPC requests. The scope of RpcContext is a complete request (the scope of the request tag is each invocation; the attachment is used to pass the request tag. Note that the value stored in the attachment will be continuously passed throughout a complete remote call. Thanks to this feature, we only need to set the tag with a single line of code at the start of the call to achieve continuous tag passing). The implicit parameters are encapsulated in the RPC protocol and forwarded to the called application during the request. Writing traffic tags to RpcContext allows them to be forwarded between applications during RPC calls.
[0030] Traffic tagging is the process of identifying and labeling traffic based on business requirements. A common solution in Dubbo applications is to implement this through request filters. A custom Dubbo request filter (RpcFilter) can be used to implement the traffic tagging logic. The Dubbo framework executes the filter before the request to complete the traffic tagging function. The Dubbo framework can rely on RpcContext for passing traffic tags, while traffic identification and tagging rely on the custom request filter.
[0031] To achieve traffic coloring using request filters, two tasks need to be completed:
[0032] First, implement a custom filter. Implement the com.alibaba.Dubbo.rpc.Filter interface in the code, write the business logic code in it, and complete the function of identifying traffic and writing tags into the RpcContext.
[0033] Second, integrate custom filters into applications. Add custom filters to the filter execution chain. The Dubbo framework executes them before initiating network requests, and finally adds traffic coloring tags to the parameters passed downstream.
[0034] A flowchart of flow coloring using filters is shown below. Figure 3 As shown, traffic coloring is implemented using filters at the protocol layer, but this implementation has the following drawbacks:
[0035] 1. Traffic coloring using filters cannot be applied to routing functions. In Dubbo's architecture, filters belong to the protocol layer, and their execution order follows the cluster layer. Dubbo's cluster layer includes cluster fault tolerance functions such as request routing and load balancing. Coloring traffic through filters will prevent the coloring results from taking effect on routing and other cluster fault tolerance functions. In real-world use cases, this approach is mostly used for traffic coloring tracing. For traffic coloring routing scenarios, such as end-to-end load testing, additional support needs to be added at the system level. The Dubbo architecture abstraction layers are as follows: Figure 2 As shown, routing and load balancing are both at the cluster layer, while filters take effect at the protocol layer. Therefore, filters take effect after load balancing.
[0036] The traffic coloring method in the Dubbo framework provided in this application introduces a predefined traffic coloring function in the cluster layer of the Dubbo framework. Before a request reaches the cluster layer of the Dubbo framework for fault tolerance, the introduced traffic coloring function is used to color the request. Therefore, the coloring mark formed after coloring can be used in the cluster layer and subsequent hierarchical structures of the Dubbo framework, thereby expanding the scope of use of the coloring mark and improving the utilization rate of the coloring mark.
[0037] In one exemplary instance, the cluster layer in the Dubbo framework introduces a predefined traffic coloring feature, including:
[0038] The cluster layer in the Dubbo framework introduces a predefined traffic coloring function by extending fault tolerance capabilities.
[0039] In one exemplary instance, the cluster layer in the Dubbo framework introduces a predefined traffic coloring function by extending fault tolerance capabilities, including:
[0040] The cluster layer in the Dubbo framework extends the fault tolerance functionality in a wrapper pattern to introduce predefined traffic coloring features.
[0041] In one exemplary instance, the cluster layer in the Dubbo framework extends the fault tolerance functionality in a wrapper pattern to introduce a predefined traffic coloring feature, including:
[0042] The fault tolerance function is extended in the cluster layer of the Dubbo framework in a wrapper pattern by calling the com.alibaba.Dubbo.rpc.cluster.Cluster interface to introduce a predefined traffic coloring function; wherein the com.alibaba.Dubbo.rpc.cluster.Cluster interface contains pre-written traffic identification and tagging logic for implementing the traffic coloring function.
[0043] For example, its custom implementation is similar to that of a filter. The code implements the com.alibaba.Dubbo.rpc.cluster.Cluster interface, writes traffic identification and tagging code in it, and adds the coloring tags to the RpcContext.
[0044] The flowchart of the traffic coloring method in the Dubbo framework provided in this application embodiment is shown below. Figure 4 As shown, the coloring tags generated by traffic coloring can be used in routing functions, load balancing functions, monitoring layers, and filters in the protocol layer at the cluster layer. This implementation method has the following advantages:
[0045] 1. Cluster fault tolerance is a function of the Cluster layer and is executed before the Monitor layer and Protocol layer. Traffic coloring is available in the latter two layers.
[0046] 2. Define the traffic coloring function in cluster fault tolerance, which can be executed before routing and load balancing within the same Cluster layer. In fact, both Router and LoadBalance functions are part of the cluster fault tolerance function, and their hierarchical structure is shown in the figure:
[0047] 3. Dubbo cluster fault tolerance offers extensions based on the wrapper pattern, effectively reducing integration costs. The advantage of the wrapper pattern is that it allows for functional enhancement of existing code through an outer wrapper without modifying its implementation. Dubbo's cluster fault tolerance strategy can only be configured once; if extensions are implemented using conventional methods, applications cannot select other cluster fault tolerance strategies. This solution extends cluster fault tolerance functionality using the wrapper pattern, allowing applications to further configure suitable fault tolerance strategies on top of this.
[0048] In one exemplary instance, after coloring the request using the introduced traffic coloring feature, the method further includes:
[0049] First, the colored tags obtained after coloring are passed from front to back in the cluster layer of the Dubbo framework according to the direction of request execution;
[0050] Secondly, when the coloring mark is passed to the fault tolerance function of the cluster layer in the Dubbo framework, the coloring mark is used to realize the coloring traffic routing.
[0051] In one exemplary instance, after implementing colored traffic routing using the colored tags, the method further includes:
[0052] First, the coloring markers are passed from the cluster layer in the Dubbo framework to the monitoring layer;
[0053] Secondly, the dyeing mark is used to realize dyeing flow detection.
[0054] In one exemplary instance, after implementing the dyeing flow detection using the dyeing marker, the method further includes:
[0055] First, the coloring marker is passed from the monitoring layer in the Dubbo framework to the protocol layer;
[0056] Secondly, the dyeing markers are used to achieve classification and filtering of dyeing flow.
[0057] The traffic coloring method in the Dubbo framework provided in this application solves the problem that traffic coloring using filters cannot take effect at the cluster layer. It requests that traffic coloring be performed before executing cluster fault tolerance functions, and the coloring markers can be used in subsequent functional modules such as routing, load balancing, and filtering. Different layers of the Dubbo framework have their own division of labor; the capabilities provided by the Cluster, Monitor, and Protocol layers are typically used to implement traffic coloring-related functions.
[0058] 1. The Cluster layer includes functions such as routing and load balancing, which can be used to implement colored traffic routing;
[0059] 2. Monitor layer, mainly containing the monitoring implementation, which can be used to achieve color traffic detection;
[0060] 3. Protocol layer, which includes filter functionality, can be used to classify and filter colored traffic.
[0061] To ensure that traffic coloring can be used for all three layers of functionality, traffic coloring must be implemented at the Cluster layer. Therefore, the traffic coloring method in the Dubbo framework provided in this application implements traffic coloring by extending the cluster fault tolerance strategy.
[0062] In one exemplary instance, the coloring mark, as the carrier of the traffic coloring label, is added to the request context RpcContext for transmission as the content corresponding to the attachment parameter.
[0063] This application embodiment also provides a flow coloring device in the Dubbo framework, including: a memory and a processor, wherein the memory is used to store an executable program;
[0064] The processor is used to read and execute the executable program to implement the traffic coloring method in the Dubbo framework described in any of the above embodiments.
[0065] The traffic coloring device in the Dubbo framework provided in this application introduces a predefined traffic coloring function in the cluster layer of the Dubbo framework. Before a request reaches the cluster layer of the Dubbo framework for fault tolerance, the introduced traffic coloring function is used to color the request. Therefore, the coloring mark formed after coloring can be used in the cluster layer and subsequent hierarchical structures of the Dubbo framework, thereby expanding the scope of use of the coloring mark and improving the utilization rate of the coloring mark.
[0066] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
Claims
1. A flow coloring method in the Dubbo framework, characterized in that, include: Introduce a predefined traffic coloring feature in the cluster layer of the Dubbo framework; Before a request reaches the cluster layer in the Dubbo framework for fault tolerance, the introduced traffic coloring feature is used to color the request.
2. The method according to claim 1, characterized in that, The cluster layer in the Dubbo framework introduces a predefined traffic coloring feature, including: The cluster layer in the Dubbo framework introduces a predefined traffic coloring function by extending fault tolerance capabilities.
3. The method according to claim 2, characterized in that, The cluster layer in the Dubbo framework introduces a predefined traffic coloring function by extending fault tolerance capabilities, including: The cluster layer in the Dubbo framework extends the fault tolerance functionality in a wrapper pattern to introduce predefined traffic coloring features.
4. The method according to claim 3, characterized in that, The cluster layer in the Dubbo framework extends the fault tolerance functionality in a wrapper pattern to introduce predefined traffic coloring functionality, including: The fault tolerance function is extended in the cluster layer of the Dubbo framework in a wrapper pattern by calling the com.alibaba.Dubbo.rpc.cluster.Cluster interface to introduce a predefined traffic coloring function; wherein the com.alibaba.Dubbo.rpc.cluster.Cluster interface contains pre-written traffic identification and tagging logic for implementing the traffic coloring function.
5. The method according to claim 1, characterized in that, After coloring the request using the introduced traffic coloring function, the method further includes: The colored tags obtained after coloring are passed from front to back in the cluster layer of the Dubbo framework according to the direction of request execution; When the coloring mark is passed to the fault tolerance function of the cluster layer in the Dubbo framework, the coloring mark is used to realize the coloring traffic routing.
6. The method according to claim 5, characterized in that, The fault tolerance features include routing and load balancing.
7. The method according to claim 5, characterized in that, After implementing colored traffic routing using the colored tags, the method further includes: The coloring markers are passed from the cluster layer in the Dubbo framework to the monitoring layer; The dyeing marker is used to achieve dyeing flow detection.
8. The method according to claim 7, characterized in that, After using the dyeing marker to achieve dyeing flow detection, the method further includes: The coloring marker is passed from the monitoring layer to the protocol layer in the Dubbo framework; The dyeing markers are used to achieve classification and filtering of dyeing flow.
9. The method according to claim 5, 7 or 8, characterized in that, The coloring mark, which serves as the carrier of the traffic coloring label, is added to the request context RpcContext for transmission, corresponding to the content of the attachment parameter.
10. A flow coloring device in a Dubbo framework, characterized in that, A memory and a processor, wherein the memory is used to store an executable program; The processor is used to read and execute the executable program to implement the traffic coloring method in the Dubbo framework as described in any one of claims 1-9.