[go: up one dir, main page]

CN115622933A - Route distribution method, device and equipment - Google Patents

Route distribution method, device and equipment Download PDF

Info

Publication number
CN115622933A
CN115622933A CN202211099157.5A CN202211099157A CN115622933A CN 115622933 A CN115622933 A CN 115622933A CN 202211099157 A CN202211099157 A CN 202211099157A CN 115622933 A CN115622933 A CN 115622933A
Authority
CN
China
Prior art keywords
link
code
weight
response
distribution
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.)
Pending
Application number
CN202211099157.5A
Other languages
Chinese (zh)
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.)
Tianyi Digital Life Technology Co Ltd
Original Assignee
Tianyi Digital Life Technology 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 Tianyi Digital Life Technology Co Ltd filed Critical Tianyi Digital Life Technology Co Ltd
Priority to CN202211099157.5A priority Critical patent/CN115622933A/en
Publication of CN115622933A publication Critical patent/CN115622933A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/14Routing performance; Theoretical aspects
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing

Landscapes

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

Abstract

本申请公开了一种路由分发方法、装置和设备,方法包括:获取应用系统中的链路在上一周期时的响应状态码;计算响应状态码为正常状态码时的码比率;利用链路分发权重动态调整算法,计算码比率对应的链路权重;当链路权重在标准链路权重范围内时,将链路权重作为链路在下一周期时的目标链路权重,以基于目标链路权重对链路进行路由分发。本申请提供了基于服务的响应状态码的链路分发权重动态调整方案,丰富了链路分发权重的手段,使得链路分发方案更加贴合服务端的服务运行状态,提升了API服务的整体质量和水平,保护了服务端的持续稳定的运行。

Figure 202211099157

This application discloses a route distribution method, device and equipment. The method includes: obtaining the response status code of the link in the application system in the previous cycle; calculating the code ratio when the response status code is a normal status code; using the link The distribution weight dynamic adjustment algorithm calculates the link weight corresponding to the code ratio; when the link weight is within the standard link weight range, the link weight is used as the target link weight of the link in the next cycle, based on the target link weight Weight distributes routes to links. This application provides a dynamic adjustment scheme for link distribution weight based on the response status code of the service, which enriches the means of link distribution weight, makes the link distribution scheme more suitable for the service operation status of the server, and improves the overall quality and quality of API services. level, which protects the continuous and stable operation of the server.

Figure 202211099157

Description

一种路由分发方法、装置和设备A route distribution method, device and equipment

技术领域technical field

本申请涉及网络技术领域,尤其涉及一种路由分发方法、装置和设备。The present application relates to the field of network technologies, and in particular to a route distribution method, device and equipment.

背景技术Background technique

随着网络技术的发展,网关和节点的数量在不断增加,导致网络规模也越来越大。With the development of network technology, the number of gateways and nodes is increasing, resulting in a larger network scale.

在现有网络中,网关或总线通过路由分发将视频、音频、Web网页等发送到最接近用户的网络边缘,使用户可以获取到所需内容。在进行路由分发时,大都基于响应时间、链接数hash等。现有的路由分发虽然可以取得一定的分发效果,但是未考虑服务端的实际服务情况,使得分发时的考虑因素不够全面且也未反应实际服务端的具体链路质量。In the existing network, the gateway or bus sends video, audio, and web pages to the edge of the network closest to the user through routing distribution, so that the user can obtain the desired content. When routing distribution, most of them are based on response time, link number hash, etc. Although the existing routing distribution can achieve a certain distribution effect, it does not consider the actual service situation of the server, so that the factors considered in the distribution are not comprehensive enough and do not reflect the specific link quality of the actual server.

发明内容Contents of the invention

有鉴于此,本申请提供了一种路由分发方法、装置和设备,考虑服务端的实际服务情况,使得分发时的考虑因素全面且也能够反应实际服务端的具体链路质量。In view of this, the present application provides a route distribution method, device and equipment, which considers the actual service situation of the server, so that the factors considered in the distribution are comprehensive and can also reflect the specific link quality of the actual server.

本申请第一方面提供了一种路由分发方法,包括:The first aspect of the present application provides a route distribution method, including:

获取应用系统中的链路在上一周期时的响应状态码;Obtain the response status code of the link in the application system in the previous cycle;

计算所述响应状态码为正常状态码时的码比率;Calculate the code ratio when the response status code is a normal status code;

利用链路分发权重动态调整算法,计算所述码比率对应的链路权重;Using a link distribution weight dynamic adjustment algorithm to calculate the link weight corresponding to the code ratio;

当所述链路权重在标准链路权重范围内时,将所述链路权重作为所述链路在下一周期时的目标链路权重,以基于所述目标链路权重对所述链路进行路由分发。When the link weight is within the range of the standard link weight, use the link weight as the target link weight of the link in the next period, so as to perform the link based on the target link weight Routing distribution.

可选地,计算所述响应状态码为正常状态码时的码比率,具体包括:Optionally, calculating the code ratio when the response status code is a normal status code specifically includes:

统计所述链路在上一周期时响应状态码的总数量;Count the total number of response status codes of the link in the last cycle;

统计所述链路在上一周期时响应状态码为正常状态码的码数量;Counting the number of codes whose response status code was a normal status code for the link in the last cycle;

