CN109587068B - Flow switching method, device, equipment and computer readable storage medium - Google Patents

Flow switching method, device, equipment and computer readable storage medium Download PDF

Info

Publication number
CN109587068B
CN109587068B CN201811468895.6A CN201811468895A CN109587068B CN 109587068 B CN109587068 B CN 109587068B CN 201811468895 A CN201811468895 A CN 201811468895A CN 109587068 B CN109587068 B CN 109587068B
Authority
CN
China
Prior art keywords
message
service
service requester
request
flow
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811468895.6A
Other languages
Chinese (zh)
Other versions
CN109587068A (en
Inventor
卢道和
杨军
陈广胜
熊梦飞
梁炜强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN201811468895.6A priority Critical patent/CN109587068B/en
Publication of CN109587068A publication Critical patent/CN109587068A/en
Application granted granted Critical
Publication of CN109587068B publication Critical patent/CN109587068B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a flow switching method, which comprises the following steps: respectively establishing network connections between a service requester and a service provider and each message channel; obtaining a flow distribution ratio of the service called by the service requester; selecting a corresponding message channel for the service requester to send the request message by adopting a preset channel selection algorithm according to the flow distribution ratio; and sending the request message from the service requester to the service provider through the selected message channel. The invention also discloses a flow switching device, equipment and a computer readable storage medium. The invention realizes the accurate switching of each message forming the flow among different message channels.

Description

Flow switching method, device, equipment and computer readable storage medium
Technical Field
The present invention relates to the field of intelligent operation and maintenance technologies, and in particular, to a method, an apparatus, a device, and a computer-readable storage medium for switching traffic.
Background
In the existing distributed technology architecture, a service requester usually adopts a single-process fixed transmission channel, and deploys a plurality of service requesters to approximately proportionally control and distribute traffic. For example, the service requester needs to deploy 10 processes in total, wherein 4 processes fixedly use the message channel a, 6 processes fixedly use the message channel B, that is, 40% of the processes select the message channel a to send messages, and 60% of the processes select the message channel B to send messages. If the traffic needs to be switched from the message channel a to the message channel B, the number of processes using the message channel a only needs to be gradually reduced until all the processes use the channel B, and then the traffic switching is completed.
As can be seen from the above, in the prior art, the flow switching is realized by adjusting the number of processes using the message channels, and although the flow switching between different message channels is realized, when the flow switching is to be performed, the configuration needs to be modified and the switching needs to be realized after the restart, and the switching process is interrupted, so that smooth and accurate switching between different message channels of each message constituting the flow cannot be realized.
Disclosure of Invention
The invention mainly aims to provide a flow switching method, a flow switching device, flow switching equipment and a computer readable storage medium, and aims to solve the problem that the prior art cannot realize smooth and accurate switching of each message forming flow among different message channels.
In order to achieve the above object, the present invention provides a traffic switching method, including the following steps:
respectively establishing network connections between a service requester and a service provider and each message channel;
obtaining a flow distribution ratio of the service called by the service requester;
selecting a corresponding message channel for the service requester to send the request message by adopting a preset channel selection algorithm according to the flow distribution ratio;
and sending the request message from the service requester to the service provider through the selected message channel.
Optionally, before the step of obtaining the traffic allocation ratio of the service called by the current service requester, the method further includes:
dynamically acquiring a service flow distribution table from a third-party configuration center and caching the service flow distribution table to the local;
the obtaining of the traffic distribution ratio of the service called by the current service requester comprises:
and searching the service flow distribution table to obtain a flow distribution ratio of the service called by the service requester, wherein the flow distribution ratio is the distribution ratio of the flow of the service requester in each message channel.
Optionally, the searching the service traffic allocation table to obtain a traffic allocation ratio of the service invoked by the service requester includes:
and searching the service flow distribution table according to the subsystem corresponding to the service requester and the data center where the subsystem is located so as to obtain the flow distribution ratio of the service called by the service requester.
Optionally, the obtaining of the traffic allocation ratio of the service called by the current service requester includes:
and searching a service flow distribution table of a third-party configuration center according to a subsystem corresponding to the service requester and a data center where the subsystem is located, so as to dynamically obtain a flow distribution ratio of the service called by the service requester, wherein the flow distribution ratio is a distribution ratio of the flow of the service requester in each message channel.
Optionally, the selecting, according to the traffic distribution ratio, a corresponding message channel of the request message sent by the current service requester by using a preset channel selection algorithm includes:
judging whether a distribution ratio equal to 1 exists in the flow distribution ratio;
if the request message exists, the message channel corresponding to the distribution ratio equal to 1 is taken as the corresponding message channel of all the request messages sent by the current service request party;
if not, taking the distribution ratio corresponding message channel which is larger than 0 and smaller than 1 as the corresponding message channel for the current service requester to send the request message;
if a plurality of corresponding message channels for sending the request message by the service requester exist, determining a message channel corresponding to each request message sent by the service requester based on a preset calculation rule.
Optionally, if there are multiple corresponding message channels for sending the request message by the service requester, determining, based on a preset calculation rule, a message channel corresponding to each request message sent by the service requester includes:
if a plurality of corresponding message channels for sending request messages by the current service requester exist, accumulating each request message sent by the current service requester to obtain the total number of the request messages;
when the total number of the request messages reaches a preset value, resetting the total number of the request messages to zero, and re-accumulating each request message sent by the current service requester;
when the request message is accumulated every time, any message channel in the selected message channels is taken as a corresponding message channel for sending the request message by the current service requester;
in the process of accumulating the request messages each time, judging whether the ratio of the number of the request messages flowing into the current message channel to the preset value reaches the flow distribution ratio corresponding to the current message channel;
if so, taking the other message channel as a corresponding message channel for sending the request message by the current service requester, and continuously judging whether the ratio of the number of the request messages flowing into the current message channel to the preset value which is re-determined reaches the flow distribution ratio corresponding to the current message channel.
Further, to achieve the above object, the present invention also provides a flow switching device, including:
the connection establishing module is used for respectively establishing network connection between the service requester and the service provider and each message channel;
the ratio acquisition module is used for acquiring the flow distribution ratio of the service called by the service requester;
the channel selection module is used for selecting a corresponding message channel of the service request party for sending the request message by adopting a preset channel selection algorithm according to the flow distribution ratio;
and the flow transmission module is used for transmitting the request message from the service requester to the service provider through the selected message channel.
Optionally, the ratio obtaining module is further configured to:
dynamically acquiring a service flow distribution table from a third-party configuration center and caching the service flow distribution table to the local;
and searching the service flow distribution table to obtain a flow distribution ratio of the service called by the service requester, wherein the flow distribution ratio is the distribution ratio of the flow of the service requester in each message channel.
Optionally, the ratio obtaining module is further configured to:
and searching the service flow distribution table according to the subsystem corresponding to the service requester and the data center where the subsystem is located so as to obtain the flow distribution ratio of the service called by the service requester.
Optionally, the ratio obtaining module is further configured to:
and searching a service flow distribution table of a third-party configuration center according to a subsystem corresponding to the service requester and a data center where the subsystem is located, so as to dynamically obtain a flow distribution ratio of the service called by the service requester, wherein the flow distribution ratio is a distribution ratio of the flow of the service requester in each message channel.
Optionally, the channel selection module is configured to:
judging whether a distribution ratio equal to 1 exists in the flow distribution ratios or not;
if the request message exists, the message channel corresponding to the distribution ratio equal to 1 is taken as the corresponding message channel of all the request messages sent by the current service request party;
if not, taking the distribution ratio corresponding message channel which is larger than 0 and smaller than 1 as the corresponding message channel for the current service requester to send the request message;
if a plurality of corresponding message channels for sending the request message by the service requester exist, determining a message channel corresponding to each request message sent by the service requester based on a preset calculation rule.
Optionally, the channel selection module is further configured to:
if a plurality of corresponding message channels for sending request messages by the current service requester exist, accumulating each request message sent by the current service requester to obtain the total number of the request messages;
when the total number of the request messages reaches a preset value, resetting the total number of the request messages to zero, and re-accumulating each request message sent by the current service requester;
when the request message is accumulated every time, any message channel in the selected message channels is taken as a corresponding message channel for sending the request message by the current service requester;
in the process of accumulating the request messages each time, judging whether the ratio of the number of the request messages flowing into the current message channel to the preset value reaches the flow distribution ratio corresponding to the current message channel;
if so, taking the other message channel as a corresponding message channel for sending the request message by the current service requester, and continuously judging whether the ratio of the number of the request messages flowing into the current message channel to the preset value which is re-determined reaches the flow distribution ratio corresponding to the current message channel.
Further, to achieve the above object, the present invention also provides a traffic switching device, which includes a memory, a processor, and a traffic switching program stored on the memory and operable on the processor, wherein the traffic switching program, when executed by the processor, implements the steps of the traffic switching method according to any one of the above.
Further, to achieve the above object, the present invention also provides a computer readable storage medium, having a traffic switching program stored thereon, where the traffic switching program, when executed by a processor, implements the steps of the traffic switching method according to any one of the above.
According to the invention, through the message channels, network connections of the service requester and the service provider with the message channels are respectively established, so that a plurality of transmission channels of the flow are established, and each message forming the flow is convenient to switch among different message channels. In addition, a flow distribution ratio of each service request party calling service is further obtained, so that a message channel corresponding to each request message sent by each service request party is determined according to the flow distribution ratio, the request message is sent from the service request party to a service provider through the message channel, flow switching of each message among different message channels is further achieved, the whole switching process is smoother due to the fact that restarting is conducted after configuration does not need to be modified, flow switching is controlled through the flow distribution ratio instead of the process number, and therefore flow switching is more accurate.
Drawings
Fig. 1 is a schematic structural diagram of a hardware operating environment of a device according to an embodiment of the traffic switching device of the present invention;
fig. 2 is a schematic flow chart illustrating a traffic switching method according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a network connection architecture between a service requester and a service provider according to an embodiment of the traffic switching method of the present invention;
FIG. 4 is a flowchart illustrating an embodiment of step S30 in FIG. 2;
fig. 5 is a functional block diagram of a first flow switching device according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The invention provides a flow switching device.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a hardware operating environment of a device according to an embodiment of the traffic switching device of the present invention.
The flow switching equipment is preferably deployed in a distributed architecture system and used for realizing flow switching control in the distributed architecture system.
As shown in fig. 1, the traffic switching apparatus may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a memory device separate from the processor 1001 described above. It should be noted that the processor 1001 is installed in the traffic switching device in an embedded chip manner.
Those skilled in the art will appreciate that the hardware configuration of the flow switching device shown in fig. 1 does not constitute a limitation of the flow switching device, and may include more or fewer components than those shown, or some components in combination, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer-readable storage medium, may include therein an operating system, a network communication module, a user interface module, and a traffic switching program. The operating system is a program for managing and controlling the flow switching equipment and software resources, and supports the operation of a network communication module, a user interface module, a flow switching program and other programs or software; the network communication module is used to manage and control the network interface 1004; the user interface module is used to manage and control the user interface 1003.
In the hardware structure of the traffic switching device shown in fig. 1, the network interface 1004 is mainly used for connecting to a system background and performing data communication with the system background; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; the traffic switching apparatus calls a traffic switching program stored in the memory 1005 by the processor 1001 and executes a traffic switching method described below.
Based on the device hardware operating environment of the traffic switching device, the following embodiments of the traffic switching method of the present invention are proposed.
The flow switching method is preferably applied to a distributed system, a plurality of subsystems are deployed in the same distributed system, the subsystems are application programs for realizing specific service functions, for example, an inquiry subsystem can realize inquiry service, a transfer subsystem can realize transfer service, and a loan subsystem can realize loan service. In addition, the distributed system adopts a multi-data center mode to deploy subsystems, and the same subsystem can be deployed in one or more data centers.
For management, the atomic business is specifically represented by a service in a distributed system, such as a deduction service representing a deduction business, a loan service representing a loan business, and the like. Different services are distinguished by a service identity (Topic). Performing a service is equivalent to implementing a corresponding service, i.e. involving inter-subsystem calls, and thus traffic may be generated between different subsystems.
Referring to fig. 2, fig. 2 is a flowchart illustrating a flow switching method according to an embodiment of the present invention. In this embodiment, the traffic switching method includes the following steps:
step S10, respectively establishing network connection between the service requester and the service provider and each message channel;
in this embodiment, the implementation of the service requires establishing a network connection between the service requester and the service provider for transmitting traffic, so as to implement interaction between the service requester and the service provider.
In this embodiment, the service requester refers to a consumer of the service (a caller of the service, which corresponds to a certain subsystem), and the service provider refers to a provider of the service (a callee of the service, which corresponds to a certain subsystem). The service requester sends a request message (equivalent to a call message) to the service provider, and then calls the service provider to perform service processing, and the service provider returns a response (or does not return a response).
Based on the above description of the distributed system, in the distributed system, different subsystems may use the same service, for example, a deposit subsystem, a loan subsystem, and a transfer subsystem all need to use a withdrawal service (for example, a withdrawal subsystem provides a withdrawal service), that is, there is traffic transmission between the deposit subsystem and the withdrawal subsystem, between the loan subsystem and the withdrawal subsystem, and between the transfer subsystem and the withdrawal subsystem. To implement flow control, it is therefore necessary to switch the flow transmission.
The present embodiment preferably implements network connection between the service requester and the service provider through multiple message channels, and further implements switching control on traffic transmission.
As shown in fig. 3, assuming that a message channel A, B is available for implementing a network connection between a service requester and a service provider, a network connection is preferably established with message channel a and message channel B, respectively, at the time of respective startup of the service requester and the service provider, so as to implement a network connection between the service requester and the service provider through message channel a and/or message channel B.
In this embodiment, the message channel refers to a channel for transmitting a request message and a response message. A messaging channel refers to any channel through which messages may be transmitted, including but not limited to message queues (i.e., message middleware) such as rockmq (message queue), ActiveMQ, RabbitMQ, etc., or a physical network that may provide for message transmission, message middleware physical hardware products, etc.
In this embodiment, the connection between the service requester and the message channel is established, specifically, the physical connection between the service requester and the message channel is established, so that the service requester can physically perform message flow with the service provider through the message channel, but does not indicate that there is no message flow. The connection between the service provider and the message channel is established, specifically, the physical connection is established between the service provider and the message channel, so that the service provider can physically receive the call message of the service requester through the message channel.
Step S20, obtaining the flow distribution ratio of the service called by the current service requester;
in this embodiment, after the network connection between the service requester and the service provider is established, the service requester may send a request message to the service provider, and the service provider may also return a response message to the service requester. In order to implement the traffic transmission control between the two, and therefore the traffic switching is required, the embodiment preferably implements the traffic switching by switching the traffic transmission channel.
To realize accurate switching control of the flow, the present embodiment preferably controls the flow switching based on the flow allocation ratio. The traffic distribution ratio is the distribution ratio of the service requester traffic in each message channel. I.e. the traffic allocation ratio is a percentage value with a value of between 0 and 1, the same service requester invokes the traffic of the same service, and the sum of the allocation ratios on the message channels is equal to 1 (100%).
The present embodiment is not limited to the configuration of the flow distribution ratio. For example, a static traffic allocation ratio may be configured in a configuration file of the service requester, or a dynamic traffic allocation ratio may be configured by an independent third party.
Step S30, according to the flow distribution ratio, selecting the corresponding message channel of the current service request party for sending the request message by adopting a preset channel selection algorithm;
in this embodiment, because a plurality of message channels are provided between the service requester and the service provider, the accurate traffic switching requires determining an output channel of each message, that is, selecting a message channel.
Since the message is initiated by the service requester, the service requester is preferably used as a selector of the message channel in this embodiment to determine which message channel each request message to be sent specifically uses for transmission to the service provider.
In this embodiment, preferably, a preset channel selection algorithm is used to select a message channel corresponding to the request message sent by the current service requester according to the obtained traffic allocation ratio of the service invoked by the current service requester. The embodiment is not limited to the specific implementation process of the channel selection algorithm.
And step S40, sending the request message from the service requester to the service provider through the selected message channel.
In this embodiment, after the sending channel of the message is determined, the request message initiated by the service requester can be transmitted to the service provider through the selected message channel, the service provider processes the service after receiving the request message, and then returns the response message to the service requester according to the original path of the original message channel.
It should be further noted that the service provider and the service requester need to introduce a consistent API to perform the sending and receiving processes of the message related to the service call.
In this embodiment, network connections between the service requester and the service provider and the message channels are respectively established through the message channels, so as to establish a plurality of transmission channels of traffic, thereby facilitating switching of each message constituting the traffic among different message channels. In addition, a flow distribution ratio of each service requester calling service is further acquired, so that a message channel corresponding to each request message sent by each service requester is determined according to the flow distribution ratio, the request message is sent from the service requester to a service provider through the message channel, and flow switching of each message among different message channels is further realized.
Furthermore, the invention establishes the network connection between the service requester and the service provider and each message channel through the message channels to establish a plurality of transmission channels of the flow, and further can control the flow switching by configuring the flow distribution ratio.
Therefore, in an embodiment, to further facilitate centralized control of the traffic distribution ratio and avoid the influence on the service requester or provider when adjusting the traffic distribution ratio, it is preferable that an independent third-party configuration center configures the traffic distribution ratio, and the specific value of the traffic distribution ratio is preferably dynamically configured by the administrator as needed.
In addition, the invention adopts the network connection established between the service requester and the service provider to transmit the flow, so that the flow distribution ratio can be set from the subsystem level granularity or the data center level granularity, and the accurate switching control of the flow can be realized.
For example, the traffic is switched by different subsystems. For example, if the deposit subsystem, loan subsystem, and transfer subsystem call withdrawal services and transmit traffic via message channel A, B, the flow allocation ratio for the deposit subsystem may be set: the allocation ratio of the message channel a is 0.3, and the allocation ratio of the message channel B is 0.7 (that is, 30% of traffic flows through the message channel a, and 70% of traffic flows through the message channel B); flow distribution ratio of loan subsystem: the distribution ratio of the message channel A is 0.5, and the distribution ratio of the message channel B is 0.5; flow distribution ratio of the transfer subsystem: the allocation ratio of the message channel A is 0.2, and the allocation ratio of the message channel B is 0.8.
For another example, the flow rate is switched according to different data center levels, for example, if the deposit subsystem moves from the flow rate of the data center 1 to the message channel a and from the flow rate of the data center 2 to the message channel B, the flow rate distribution ratio of the deposit subsystem in different data centers may be set: the distribution ratio of the message channel A in the data center 1 is 1, and the distribution ratio of the message channel B is 0; the allocation ratio of the message channel a in the data center 2 is 0, and the allocation ratio of the message channel B is 1.
As can be seen from the above description, the flow distribution ratio of the present embodiment has the following advantages:
(1) smoothing the process: the flow distribution ratio is dynamically adjusted according to the needs, so that smooth adjustment of the flow switching process can be realized, and sudden change of flow transmission quantity caused by flow switching can be avoided.
(2) The process is accurate, and the risk is controllable: on the first hand, the flow distribution ratio can be adjusted from small to large, and if the situation which is not expected in the flow switching process occurs, the service call is not influenced in large batch. In the second aspect, the flow can be switched according to different subsystems, that is, the flow switching can be performed on the subsystems one by one, so that the influence of the fact that all the subsystems use the same flow distribution ratio is too wide is avoided. In a third aspect, traffic may be switched at a data center level, such as where a subsystem travels through lane a at data center 1 and a subsystem travels through lane B at another data center 2.
In addition, only the flow distribution ratio necessary for the current service is acquired according to the subsystem level and the data center level, and further the waste of the bandwidth and the computing resources of the distributed system can be avoided.
(3) And (3) control centralization: the manager of the dominant traffic switching can centrally adjust the traffic distribution ratio by modifying the data of the configuration center, and the adjustment process does not require the service requester or the service provider to change any configuration information.
(4) The elasticity is strong: since the traffic distribution ratio of the embodiment is configured by the third-party configuration center, that is, the traffic distribution ratio can be configured based on the actual situation of the distributed system, the method is suitable for a scenario of switching traffic of a small amount of systems in a small enterprise, and is also suitable for a scenario of switching traffic of thousands of systems.
(5) Boundary sensitivity: the flow distribution ratio of the embodiment is manually configured by the third-party configuration center, so that the flow can be accurately switched to the corresponding message channel for transmission, and the situation of flow deviation does not exist. For example, if a random algorithm is used to determine the traffic distribution ratio, it is difficult to ensure that the same traffic is distributed at a sum of the distribution ratios on the message channels equal to 1, and it is also difficult to ensure that the distribution ratio can be divided by the number of messages, for example, 100 messages, where 33.33% of the messages are transmitted through the message channel a and 66.67% of the messages are transmitted through the message channel B, and since 33.33% and 66.67% of the messages cannot be divided by 100, there is a traffic skew situation.
Further, since the traffic distribution ratio exists in the third-party configuration center, the traffic distribution ratio needs to be acquired from the third-party configuration center. In one embodiment, the flow allocation ratio is preferably obtained from a third party configuration center by any of the following means.
The first method is as follows: the method comprises the steps of firstly, dynamically obtaining a service flow distribution table from a third-party configuration center and caching the service flow distribution table to the local, and then, inquiring the service flow distribution table to obtain a flow distribution ratio of the service called by a current service requester.
The second method comprises the following steps: directly initiating a query request to a third-party configuration center, and dynamically acquiring a traffic distribution ratio of the service called by the current service requester by searching a service traffic distribution table of the third-party configuration center.
In this embodiment, since the flow allocation ratio may be adjusted in the third-party configuration center, it is preferable to dynamically acquire the flow allocation ratio from the third-party configuration center at regular time. It should be noted that in the two manners, the flow allocation ratio may be obtained dynamically from the third-party configuration center at regular time, or may be obtained dynamically from the third-party configuration center at irregular time.
Furthermore, as can be seen from the above embodiments, to achieve precise control over traffic switching, the traffic allocation ratio can thus be set from either subsystem-level granularity or data center-level granularity. Therefore, in this embodiment, the service traffic allocation table may be searched according to the subsystem corresponding to the service requester and the data center where the subsystem is located, so as to obtain the traffic allocation ratio of the service invoked by the service requester this time.
The service traffic allocation table and the traffic allocation ratio are further illustrated below.
The service flow distribution table is used for storing flow distribution ratios of services required to be called by the subsystems, and the subsystems are divided according to the data center.
The traffic distribution ratio is the distribution ratio of the service requester traffic in each message channel. I.e. the traffic allocation ratio is a percentage value with a value of between 0 and 1, the same service requester invokes the traffic of the same service, and the sum of the allocation ratios on the message channels is equal to 1 (100%).
TABLE 1
Figure BDA0001889160210000111
The service traffic distribution table shown in table 1 configures a traffic distribution ratio specifically for a subsystem level and a data center level. The flow distribution ratio corresponding to the subsystem 1 calling the service T1 in the data center 1 is as follows: the distribution ratio of the message channel A is 0, the distribution ratio of the message channel B is 0.8, and the distribution ratio of the message channel C is 0.2; the flow distribution ratio corresponding to the subsystem 2 calling the service T1 in the data center 1 is: the allocation ratio of the message channel A is 1, the allocation ratio of the message channel B is 0, and the allocation ratio of the message channel C is 0.
Further, referring to fig. 4, fig. 4 is a flowchart illustrating an embodiment of step S30 in fig. 2. Based on the service traffic distribution table and the traffic distribution ratio description described in the above embodiments, a description is given to a message channel selection process.
In this embodiment, the step S30 further includes:
step S301, judging whether a distribution ratio equal to 1 exists in the flow distribution ratio;
step S302, if the request message exists, the message channel corresponding to the distribution ratio equal to 1 is used as the corresponding message channel of all the request messages sent by the current service request party;
in this embodiment, since the traffic distribution ratio is a distribution ratio of traffic of the service requester in each message channel, if the traffic needs to flow through a certain message channel, the distribution ratio corresponding to the message channel is inevitably greater than 0, and similarly, if the traffic needs to be controlled not to flow through a certain message channel, the distribution ratio corresponding to the message channel only needs to be set to 0. As shown in table 1 above, since the allocation ratio of the subsystem 1 in the message channel a is 0, the traffic of the subsystem 1 calling the service T1 does not flow through the channel a.
As can be seen from the above description, if it is necessary to control the flow through one or more message channels, it is only necessary to set the distribution ratio corresponding to the message channel to 1 or to set the distribution ratio to a value greater than 0 and less than 1. And thus can only be selected from the message channels for which the assignment ratio is 1 or a value greater than 0 and less than 1.
In this embodiment, since the sum of the distribution ratios of the same traffic on each message channel is equal to 1, if there is a distribution ratio equal to 1 in the traffic distribution ratio, only one message channel may transmit traffic, and other message channels cannot transmit traffic because the distribution ratio is 0, so that it can be uniquely determined that the message channel corresponding to the distribution ratio is the corresponding message channel of all request messages selected as the service requester for this time.
As shown in table 1, since the allocation ratio of the subsystem 2 in the message channel a is 1, and the allocation ratio in the other message channels is 0, the traffic of the subsystem 2 calling the service T1 is transmitted only through the message channel a. If the distribution ratio of the traffic of the subsystem 2 calling service T1 in table 1 is adjusted in each message channel, the switching control of the traffic can be realized.
Step S303, if not, using the distribution ratio corresponding message channel which is greater than 0 and less than 1 as the corresponding message channel of the current service request party for sending the request message;
in this embodiment, if there is no allocation ratio equal to 1 in the allocation ratios of the same traffic, there is only an allocation ratio greater than 0 and smaller than 1, and therefore, the message channel corresponding to the allocation ratio greater than 0 and smaller than 1 is used as the message channel corresponding to the current service requester sending the request message.
In addition, since the sum of the distribution ratios of the same traffic on each message channel is equal to 1, there is no case where the distribution ratios of all message channels are 0, and meanwhile, if there is no distribution ratio equal to 1 in the distribution ratio of the same traffic, there are inevitably a plurality of distribution ratios greater than 0 and smaller than 1.
As shown in table 1 above, the subsystem 1 has an allocation ratio of 0 for the message channel a, 0.8 for the message channel B, and 0.2 for the message channel C. When the subsystem 1 calls the service T1, the transmission channel corresponding to the traffic is the message channel B, C, that is, there are multiple corresponding message channels.
Step S304, if there are multiple corresponding message channels for the request message sent by the current service requester, determining a message channel corresponding to each request message sent by the current service requester based on a preset calculation rule.
In this embodiment, to implement accurate switching control of traffic, when there are multiple corresponding message channels selected for the service requester to send the request message this time, the message channel corresponding to each request message sent by the service requester this time is further determined based on a preset calculation rule. One is arbitrarily selected, corresponding to the presence of a plurality of channels.
According to the embodiment, the flow switching control can be performed on the subsystem or the data center where the subsystem is located, and meanwhile, the transmission channel of each request message can be accurately controlled, so that the flow of each message among different message channels can be accurately switched.
Further optionally, in an embodiment, when there are multiple corresponding message channels through which the service requester sends the request message, the message channel corresponding to each request message sent by the service requester is determined specifically according to the following calculation rules:
(1) and carrying out flow block cutting processing on a request message sent by a service request party to obtain a reference value of flow proportional distribution.
In this embodiment, the number of request messages transmitted by a message channel is not only related to the traffic allocation ratio of the channel, but also related to the total number of request messages sent by the service requester. Since the request message sent by the service requester is generated randomly, sporadically and in real time, the total number of the request messages cannot be obtained in advance, and the reference value for the flow rate proportional distribution cannot be determined. Therefore, it is necessary to perform traffic blocking processing on request messages sent by a service requester, so that the number of request messages for one traffic block is used as a reference value for traffic proportional allocation.
In this embodiment, a flow block is obtained specifically by the following method: when a service request party sends a request message, accumulating each request message sent by the service request party to obtain the total number of the request messages; when the total number of the request messages reaches a preset value, a flow block is obtained, the total number of the current request messages is reset to zero, and each request message sent by the service requester at this time is accumulated again to obtain the next flow block.
(2) And in the same traffic slice, determining a message channel corresponding to each request message in the traffic slice.
2.1, when the request message is accumulated every time, any message channel in the selected message channels is taken as a corresponding message channel for the current service request party to send the request message;
2.2, in the process of accumulating the request messages each time, judging whether the ratio of the number of the request messages flowing into the current message channel to a preset value reaches the flow distribution ratio corresponding to the current message channel;
2.3, if so, taking the other message channel as a corresponding message channel for sending the request message by the current service requester, and continuously judging whether the ratio of the number of the request messages flowing into the current message channel to the preset value which is determined again reaches the flow distribution ratio corresponding to the current message channel; otherwise, continuing to send the request message to the current message channel.
To facilitate understanding of the present embodiment, the sub-system 1 calling service T1 in table 1 above is exemplified below.
Assume that the total number of request messages in a traffic chunk is 1000, and the total number of request messages is msgNum, which is used to accumulate each request message sent by a service requester. Since the allocation ratios of the message channel B, C are all greater than 0 and less than 1, the message channel B, C is used as the corresponding message channel for sending the request message when the subsystem 1 calls the service T1 this time.
1. When the request messages sent by the subsystem 1 begin to be accumulated, sending a first request message to a message channel B or a message channel C, and supposing that the message channel B is selected to send the request message;
2. while continuing to send request messages to the message channel B, judging whether the ratio (set as K) between the number of the request messages flowing into the current message channel B and a preset value (1000) reaches the flow distribution ratio (0.8) corresponding to the current message channel B;
3. if the traffic allocation ratio corresponding to the message channel B is reached, that is, when msgNum is 800, K is 0.8, traffic switching is required, and specifically, the message channel C is used as a switched traffic transmission channel;
4. when the flow is switched to the message channel C and the request message is continuously sent, whether the ratio of the number of the request messages flowing into the current message channel C to the preset value reaches the flow distribution ratio (0.2) corresponding to the current message channel C is judged; the number of request messages flowing into the message channel C can be obtained from msgNum-800. When the value of msgNum reaches 1000, that is, K is 0.2, since the value of msgNum has reached the preset value, it is necessary to switch to the traffic transmission channel in the next traffic slice, and reset msgNum to 0.
In this embodiment, when there are multiple corresponding message channels through which a service requester sends a request message, traffic is divided in a block manner, and the number of request messages flowing into each message channel is determined in each traffic block according to a traffic distribution ratio configured for each message channel, so that accurate traffic switching of each message between different message channels is achieved.
The invention also provides a flow switching device.
Referring to fig. 5, fig. 5 is a functional module schematic diagram of a first flow switching device according to the present invention. In this embodiment, the traffic switching apparatus includes:
a connection establishing module 10, configured to respectively establish network connections between the service requester and the service provider and each message channel;
in this embodiment, the implementation of the service requires establishing a network connection between the service requester and the service provider for transmitting traffic, so as to implement interaction between the service requester and the service provider.
In this embodiment, the service requester refers to a consumer of the service (a caller of the service, which corresponds to a certain subsystem), and the service provider refers to a provider of the service (a callee of the service, which corresponds to a certain subsystem). The service requester sends a request message (equivalent to a call message) to the service provider, and then calls the service provider to perform service processing, and the service provider returns a response (or does not return a response).
Based on the above description of the distributed system, in the distributed system, different subsystems may use the same service, for example, a deposit subsystem, a loan subsystem, and a transfer subsystem all need to use a withdrawal service (for example, a withdrawal subsystem provides a withdrawal service), that is, there is traffic transmission between the deposit subsystem and the withdrawal subsystem, between the loan subsystem and the withdrawal subsystem, and between the transfer subsystem and the withdrawal subsystem. To implement flow control, it is therefore necessary to switch the flow transmission.
In this embodiment, preferably, network connection between the service requester and the service provider is implemented through multiple message channels, and meanwhile, switching control of traffic transmission is further implemented.
As shown in fig. 3, assuming that a message channel A, B is available for implementing a network connection between a service requester and a service provider, a network connection is preferably established with message channel a and message channel B, respectively, at the time of respective startup of the service requester and the service provider, so as to implement a network connection between the service requester and the service provider through message channel a and/or message channel B.
In this embodiment, the message channel refers to a channel for transmitting a request message and a response message. The messaging channel refers to any channel through which messages may be transferred, including but not limited to message queues (i.e., message middleware) such as rockmq, ActiveMQ, RabbitMQ, or physical networks, message middleware physical hardware products, etc., that may provide for message transfer.
In this embodiment, the connection between the service requester and the message channel is established, specifically, the physical connection between the service requester and the message channel is established, so that the service requester can physically perform message flow with the service provider through the message channel, but does not indicate that there is no message flow. The connection between the service provider and the message channel is established, specifically, the physical connection between the service provider and the message channel is established, so that the service provider can physically receive the call message of the service requester through the message channel.
A ratio obtaining module 20, configured to obtain a traffic distribution ratio of the service called by the service requester;
in this embodiment, after the network connection between the service requester and the service provider is established, the service requester may send a request message to the service provider, and the service provider may also return a response message to the service requester. In order to implement the traffic transmission control between the two, and therefore the traffic switching is required, the embodiment preferably implements the traffic switching by switching the traffic transmission channel.
To realize accurate switching control of the flow, the present embodiment preferably controls the flow switching based on the flow allocation ratio. The traffic distribution ratio is the distribution ratio of the service requester traffic in each message channel. I.e. the traffic allocation ratio is a percentage value with a value of between 0 and 1, the same service requester invokes the traffic of the same service, and the sum of the allocation ratios on the message channels is equal to 1 (100%).
The present embodiment is not limited to the configuration of the flow distribution ratio. For example, a static traffic allocation ratio may be configured in a configuration file of the service requester, or a dynamic traffic allocation ratio may be configured by an independent third party.
A channel selection module 30, configured to select, according to the traffic distribution ratio, a corresponding message channel for the current service requester to send the request message by using a preset channel selection algorithm;
in this embodiment, because a plurality of message channels are provided between the service requester and the service provider, the accurate traffic switching requires determining an output channel of each message, that is, selecting a message channel.
Since the message is initiated by the service requester, the service requester is preferably used as a selector of the message channel in the embodiment to determine which message channel each request message to be sent is transmitted to the service provider.
In this embodiment, preferably, a preset channel selection algorithm is adopted to select a corresponding message channel for the current service requester to send the request message according to the obtained traffic allocation ratio of the current service requester to invoke the service. The embodiment is not limited to the specific implementation process of the channel selection algorithm.
And the traffic transmission module 40 is used for transmitting the request message from the service requester to the service provider through the selected message channel.
In this embodiment, after the sending channel of the message is determined, the request message initiated by the service requester can be transmitted to the service provider through the selected message channel, the service provider processes the service after receiving the request message, and then returns the response message to the service requester according to the original path of the original message channel.
It should be further noted that the service provider and the service requester need to introduce a consistent API to perform the sending and receiving processes of the message related to the service call.
In this embodiment, network connections between the service requester and the service provider and the message channels are respectively established through the message channels, so as to establish a plurality of transmission channels of traffic, thereby facilitating switching of each message constituting the traffic among different message channels. In addition, a flow distribution ratio of each service requester calling service is further acquired, so that a message channel corresponding to each request message sent by each service requester is determined according to the flow distribution ratio, the request message is sent from the service requester to a service provider through the message channel, and flow switching of each message among different message channels is further realized.
Furthermore, the flow switching device of the invention builds the network connection between the service requester and the service provider and each message channel through the message channel to build a plurality of transmission channels of the flow, and further can control the flow switching by configuring the flow distribution ratio.
Therefore, in an embodiment of the traffic switching device of the present invention, in order to further facilitate centralized control of the traffic distribution ratio and avoid an influence on the service requester or the service provider when adjusting the traffic distribution ratio, it is preferable that an independent third-party configuration center configures the traffic distribution ratio, and a manager dynamically configures a specific value of the traffic distribution ratio as needed.
Since the traffic distribution ratio exists in the third-party configuration center, the traffic distribution ratio needs to be acquired from the third-party configuration center. In one embodiment, the ratio acquisition module 20 preferably acquires the flow distribution ratio from the third party configuration center by any one of the following methods.
The first method is as follows: the method comprises the steps of firstly, dynamically obtaining a service flow distribution table from a third-party configuration center and caching the service flow distribution table to the local, and then, inquiring the service flow distribution table to obtain a flow distribution ratio of the service called by a current service requester.
The second method comprises the following steps: directly initiating a query request to a third-party configuration center, and dynamically acquiring a traffic distribution ratio of the service called by the current service requester by searching a service traffic distribution table of the third-party configuration center.
In this embodiment, since the flow allocation ratio may be adjusted in the third-party configuration center, it is preferable to dynamically acquire the flow allocation ratio from the third-party configuration center at regular time. It should be noted that in the above two manners, the traffic allocation ratio may be dynamically acquired from the third-party configuration center at regular time, or may be dynamically acquired from the third-party configuration center at irregular time.
In addition, the invention adopts the network connection established between the service requester and the service provider to transmit the flow, so that the flow distribution ratio can be set from the subsystem level granularity or the data center level granularity, and the accurate switching control of the flow can be realized. Therefore, in an embodiment, the ratio obtaining module 20 may search the service traffic distribution table according to the subsystem corresponding to the service requester and the data center where the subsystem is located, so as to obtain the traffic distribution ratio of the service invoked by the service requester this time.
The service traffic allocation table and the traffic allocation ratio are further illustrated below.
The service flow distribution table is used for storing flow distribution ratios of services required to be called by the subsystems, and the subsystems are divided according to the data center.
The traffic distribution ratio is the distribution ratio of the service requester traffic in each message channel. I.e. the traffic allocation ratio is a percentage value with a value of between 0 and 1, the same service requester invokes the traffic of the same service, and the sum of the allocation ratios on the message channels is equal to 1 (100%).
TABLE 2
Figure BDA0001889160210000181
The service traffic distribution table shown in table 2 configures the traffic distribution ratio specifically for the subsystem level and the data center level. The flow distribution ratio corresponding to the subsystem 1 calling the service T2 in the data center 1 is as follows: the distribution ratio of the message channel A is 0.3, the distribution ratio of the message channel B is 0.5, and the distribution ratio of the message channel C is 0.2; the flow distribution ratio corresponding to the subsystem 2 calling the service T2 in the data center 1 is: the allocation ratio of the message channel A is 1, the allocation ratio of the message channel B is 0, and the allocation ratio of the message channel C is 0.
Further, based on the service traffic distribution table and the traffic distribution ratio description in the embodiment of the traffic switching apparatus, a process of selecting a message channel is described.
In this embodiment, the channel selection module 30 is specifically configured to:
judging whether a distribution ratio equal to 1 exists in the flow distribution ratio;
if the request message exists, the message channel corresponding to the distribution ratio equal to 1 is taken as the corresponding message channel of all the request messages sent by the current service request party;
if not, taking the distribution ratio corresponding message channel which is larger than 0 and smaller than 1 as the corresponding message channel for the current service requester to send the request message;
if a plurality of corresponding message channels for sending the request message by the service requester exist, determining a message channel corresponding to each request message sent by the service requester based on a preset calculation rule.
In this embodiment, since the traffic distribution ratio is a distribution ratio of traffic of the service requester in each message channel, if the traffic needs to flow through a certain message channel, the distribution ratio corresponding to the message channel is inevitably greater than 0, and similarly, if the traffic needs to be controlled not to flow through a certain message channel, the distribution ratio corresponding to the message channel only needs to be set to 0. As shown in table 2 above, since the allocation ratio of the subsystem 2 on the message channel B, C is 0, the traffic of the subsystem 2 calling the service T2 does not flow through the channel B, C.
As can be seen from the above description, if it is necessary to control the flow through one or more message channels, it is only necessary to set the distribution ratio corresponding to the message channel to 1 or to set the distribution ratio to a value greater than 0 and less than 1. And thus can only be selected from the message channels for which the assignment ratio is 1 or a value greater than 0 and less than 1.
In this embodiment, since the sum of the distribution ratios of the same traffic on each message channel is equal to 1, if there is a distribution ratio equal to 1 in the traffic distribution ratio, only one message channel may transmit traffic, and other message channels cannot transmit traffic because the distribution ratio is 0, so that it can be uniquely determined that the message channel corresponding to the distribution ratio is the corresponding message channel of all request messages selected as the service requester for this time.
As shown in table 2, since the allocation ratio of the subsystem 2 in the message channel a is 1, and the allocation ratio in the other message channels is 0, the traffic of the subsystem 2 calling the service T2 is transmitted only through the message channel a. If the distribution ratio of the traffic of the subsystem 2 calling service T2 in table 2 in each message channel is adjusted, the switching control of the traffic can be realized.
In this embodiment, if there is no allocation ratio equal to 1 in the allocation ratios of the same traffic, there is only an allocation ratio greater than 0 and smaller than 1, and therefore, the message channel corresponding to the allocation ratio greater than 0 and smaller than 1 is used as the message channel corresponding to the current service requester sending the request message.
In addition, since the sum of the distribution ratios of the same traffic on each message channel is equal to 1, there is no case where the distribution ratios of all message channels are 0, and meanwhile, if there is no distribution ratio equal to 1 in the distribution ratio of the same traffic, there are inevitably a plurality of distribution ratios greater than 0 and smaller than 1.
As shown in table 2 above, the subsystem 1 has an allocation ratio of 0.3 for the message channel a, 0.5 for the message channel B, and 0.2 for the message channel C. When the subsystem 1 calls the service T2, the transmission channel corresponding to the traffic is the message channel A, B, C, that is, there are multiple corresponding message channels.
In this embodiment, to implement accurate switching control of traffic, when there are multiple corresponding message channels selected for the service requester to send the request message this time, the message channel corresponding to each request message sent by the service requester this time is further determined based on a preset calculation rule.
According to the embodiment, the flow switching control can be performed on the subsystem or the data center where the subsystem is located, and meanwhile, the transmission channel of each request message can be accurately controlled, so that the flow of each message among different message channels can be accurately switched.
Further optionally, in another embodiment of the traffic switching apparatus of the present invention, when there are multiple corresponding message channels through which the service requester sends the request message, the channel selection module 30 specifically determines, according to the following calculation rules, a message channel corresponding to each request message sent by the service requester this time:
(1) and carrying out flow block cutting processing on a request message sent by a service request party to obtain a reference value of flow proportional distribution.
In this embodiment, the number of request messages transmitted by a message channel is not only related to the traffic allocation ratio of the channel, but also related to the total number of request messages sent by the service requester. Since the request message sent by the service requester is generated randomly, sporadically and in real time, the total number of the request messages cannot be obtained in advance, and the reference value for the flow rate proportional distribution cannot be determined. Therefore, it is necessary to perform traffic blocking processing on request messages sent by a service requester, so that the number of request messages for one traffic block is used as a reference value for traffic proportional allocation.
In this embodiment, a flow block is obtained specifically by the following method: when a service request party sends a request message, accumulating each request message sent by the service request party to obtain the total number of the request messages; and when the total number of the request messages reaches a preset value, obtaining a flow block, resetting the total number of the current request messages to zero, and re-accumulating each request message sent by the current service request party to obtain the next flow block.
(2) And in the same traffic slice, determining a message channel corresponding to each request message in the traffic slice.
2.1, when the request message is accumulated every time, any message channel in the selected message channels is taken as a corresponding message channel for the current service request party to send the request message;
2.2, in the process of accumulating the request messages each time, judging whether the ratio of the number of the request messages flowing into the current message channel to a preset value reaches the flow distribution ratio corresponding to the current message channel;
2.3, if so, taking the other message channel as a corresponding message channel for sending the request message by the current service requester, and continuously judging whether the ratio of the number of the request messages flowing into the current message channel to the preset value which is determined again reaches the flow distribution ratio corresponding to the current message channel; otherwise, continuing to send the request message to the current message channel.
To facilitate understanding of the present embodiment, the sub-system 1 calls the service T2 in table 2 above as an example.
Assume that the total number of request messages in a traffic chunk is 1000, and the total number of request messages is msgNum, which is used to accumulate each request message sent by a service requester. Since the allocation ratios of the message channel A, B, C are all greater than 0 and less than 1, the message channel A, B, C is used as the corresponding message channel for sending the request message when the subsystem 1 calls the service T2 this time.
1. When the request messages sent by the subsystem 1 begin to be accumulated, sending a first request message to a message channel A or a message channel B or a message channel C, and assuming that the message channel B is selected to send the request message;
2. while continuing to send request messages to the message channel B, judging whether the ratio (set as K) between the number of the request messages flowing into the current message channel B and a preset value (1000) reaches the flow distribution ratio (0.5) corresponding to the current message channel B;
3. if the traffic allocation ratio corresponding to the message channel B is reached, that is, when msgNum is 500, K is 0.5, traffic switching is required, and it is assumed that the message channel C is used as a switched traffic transmission channel;
4. when the flow is switched to the message channel C and the request message is continuously sent, whether the ratio of the number of the request messages flowing into the current message channel C to the preset value reaches the flow distribution ratio (0.2) corresponding to the current message channel C is judged; the number of request messages flowing into the message channel C can be obtained from msgNum-500.
5. If the flow distribution ratio corresponding to the message channel C is reached, that is, when msgNum is 700, K is 0.2, the flow switching is required, and the message channel a is used as a switched flow transmission channel;
6. when the flow is switched to the message channel A and the request message is continuously sent, whether the ratio of the number of the request messages flowing into the current message channel A to the preset value reaches the flow distribution ratio (0.3) corresponding to the current message channel A is judged; wherein, the number of request messages flowing in the message channel A can be obtained from msgNum-500-. When the value of msgNum reaches 1000, that is, K is 0.3, since the value of msgNum has reached the preset value, it is necessary to switch to the traffic transmission channel in the next traffic slice, and reset msgNum to 0.
In this embodiment, when there are multiple corresponding message channels through which a service requester sends a request message, traffic is divided in a block manner, and the number of request messages flowing into each message channel is determined in each traffic block according to a traffic distribution ratio configured for each message channel, so that accurate traffic switching of each message between different message channels is achieved.
The invention also provides a computer readable storage medium.
The computer-readable storage medium of the present invention stores thereon a traffic switching program, which when executed by a processor implements the steps of the traffic switching method as described in any one of the above embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM), and includes instructions for causing a terminal (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The present invention is described in connection with the accompanying drawings, but the present invention is not limited to the above embodiments, which are only illustrative and not restrictive, and those skilled in the art can make various changes without departing from the spirit and scope of the invention as defined by the appended claims, and all changes that come within the meaning and range of equivalency of the specification and drawings that are obvious from the description and the attached claims are intended to be embraced therein.

Claims (14)

1. A traffic switching method, characterized by comprising the steps of:
respectively establishing network connections between a service requester and a service provider and each message channel;
obtaining a flow distribution ratio of the service called by the service requester, wherein the flow distribution ratio is configured by a third-party configuration center according to the subsystem level granularity of a subsystem corresponding to the service requester and the data center level granularity of a data center corresponding to the subsystem;
selecting a corresponding message channel for the service requester to send the request message by adopting a preset channel selection algorithm according to the flow distribution ratio;
sending the request message from the service requester to the service provider through the selected message channel;
the step of selecting the corresponding message channel of the current service requester for sending the request message by using a preset channel selection algorithm according to the flow distribution ratio comprises the following steps:
if a plurality of corresponding message channels for the service requester to send the request message exist, accumulating each request message sent by the service requester when the service requester sends the request message to obtain the total number of the request messages;
when the total number of the request messages reaches a preset value, obtaining a flow block, resetting the total number of the current request messages to zero, and re-accumulating each request message sent by the current service request party to obtain the next flow block;
and in the same flow block, determining a message channel corresponding to each request message in the flow block according to the flow distribution ratio configured by each message channel.
2. The traffic switching method according to claim 1, wherein before the step of obtaining the traffic allocation ratio of the service invoked by the current service requester, the method further comprises:
dynamically acquiring a service flow distribution table from a third-party configuration center and caching the service flow distribution table to the local;
the obtaining of the traffic distribution ratio of the service called by the current service requester comprises:
and searching the service flow distribution table to obtain a flow distribution ratio of the service called by the service requester, wherein the flow distribution ratio is the distribution ratio of the flow of the service requester in each message channel.
3. The traffic switching method according to claim 2, wherein the searching the service traffic distribution table to obtain the traffic distribution ratio of the service invoked by the current service requester comprises:
and searching the service flow distribution table according to the subsystem corresponding to the service requester and the data center where the subsystem is located so as to obtain the flow distribution ratio of the service called by the service requester.
4. The traffic switching method according to claim 1, wherein the obtaining of the traffic allocation ratio of the service invoked by the current service requester comprises:
and searching a service flow distribution table of a third-party configuration center according to a subsystem corresponding to the service requester and a data center where the subsystem is located, so as to dynamically obtain a flow distribution ratio of the service called by the service requester, wherein the flow distribution ratio is a distribution ratio of the flow of the service requester in each message channel.
5. The traffic switching method according to claim 3 or 4, wherein the selecting, according to the traffic allocation ratio, the corresponding message channel for the current service requester to send the request message by using a preset channel selection algorithm includes:
judging whether a distribution ratio equal to 1 exists in the flow distribution ratio;
if the request message exists, the message channel corresponding to the distribution ratio equal to 1 is taken as the corresponding message channel of all the request messages sent by the current service request party;
if not, taking the distribution ratio corresponding message channel which is larger than 0 and smaller than 1 as the corresponding message channel for the current service requester to send the request message;
if a plurality of corresponding message channels for sending the request message by the service requester exist, determining a message channel corresponding to each request message sent by the service requester based on a preset calculation rule.
6. The traffic switching method according to claim 5, wherein, if there are a plurality of corresponding message channels for the current service requester to send the request message, determining, based on a preset calculation rule, a message channel corresponding to each request message sent by the current service requester includes:
if a plurality of corresponding message channels for sending request messages by the current service requester exist, accumulating each request message sent by the current service requester to obtain the total number of the request messages;
when the total number of the request messages reaches a preset value, resetting the total number of the request messages to zero, and re-accumulating each request message sent by the current service requester;
when the request message is accumulated every time, any message channel in the selected message channels is taken as a corresponding message channel for sending the request message by the current service requester;
in the process of accumulating the request messages each time, judging whether the ratio of the number of the request messages flowing into the current message channel to the preset value reaches the flow distribution ratio corresponding to the current message channel;
if so, taking the other message channel as a corresponding message channel for sending the request message by the current service requester, and continuously judging whether the ratio of the number of the request messages flowing into the current message channel to the preset value, which is re-determined, reaches the flow distribution ratio corresponding to the current message channel.
7. A flow switching device, characterized in that the flow switching device comprises:
the connection establishing module is used for respectively establishing network connection between the service requester and the service provider and each message channel;
the system comprises a ratio acquisition module, a service request sending module and a service request sending module, wherein the ratio acquisition module is used for acquiring the flow distribution ratio of the service called by the service request sending module, and the flow distribution ratio is configured by a third-party configuration center according to the subsystem level granularity of a subsystem corresponding to the service request sending module and the data center level granularity of a data center corresponding to the subsystem;
the channel selection module is used for selecting a corresponding message channel of the service request party for sending the request message by adopting a preset channel selection algorithm according to the flow distribution ratio;
the channel selection module is further configured to, if there are multiple corresponding message channels through which the service requester sends the request message, accumulate each request message sent by the service requester when the service requester sends the request message, and obtain a total number of the request messages; when the total number of the request messages reaches a preset value, obtaining a flow block, resetting the total number of the current request messages to zero, and re-accumulating each request message sent by the current service request party to obtain the next flow block; in the same flow rate cut-off block, determining a message channel corresponding to each request message in the flow rate cut-off block according to the flow rate distribution ratio configured by each message channel;
and the flow transmission module is used for transmitting the request message from the service requester to the service provider through the selected message channel.
8. The flow switching device of claim 7, wherein the ratio acquisition module is further configured to:
dynamically acquiring a service flow distribution table from a third-party configuration center and caching the service flow distribution table to the local;
and searching the service flow distribution table to obtain a flow distribution ratio of the service called by the service requester, wherein the flow distribution ratio is the distribution ratio of the service requester flow in each message channel.
9. The flow switching device of claim 8, wherein the ratio acquisition module is further configured to:
and searching the service flow distribution table according to the subsystem corresponding to the service requester and the data center where the subsystem is located so as to obtain the flow distribution ratio of the service called by the service requester.
10. The flow switching device of claim 7, wherein the ratio acquisition module is further configured to:
and searching a service flow distribution table of a third-party configuration center according to a subsystem corresponding to the service requester and a data center where the subsystem is located, so as to dynamically obtain a flow distribution ratio of the service called by the service requester, wherein the flow distribution ratio is a distribution ratio of the flow of the service requester in each message channel.
11. The flow switching device according to claim 9 or 10, wherein the channel selection module is configured to:
judging whether a distribution ratio equal to 1 exists in the flow distribution ratio;
if the request message exists, the message channel corresponding to the distribution ratio equal to 1 is taken as the corresponding message channel of all the request messages sent by the current service request party;
if not, taking the distribution ratio corresponding message channel which is larger than 0 and smaller than 1 as the corresponding message channel for the current service requester to send the request message;
if a plurality of corresponding message channels for sending the request message by the service requester exist, determining a message channel corresponding to each request message sent by the service requester based on a preset calculation rule.
12. The flow switching device of claim 11, wherein the channel selection module is further configured to:
if a plurality of corresponding message channels for sending request messages by the current service requester exist, accumulating each request message sent by the current service requester to obtain the total number of the request messages;
when the total number of the request messages reaches a preset value, resetting the total number of the request messages to zero, and re-accumulating each request message sent by the current service requester;
when the request message is accumulated every time, any message channel in the selected message channels is taken as a corresponding message channel for sending the request message by the current service requester;
in the process of accumulating the request messages each time, judging whether the ratio of the number of the request messages flowing into the current message channel to the preset value reaches the flow distribution ratio corresponding to the current message channel;
if so, taking the other message channel as a corresponding message channel for sending the request message by the current service requester, and continuously judging whether the ratio of the number of the request messages flowing into the current message channel to the preset value which is re-determined reaches the flow distribution ratio corresponding to the current message channel.
13. A traffic switching device, characterized in that the traffic switching device comprises a memory, a processor and a traffic switching program stored on the memory and executable on the processor, which when executed by the processor implements the steps of the traffic switching method according to any of claims 1-6.
14. A computer-readable storage medium, having stored thereon a traffic switching program, which when executed by a processor, performs the steps of the traffic switching method according to any one of claims 1-6.
CN201811468895.6A 2018-12-03 2018-12-03 Flow switching method, device, equipment and computer readable storage medium Active CN109587068B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811468895.6A CN109587068B (en) 2018-12-03 2018-12-03 Flow switching method, device, equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811468895.6A CN109587068B (en) 2018-12-03 2018-12-03 Flow switching method, device, equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN109587068A CN109587068A (en) 2019-04-05
CN109587068B true CN109587068B (en) 2022-08-12

Family

ID=65926855

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811468895.6A Active CN109587068B (en) 2018-12-03 2018-12-03 Flow switching method, device, equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN109587068B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109995669B (en) * 2019-04-09 2024-05-03 深圳前海微众银行股份有限公司 Distributed current limiting method, device, equipment and readable storage medium
CN111711971B (en) * 2020-06-15 2023-04-28 京东方科技集团股份有限公司 Data transmission method and device, storage medium and electronic equipment
CN114500542A (en) * 2020-11-12 2022-05-13 中移信息技术有限公司 Service flow distribution method, device, equipment and computer storage medium

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101247348B (en) * 2008-03-12 2010-08-04 华为技术有限公司 Load sharing method and device
CN102868628B (en) * 2011-07-06 2016-03-02 阿里巴巴集团控股有限公司 Flow segmentation, device and system
CN105490825B (en) * 2014-09-15 2019-03-19 阿里巴巴集团控股有限公司 A kind of method and device for business processing
CN105630590B (en) * 2014-11-28 2019-08-09 阿里巴巴集团控股有限公司 A kind of business information processing method and processing device
CN106330748B (en) * 2015-06-30 2019-04-09 中兴通讯股份有限公司 A kind of flow control methods and device
CN107015972B (en) * 2016-01-27 2020-02-18 五八同城信息技术有限公司 Method, device and system for migrating machine room services
CN108874413A (en) * 2017-10-30 2018-11-23 北京旷视科技有限公司 Service upgrade method, apparatus, system and storage medium
CN108667938B (en) * 2018-05-18 2020-12-29 阿里巴巴集团控股有限公司 Traffic switching method and device and server
CN108809730B (en) * 2018-06-25 2021-11-19 创新先进技术有限公司 Method and device for controlling flow switching of machine room

Also Published As

Publication number Publication date
CN109587068A (en) 2019-04-05

Similar Documents

Publication Publication Date Title
CN109587068B (en) Flow switching method, device, equipment and computer readable storage medium
WO2019001421A1 (en) Method, device, and computer readable storage medium for managing network slice
CN111787069A (en) Method, device and equipment for processing service access request and computer storage medium
CN110247856B (en) Server resource release method and device
CN108011899B (en) Session establishment optimization method, device and system
US11038760B2 (en) Resource adjustment method, apparatus, and system
CN108667882B (en) Load balancing method and device based on dynamic weight adjustment and electronic equipment
CN107015972B (en) Method, device and system for migrating machine room services
CN112600693B (en) Service request processing method, system, electronic equipment and computer storage medium
KR102233894B1 (en) Network function and method for processing request using the same
CN110855564B (en) Intelligent routing path selection method, device and equipment and readable storage medium
CN114302429B (en) NWDAF network element determination method, device, equipment and storage medium
US10216593B2 (en) Distributed processing system for use in application migration
EP3672203A1 (en) Distribution method for distributed data computing, device, server and storage medium
CN110071952B (en) Service call quantity control method and device
CN109815204A (en) A kind of metadata request distribution method and equipment based on congestion aware
CN111382141B (en) Master-slave architecture configuration method, device, equipment and computer readable storage medium
CN110727511B (en) Control method for application program, network side device and computer readable storage medium
CN109831467B (en) Data transmission method, equipment and system
CN103516758A (en) Method and device for processing service requests of resource route and call center seats
US20230275807A1 (en) Data processing method and device
CN111371675B (en) Intelligent addressing method, device, equipment and storage medium thereof
US20180192294A1 (en) Resource allocation
CN115190180A (en) Method and device for scheduling network resource request during sudden increase of network resource request
US20190065555A1 (en) System, method of real-time processing under resource constraint at edge

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant