Traffic diversion method, device, computer-readable storage medium, and electronic device
By performing traffic shunt calculation in the target container, the problem of high coupling between the shunt tool and business applications in AB test is solved, and the effect of reducing work costs and resource occupation is achieved.
Patent Information
- Application Number
- CN202210827687.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-14
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2042-07-14
AI Technical Summary
In the prior art, during the AB test, the relevant shunt tools are highly coupled with business applications, resulting in high work costs.
By performing traffic shunt calculations in a target container separated from the application container, the correspondence between each target object and the version of the business application is determined, and traffic is routed to the corresponding resource management component.
It reduces the coupling between shunt tools and business applications, reduces development costs and resource usage, and avoids the problem of high code management complexity.
Smart Images

Figure CN115190076B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing, and in particular to a traffic diversion method, device, computer-readable storage medium and electronic device. Background Art
[0002] As the Internet traffic dividend gradually declines, more and more product operations have begun to focus on data-driven refined operation methods, hoping to continue to achieve steady user growth through refined operations. AB testing is one of the effective refined operation methods: before the product is officially iterated and released, two or more plans are formulated for the same goal, and user traffic is divided into several groups. Under the premise of ensuring that the characteristics of each group of users are similar, users are allowed to see different plan designs separately, and scientific decisions are made based on the real data feedback from several groups of users.
[0003] As a basic function of AB testing, diversion provides application products with the ability to integrate AB testing in AB testing, and realizes the random allocation effect of different users on different experimental plans for business applications. Based on the results of diversion, the application product presents different plans to users, providing basic support for subsequent statistics on user usage in the product.
[0004] However, in the prior art, the code of the relevant diversion tool is usually introduced into the business application code to achieve diversion. Figure 1 As shown, the business party that needs to conduct AB testing introduces SDK (Software Development Kit) into the application product. The application product obtains the necessary AB test information (such as experimental information / experimental grouping) pre-configured in the infrastructure of the AB test platform by calling the SDK interface, and obtains the experimental group assigned to the user in the AB test through the SDK when the user initiates an access request, thereby returning the page or data of the corresponding plan of the user's corresponding experimental group to achieve the user's diversion effect. Among them, the SDK is provided to the application product that needs to conduct AB testing in the form of a dependency package. The application product introduces the SDK into the product code library and conducts personalized development. Finally, the SDK will be built together with the business code as part of the application product code and released to the operating environment for integration with the application business system.
[0005] Therefore, in the process of implementing AB test diversion, the relevant methods in the prior art need to introduce external code (code of the relevant diversion tool) into the business application code, which makes the coupling between the relevant diversion tool and the business application too high. On the one hand, this increases the development cost of the business. On the other hand, the external code runs as part of the business system, which will occupy some resources and even cause abnormal situations in the process, thereby producing negative effects, and thus causing the problem of high work costs.
[0006] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0007] The embodiments of the present invention provide a traffic diversion method, device, computer-readable storage medium and electronic device to at least solve the technical problem of high working cost caused by the high coupling between related diversion tools and business applications during AB testing in the prior art.
[0008] According to one aspect of an embodiment of the present invention, a traffic diversion method is provided, comprising: obtaining traffic of at least one target object requesting access to a business application; performing traffic diversion calculation on the current target container to determine the correspondence between each target object and the version of the business application, wherein the target container corresponds to the application container one-to-one, different application containers are used to run different versions of the same business application, and different application containers are set in different resource management components; based on the correspondence, routing the traffic corresponding to the at least one target object to the target resource management component.
[0009] Furthermore, the traffic diversion method also includes: determining a random number corresponding to each target object based on a traffic factor corresponding to the traffic of the current target container; obtaining the total number of buckets corresponding to all versions; performing modulo calculation on the random number and the total number of buckets to obtain a calculation result; determining the bucket to which each target object belongs based on the calculation result; and determining the correspondence between each target object and the version based on the bucket to which each target object belongs.
[0010] Furthermore, the traffic diversion method also includes: if the corresponding relationship represents that the target version is the same as the version corresponding to the current target container, then the current resource management component is determined to be the target resource management component, and the target traffic is routed to the current application container, wherein the target version is the version corresponding to the target traffic, and the target traffic is the traffic in the traffic corresponding to at least one target object; if the corresponding relationship represents that the target version is different from the version corresponding to the current target container, then the resource management component corresponding to the target version is determined to be the target resource management component, and the target traffic is routed to the target container in the target resource management component.
[0011] Furthermore, the target container in the target resource management component is used to determine whether there is a target identifier in the target request after routing the target traffic to the target container in the target resource management component. If there is a target identifier, the target traffic is routed to the application container in the target resource management component, wherein the target request is used to request the target resource management component to process the target traffic, and the target identifier indicates that the target traffic has completed the diversion calculation.
[0012] Furthermore, the traffic diversion method also includes: before obtaining the traffic of at least one target object requesting access to the business application, based on different versions of the business application, building an image file corresponding to each version; determining a resource management component for running the image file; and configuring a target container in the resource management component for running the image file.
[0013] Furthermore, the traffic diversion method also includes: after configuring the target container in the resource management component used to run the image file, updating the routing object of the target gateway from the port of the application container to the port of the target container, wherein the target gateway is used to receive traffic from at least one target object requesting access to the business application.
[0014] Furthermore, the traffic diversion method also includes: after configuring the target container in the resource management component used to run the image file, obtaining at least one diversion rule, wherein the diversion rule is used to determine the method by which the target container performs traffic diversion calculation; obtaining the host address of the host where each resource management component is located; based on the diversion rule and the host address, generating a target diversion rule, wherein the target diversion rule is used for the target container to determine the correspondence between the version and the resource management component.
[0015] According to another aspect of an embodiment of the present invention, a traffic diversion device is also provided, including: an acquisition module, used to obtain the traffic of at least one target object requesting access to a business application; a determination module, used to perform traffic diversion calculations on the current target container, and determine the correspondence between each target object and the version of the business application, wherein the target container corresponds to the application container one-to-one, different application containers are used to run different versions of the same business application, and different application containers are set in different resource management components; a processing module, used to route the traffic corresponding to at least one target object to the target resource management component based on the correspondence.
[0016] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned traffic diversion method when running.
[0017] According to another aspect of an embodiment of the present invention, an electronic device is also provided, which includes one or more processors; a memory for storing one or more programs, which, when the one or more programs are executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the above-mentioned traffic diversion method when running.
[0018] In the embodiment of the present invention, a traffic diversion method is implemented based on a target container separated from an application container, by obtaining the traffic of at least one target object requesting access to a business application, and then performing diversion calculation on the traffic through the current target container, determining the correspondence between each target object and the version of the business application, and then routing the traffic corresponding to at least one target object to the target resource management component based on the correspondence. Among them, the target container corresponds to the application container one by one, different application containers are used to run different versions of the same business application, and different application containers are set in different resource management components.
[0019] In the above process, since the application container is used to run business applications, the traffic is diverted and calculated based on the target container separated from the application container, and the traffic corresponding to at least one target object is routed to the target resource management component based on the correspondence between the target object and the version determined by the diversion calculation, which effectively reduces the coupling between the diversion tool and the business application, and avoids introducing external code used to implement diversion into the business application code, thereby reducing the development cost of the business application on the one hand, and reducing the resource occupation of the business application during operation on the other hand, thereby achieving relatively low-cost traffic diversion. In addition, using different application containers to run different versions of business applications avoids the problem of high code management complexity caused by the need to support different versions in the same set of code when the differences between different versions are large.
[0020] It can be seen that the solution provided in the present application achieves the purpose of realizing traffic diversion based on the target container separated from the application container, thereby achieving the technical effect of reducing work costs, and further solving the technical problem of high work costs caused by the high coupling between related diversion tools and business applications in the process of AB testing in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0022] Figure 1 It is a schematic diagram of a flow diversion method in the prior art;
[0023] Figure 2 is a schematic diagram of an optional traffic diversion method according to an embodiment of the present invention;
[0024] Figure 3 is a schematic diagram of an optional traffic diversion method according to an embodiment of the present invention;
[0025] Figure 4is a schematic diagram of an optional target gateway routing object before updating according to an embodiment of the present invention;
[0026] Figure 5 is a schematic diagram of an optional target gateway after the routing object is updated according to an embodiment of the present invention;
[0027] Figure 6 is a schematic diagram of an optional traffic diversion method according to an embodiment of the present invention;
[0028] Figure 7 is a schematic diagram of an optional traffic bucketing algorithm according to an embodiment of the present invention;
[0029] Figure 8 is a schematic diagram of an optional flow diversion device according to an embodiment of the present invention;
[0030] Fig. 9 is a schematic diagram of an optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] For the convenience of description, some nouns or terms involved in the embodiments of the present application are explained below:
[0034] SDK (Software Development Kit): Generally, it is a collection of development tools used by software engineers to build application software for specific software packages, software frameworks, hardware platforms, operating systems, etc., or a toolkit provided by a third-party service provider to implement a certain function of a software product, which usually appears in the form of API documentation, examples, and tools.
[0035] Container: A container is a standardized software unit that packages code and all its dependencies so that applications can run reliably and quickly from one computing environment to another. A container image is a lightweight, independent executable software package. It contains everything a program needs to run: code, runtime dependencies, system tools, system libraries, and settings. The container is an abstraction at the application layer that packages code and dependencies together. Multiple containers can run on the same machine and share the operating system kernel with other containers, and each container runs as an independent process in user space.
[0036] Kubernetes: Kubernetes is an open source container orchestration engine from Google that supports automated deployment, large-scale scalability, and application container management. Kubernetes is a portable, extensible, open source platform for managing containerized workloads and services that facilitates declarative configuration and automation. Kubernetes has a large and rapidly growing ecosystem with a wide range of services, support, and tools.
[0037] Pod: In a kubernetes cluster, Pod is the basis of all business types, the smallest unit level of K8S management, and the smallest resource management component. It is a combination of one or more containers. These containers share storage, network, and namespace, as well as specifications for how to run. In a Pod, all containers are arranged and scheduled in the same way and run in a shared context. For specific applications, Pod is their logical host, and Pod contains multiple application containers related to the business.
[0038] Sidecar container: A Sidecar container is a container that runs with the main container in a Pod. The Sidecar pattern can extend and enhance the functionality of the current container without changing it. The sidecar can access the same resources as the main application. The sidecar is independent of its main application and is not restricted by the main application development language.
[0039] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0040] Example 1
[0041] According to an embodiment of the present invention, an embodiment of a traffic diversion method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0042] Figure 2 is a schematic diagram of an optional flow diversion method according to an embodiment of the present invention, such as Figure 2 As shown, the method is applied to the AB testing scenario and includes the following steps:
[0043] Step S201: Obtain traffic of at least one target object requesting access to a business application.
[0044] In step S201, traffic of at least one target object requesting to access a business application can be obtained through an electronic device, an application system, a server, etc. In the present application, traffic of at least one target object requesting to access a business application is obtained through a traffic diversion system. Optionally, traffic of at least one target object requesting to access a business application can be obtained through a current target container in the traffic diversion system.
[0045] Step S202, traffic is split and calculated through the current target container to determine the correspondence between each target object and the version of the business application, wherein the target container corresponds to the application container one-to-one, different application containers are used to run different versions of the same business application, and different application containers are set in different resource management components.
[0046] Optionally, the aforementioned traffic diversion system may include multiple resource management components, such as Figure 3 As shown in the rightmost box in the figure, different resource management components and different versions of the same business application (such as Figure 3 The resource management component may be a Pod in the Kubernetes system, the target container may be a Sidecar container, and the different versions of the same business application may be used to implement AB testing of the business application.
[0047] Optionally, the current target container is a target container in a resource management component in the traffic diversion system, and in the present application, the working process of the target container in each resource management component is illustrated by the working process of the current target container. Specifically, when the current target container obtains the traffic of at least one target object requesting access to a business application, the current target container can determine a method for performing diversion calculation on the aforementioned traffic based on the pre-pulled diversion configuration information, wherein the method for performing diversion calculation on the aforementioned traffic can be used to determine the proportion of the traffic corresponding to each version in the total traffic, the diversion algorithm used, etc., so that the correspondence between each target object and the version of the business application can be determined based on the result of the diversion calculation.
[0048] It should be noted that since the application container is used to run business applications, the traffic is diverted and calculated based on the target container separated from the application container, which effectively reduces the coupling between the diversion tool and the business application, and avoids the introduction of external code used to implement diversion into the business application code, thereby reducing the development cost of the business application on the one hand, and reducing the resource usage of the business application when it is running on the other hand. In addition, using different application containers to run different versions of business applications avoids the problem of high code management complexity caused by the need to support different versions in the same set of code using SDK when there are large differences between different versions.
[0049] Step S203: Based on the corresponding relationship, the traffic corresponding to at least one target object is routed to the target resource management component.
[0050] Optionally, after determining the correspondence between each target object and the version, the current target container can use the resource management component corresponding to the version corresponding to the traffic of at least one target object as the target resource management component, and can route the traffic corresponding to at least one target object to the target container in the target resource management component through a proxy, and then route the traffic to the application container in the target resource management component through the target container in the target resource management component for AB testing. The current target container can determine the correspondence between each version and the resource management component based on the aforementioned diversion configuration information.
[0051] Based on the scheme defined in the above steps S201 to S203, it can be known that in an embodiment of the present invention, a traffic diversion method is implemented based on a target container separated from an application container, by obtaining the traffic of at least one target object requesting access to a business application, and then performing diversion calculation on the traffic through the current target container, determining the correspondence between each target object and the version of the business application, and then routing the traffic corresponding to at least one target object to the target resource management component based on the correspondence. Among them, the target container corresponds to the application container one by one, different application containers are used to run different versions of the same business application, and different application containers are set in different resource management components.
[0052] It is easy to notice that in the above process, since the application container is used to run business applications, the traffic is diverted and calculated based on the target container separated from the application container, and the traffic corresponding to at least one target object is routed to the target resource management component based on the correspondence between the target object and the version determined by the diversion calculation, which effectively reduces the coupling between the diversion tool and the business application, and avoids introducing the external code used to implement the diversion into the business application code, thereby reducing the development cost of the business application on the one hand, and reducing the resource usage of the business application during operation on the other hand, thereby achieving relatively low-cost traffic diversion. In addition, the use of different application containers to run different versions of business applications avoids the problem of high code management complexity caused by the need to support different versions in the same set of code when the differences between different versions are large.
[0053] It can be seen that the solution provided in the present application achieves the purpose of realizing traffic diversion based on the target container separated from the application container, thereby achieving the technical effect of reducing work costs, and further solving the technical problem of high work costs caused by the high coupling between related diversion tools and business applications in the process of AB testing in the prior art.
[0054] In an optional embodiment, before obtaining traffic from at least one target object requesting access to a business application, the traffic diversion system may build an image file corresponding to each version based on different versions of the business application, and then determine a resource management component for running the image file, thereby configuring a target container in the resource management component for running the image file.
[0055] Optional, such as Figure 3As shown, relevant staff can develop various versions in AB testing, and the traffic diversion system can build the corresponding image files based on the developed business application versions. After that, the traffic diversion system can determine the Pods assigned to each image, and then configure target containers for these Pods, and finally deploy and run the application containers and target containers corresponding to the versions in each Pod.
[0056] It should be noted that by configuring the target container in the resource management component used to run the image file, the external code used to implement the diversion is avoided from being introduced into the business application code, thereby effectively reducing the coupling between the diversion tool and the business application.
[0057] In an optional embodiment, after configuring the target container in the resource management component used to run the image file, the traffic diversion system can update the routing object of the target gateway from the port of the application container to the port of the target container, wherein the target gateway is used to receive traffic from at least one target object requesting access to the business application.
[0058] Optional, such as Figure 4 , Figure 5 As shown in the figure, in the actual application scenario, the traffic of the user (i.e. the aforementioned target object) enters the business application through the target gateway, and the target gateway randomly distributes the traffic to a certain Pod. Therefore, after configuring the target container, in order to ensure that the target container can obtain and distribute traffic, it is necessary to use traffic hijacking to replace the routing object of the target gateway from Figure 4 The port of the application container shown (i.e. Figure 4 Update the "Application Container: 80" in the Figure 5 The port of the target container shown (i.e. Figure 5 The "target container: 80" in the example above indicates that the port exposed by the original business application is taken over by the target container so that the target container can implement traffic proxy. The configuration of the target gateway can remain unchanged.
[0059] It should be noted that the effective implementation of the offload calculation is ensured by replacing the routing object of the target gateway.
[0060] In an optional embodiment, after configuring the target container in the resource management component for running the image file, the traffic diversion system can obtain at least one diversion rule, and then obtain the host address of the host where each resource management component is located, thereby generating a target diversion rule based on the diversion rule and the host address. The diversion rule is used to determine the method by which the target container performs diversion calculation on the traffic, and the target diversion rule is at least used for the target container to determine the corresponding relationship between the version and the resource management component.
[0061] Optionally, after configuring the target container, such as Figure 3 As shown, relevant staff can define AB testing to obtain experimental information (i.e., diversion rules), and configure the experimental information to the experimental diversion service in the traffic diversion system. Among them, the diversion rules are used to determine the method of diversion calculation for the aforementioned traffic, and the method of diversion calculation for the aforementioned traffic can be used to determine the proportion of traffic corresponding to each version in the total traffic, the diversion algorithm used, etc.
[0062] Furthermore, if Figure 3 As shown, the experimental diversion service in the traffic diversion system can also be connected to the service registration center in the traffic diversion system. Optionally, the working process of the registration center is first described. Specifically, Figure 3 As shown, business applications are deployed through microservices. When the application container and the target container in the Pod are running, each container can register its own service information (such as port address, etc.) to the service registration center. And all container copies that provide the same business functions need to be regarded as the same service, that is, the Pods corresponding to the same version are regarded as the same service. Therefore, it is necessary to uniformly manage the service information of each service and the running copy address (that is, the aforementioned host address) and other information through a centralized service registration center. Among them, it should be noted that in order to ensure the efficiency of the traffic diversion system in processing user traffic, corresponding multiple groups of Pods can be set for the same version of the same business application.
[0063] Furthermore, if Figure 3 As shown, the experimental diversion service can pull the service information and running copy address of each Pod from the service registration center, and finally calculate and form the diversion configuration information required by the target container (i.e., the aforementioned target diversion rule) in combination with the aforementioned experimental information, so that the target container can successfully route the traffic corresponding to the version corresponding to the Pod to the Pod based on the running copy address of each Pod and other information. Among them, the target container can obtain the diversion configuration information from the experimental diversion service through a network request with a fixed protocol by using a timed pull method.
[0064] It should be noted that by determining the target diversion rule based on the diversion rule and the host address of the host where each resource management component is located, it is ensured that the target container in each resource management component can successfully route each traffic to the corresponding resource management component during the application process.
[0065] In an optional embodiment, in the process of performing traffic diversion calculation on the current target container to determine the correspondence between each target object and the version of the business application, the traffic diversion system can determine the random number corresponding to each target object based on the traffic factor corresponding to the traffic through the current target container, and then obtain the total number of buckets corresponding to all versions, and then perform modulo calculation on the random number and the total number of buckets to obtain the calculation result, thereby determining the bucket to which each target object belongs based on the calculation result, and then determining the correspondence between each target object and the version based on the bucket to which each target object belongs.
[0066] Optional, such as Figure 6 As shown, the current target container includes a traffic diversion algorithm executor. The current target container can implement the traffic diversion algorithm executor through a traffic bucketing algorithm. Figure 6 , Figure 7 As shown, during the configuration of experimental information and application operation stages, the experimental diversion service can randomly assign buckets to each version (i.e., determine the correspondence between each bucket and the version) to obtain bucket results, and use the bucket results as part of the diversion configuration information so that the current target container can pull and cache them locally through the diversion configuration information during the startup phase.
[0067] Furthermore, when the traffic from users requesting access to business applications arrives, Figure 7 As shown, the current target container can calculate the random number corresponding to each user according to the traffic factor carried by each flow through the hash algorithm, and perform modulo calculation on the obtained random number and the aforementioned total number of buckets to obtain the calculation result, and use the calculation result as the bucket number of the bucket to which the user belongs, so that the bucket to which each user belongs can be determined based on the calculation result. Afterwards, the version corresponding to each user can be determined based on the aforementioned bucket result.
[0068] Furthermore, in the same business application, there can be multiple types of pages, such as payment pages, advertising pages, etc., where different types of pages can correspond to multiple versions, and it can be determined that multiple versions corresponding to the same type of page belong to the same experimental layer and correspond to the same experimental layer number, and different types of pages belong to different experimental layers, that is, the number of experimental layers of the same business application is equal to the number of its page types. Therefore, Figure 7 As shown, when the traffic of user requests to access the business application arrives, the current target container can use the hash algorithm to calculate the random number corresponding to each user and each experimental layer according to the traffic factor carried by each traffic and the experimental layer number, thereby determining the correspondence between the user and the different versions in each page type.
[0069] Furthermore, with respect to the aforementioned situation in which there are multiple types of pages corresponding to multiple versions in the same business application, the possible combinations of versions corresponding to each type of page can be determined based on the method of permutations and combinations, and each combination can be identified as a version of the business application, that is, multiple Pods are used to run the aforementioned different combinations respectively, and each Pod runs one combination to facilitate subsequent proxy traffic.
[0070] It should be noted that by determining the correspondence between each target object and the version of the business application based on the traffic bucketing algorithm, effective distribution of the traffic of the target object is achieved, which facilitates improving the test effect of the AB test.
[0071] In an optional embodiment, in the process of routing the traffic corresponding to at least one target object to the target resource management component based on the correspondence, if the correspondence indicates that the target version is the same as the version corresponding to the current target container, the traffic diversion system can determine that the current resource management component is the target resource management component and route the target traffic to the current application container. If the correspondence indicates that the target version is different from the version corresponding to the current target container, the traffic diversion system can determine that the resource management component corresponding to the target version is the target resource management component and route the target traffic to the target container in the target resource management component. The target version is the version corresponding to the target traffic, and the target traffic is the traffic in the traffic corresponding to at least one target object.
[0072] Optionally, after the traffic diversion algorithm executor in the current application container determines the correspondence between each user and version, such as Figure 6 As shown, the traffic diversion algorithm executor can distribute the traffic through the traffic proxy router in the current application container.
[0073] Specifically, Figure 6 As shown in the figure, if the version corresponding to the traffic of a certain user (i.e. the aforementioned target traffic) is the same as the version corresponding to the Pod where the current application container is located, the traffic proxy router can directly route the traffic to the application container in the Pod where the current application container is located (i.e. the aforementioned current application container) through a proxy. If the version corresponding to the traffic of a certain user is different from the version corresponding to the Pod where the current application container is located, the traffic proxy router can route the traffic through a proxy to the target container in the Pod with the same version as the traffic.
[0074] Among them, since the containers in the same Pod share the network and storage and expose the same network address to the outside, for the business container and application container in the same Pod, Figure 6As shown, the two can access each other through the local host localhost, and both present the same network address to the outside world.
[0075] It should be noted that by routing the target object's traffic to the target container or application container according to the different target resource management components, the problem of lack of supervision caused by still routing the traffic to the application container during the process of routing traffic between different Pods is avoided.
[0076] In an optional embodiment, the target container in the target resource management component is used to determine whether there is a target identifier in the target request after routing the target traffic to the target container in the target resource management component; if the target identifier exists, the target traffic is routed to the application container in the target resource management component, wherein the target request is used to request the target resource management component to process the target traffic, and the target identifier indicates that the target traffic has completed the diversion calculation.
[0077] Optionally, when the version corresponding to a user's traffic is different from the version corresponding to the Pod where the current application container is located, and the traffic proxy router in the current application container routes the traffic to the target container in the Pod with the same version as the traffic, the target container responsible for receiving the traffic (i.e., the target container in the target resource management component) can determine whether the request containing the traffic (i.e., the target request) carries a target identifier. If there is a target identifier, the target container responsible for receiving the traffic can route the target traffic to the application container in the Pod where the target container responsible for receiving the traffic is located. On the contrary, if there is no target identifier, the target container responsible for receiving the traffic will perform diversion calculation on the traffic.
[0078] Furthermore, after the target container responsible for receiving the traffic determines that there is a target identifier, the target container responsible for receiving the traffic can also determine whether the version recorded in the target identifier is the same as the version corresponding to itself, so as to achieve a supervision effect. If they are different, the traffic can be recalculated or an error can be reported. Among them, the target identifier can also represent the target version corresponding to the target traffic.
[0079] It should be noted that by routing the target traffic to the application container in the target resource management component when there is a target identifier in the target request, it is possible to effectively distinguish the traffic received by the target container from the gateway and the traffic received from other Pods, thereby ensuring the accuracy of traffic diversion.
[0080] In an optional embodiment, based on Figure 6The traffic diversion method shown in the figure illustrates the working process of the target container in the application scenario. Specifically, after the user traffic enters the business application through the gateway, it is randomly distributed to the Pod by the gateway. The target container obtains the traffic as the Pod network entrance, and the diversion algorithm executor performs the diversion calculation according to the traffic factor carried by the traffic (generally the user number, etc.), and obtains the version corresponding to the user. Then the traffic proxy router distributes the traffic. If the version corresponding to the user corresponds to the Pod where the current application container is located, the traffic is directly proxied to the current business container; if the version corresponding to the user corresponds to other Pods, the proxy traffic is sent to the corresponding Pod, thereby realizing traffic diversion.
[0081] Based on the above content, it can be known that in this application, user traffic is proxied to application containers corresponding to different versions by requesting traffic proxy. Prior to this, it was only necessary to add the target container image to the application deployment strategy and assist with a small amount of port configuration and other work without the need to dock and transform the business application code, thereby eliminating the need to introduce additional dependencies into the application and perform access development work. At the same time, no additional dependencies also means that there will be no negative impact on the operation of the business application itself. In addition, the use of different application containers to run different versions of business applications avoids the problem of high code management complexity caused by the need to support different versions in the same set of code using the SDK when there are large differences between different versions.
[0082] It can be seen that the solution provided in the present application achieves the purpose of realizing traffic diversion based on the target container separated from the application container, thereby achieving the technical effect of reducing work costs, and further solving the technical problem of high work costs caused by the high coupling between related diversion tools and business applications in the process of AB testing in the prior art.
[0083] Example 2
[0084] According to an embodiment of the present invention, an embodiment of a flow splitting device is provided, wherein: Figure 8 is a schematic diagram of an optional flow diversion device according to an embodiment of the present invention, such as Figure 8 As shown, the device comprises:
[0085] The acquisition module 801 is used to acquire the traffic of at least one target object requesting to access a business application;
[0086] The determination module 802 is used to perform traffic flow calculation through the current target container to determine the correspondence between each target object and the version of the business application, wherein the target container corresponds to the application container one by one, different application containers are used to run different versions of the same business application, and different application containers are set in different resource management components;
[0087] The processing module 803 is used to route the traffic corresponding to at least one target object to the target resource management component based on the corresponding relationship.
[0088] It should be noted that the above-mentioned acquisition module 801, determination module 802 and processing module 803 correspond to steps S201 to S203 in the above-mentioned embodiment. The examples and application scenarios implemented by the three modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned embodiment 1.
[0089] Optionally, the determination module also includes: a first determination submodule, used to determine the random number corresponding to each target object through the current target container based on the traffic factor corresponding to the traffic; a first acquisition submodule, used to obtain the total number of buckets corresponding to all versions; a calculation module, used to perform modulus calculation on the random number and the total number of buckets to obtain a calculation result; a second determination submodule, used to determine the bucket to which each target object belongs based on the calculation result; and a third determination submodule, used to determine the correspondence between each target object and the version based on the bucket to which each target object belongs.
[0090] Optionally, the processing module also includes: a first processing sub-module, used to determine that the current resource management component is the target resource management component if the corresponding relationship represents that the target version is the same as the version corresponding to the current target container, and route the target traffic to the current application container, wherein the target version is the version corresponding to the target traffic, and the target traffic is the traffic in the traffic corresponding to at least one target object; a second processing sub-module, used to determine that the resource management component corresponding to the target version is the target resource management component if the corresponding relationship represents that the target version is different from the version corresponding to the current target container, and route the target traffic to the target container in the target resource management component.
[0091] Optionally, the target container in the target resource management component is used to determine whether there is a target identifier in the target request after routing the target traffic to the target container in the target resource management component; if there is a target identifier, the target traffic is routed to the application container in the target resource management component, wherein the target request is used to request the target resource management component to process the target traffic, and the target identifier indicates that the target traffic has completed the diversion calculation.
[0092] Optionally, the traffic diversion device also includes: a construction module, used to build an image file corresponding to each version based on different versions of the business application; a fourth determination submodule, used to determine the resource management component used to run the image file; and a configuration module, used to configure the target container in the resource management component used to run the image file.
[0093] Optionally, the traffic diversion device also includes: an update module, used to update the routing object of the target gateway from the port of the application container to the port of the target container, wherein the target gateway is used to receive traffic from at least one target object requesting access to the business application.
[0094] Optionally, the traffic diversion device also includes: a second acquisition submodule, used to acquire at least one diversion rule, wherein the diversion rule is used to determine the method for the target container to perform traffic diversion calculation; a third acquisition submodule, used to acquire the host address of the host where each resource management component is located; and a generation module, used to generate a target diversion rule based on the diversion rule and the host address, wherein the target diversion rule is used for the target container to determine the correspondence between the version and the resource management component.
[0095] Example 3
[0096] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned traffic diversion method when running.
[0097] Example 4
[0098] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, wherein: Fig. 9 is a schematic diagram of an optional electronic device according to an embodiment of the present invention, such as Fig. 9 As shown, the electronic device includes one or more processors; a memory for storing one or more programs, which, when the one or more programs are executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the above-mentioned traffic diversion method when running.
[0099] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0100] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0101] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0102] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0103] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0104] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0105] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A flow diversion method, characterized in that: include: Obtaining traffic from at least one target object requesting access to a business application; The traffic is split and calculated through the current target container to determine the corresponding relationship between each target object and the version of the business application, wherein the target container corresponds to the application container one by one, different application containers are used to run different versions of the same business application, and different application containers are set in different resource management components, each resource management component includes an application container and a target container, the resource management component is a Pod in the Kubernetes system, and the current target container is in the resource management component; Based on the corresponding relationship, routing the traffic corresponding to the at least one target object to the target resource management component; Wherein, based on the corresponding relationship, routing the traffic corresponding to the at least one target object to the target resource management component includes: If the target version represented by the correspondence relationship is the same as the version corresponding to the current target container, the current resource management component is determined to be the target resource management component, and the target traffic is routed to the current application container, wherein the target version is the version corresponding to the target traffic, and the target traffic is the traffic in the traffic corresponding to the at least one target object, wherein the current target container and the current application container are within the current resource management component.
2. The method according to claim 1, characterized in that The traffic is split and calculated by the current target container to determine the corresponding relationship between each target object and the version of the business application, including: Determine, by the current target container, a random number corresponding to each target object based on a flow factor corresponding to the flow; Get the total number of buckets corresponding to all versions; Performing a modulo calculation on the random number and the total number of buckets to obtain a calculation result; Determine the bucket to which each target object belongs based on the calculation result; The correspondence between each target object and the version is determined based on the bucket to which each target object belongs.
3. The method according to claim 1, characterized in that Based on the corresponding relationship, routing the traffic corresponding to the at least one target object to the target resource management component includes: If the corresponding relationship indicates that the target version is different from the version corresponding to the current target container, the resource management component corresponding to the target version is determined as the target resource management component, and the target traffic is routed to the target container in the target resource management component.
4. The method according to claim 3, characterized in that: The target container in the target resource management component is used to determine whether there is a target identifier in the target request after routing the target traffic to the target container in the target resource management component; if the target identifier exists, the target traffic is routed to the application container in the target resource management component, wherein the target request is used to request the target resource management component to process the target traffic, and the target identifier indicates that the target traffic has completed the diversion calculation.
5. The method according to claim 1, characterized in that Before obtaining the traffic of at least one target object requesting to access the business application, the method further includes: Based on different versions of the business application, build an image file corresponding to each version; Determining a resource management component for running the image file; The target container is configured in a resource management component used to run the image file.
6. The method according to claim 5, characterized in that After configuring the target container in a resource management component for running the image file, the method further includes: The routing object of the target gateway is updated from the port of the application container to the port of the target container, wherein the target gateway is used to receive traffic from the at least one target object requesting access to the business application.
7. The method according to claim 5, characterized in that After configuring the target container in a resource management component for running the image file, the method further includes: Acquire at least one diversion rule, wherein the diversion rule is used to determine a method for the target container to perform diversion calculation on the flow; Get the host address of the host where each resource management component is located; A target diversion rule is generated based on the diversion rule and the host address, wherein the target diversion rule is at least used for the target container to determine the correspondence between the version and the resource management component.
8. A flow diversion device, characterized in that: include: An acquisition module, used to acquire traffic of at least one target object requesting to access a business application; A determination module, used to perform flow splitting calculation on the traffic through the current target container, and determine the correspondence between each target object and the version of the business application, wherein the target container corresponds to the application container one by one, different application containers are used to run different versions of the same business application, and different application containers are set in different resource management components, each resource management component includes an application container and a target container, the resource management component is a Pod in the Kubernetes system, and the current target container is in the resource management component; A processing module, configured to route traffic corresponding to the at least one target object to a target resource management component based on the corresponding relationship; The first processing submodule is used to determine that the current resource management component is the target resource management component if the target version represented by the correspondence relationship is the same as the version corresponding to the current target container, and route the target traffic to the current application container, wherein the target version is the version corresponding to the target traffic, and the target traffic is the traffic in the traffic corresponding to the at least one target object, wherein the current target container and the current application container are within the current resource management component.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the traffic diversion method described in any one of claims 1 to 7 when running.
10. An electronic device, characterized in that: The electronic device includes one or more processors; A memory for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the traffic diversion method described in any one of claims 1 to 7 when running.
Citation Information
Patent Citations
Service data selection method and device for testing and electronic equipment
CN111338607A
Test processing method and device, electronic equipment and computer readable storage medium
CN112929230A