根据所述码数量和所述总数量,计算所述响应状态码为正常状态码时的码比率。Calculate a code ratio when the response status code is a normal status code according to the code quantity and the total quantity.

可选地,计算所述响应状态码为正常状态码时的码比率,之前还包括:Optionally, calculating the code ratio when the response status code is a normal status code also includes:

删除所述响应状态码中的异常数据。Delete the abnormal data in the response status code.

可选地,所述异常数据包括:空值的响应状态码和响应时长超过预设时长的响应状态码。Optionally, the abnormal data includes: a response status code with a null value and a response status code whose response duration exceeds a preset duration.

可选地,利用链路分发权重动态调整算法,计算所述码比率对应的链路权重,具体包括:Optionally, using a link distribution weight dynamic adjustment algorithm to calculate the link weight corresponding to the code ratio, specifically including:

获取链路分发权重动态调整算法对应的计算公式;Obtain the calculation formula corresponding to the link distribution weight dynamic adjustment algorithm;

基于所述计算公式,计算所述码比率对应的链路权重,其中,所述计算公式为:Based on the calculation formula, calculate the link weight corresponding to the code ratio, where the calculation formula is:

Figure BDA0003837237600000021
Figure BDA0003837237600000021

式中,Rw为链路权重,Nri为链路在上一周期时的码比率,N为应用系统中的链路数量,Pw为预设链路权重,Mw为各个链路的质量权重之和,a1、a2为常数,a1+a2=1。In the formula, Rw is the link weight, Nr i is the code rate of the link in the previous cycle, N is the number of links in the application system, Pw is the preset link weight, and Mw is the ratio of the quality weight of each link And, a 1 and a 2 are constants, a 1 +a 2 =1.

本申请第二方面提供了一种路由分发装置,包括:The second aspect of the present application provides a route distribution device, including:

获取单元,用于获取应用系统中的链路在上一周期时的响应状态码;The obtaining unit is used to obtain the response status code of the link in the application system in the previous cycle;

第一计算单元,用于计算所述响应状态码为正常状态码时的码比率;A first calculation unit, configured to calculate a code ratio when the response status code is a normal status code;

第二计算单元,用于利用链路分发权重动态调整算法,计算所述码比率对应的链路权重;The second calculation unit is used to calculate the link weight corresponding to the code ratio by using the link distribution weight dynamic adjustment algorithm;

赋值单元,用于当所述链路权重在标准链路权重范围内时,将所述链路权重作为所述链路在下一周期时的目标链路权重,以基于所述目标链路权重对所述链路进行路由分发。An assignment unit, configured to use the link weight as the target link weight of the link in the next period when the link weight is within the standard link weight range, so as to set the target link weight based on the target link weight The link distributes routes.

可选地,所述第一计算单元具体包括:Optionally, the first computing unit specifically includes:

第一统计子单元,用于统计所述链路在上一周期时响应状态码的总数量;The first statistical subunit is used to count the total number of response status codes of the link in the previous cycle;

第二统计子单元,用于统计所述链路在上一周期时响应状态码为正常状态码的码数量;The second statistical subunit is used to count the number of codes whose response status code is a normal status code in the last cycle of the link;

第一计算子单元,用于根据所述码数量和所述总数量,计算所述响应状态码为正常状态码时的码比率。A first calculating subunit, configured to calculate a code ratio when the response status code is a normal status code according to the code quantity and the total quantity.

可选地,所述装置还包括:Optionally, the device also includes:

删除单元,用于删除所述响应状态码中的异常数据。A deletion unit, configured to delete the abnormal data in the response status code.

可选地,所述第二计算单元具体包括:Optionally, the second calculation unit specifically includes:

获取子单元,用于获取链路分发权重动态调整算法对应的计算公式;The obtaining subunit is used to obtain the calculation formula corresponding to the link distribution weight dynamic adjustment algorithm;

第二计算子单元,用于基于所述计算公式,计算所述码比率对应的链路权重,其中,所述计算公式为:The second calculation subunit is configured to calculate the link weight corresponding to the code ratio based on the calculation formula, wherein the calculation formula is:

Figure BDA0003837237600000031
Figure BDA0003837237600000031

式中,Rw为链路权重,Nri为链路在上一周期时的码比率,N为应用系统中的链路数量,Pw为预设链路权重,Mw为各个链路的质量权重之和,a1、a2为常数,a1+a2=1。In the formula, Rw is the link weight, Nr i is the code rate of the link in the previous cycle, N is the number of links in the application system, Pw is the preset link weight, and Mw is the ratio of the quality weight of each link And, a 1 and a 2 are constants, a 1 +a 2 =1.

本申请第三方面提供了一种路由分发设备,包括处理器以及存储器;The third aspect of the present application provides a route distribution device, including a processor and a memory;

所述存储器用于存储程序代码,并将所述程序代码传输给所述处理器;The memory is used to store program codes and transmit the program codes to the processor;

所述处理器用于根据所述程序代码中的指令执行任一种第一方面所述的路由分发方法。The processor is configured to execute any route distribution method described in the first aspect according to instructions in the program code.

从以上技术方案可以看出,本申请具有以下优点:As can be seen from the above technical solutions, the present application has the following advantages:

本申请中路由分发方法包括:获取应用系统中的链路在上一周期时的响应状态码;计算响应状态码为正常状态码时的码比率;利用链路分发权重动态调整算法,计算码比率对应的链路权重;当链路权重在标准链路权重范围内时,将链路权重作为链路在下一周期时的目标链路权重,以基于目标链路权重对链路进行路由分发。The route distribution method in this application includes: obtaining the response status code of the link in the application system in the previous cycle; calculating the code ratio when the response status code is a normal status code; using the link distribution weight dynamic adjustment algorithm to calculate the code ratio Corresponding link weight; when the link weight is within the standard link weight range, the link weight is used as the target link weight of the link in the next cycle, so as to distribute routes to the link based on the target link weight.

为了在当前复杂的互联网环境下提供高质量稳定性的服务,本申请中在进行路由分发时,先获取应用系统中的链路在上一周期时的响应状态码,接着计算响应状态码为正常状态码时的码比率,然后利用链路分发权重动态调整算法,计算码比率对应的链路权重,最后当链路权重在标准链路权重范围内时,将链路权重作为链路在下一周期时的目标链路权重,以基于目标链路权重对链路进行路由分发,即本申请提供了基于服务的响应状态码的链路分发权重动态调整方案,丰富了链路分发权重的确定手段,使得链路由分发方案更加贴合服务端的服务运行状态,提升了API服务的整体质量和水平,保护了服务端的持续稳定的运行。In order to provide high-quality and stable services in the current complex Internet environment, when routing distribution in this application, first obtain the response status code of the link in the application system in the previous cycle, and then calculate the response status code as normal The code ratio of the status code, and then use the link distribution weight dynamic adjustment algorithm to calculate the link weight corresponding to the code ratio. Finally, when the link weight is within the standard link weight range, the link weight is used as the link weight in the next cycle. The weight of the target link at the time is used to distribute the link based on the weight of the target link. That is, this application provides a dynamic adjustment scheme of the link distribution weight based on the response status code of the service, which enriches the means of determining the link distribution weight. This makes the link routing distribution scheme more suitable for the service operation status of the server, improves the overall quality and level of API services, and protects the continuous and stable operation of the server.

附图说明Description of drawings

为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings that need to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, other drawings can also be obtained based on these drawings without any creative effort.

图1为本申请实施例中一种路由分发方法的实施例一的流程示意图;FIG. 1 is a schematic flowchart of Embodiment 1 of a route distribution method in the embodiment of the present application;

图2为本申请实施例中一种路由分发方法的实施例二的流程示意图;FIG. 2 is a schematic flow diagram of Embodiment 2 of a route distribution method in the embodiment of the present application;

图3为本申请实施例中一种路由分发装置的结构示意图。FIG. 3 is a schematic structural diagram of a route distribution device in an embodiment of the present application.

具体实施方式detailed description

本申请实施例提供了一种路由分发方法、装置和设备,考虑服务端的实际服务情况,使得分发时的考虑因素全面且也能够反应实际服务端的具体链路质量。The embodiments of the present application provide a route distribution method, device, and equipment, which consider the actual service conditions of the server, so that the factors considered during distribution are comprehensive and can also reflect the specific link quality of the actual server.

为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiment of the application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiment of the application. Obviously, the described embodiment is only It is a part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of this application.

本申请实施例第一方面提供了一种路由分发方法的实施例。The first aspect of the embodiments of the present application provides an embodiment of a route distribution method.

请参阅图1,本申请实施例中一种路由分发方法的实施例一的流程示意图。Please refer to FIG. 1 , which is a schematic flowchart of Embodiment 1 of a route distribution method in the embodiment of the present application.

本实施例中路由分发方法包括:The routing distribution method in this embodiment includes:

步骤101、获取应用系统中的链路在上一周期时的响应状态码。Step 101. Obtain the response status code of the link in the application system in the previous cycle.

响应状态码用以表示服务端的各链路在响应请求时的状态,即服务端在响应请求后,不同的响应状态码代表不同的响应状态,正常响应请求时的响应状态码和未正常响应请求时的响应状态码不相同,例如正常响应时的响应状态码可以为200或者201等,异常响应时的响应状态码可以是404或304等。The response status code is used to indicate the status of each link of the server when responding to the request, that is, after the server responds to the request, different response status codes represent different response statuses, the response status code when the request is normally responded to and the request is not responded normally The response status codes are different. For example, the response status code for a normal response can be 200 or 201, and the response status code for an abnormal response can be 404 or 304.

可以理解的是,步骤101中的应用系统指的是服务端所对应的应用系统,该系统中包括多条链路,在面对一个请求时,这多条链路可能会同时响应,且在一个周期内,可能会获取到多个请求,对应的链路也可能有多个响应状态码。It can be understood that the application system in step 101 refers to the application system corresponding to the server, and the system includes multiple links. When faced with a request, these multiple links may respond at the same time, and in In one cycle, multiple requests may be obtained, and the corresponding link may also have multiple response status codes.

本实施例中的上一周期指的是当前周期的上一个周期,下一周期指的是当前周期的下一个周期。可以理解的是,本实施例中在进行路由分发时,以上一周期、当前周期、下一周期三个周期为一组,在当前周期中对服务端的应用系统在上一周期时的响应状态码进行分析计算,以得到下一周期时应用系统中链路的链路权重,以进行路由分发。The previous period in this embodiment refers to a period preceding the current period, and the next period refers to a period next to the current period. It can be understood that in this embodiment, when routing distribution is performed, the previous cycle, the current cycle, and the next cycle are used as a group. In the current cycle, the response status code of the application system of the server in the previous cycle Perform analysis and calculation to obtain the link weight of the link in the application system in the next cycle for routing distribution.

需要说明的是,上述的链路可以是应用系统中的某一链路,也可以是部分链路,还可以是全部的链路。当本实施例中的链路为单一的某一链路时,本实施例中的响应状态码即该单一的某一链路的响应状态码;当链路为多个链路(部分链路或全部的链路)时,本实施例中的响应状态码即针对多个链路中的各链路获取各链路对应的响应状态码。在获取到链路对应的响应状态码后,针对各链路执行本实施例中的后续计算方法。It should be noted that the above-mentioned link may be a certain link in the application system, or may be some links, or may be all links. When the link in this embodiment is a single link, the response status code in this embodiment is the response status code of this single link; when the link is a plurality of links (partial links) or all links), the response status code in this embodiment is to obtain the response status code corresponding to each link for each link in the multiple links. After the response status code corresponding to the link is obtained, the subsequent calculation method in this embodiment is executed for each link.

步骤102、计算响应状态码为正常状态码时的码比率。Step 102, calculating the code ratio when the response status code is a normal status code.

可以理解的是,响应状态码不仅包括正常响应时的正常状态码,还包括异常响应时的异常状态码等,而要想提高服务端中链路的服务质量,依据的是正常状态码,故本实施例中计算响应状态码为正常状态码时的码比率。It can be understood that the response status code includes not only the normal status code for normal response, but also the abnormal status code for abnormal response, etc., but to improve the service quality of the link in the server, it is based on the normal status code, so In this embodiment, the code ratio when the response status code is a normal status code is calculated.

步骤103、利用链路分发权重动态调整算法,计算码比率对应的链路权重。Step 103, using the link distribution weight dynamic adjustment algorithm to calculate the link weight corresponding to the code ratio.

在得到正常状态码对应的码比率后,可以利用链路分发权重动态调整算法,计算该码比率对应的链路权重。After obtaining the code ratio corresponding to the normal state code, the link weight corresponding to the code ratio can be calculated by using the link distribution weight dynamic adjustment algorithm.

步骤104、当链路权重在标准链路权重范围内时,将链路权重作为链路在下一周期时的目标链路权重,以基于目标链路权重对链路进行路由分发。Step 104, when the link weight is within the standard link weight range, use the link weight as the target link weight of the link in the next cycle, so as to distribute routes to the link based on the target link weight.

计算得到链路权重后,为了避免极端情况导致的计算错误,将链路权重和标准链路权重范围进行比较,当链路权重在标准链路权重范围内时,将链路权重作为链路在下一周期时的目标链路权重,以基于目标链路权重对链路进行路由分发。After the link weight is calculated, in order to avoid calculation errors caused by extreme conditions, compare the link weight with the standard link weight range. When the link weight is within the standard link weight range, use the link weight as the link below The weight of the target link in one cycle, so as to distribute routes to links based on the weight of the target link.

可以理解的是,标准权重范围可以取值为[10,90],这样设置避免链路对应的目标链路权重过大或过小。It can be understood that the standard weight range may be [10,90], so that the weight of the target link corresponding to the link is prevented from being too large or too small.

本实施例中在进行路由分发时,首先获取应用系统中的链路在上一周期时的响应状态码,接着计算响应状态码为正常状态码时的码比率,然后利用链路分发权重动态调整算法,计算码比率对应的链路权重,最后当链路权重在标准链路权重范围内时,将链路权重作为链路在下一周期时的目标链路权重,以基于目标链路权重对链路进行路由分发,即本申请提供了基于服务的响应状态码的链路分发权重动态调整方案,丰富了链路分发权重的确定手段,使得链路由分发方案更加贴合服务端的服务运行状态,提升了API服务的整体质量和水平,保护了服务端的持续稳定的运行。In this embodiment, when performing route distribution, first obtain the response status code of the link in the application system in the previous cycle, then calculate the code ratio when the response status code is a normal status code, and then use the link distribution weight to dynamically adjust Algorithm to calculate the link weight corresponding to the code ratio. Finally, when the link weight is within the standard link weight range, the link weight is used as the target link weight of the link in the next cycle, and the chain route distribution, that is, this application provides a dynamic adjustment scheme of link distribution weight based on the response status code of the service, which enriches the means of determining the link distribution weight and makes the link routing distribution scheme more suitable for the service operation status of the server. It improves the overall quality and level of API services and protects the continuous and stable operation of the server.

以上为本申请实施例提供的一种路由分发方法的实施例一,以下为本申请实施例提供的一种路由分发方法的实施例二。The above is the first embodiment of the route distribution method provided by the embodiment of the present application, and the following is the second embodiment of the route distribution method provided by the embodiment of the present application.

本申请实施例第一方面提供了一种路由分发方法的实施例。The first aspect of the embodiments of the present application provides an embodiment of a route distribution method.

请参阅图2,本申请实施例中一种路由分发方法的实施例二的流程示意图。Please refer to FIG. 2 , which is a schematic flowchart of Embodiment 2 of a route distribution method in the embodiment of the present application.

本实施例中路由分发方法包括:The routing distribution method in this embodiment includes:

步骤201、获取应用系统中的链路在上一周期时的响应状态码。Step 201, acquire the response status code of the link in the application system in the last cycle.

可以理解的是,步骤201和步骤101的描述相同,具体可以参见步骤101的描述,在此不在赘述。It can be understood that the description of step 201 is the same as that of step 101, for details, refer to the description of step 101, and details are not repeated here.

步骤202、删除响应状态码中的异常数据。Step 202, delete the abnormal data in the response status code.

为了避免响应状态码中的异常数据导致的链路权重计算错误,本实施例中在获取到链路在上一周期时的响应状态码后,将响应状态码中的异常数据进行清洗,即删除响应状态码中的异常数据。可以理解的是,本实施例中的异常数据可以包括:空值的响应状态码和响应时长超过预设时长的响应状态码。In order to avoid link weight calculation errors caused by abnormal data in the response status code, in this embodiment, after obtaining the response status code of the link in the previous cycle, the abnormal data in the response status code is cleaned, that is, deleted Exception data in the response status code. It can be understood that the abnormal data in this embodiment may include: a response status code with a null value and a response status code with a response duration exceeding a preset duration.

步骤203、统计链路在上一周期时响应状态码的总数量。Step 203, counting the total number of link response status codes in the last cycle.

本实施例中正常状态码的码比率是根据所有的响应状态码和正常状态码计算的,故本实施例中在删除响应状态码中的异常数据后,计算出链路在上一周期时的响应状态码的总数量。In this embodiment, the code ratio of the normal status code is calculated according to all response status codes and normal status codes. Therefore, in this embodiment, after deleting the abnormal data in the response status code, the link is calculated in the previous cycle. The total number of response status codes.

步骤204、统计链路在上一周期时响应状态码为正常状态码的码数量。Step 204, counting the number of codes whose response status code was a normal status code in the last period of the link.

在统计链路在上一周期时响应状态码的总数量的同时,统计链路在上一周期时响应状态码为正常状态码的码数量。While counting the total number of link response status codes in the last cycle, count the number of codes whose link response status codes are normal status codes in the last cycle.

步骤205、根据码数量和总数量,计算响应状态码为正常状态码时的码比率。Step 205, according to the number of codes and the total number, calculate the code ratio when the response status code is a normal status code.

可以理解的是,正常状态码时的码比率为正常状态码的码数量/响应状态码的总数量。It can be understood that the code ratio for normal status codes is the number of normal status codes/the total number of response status codes.

可以理解的是,多个链路中,如果出现码比率低于50%,说明该码比率对应的链路异常程度大,故触发算法,重新计算总体业务在各个链路上的分发权重。其中各个链路的码比率独立计算,取值范围是0~1,越是靠近1,说明业务越是正常。It can be understood that if the code rate is lower than 50% in multiple links, it means that the link corresponding to the code rate is abnormal, so the algorithm is triggered to recalculate the distribution weight of the overall service on each link. The code ratio of each link is calculated independently, and the value ranges from 0 to 1. The closer to 1, the more normal the service is.

步骤206、获取链路分发权重动态调整算法对应的计算公式。Step 206, obtaining a calculation formula corresponding to the link distribution weight dynamic adjustment algorithm.

具体地,本实施例中的计算公式为:Specifically, the calculation formula in this embodiment is:

Figure BDA0003837237600000071
Figure BDA0003837237600000071

式中,Rw为链路权重,Nri为链路在上一周期时的码比率,N为应用系统中的链路数量,Pw为预设链路权重,a1、a2为常数,a1+a2=1,Mw为各个链路的质量权重之和。In the formula, Rw is the link weight, Nr i is the code rate of the link in the previous cycle, N is the number of links in the application system, Pw is the preset link weight, a 1 and a 2 are constants, a 1 +a 2 =1, Mw is the sum of the quality weights of each link.

为了便于理解,本实施例中对Mw进行举例说明,如以3个链路为例,Mw=((Nr1+(1-Nri…)/N)*40%+Pw*60%)+((Nr2+(1-Nri…)/N)*40%+Pw*60%)+((Nr3+(1-Nri…)/N)*40%+Pw*60%)。For ease of understanding, Mw is illustrated in this embodiment. For example, taking three links as an example, Mw=((Nr 1 +(1-Nr i ...)/N)*40%+Pw*60%)+ ((Nr 2 +(1-Nr i ...)/N)*40%+Pw*60%)+((Nr 3 +(1-Nr i ...)/N)*40%+Pw*60%).

可以理解的是,上述的a1、a2是常数,可以根据实际需要设置具体的取值。It can be understood that the above-mentioned a 1 and a 2 are constants, and specific values can be set according to actual needs.

步骤207、基于计算公式,计算码比率对应的链路权重。Step 207, based on the calculation formula, calculate the link weight corresponding to the code rate.

步骤208、当链路权重在标准链路权重范围内时,将链路权重作为链路在下一周期时的目标链路权重,以基于目标链路权重对链路进行路由分发。Step 208, when the link weight is within the standard link weight range, use the link weight as the target link weight of the link in the next period, so as to distribute routes to the link based on the target link weight.

在一个应用例中,a1取值40%,a2取值60%,以某应用系统的三条链路为例进行本实施例中的上述链路权重计算,在计算初始,三条链路各自对应的目标链路权重均为33%,即三者的目标链路权重比为:1:1:1,具体的计算结果如下表1所示:In an application example, the value of a 1 is 40%, and the value of a 2 is 60%. Taking the three links of an application system as an example to perform the above-mentioned link weight calculation in this embodiment, at the beginning of the calculation, each of the three links The corresponding target link weights are all 33%, that is, the target link weight ratio of the three is: 1:1:1. The specific calculation results are shown in Table 1 below:

表1Table 1

Figure BDA0003837237600000072
Figure BDA0003837237600000072

Figure BDA0003837237600000081
Figure BDA0003837237600000081

由表1可知,当当前周期为当A-2周期时,也就是计算初始,此时由于该周期不存在前两个周期,也就无法通过计算得到该A-2周期时应用系统中链路的目标链路权重,此时采用初始的目标链路权重,即33%,同理A-1周期也是。而利用A-2周期的应用系统的响应状态码计算得到的链路权重,是A周期是各链路用于路由分发的目标链路权重。同理,利用A-1周期的响应状态码计算得到的链路权重,是A+1周期是各链路用于路由分发的目标链路权重。It can be seen from Table 1 that when the current period is the A-2 period, that is, the initial calculation, since the previous two periods do not exist in this period, it is impossible to obtain the link in the application system of the A-2 period through calculation. The target link weight of , the initial target link weight is used at this time, that is, 33%, and the same is true for the A-1 cycle. The link weight calculated by using the response status code of the application system in the A-2 period is that the A period is the target link weight for each link for route distribution. Similarly, the link weight calculated by using the response status code of the A-1 period is that the A+1 period is the target link weight for each link for route distribution.

本实施例中在进行路由分发时,先获取应用系统中的链路在上一周期时的响应状态码,接着计算响应状态码为正常状态码时的码比率,然后利用链路分发权重动态调整算法,计算码比率对应的链路权重,最后当链路权重在标准链路权重范围内时,将链路权重作为链路在下一周期时的目标链路权重,以基于目标链路权重对链路进行路由分发,即本申请提供了基于服务的响应状态码的链路分发权重动态调整方案,丰富了链路分发权重的确定手段,使得链路由分发方案更加贴合服务端的服务运行状态,提升了API服务的整体质量和水平,保护了服务端的持续稳定的运行。In this embodiment, when performing route distribution, first obtain the response status code of the link in the application system in the previous cycle, then calculate the code ratio when the response status code is a normal status code, and then use the link distribution weight to dynamically adjust Algorithm to calculate the link weight corresponding to the code ratio. Finally, when the link weight is within the standard link weight range, the link weight is used as the target link weight of the link in the next cycle, and the chain route distribution, that is, this application provides a dynamic adjustment scheme of link distribution weight based on the response status code of the service, which enriches the means of determining the link distribution weight and makes the link routing distribution scheme more suitable for the service operation status of the server. It improves the overall quality and level of API services and protects the continuous and stable operation of the server.

本申请实施例第二方面提供了一种路由分发装置的实施例。The second aspect of the embodiments of the present application provides an embodiment of a route distribution device.

请参阅图3,本申请实施例中一种路由分发装置的结构示意图。Please refer to FIG. 3 , which is a schematic structural diagram of a route distribution device in an embodiment of the present application.

本实施例中的一种路由分发装置包括:A routing distribution device in this embodiment includes:

获取单元,用于获取应用系统中的链路在上一周期时的响应状态码;The obtaining unit is used to obtain the response status code of the link in the application system in the previous cycle;

第一计算单元,用于计算响应状态码为正常状态码时的码比率;The first calculation unit is used to calculate the code ratio when the response status code is a normal status code;

第二计算单元,用于利用链路分发权重动态调整算法,计算码比率对应的链路权重;The second calculation unit is used to calculate the link weight corresponding to the code ratio by using the link distribution weight dynamic adjustment algorithm;

赋值单元,用于当链路权重在标准链路权重范围内时,将链路权重作为链路在下一周期时的目标链路权重,以基于目标链路权重对链路进行路由分发。The assigning unit is configured to use the link weight as the target link weight of the link in the next period when the link weight is within the standard link weight range, so as to perform route distribution on the link based on the target link weight.

可选地,第一计算单元具体包括:Optionally, the first computing unit specifically includes:

第一统计子单元,用于统计链路在上一周期时响应状态码的总数量;The first statistical subunit is used to count the total number of link response status codes in the previous period;

第二统计子单元,用于统计链路在上一周期时响应状态码为正常状态码的码数量;The second statistical subunit is used to count the number of codes whose response status code is a normal status code in the last cycle of the link;

第一计算子单元,用于根据码数量和总数量,计算响应状态码为正常状态码时的码比率。The first calculation subunit is used to calculate the code ratio when the response status code is a normal status code according to the number of codes and the total number.

可选地,装置还包括:Optionally, the device also includes:

删除单元,用于删除响应状态码中的异常数据。The delete unit is used to delete the abnormal data in the response status code.

可选地,第二计算单元具体包括:Optionally, the second computing unit specifically includes:

获取子单元,用于获取链路分发权重动态调整算法对应的计算公式;The obtaining subunit is used to obtain the calculation formula corresponding to the link distribution weight dynamic adjustment algorithm;

第二计算子单元,用于基于计算公式,计算码比率对应的链路权重,其中,计算公式为:The second calculation subunit is used to calculate the link weight corresponding to the code ratio based on the calculation formula, wherein the calculation formula is:

Figure BDA0003837237600000091
Figure BDA0003837237600000091

式中,Rw为链路权重,Nri为链路在上一周期时的码比率,N为应用系统中的链路数量,Pw为预设链路权重,Mw为各个链路的质量权重之和,a1、a2为常数,a1+a2=1。In the formula, Rw is the link weight, Nr i is the code rate of the link in the previous cycle, N is the number of links in the application system, Pw is the preset link weight, and Mw is the ratio of the quality weight of each link And, a 1 and a 2 are constants, a 1 +a 2 =1.

本实施例中在进行路由分发时,先获取应用系统中的链路在上一周期时的响应状态码,接着计算响应状态码为正常状态码时的码比率,然后利用链路分发权重动态调整算法,计算码比率对应的链路权重,最后当链路权重在标准链路权重范围内时,将链路权重作为链路在下一周期时的目标链路权重,以基于目标链路权重对链路进行路由分发,即本申请提供了基于服务的响应状态码的链路分发权重动态调整方案,丰富了链路分发权重的确定手段,使得链路由分发方案更加贴合服务端的服务运行状态,提升了API服务的整体质量和水平,保护了服务端的持续稳定的运行。In this embodiment, when performing route distribution, first obtain the response status code of the link in the application system in the previous cycle, then calculate the code ratio when the response status code is a normal status code, and then use the link distribution weight to dynamically adjust Algorithm to calculate the link weight corresponding to the code ratio. Finally, when the link weight is within the standard link weight range, the link weight is used as the target link weight of the link in the next cycle, and the chain route distribution, that is, this application provides a dynamic adjustment scheme of link distribution weight based on the response status code of the service, which enriches the means of determining the link distribution weight and makes the link routing distribution scheme more suitable for the service operation status of the server. It improves the overall quality and level of API services and protects the continuous and stable operation of the server.

本申请实施例第三方面提供了一种路由分发设备的实施例。The third aspect of the embodiments of the present application provides an embodiment of a route distribution device.

一种路由分发设备,包括处理器以及存储器;存储器用于存储程序代码,并将程序代码传输给处理器;处理器用于根据程序代码中的指令执行第一方面的路由分发方法。A route distribution device includes a processor and a memory; the memory is used to store program codes and transmit the program codes to the processor; the processor is used to execute the route distribution method of the first aspect according to instructions in the program codes.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described devices and units can refer to the corresponding process in the foregoing method embodiments, and details are not repeated here.

在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个待安装电网网络,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated. to another grid network to be installed, or some features can be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.

作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。A unit described as a separate component may or may not be physically separated, and a component shown as a unit may or may not be a physical unit, that is, it may be located in one place, or may also be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-OnlyMemory)、随机存取存储器(RAM,RandomAccessMemory)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is realized in the form of a software function 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 application is essentially or part of the contribution 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 several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-OnlyMemory), random access memory (RAM, RandomAccessMemory), magnetic disk or optical disk and other media that can store program codes.

以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: it can still understand the foregoing The technical solutions described in each embodiment are modified, or some of the technical features are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the application.

Claims (10)

1. A method for route distribution, comprising:
acquiring a response state code of a link in an application system in an upper period;
calculating the code ratio when the response state code is a normal state code;
calculating the link weight corresponding to the code ratio by using a link distribution weight dynamic adjustment algorithm;
when the link weight is within a standard link weight range, the link weight is taken as a target link weight of the link at the next period, so that the link is subjected to route distribution based on the target link weight.
2. The route distribution method according to claim 1, wherein calculating the code ratio when the response status code is a normal status code specifically includes:
counting the total number of response status codes of the link in the last period;
counting the number of codes of which the response state codes are normal state codes in the last period of the link;
and calculating the code ratio when the response state code is a normal state code according to the code number and the total number.
3. The route distribution method according to claim 1, wherein calculating the code ratio when the response status code is a normal status code further comprises:
and deleting abnormal data in the response status code.
4. The route distribution method according to claim 3, wherein the anomaly data comprises: the response state code of the null value and the response state code of which the response time length exceeds the preset time length.
5. The route distribution method according to claim 1, wherein calculating the link weight corresponding to the code ratio by using a link distribution weight dynamic adjustment algorithm specifically includes:
obtaining a calculation formula corresponding to a link distribution weight dynamic adjustment algorithm;
calculating the link weight corresponding to the code ratio based on the calculation formula, wherein the calculation formula is as follows:
Figure FDA0003837237590000011
where Rw is the link weight, nr i Is the code ratio of the link at the last cycle, N is the number of links in the application,pw is the weight of the preset link, mw is the sum of the quality weights of the links, a 1 、a 2 Is a constant number, a 1 +a 2 =1。
6. A route distribution apparatus, comprising:
the acquisition unit is used for acquiring a response status code of a link in an application system during a previous period;
a first calculation unit for calculating a code ratio when the response status code is a normal status code;
a second calculating unit, configured to calculate, by using a link distribution weight dynamic adjustment algorithm, a link weight corresponding to the code ratio;
and the assigning unit is used for taking the link weight as a target link weight of the link in the next period when the link weight is in a standard link weight range so as to perform route distribution on the link based on the target link weight.
7. The route distribution apparatus according to claim 6, wherein the first computing unit specifically includes:
the first counting subunit is used for counting the total number of the response status codes of the link in the last period;
the second counting subunit is used for counting the number of codes of which the response state codes are normal state codes in the last period of the link;
and the first calculating subunit is used for calculating the code ratio when the response state code is a normal state code according to the code number and the total number.
8. The route distribution device of claim 6, wherein the device further comprises:
and the deleting unit is used for deleting the abnormal data in the response state code.
9. The routing distribution device according to claim 6, wherein the second computing unit specifically includes:
the acquiring subunit is used for acquiring a calculation formula corresponding to the link distribution weight dynamic adjustment algorithm;
a second calculating subunit, configured to calculate, based on the calculation formula, a link weight corresponding to the code ratio, where the calculation formula is:
Figure FDA0003837237590000021
where Rw is the link weight, nr i Is the code ratio of the link in the last period, N is the number of links in the application system, pw is the preset link weight, mw is the sum of the quality weights of the links, a 1 、a 2 Is a constant number, a 1 +a 2 =1。
10. A route distribution device comprising a processor and a memory;
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to execute the route distribution method of any one of claims 1 to 5 according to instructions in the program code.
CN202211099157.5A 2022-09-07 2022-09-07 Route distribution method, device and equipment Pending CN115622933A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211099157.5A CN115622933A (en) 2022-09-07 2022-09-07 Route distribution method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211099157.5A CN115622933A (en) 2022-09-07 2022-09-07 Route distribution method, device and equipment

Publications (1)

Publication Number Publication Date
CN115622933A true CN115622933A (en) 2023-01-17

Family

ID=84859177

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211099157.5A Pending CN115622933A (en) 2022-09-07 2022-09-07 Route distribution method, device and equipment

Country Status (1)

Country Link
CN (1) CN115622933A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060282534A1 (en) * 2005-06-09 2006-12-14 International Business Machines Corporation Application error dampening of dynamic request distribution
CN110417654A (en) * 2019-07-30 2019-11-05 杭州迪普科技股份有限公司 The optimization method and device of minimum discharge link scheduling algorithm
CN113748648A (en) * 2019-05-23 2021-12-03 慧与发展有限责任合伙企业 Weight routing
CN114422325A (en) * 2021-12-30 2022-04-29 优刻得科技股份有限公司 Content distribution network abnormal location method, device, device and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060282534A1 (en) * 2005-06-09 2006-12-14 International Business Machines Corporation Application error dampening of dynamic request distribution
CN113748648A (en) * 2019-05-23 2021-12-03 慧与发展有限责任合伙企业 Weight routing
CN110417654A (en) * 2019-07-30 2019-11-05 杭州迪普科技股份有限公司 The optimization method and device of minimum discharge link scheduling algorithm
CN114422325A (en) * 2021-12-30 2022-04-29 优刻得科技股份有限公司 Content distribution network abnormal location method, device, device and storage medium

Similar Documents

Publication Publication Date Title
CN110120973A (en) A kind of request control method, relevant device and computer storage medium
CN109413175B (en) Information processing method and device and electronic equipment
CN107317879B (en) A method and system for distributing user requests
CN113037869A (en) Method and apparatus for back-sourcing of content distribution network system
CN108762924A (en) A kind of method, apparatus and computer readable storage medium of load balancing
CN110365765A (en) A bandwidth scheduling method and device for a cache server
CN113472852A (en) CDN node back-source method, device and equipment
CN113037791B (en) Operation and maintenance method and system, and computer readable storage medium
WO2016044329A1 (en) Real-time, low memory estimation of unique client computers communicating with a server computer
CN107623732A (en) A cloud platform-based data storage method, device, equipment and storage medium
CN115696356B (en) Cell capacity adjustment method and device, electronic equipment and storage medium
CN110505540A (en) A method and device for judging the priority of PON port expansion
CN103227756B (en) Online protocol optimization method and device
CN108390775A (en) A kind of user experience quality evaluation method and system based on SPICE
CN112637286B (en) Network architecture adjusting method, device, system and computer readable storage medium
CN108959047B (en) Pressure testing method and device based on service scene
CN112988892A (en) Distributed system hot spot data management method
CN109831508A (en) A kind of caching method and equipment, storage medium
CN114844843B (en) Method and device for adjusting number of application instances
US9141508B2 (en) Assigning read requests based on busyness of devices
CN115622933A (en) Route distribution method, device and equipment
CN107436954B (en) A kind of online flow data approximate processing method of quality control and device
CN112187870B (en) A kind of bandwidth smoothing method and device
TW202218380A (en) Reliability evaluation method of multi-state distributed network system
CN111966490A (en) A Spark Partition Load Balancing Method

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20230117