[go: up one dir, main page]

CN117134946A - Access request current limiting methods, devices, equipment and storage media - Google Patents

Access request current limiting methods, devices, equipment and storage media Download PDF

Info

Publication number
CN117134946A
CN117134946A CN202310914324.5A CN202310914324A CN117134946A CN 117134946 A CN117134946 A CN 117134946A CN 202310914324 A CN202310914324 A CN 202310914324A CN 117134946 A CN117134946 A CN 117134946A
Authority
CN
China
Prior art keywords
target
access request
request
requests
current limiting
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
CN202310914324.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.)
China Mobile Communications Group Co Ltd
China Mobile Hangzhou Information Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Hangzhou Information 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 China Mobile Communications Group Co Ltd, China Mobile Hangzhou Information Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202310914324.5A priority Critical patent/CN117134946A/en
Publication of CN117134946A publication Critical patent/CN117134946A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/10Network architectures or network communication protocols for network security for controlling access to devices or network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1408Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic by monitoring network traffic
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application relates to the technical field of communication and provides a method, a device, equipment and a storage medium for limiting access requests. The method comprises the following steps: acquiring a tag identifier of an access request of a back-end service; the tag identifier is used for indicating an initial current limit value corresponding to the access request and a first target server accessed by the access request; determining target requests of which the request quantity exceeds an initial current limit value corresponding to the tag identification; inquiring the resource use information of the first target server, and limiting the current of the target request according to the resource use information; the resource usage information includes processor resource usage, disk usage, and memory usage. According to the access request current limiting method provided by the embodiment of the application, the label identification is introduced, the initial current limiting value based on the label identification is used for current limiting, and the dynamic current limiting of the access request exceeding the initial current limiting value based on the resource use condition is combined, so that the utilization rate of the resource can be improved.

Description

访问请求限流方法、装置、设备及存储介质Access request current limiting methods, devices, equipment and storage media

技术领域Technical field

本申请涉及通信技术领域,具体涉及一种访问请求限流方法、装置、设备及存储介质。The present application relates to the field of communication technology, and specifically relates to an access request current limiting method, device, equipment and storage medium.

背景技术Background technique

随着微服务的应用越来越广泛,由于各微服务的业务流程接口之间存在相互依赖的关系,形成了众多平台调用同一平台的复杂依赖关系,如果某一系统的某一请求出现问题,就会导致调用异常,可能导致整个服务出现瘫痪现象。为此,需要对微服务框架下的业务进行灵活的隔离限流处理。同时,限流虽然可以使系统变得很稳定,但是却会在一定程度上降低系统吞吐量,降低资源的利用率,增加服务器成本。例如,在业务繁忙时每秒查询率QPS(Queries-per-second)为1000,在另外一个空闲时间段QPS为3000,限流设置为了让系统稳定提供服务,会设置QPS为1000,这使得在QPS为3000的时间段只能提供QPS为1000的服务能力。As the application of microservices becomes more and more widespread, due to the interdependence between the business process interfaces of each microservice, complex dependencies are formed where many platforms call the same platform. If there is a problem with a certain request of a certain system, This will lead to abnormal calls and may cause the entire service to be paralyzed. To this end, it is necessary to implement flexible isolation and current limiting processing for businesses under the microservice framework. At the same time, although current limiting can make the system very stable, it will reduce system throughput, reduce resource utilization, and increase server costs to a certain extent. For example, when the business is busy, the query rate per second (QPS) is 1000, and in another idle period, the QPS is 3000. In order to allow the system to stably provide services, the current limiting setting will set the QPS to 1000, which makes the A time period with a QPS of 3,000 can only provide service capabilities with a QPS of 1,000.

现有的限流方式都是静态的限流,如漏桶、令牌桶、计数器法等,可以限制单位时间内的请求数量,保证系统的正常运行,但是这类方法都是对请求进行统一的限流,更细粒度的也只是对系统的接口进行限流,没有对于请求的服务或系统进行隔离区分,很容易导致因某一个请求的异常,影响其他系统的请求。基于此,现有的部分限流方法对请求进行了优先级配置,先响应高优先级的服务请求,再响应低优先级的服务请求。此方式在并发量不高的情况下,由于预留太多资源给高优先级请求,即便服务空闲,低优先级请求仍会出现请求不被响应的问题,会极大的减低资源利用率。Existing current limiting methods are all static current limiting methods, such as leaky bucket, token bucket, counter method, etc., which can limit the number of requests per unit time and ensure the normal operation of the system. However, these methods all unify requests. The current limit is more granular and only limits the system interface. There is no isolation and differentiation of the requested service or system. It is easy to cause an exception in a certain request to affect the requests of other systems. Based on this, some existing current limiting methods configure the priority of requests, respond to high-priority service requests first, and then respond to low-priority service requests. When the amount of concurrency is not high, this method reserves too many resources for high-priority requests. Even if the service is idle, low-priority requests will still have the problem of unresponsive requests, which will greatly reduce resource utilization.

发明内容Contents of the invention

本申请实施例提供一种访问请求限流方法、装置、设备及存储介质,用以解决现有的访问请求的限流方式资源利用率低的技术问题。Embodiments of the present application provide an access request current limiting method, device, equipment, and storage medium to solve the technical problem of low resource utilization in existing access request current limiting methods.

第一方面,本申请实施例提供一种访问请求限流方法,包括:In the first aspect, embodiments of this application provide a method for limiting access request current, including:

获取后端服务的访问请求的标签标识;所述标签标识用于指示所述访问请求对应的初始限流值,以及所述访问请求访问的第一目标服务器;Obtain the label identification of the access request of the back-end service; the label identification is used to indicate the initial current limit value corresponding to the access request, and the first target server accessed by the access request;

确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求;Determine the target request whose number of requests for the access request exceeds the initial current limit value corresponding to the tag identification;

查询所述第一目标服务器的资源使用信息,根据所述资源使用信息对所述目标请求进行限流;所述资源使用信息包括处理器资源使用率、磁盘使用率和内存使用率。Query the resource usage information of the first target server, and limit the flow of the target request according to the resource usage information; the resource usage information includes processor resource usage, disk usage, and memory usage.

在一个实施例中,所述标签标识还用于指示所述访问请求所需的资源类型,所述资源类型包括处理器资源、内存资源和磁盘资源;所述根据所述资源使用信息对所述目标请求进行限流,包括:In one embodiment, the tag identification is also used to indicate the resource type required by the access request, and the resource type includes processor resources, memory resources and disk resources; the resource usage information is used to determine the resource type. Target requests are flow-limited, including:

根据所述标签标识确定所述目标请求所需的目标资源类型;Determine the target resource type required by the target request according to the tag identification;

根据所述资源使用信息,确定所述第一目标服务器的剩余资源;Determine remaining resources of the first target server according to the resource usage information;

基于所述目标资源类型和所述剩余资源,确定所述第一目标服务器是否存在所述目标请求对应的可用资源;Based on the target resource type and the remaining resources, determine whether the first target server has available resources corresponding to the target request;

若不存在,获取基于所述目标资源类型,查询所述后端服务中是否第二目标服务器;所述第二目标服务器是所述后端服务中除所述第一目标服务器中之外,存在所述目标请求对应的可用资源的服务器;If it does not exist, obtain the target resource type and query whether there is a second target server in the back-end service; the second target server is the one that exists in the back-end service in addition to the first target server. The server of available resources corresponding to the target request;

若所述后端服务中存在第二目标服务器,根据所述第二目标服务器的可用资源对所述目标请求进行限流。If there is a second target server in the backend service, the target request is flow-limited according to the available resources of the second target server.

在一个实施例中,所述标签标识还用于指示所述访问请求的时间戳信息;所述根据所述第二目标服务器的可用资源对所述目标请求进行限流,包括:In one embodiment, the tag identifier is also used to indicate the timestamp information of the access request; and limiting the target request according to the available resources of the second target server includes:

获取所述目标请求在所述标签标识下的目标时间戳;Obtain the target timestamp of the target request under the tag identification;

根据所述第二目标服务器的可用资源确定窗口尺寸;Determine the window size based on the available resources of the second target server;

按照所述目标时间戳对应的先后顺序对所述目标请求进行排序;Sort the target requests according to the order corresponding to the target timestamp;

根据对所述目标请求的排序顺序,基于所述窗口尺寸采用滑动窗口算法对所述目标请求进行响应,以对所述目标请求进行限流。According to the sorting order of the target requests, a sliding window algorithm is used to respond to the target requests based on the window size to limit the flow of the target requests.

在一个实施例中,根据下列公式查询所述后端服务中的第二目标服务器是否存在所述目标请求对应的可用资源:In one embodiment, query whether the second target server in the backend service has available resources corresponding to the target request according to the following formula:

R=αC+βM+δD;R=αC+βM+δD;

其中,C为处理器使用率、M为内存使用率、D为磁盘使用率、R为资源富裕度,Ei为所述后端服务中除所述第一目标服务器之外的第i各服务器的剩余资源指标值、busness为所述目资源类型对应的资源类型偏好因子、failcount为历史预设时长内的请求失败数量;ε、 α、β和δ均为预设的权重参数。Among them, C is the processor usage, M is the memory usage, D is the disk usage, R is the resource abundance, and E i is the i-th server in the back-end service except the first target server. The remaining resource indicator value, busness is the resource type preference factor corresponding to the target resource type, and fail count is the number of failed requests within the historical preset time period; ε, α, β and δ are all preset weight parameters.

在一个实施例中,所述确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求,包括:In one embodiment, determining that the number of request requests for the access request exceeds the target request corresponding to the initial current limit value corresponding to the tag identification includes:

基于所述标签标识对所述访问请求进行分类汇总,将所述标签标识相同的访问请求分类汇总到同一标签分类下;Classify and summarize the access requests based on the label identification, and classify and summarize the access requests with the same label identification under the same label classification;

根据分类汇总结果,确定目标标签分类下的访问请求的请求数量;所述目标标签分类为所述标签标识对应的各标签分类中的任意一个;According to the classification summary results, determine the number of access requests under the target label classification; the target label classification is any one of the label classifications corresponding to the label identification;

若所述请求数量超过所述目标标签分类下的标签标识对应的初始限流值,获取所述目标标签分类下超过所述初始限流值的目标请求。If the number of requests exceeds the initial current limit value corresponding to the tag identifier under the target tag category, obtain the target requests under the target tag category that exceed the initial current limit value.

在一个实施例中,所述获取后端服务的访问请求的标签标识之前,还包括:In one embodiment, before obtaining the tag identifier of the access request for the backend service, the method further includes:

获取后端服务的访问请求的请求信息;所述请求信息包括所述访问请求访问的第一目标服务器、所述访问请求所需的资源类型和所述访问请求的时间戳信息;Obtain the request information of the access request of the back-end service; the request information includes the first target server accessed by the access request, the resource type required by the access request, and the timestamp information of the access request;

根据所述请求信息生成所述访问请求的标签标识。Generate a label identification of the access request according to the request information.

在一个实施例中,所述访问请求限流方法还包括:In one embodiment, the access request current limiting method further includes:

获取历史访问请求的资源使用信息;Obtain resource usage information of historical access requests;

根据所述资源使用信息确定所述历史访问请求的标签标识对应的初始限流值。The initial current limit value corresponding to the tag identifier of the historical access request is determined according to the resource usage information.

第二方面,本申请实施例提供一种访问请求限流装置,包括:In the second aspect, embodiments of the present application provide an access request current limiting device, including:

请求拦截模块,用于获取后端服务的访问请求的标签标识;所述标签标识用于指示所述访问请求对应的初始限流值,以及所述访问请求访问的第一目标服务器;A request interception module, used to obtain the tag identification of the access request of the back-end service; the tag identification is used to indicate the initial current limit value corresponding to the access request, and the first target server accessed by the access request;

第一限流模块,用于确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求;A first current limiting module, configured to determine target requests whose number of access requests exceeds the initial current limiting value corresponding to the tag identification;

第二限流模块,用于查询所述第一目标服务器的资源使用信息,根据所述资源使用信息对所述目标请求进行限流;所述资源使用信息包括处理器资源使用率、磁盘使用率和内存使用率。The second current limiting module is used to query the resource usage information of the first target server and limit the current flow of the target request according to the resource usage information; the resource usage information includes processor resource usage and disk usage. and memory usage.

第三方面,本申请实施例提供一种电子设备,包括处理器和存储有计算机程序的存储器,所述处理器执行所述程序时实现第一方面所述的访问请求限流方法的步骤。In a third aspect, embodiments of the present application provide an electronic device, including a processor and a memory storing a computer program. When the processor executes the program, the steps of the access request current limiting method described in the first aspect are implemented.

第四方面,本申请实施例提供一种非暂态的计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现第一方面所述的访问请求限流方法的步骤。In the fourth aspect, embodiments of the present application provide a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the access request current limiting method described in the first aspect is implemented. step.

第五方面,本申请实施例提供一种计算机程序产品,包括计算机程序,所述计算机程序被处理器执行时实现第一方面所述的访问请求限流方法的步骤。In a fifth aspect, embodiments of the present application provide a computer program product, including a computer program that, when executed by a processor, implements the steps of the access request current limiting method described in the first aspect.

本申请实施例提供的访问请求限流方法、装置、设备及存储介质,通过获取用于指示初始限流值和请求访问的服务器的标签标识,并确定访问请求的请求数量超过标签标识对应的初始限流值的目标请求;查询第一目标服务器的处理器资源使用率、磁盘使用率和内存使用率等资源使用信息,根据资源使用信息对目标请求进行限流,可以对服务器剩余的可用性资源进行灵活利用,实现对请求的动态限流,提高资源利用率。The access request current limiting method, device, equipment and storage medium provided by the embodiments of the present application obtain the tag identifier used to indicate the initial current limit value and the server requesting access, and determine that the number of access requests exceeds the initial number corresponding to the tag identifier. Target request with current limit value; query resource usage information such as processor resource usage, disk usage, and memory usage of the first target server, limit the target request based on the resource usage information, and perform the remaining availability resources of the server. Flexible utilization enables dynamic flow limitation of requests and improves resource utilization.

附图说明Description of the drawings

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

图1是本申请实施例提供的访问请求限流方法的流程示意图之一;Figure 1 is one of the flow diagrams of the access request current limiting method provided by the embodiment of the present application;

图2是本申请实施例提供的标签标识控制位示意图;Figure 2 is a schematic diagram of the tag identification control bit provided by the embodiment of the present application;

图3是本申请实施例提供的访问请求的标签标识的示意图;Figure 3 is a schematic diagram of the tag identification of the access request provided by the embodiment of the present application;

图4至图5是本申请实施例提供的标签标识的标签分类示意图;Figures 4 to 5 are schematic diagrams of label classification of label identification provided by embodiments of the present application;

图6是本申请实施例提供的访问请求限流方法的流程示意图之二;Figure 6 is the second schematic flowchart of the access request current limiting method provided by the embodiment of the present application;

图7是本申请实施例提供的访问请求限流方法的流程示意图之三;Figure 7 is the third schematic flowchart of the access request current limiting method provided by the embodiment of the present application;

图8是本申请实施例提供的访问请求限流装置的结构示意图;Figure 8 is a schematic structural diagram of an access request current limiting device provided by an embodiment of the present application;

图9是本申请实施例提供的电子设备的结构示意图。Figure 9 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.

具体实施方式Detailed ways

为使本申请的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are part of this application. Examples, not all examples. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of this application.

图1为本申请实施例提供的访问请求限流方法的流程示意图。参照图1,本申请实施例提供的访问请求限流方法,可以包括:Figure 1 is a schematic flowchart of an access request current limiting method provided by an embodiment of the present application. Referring to Figure 1, the access request current limiting method provided by the embodiment of the present application may include:

步骤100,获取后端服务的访问请求的标签标识;所述标签标识用于指示所述访问请求对应的初始限流值,以及所述访问请求访问的第一目标服务器;Step 100: Obtain the tag identifier of the access request of the back-end service; the tag identifier is used to indicate the initial current limit value corresponding to the access request, and the first target server accessed by the access request;

获取后端服务的访问请求的标签标识(serviceID),该标签标识用于指示访问请求对应的初始限流值,以及访问请求访问的第一目标服务器,标签标识还用于指示请求的服务,以及服务要调用的业务系统,请求的服务与第一目标服务器可以是对应的。在微服务框架下的集群服务中,一个业务系统可以通过访问请求调用另外的一个或多个业务系统,同一个业务系统也可以被其他的一个或多个业务系统调用,从而在集群中形成复杂的调用依赖关系,不同的服务需要调用不同的业务系统,从而需要请求调用不同的接口。Obtain the tag ID (serviceID) of the access request of the backend service. The tag ID is used to indicate the initial current limit value corresponding to the access request, and the first target server accessed by the access request. The tag ID is also used to indicate the requested service, and The business system to be called by the service, and the requested service may correspond to the first target server. In the cluster service under the microservice framework, one business system can call another one or more business systems through access requests, and the same business system can also be called by one or more other business systems, thus forming a complex situation in the cluster. Calling dependencies, different services need to call different business systems, thus requiring calls to different interfaces.

进一步地,标签标识可以是在访问请求发起时,基于预先配置的标签标识映射规则,对访问请求的请求信息进行映射生成的。具体地,在标签标识映射规则中,不同的业务系统、不同的服务器、不同的资源类型以及不同的接口,对应不同的标识符,基于预设的标签标识映射规则,根据访问请求要调用的业务系统,和/或请求的服务,和/或所需的资源类型,和/或调用的接口,生成访问请求的标签标识。Furthermore, the label identification may be generated by mapping the request information of the access request based on preconfigured label identification mapping rules when the access request is initiated. Specifically, in the label identification mapping rules, different business systems, different servers, different resource types, and different interfaces correspond to different identifiers. Based on the preset label identification mapping rules, the business to be called according to the access request The system, and/or the requested service, and/or the required resource type, and/or the interface called, generates the label identification of the access request.

需要说明的是,标签标识的生成,是通过在访问请求的消息体的头部添加如图2所示的标签控制位实现的,访问请求的标签控制位相同,表示请求属于同一标签。每个系统可以生成同一个或者多个不同标签的访问请求,其中,同一个业务系统生成包含多个不同标签的访问请求的标签标识如图3所示,在图3中,访问请求要调用的业务系统包括系统A和系统B,因此,生成的访问请求中的标签标识包括系统A对应的标识serviceIDa,以及系统B对应的标识serviceIDb。It should be noted that the label identification is generated by adding the label control bit as shown in Figure 2 to the header of the message body of the access request. The label control bits of the access request are the same, indicating that the requests belong to the same label. Each system can generate the same or multiple access requests with different labels. The same business system generates access requests containing multiple different labels. The label identification is shown in Figure 3. In Figure 3, the access request to be called The business system includes system A and system B. Therefore, the tag identifier in the generated access request includes the identifier serviceIDa corresponding to system A and the identifier serviceIDb corresponding to system B.

步骤200,确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求;Step 200: Determine target requests whose number of access requests exceeds the initial current limit value corresponding to the tag identification;

确定访问请求的请求数量超过标签标示对应的初始限流值的目标请求,可以理解的是,访问请求的请求数量在不超过初始限流值时,可以对访问请求直接进行响应,当访问请求的请求数量超过初始限流值时,对不超过初始限流值的请求进行响应,而对于超过初始限流值的请求,则需要进行限流处理。对于超过初始限流值的目标请求,可以是根据请求的时间顺序,和/或,请求的优先级,在不超过初始限流值的前提下,选取访问请求中请求时间在前,和/或,优先级最高的请求进行响应,对于请求时间在后,和/或优先级较低的,作为超过初始限流值的目标请求进行限流。Determine the target request whose number of access requests exceeds the initial current limit value corresponding to the tag. It can be understood that when the number of access requests does not exceed the initial current limit value, you can directly respond to the access request. When the number of access requests When the number of requests exceeds the initial current limit value, the system will respond to requests that do not exceed the initial current limit value, and for requests that exceed the initial current limit value, current limit processing is required. For target requests that exceed the initial current limit value, the access request can be selected based on the time sequence of the requests and/or the priority of the requests, provided that the initial current limit value is not exceeded, and the request time is first among the access requests, and/or , the request with the highest priority will be responded to, and the request time will be later and/or the priority will be lower, and the current will be limited as the target request that exceeds the initial current limit value.

进一步地,不同的标签标识对应的初始限流值可以相同,也可以不同,不同的标签标识下的访问请求,所需的资源类型以及所需的资源量也可以不同,在集群服务中,根据不同标签标识所需的资源类型以及资源量,对不同的标签标识分配不同的初始限流值,同一标签标识下的访问请求超过其初始限流值时,则对超过初始限流值的目标请求进行限流。Furthermore, the initial current limit values corresponding to different label identifiers can be the same or different. The required resource types and required resource amounts for access requests under different label identifiers can also be different. In cluster services, according to Different label identifiers require resource types and resource amounts, and different initial current limit values are assigned to different label identifiers. When access requests under the same label identifier exceed its initial current limit value, target requests that exceed the initial current limit value will be processed. Perform current limiting.

步骤300,查询所述第一目标服务器的资源使用信息,根据所述资源使用信息对所述目标请求进行限流;所述资源使用信息包括处理器资源使用率、磁盘使用率和内存使用率。Step 300: Query the resource usage information of the first target server, and limit the flow of the target request according to the resource usage information; the resource usage information includes processor resource usage, disk usage, and memory usage.

在对目标请求进行限流时,具体是查询第一目标服务器的资源使用信息,根据该资源使用信息对目标请求进行限流。具体地,若第一目标服务器存在目标请求可用的资源,则使用第一目标服务器的资源对目标请求进行响应;若第一目标服务器不存在目标请求可用的资源,则从后端服务中选取资源剩余最多的服务器,对目标请求进行响应,实现对目标请求的动态限流。When limiting the target request, specifically, the resource usage information of the first target server is queried, and the target request is limited based on the resource usage information. Specifically, if the first target server has resources available for the target request, use the resources of the first target server to respond to the target request; if the first target server does not have resources available for the target request, select resources from the back-end service. The server with the most remaining responds to the target request and implements dynamic current limiting of the target request.

进一步地,基于标签标识所指示的请求信息,可以基于标签标识实现基于请求信息中的任意一项或多项,对访问请求进行不同维度的限流,从而对后端服务的访问请求的限流颗粒度进行灵活控制,实现动态限流。Furthermore, based on the request information indicated by the tag identifier, the tag identifier can be used to limit the flow of access requests in different dimensions based on any one or more items in the request information, thereby limiting the flow of access requests to the back-end service. Granularity can be flexibly controlled to achieve dynamic current limiting.

在本实施例中,通过获取用于指示初始限流值和请求访问的服务器的标签标识,并确定访问请求的请求数量超过标签标识对应的初始限流值的目标请求;查询第一目标服务器的处理器资源使用率、磁盘使用率和内存使用率等资源使用信息,根据资源使用信息对目标请求进行限流,可以对服务器剩余的可用性资源进行灵活利用,实现对请求的动态限流,提高资源利用率。In this embodiment, by obtaining the tag identifier indicating the initial current limit value and the server requesting access, and determining the target request whose number of access requests exceeds the initial current limit value corresponding to the tag identifier; querying the first target server Resource usage information such as processor resource usage, disk usage, and memory usage can be used to limit the target request based on the resource usage information. The remaining availability resources of the server can be flexibly utilized to achieve dynamic flow limitation of requests and improve resources. Utilization.

优选地,步骤100中,在获取后端服务的访问请求的标签标识之前,首先需要获取后端服务的访问请求,并生成访问请求对应的标签标识。具体地,获取后端服务的访问请求的标签标识之前,还可以包括:Preferably, in step 100, before obtaining the tag identification of the access request of the back-end service, it is first necessary to obtain the access request of the back-end service and generate the tag identification corresponding to the access request. Specifically, before obtaining the label identification of the access request of the backend service, you may also include:

步骤001,获取后端服务的访问请求的请求信息;所述请求信息包括所述访问请求访问的第一目标服务器、所述访问请求所需的资源类型和所述访问请求的时间戳信息;Step 001, obtain the request information of the access request of the back-end service; the request information includes the first target server accessed by the access request, the resource type required by the access request, and the timestamp information of the access request;

步骤002,根据所述请求信息生成所述访问请求的标签标识。Step 002: Generate a tag identification of the access request according to the request information.

获取后端服务的访问请求及其请求信息,该请求信息包括访问请求访问的第一目标服务器,请求所需的资源类型以及请求的时间戳信息,根据的访问请求的请求信息,生成访问请求的标签标识。标签标识可以是基于预设规则对请求信息进行映射生成的,也可以是基于提前设置的请求信息与标签标识之间的对应关系表,对访问请求的请求信息与对应关系表进行匹配得到的,在此不作具体限定。Obtain the access request of the back-end service and its request information. The request information includes the first target server accessed by the access request, the resource type required by the request and the timestamp information of the request. Based on the request information of the access request, generate the access request Label identification. The label identification can be generated by mapping the request information based on preset rules, or it can be obtained by matching the request information of the access request with the corresponding relationship table based on the correspondence table between the request information and the label identification set in advance. There is no specific limitation here.

优选地,标签标识对应的初始限流值是基于每个标签标识下的访问请求的资源使用情况确定的,本申请实施例提供的访问请求限流方法还可以包括:Preferably, the initial current limiting value corresponding to the tag identification is determined based on the resource usage of the access request under each tag identification. The access request current limiting method provided by the embodiment of the present application may also include:

步骤01,获取历史访问请求的资源使用信息;Step 01: Obtain the resource usage information of historical access requests;

步骤02,根据所述资源使用信息确定所述历史访问请求的标签标识对应的初始限流值。Step 02: Determine the initial current limit value corresponding to the tag identifier of the historical access request based on the resource usage information.

获取历史访问请求的资源使用信息,不同的标签标识所需的资源类型不同,所需的资源类型相同的标签标识,访问请求所需的资源量也可以不同。基于历史访问请求的资源使用信息,确定各标签标识下的访问请求的资源使用情况,从而结合集群服务的资源情况,为各标签标识分配可用资源,设置各标签标识对应的初始限流值。Obtain the resource usage information of historical access requests. Different tag identifiers require different resource types. Tag identifiers that require the same resource type can also require different resource amounts for access requests. Based on the resource usage information of historical access requests, determine the resource usage of access requests under each label identification, and then allocate available resources to each label identification based on the resource situation of the cluster service, and set the initial current limit value corresponding to each label identification.

在一个实施例中,不同的标签标识对应的初始限流值不同,标签标识对应的初始限流值可以是基于预先设计的标签资源表确定的,在预先设计的标签资源表中,每个标签标识对应有初始限流值,该初始限流值是基于历史访问请求中各标签标识下的访问请求的资源使用情况确定的。具体地,每一个标签标识根据其对资源的使用情况,设定一个初始预置QPS,Ti是标签标识为i的静态初始值,也即标签标识i的初始限流值。后端服务实际的QPS为Ai(Ai≥Ti)。初始预置QPS初始值在设置的时候可以进行压测评估,也可以建立模型通过遗传算法进行参数调优。In one embodiment, different tag identifiers correspond to different initial current limit values. The initial current limit value corresponding to the tag identifier can be determined based on a pre-designed tag resource table. In the pre-designed tag resource table, each tag The identifier corresponds to an initial current limit value, which is determined based on the resource usage of access requests under each tag identifier in historical access requests. Specifically, each tag identifier sets an initial preset QPS according to its usage of resources. Ti is the static initial value of the tag identifier i, that is, the initial current limit value of the tag identifier i. The actual QPS of the backend service is A i (A i ≥ T i ). The initial preset QPS initial value can be used for stress test evaluation when setting, or a model can be established for parameter tuning through genetic algorithms.

优选地,获取的超过标签标识对应的初始限流值的目标请求,是基于对标签标识的标签分类,获取每一标签分类下超过初始限流值的目标请求。步骤200中,确定访问请求的请求数量超过标签标识对应的初始限流值的目标请求,具体还可以包括:Preferably, the obtained target requests that exceed the initial current limit value corresponding to the tag identifier are based on the label classification of the tag identifier, and obtain the target requests that exceed the initial current limit value under each label classification. In step 200, determining the target request whose number of access requests exceeds the initial current limit value corresponding to the tag identification may also include:

步骤201,基于所述标签标识对所述访问请求进行分类汇总,将所述标签标识相同的访问请求分类汇总到同一标签分类下;Step 201: Classify and summarize the access requests based on the label identification, and classify and summarize the access requests with the same label identification under the same label classification;

步骤202,根据分类汇总结果,确定目标标签分类下的访问请求的请求数量;所述目标标签分类为所述标签标识对应的各标签分类中的任意一个;Step 202: Determine the number of access requests under the target label classification according to the classification and summary results; the target label classification is any one of the label classifications corresponding to the label identification;

步骤203,若所述请求数量超过所述目标标签分类下的标签标识对应的初始限流值,获取所述目标标签分类下超过所述初始限流值的目标请求。Step 203: If the number of requests exceeds the initial current limit value corresponding to the tag identifier under the target tag category, obtain the target requests under the target tag category that exceed the initial current limit value.

在确定访问请求的请求数量超过标签标识对应的初始限流值的目标请求时,首先基于标签标识对访问请求进行分类汇总,将标签标识相同的访问请求分类汇总到同一标签分类下,标签分类与标签标识具有对应关系,在不同的限流控制维度下,同一标签标识对应的标签分类可能不同,但在特定的限流控制维度下,标签分类与标签标识具有一一对应的关系。When determining the target request whose number of access requests exceeds the initial current limit value corresponding to the tag ID, first classify and summarize the access requests based on the tag ID, and classify and summarize the access requests with the same tag ID under the same tag category. The tag classification is the same as the tag ID. Tag identification has a corresponding relationship. Under different current limiting control dimensions, the label classification corresponding to the same label identification may be different. However, under a specific current limiting control dimension, the label classification and label identification have a one-to-one correspondence.

根据对访问请求的分类汇总结果,确定目标标签分类下的访问请求的请求数量,该目标标签分类是标签标识对应的各标签分类中的任意一个。也即,根据对访问请求的分类汇总结果,确定各标签分类下的请求数量,即具有相同标签标识的访问请求的请求数量,若同一标签标识下的访问请求的请求数量超过该标签标识对应的初始限流值,则获取该目标标签分类下的超过初始限流值的目标请求。Based on the classification and summary results of the access requests, the number of access requests under the target label classification is determined, and the target label classification is any one of the label classifications corresponding to the label identification. That is, based on the classification and summary results of access requests, determine the number of requests under each label classification, that is, the number of access requests with the same label identification. If the number of access requests under the same label identification exceeds the number corresponding to the label identification, Initial current limit value, then obtain the target requests under the target label category that exceed the initial current limit value.

在一个实施例中,参照图4,图4为本申请实施例提供的标签分类方式示意图,基于图4,微服务集群中的各业务系统作为调用系统,向服务器发起访问请求,调用相应的服务,调用系统的访问请求经过负载均衡器F5转发至服务器进行响应。其中,F5作为负载均衡器,用于将流量分配到多个服务器上以提高系统的可用性。对于各调用系统的访问请求,根据访问请求的标签标识进行分类汇总,对各调用系统的访问请求的标签分类方式如图5所示。In one embodiment, refer to Figure 4, which is a schematic diagram of the label classification method provided by the embodiment of the present application. Based on Figure 4, each business system in the microservice cluster serves as a calling system, initiates an access request to the server, and calls the corresponding service , the access request calling the system is forwarded to the server through the load balancer F5 for response. Among them, F5 acts as a load balancer to distribute traffic to multiple servers to improve system availability. The access requests of each calling system are classified and summarized according to the label identification of the access requests. The label classification method of the access requests of each calling system is shown in Figure 5.

基于图4和图5所示的标签分类方式,若系统A的请求接口的标签标识包含{Q1,…,A,…,Qn},系统B的请求接口的标签标识为{B1,…A,…,Bn},系统A和系统B的请求接口中包含相同的标签标识集合{A},也包含不同的标签集合。基于访问请求消息体中的标签分类方式,使限流的控制颗粒度更精确和灵活。Based on the label classification methods shown in Figures 4 and 5, if the label identification of the request interface of system A contains {Q 1 ,…,A,…,Q n }, the label identification of the request interface of system B is {B 1 , …A,…,B n }, the request interfaces of system A and system B contain the same label identification set {A}, but also contain different label sets. Based on the label classification method in the access request message body, the control granularity of current limiting is more precise and flexible.

进一步地,如图4所示,调用的n个系统的标签标识集合为A{A1,A2,...,An},每个标签对应集合A的一个子集U{ui,...,uj}。比如,调用系统A的标签标识和调用系统B的标签均为serviceIDab,调用系统C的标签为serviceIDc。基于调用系统的分类方法可以使限流的颗粒度在系统层面更精确和灵活。Further, as shown in Figure 4, the label identification set of the n systems called is A{A 1 ,A 2 ,...,A n }, and each label corresponds to a subset U{u i of the set A, ..., u j }. For example, the label identification of calling system A and the label of calling system B are both serviceIDab, and the label of calling system C is serviceIDc. The classification method based on the call system can make the granularity of current limiting more precise and flexible at the system level.

优选地,访问请求的标签标识还用于指示访问请求所需的资源类型,该资源类型包括处理器资源、内存资源和磁盘资源,可知地,不同的访问请求对应不同的服务,所需的资源类型不同,因此,不同标签标识下的访问请求存在不同的资源类型偏好。进一步地,在对同一标签标识下的目标请求进行限流时,基于滑动窗口算法,对目标请求进行动态的限流控制,步骤300中,根据第一目标服务器的资源使用信息对目标请求进行限流,具体包括:Preferably, the tag identification of the access request is also used to indicate the resource type required for the access request. The resource type includes processor resources, memory resources and disk resources. It can be seen that different access requests correspond to different services and the required resources The types are different. Therefore, access requests under different label identifications have different resource type preferences. Further, when limiting the target request under the same tag identification, the target request is dynamically limited based on the sliding window algorithm. In step 300, the target request is limited according to the resource usage information of the first target server. Streams, specifically including:

步骤301,根据所述标签标识确定所述目标请求所需的目标资源类型;Step 301: Determine the target resource type required by the target request according to the tag identification;

步骤302,根据所述资源使用信息,确定所述第一目标服务器的剩余资源;Step 302: Determine remaining resources of the first target server based on the resource usage information;

步骤303,基于所述目标资源类型和所述剩余资源,确定所述第一目标服务器是否存在所述目标请求对应的可用资源;Step 303: Based on the target resource type and the remaining resources, determine whether the first target server has available resources corresponding to the target request;

步骤304,若不存在,获取基于所述目标资源类型,查询所述后端服务中是否第二目标服务器;所述第二目标服务器是所述后端服务中除所述第一目标服务器中之外,存在所述目标请求对应的可用资源的服务器;Step 304: If it does not exist, obtain the second target server in the back-end service based on the target resource type; the second target server is one of the back-end services except the first target server. In addition, there is a server with available resources corresponding to the target request;

步骤305,若所述后端服务中存在第二目标服务器,根据所述第二目标服务器的可用资源对所述目标请求进行限流。Step 305: If there is a second target server in the backend service, limit the flow of the target request according to the available resources of the second target server.

根据目标请求的标签标识确定目标请求所需的目标资源类型,根据第一目标服务器的资源使用信息,确定第一目标服务器的剩余资源,基于目标请求所需的目标资源类型以及第一目标服务器的剩余资源,确定第一目标服务器是否存在目标请求可用的资源,若存在,则基于第一目标服务器对目标请求进行限流响应;若第一目标服务器不存在目标请求可用的资源,或者,第一目标服务器的剩余资源小于目标请求所需的资源,则查询后端服务中是否存在第二目标服务器,若存在第二目标服务器,则根据第二目标服务器的可用资源对目标请求进行限流响应。Determine the target resource type required by the target request according to the tag identification of the target request, determine the remaining resources of the first target server based on the resource usage information of the first target server, and determine the target resource type required by the target request and the first target server's remaining resources. For remaining resources, determine whether the first target server has resources available for the target request. If there are resources available for the target request, perform a current limiting response to the target request based on the first target server; if the first target server does not have resources available for the target request, or the first If the remaining resources of the target server are less than the resources required by the target request, the backend service is queried to see if there is a second target server. If a second target server exists, a current-limiting response to the target request is performed based on the available resources of the second target server.

进一步地,第二目标服务器是后端服务中除第一目标服务器之外的,存在目标请求对应的可用资源的服务器,可选地,第二目标服务器是后端服务中,存在目标请求的可用资源最多的服务器。Further, the second target server is a server in the back-end service other than the first target server that has available resources corresponding to the target request. Optionally, the second target server is a server in the back-end service that has available resources corresponding to the target request. The server with the most resources.

优选地,访问请求的标签标识还用于指示访问请求的时间戳信息,步骤305中,根据第二目标服务器的可用资源对目标请求进行限流,还可以包括:Preferably, the tag identification of the access request is also used to indicate the timestamp information of the access request. In step 305, limiting the target request according to the available resources of the second target server may also include:

步骤315,获取所述目标请求在所述标签标识下的目标时间戳;Step 315: Obtain the target timestamp of the target request under the tag identification;

步骤325,根据所述第二目标服务器的可用资源确定窗口尺寸;Step 325, determine the window size according to the available resources of the second target server;

步骤335,按照所述目标时间戳对应的先后顺序对所述目标请求进行排序;Step 335: Sort the target requests according to the order corresponding to the target timestamp;

步骤345,根据对所述目标请求的排序顺序,基于所述窗口尺寸采用滑动窗口算法对所述目标请求进行响应,以对所述目标请求进行限流。Step 345: According to the sorting order of the target requests, a sliding window algorithm is used to respond to the target requests based on the window size to limit the flow of the target requests.

根据第二目标服务器的可用资源对目标请求进行限流响应时,首先获取目标请求的时间戳信息,即目标时间戳,该时间戳是在目标请求进入时生成的。根据第二目标服务器的可用资源确定窗口尺寸,按照目标请求的时间戳对应的时间先后顺序对目标请求进行排序,根据排序顺序,基于窗口尺寸采用滑动窗口算对目标请求进行响应,以实现对目标请求的限流。When performing a current-limiting response to a target request based on the available resources of the second target server, first obtain the timestamp information of the target request, that is, the target timestamp, which is generated when the target request enters. The window size is determined according to the available resources of the second target server, and the target requests are sorted according to the time sequence corresponding to the timestamp of the target request. According to the sorting order, a sliding window algorithm is used to respond to the target request based on the window size to achieve the goal. Requested current limit.

在对目标请求进行限流响应时,采用滑动窗口算法,每次对窗口内的请求进行响应,窗口尺寸根据第二目标服务器的可用资源确定,确保响应目标请求所用资源不超过第二目标服务器的负荷。When performing a current-limiting response to a target request, a sliding window algorithm is used to respond to a request within the window each time. The window size is determined based on the available resources of the second target server to ensure that the resources used to respond to the target request do not exceed the resources of the second target server. load.

进一步地,在确定后端服务中是否存在第二目标服务器时,根据下列公式1-2的方式,计算出后端服务中除第一目标服务器之外的各服务器的剩余资源指标,根据计算出的指标值,确定是否存在满足条件的第二目标服务器,其中,公式1-2如下所示:Further, when determining whether there is a second target server in the back-end service, the remaining resource indicators of each server in the back-end service except the first target server are calculated according to the following formula 1-2. According to the calculated The indicator value is used to determine whether there is a second target server that meets the conditions, where Formula 1-2 is as follows:

R=αC+βM+δD;(2)R=αC+βM+δD; (2)

其中,C为处理器使用率、M为内存使用率、D为磁盘使用率、R为资源富裕度,Ei为所述后端服务中除所述第一目标服务器之外的第i各服务器的剩余资源指标值、busness为所述目资源类型对应的资源类型偏好因子、failcount为历史预设时长内的请求失败数量;ε、 α、β和δ均为预设的权重参数。Among them, C is the processor usage, M is the memory usage, D is the disk usage, R is the resource abundance, and E i is the i-th server in the back-end service except the first target server. The remaining resource indicator value, busness is the resource type preference factor corresponding to the target resource type, and fail count is the number of failed requests within the historical preset time period; ε, α, β and δ are all preset weight parameters.

当目标请求为某一标签标识下的访问请求时,由于为每个标签标识分配了初始限流值,则对应地为每个标签标识分配了不同类型的资源,在此情况下,公式1-2中,C为该标签标识下的处理器使用率,M为该标签标识下的内存的使用率,D为该标签标识下的磁盘使用率,busness为该标签标识下的访问请求的所需的资源类型对应的资源类型偏好因子。When the target request is an access request under a certain tag ID, since each tag ID is assigned an initial current limit value, different types of resources are correspondingly allocated to each tag ID. In this case, Formula 1- In 2, C is the processor usage under the label, M is the memory usage under the label, D is the disk usage under the label, and busness is the required access request under the label. The resource type preference factor corresponding to the resource type.

为了防止集群服务因某个节点损坏导致请求处理失败,但是资源仍上报的情况,剩余情况指标E引入了历史预设时长的请求失败数量,请求失败数越多,后续该服务器被调用的概率就越低。不同的标签标识的请求所需的资源偏向不同,比如有些访问请求需要消耗CPU处理器资源,有些访问请求需要消耗内存资源,资源剩余指标E为不同标签标识引入了请求资源偏好因素busness。后端服务除第一目标服务器之外的各服务器中,第i个服务器的资源剩余情况的总体因素为Ei,选取Ei值最大的服务器作为第二目标服务器,对目标请求进行限流响应。In order to prevent the cluster service from failing to process requests due to damage to a certain node, but resources are still reported, the remaining situation indicator E introduces the number of failed requests for a preset time period in history. The greater the number of failed requests, the higher the probability that the server will be called later. The lower. Requests identified by different tags require different resource preferences. For example, some access requests consume CPU processor resources, and some access requests consume memory resources. The resource remaining indicator E introduces the request resource preference factor busness for different tag identifiers. Among the servers in the back-end service except the first target server, the overall factor of the remaining resources of the i-th server is E i . The server with the largest E i value is selected as the second target server and performs a current-limiting response to the target request. .

在一个实施例中,对访问请求的动态限流基于预设的动态限流控制器实现,该动态限流控制器包括拦截器、限流控制器和动态调节模块,基于该动态限流控制器的访问请求限流过程如图6所示。如图6所示,动态限流控制器中还存储有后端服务的资源信息,该资源信息可以是后端服务中各服务器主动上报的,也可以是动态限流控制器主动获取的,在此不作具体限定。In one embodiment, dynamic current limiting of access requests is implemented based on a preset dynamic current limiting controller. The dynamic current limiting controller includes an interceptor, a current limiting controller and a dynamic adjustment module. Based on the dynamic current limiting controller The access request current limiting process is shown in Figure 6. As shown in Figure 6, the dynamic current limiting controller also stores resource information of the backend service. This resource information can be actively reported by each server in the backend service, or can be actively obtained by the dynamic current limiting controller. This is not specifically limited.

基于图6所示的动态限流过程,对于调用系统A、调用系统B以及调用系统C等业务系统的访问请求,先通过负载均衡器F5进入拦截器,之后请求被转发到限流控制器,拦截器用于接收来自限流控制器的指令,拦截访问请求并转发至限流控制器中。限流控制器对于每一个标签标识下的请求进行初始限流值的流量控制,超出初始限流值的请求进入动态调节模块进行动态限流。Based on the dynamic current limiting process shown in Figure 6, access requests from business systems such as calling system A, calling system B, and calling system C first enter the interceptor through load balancer F5, and then the request is forwarded to the current limiting controller. The interceptor is used to receive instructions from the current limiting controller, intercept access requests and forward them to the current limiting controller. The current limit controller controls the flow of the initial current limit value for each request identified by the tag. Requests that exceed the initial current limit value enter the dynamic adjustment module for dynamic current limit.

进一步地,动态限流模块中设有资源监测表,该资源监测表是基于后端服务的资源信息生成的,基于该资源监测表将集群中的节点的资源剩余情况映射到资源剩余情况指标,得到各节点服务器的资源剩余情况指标值。若请求访问的服务器存在可用的剩余资源,就使用请求访问的服务器资源进行限流响应,若请求访问的服务器不存在可用资源,就使用资源剩余最多的服务器的资源进行动态限流响应。Further, the dynamic current limiting module is provided with a resource monitoring table. The resource monitoring table is generated based on the resource information of the back-end service. Based on the resource monitoring table, the resource remaining status of the nodes in the cluster is mapped to the resource remaining status indicator. Obtain the resource remaining status indicator value of each node server. If the requested server has available remaining resources, the requested server resources will be used to perform a current limiting response. If the requested server does not have available resources, the resources of the server with the most remaining resources will be used to perform a dynamic current limiting response.

在动态限流响应时,集群记录每个标签标识serviceID的时间戳,并采用滑动窗口算法进行限流控制。集群中设置唯一标识为包含标签关键字key的set序列集合。通过设置集群的key存活时间,基于滑动窗口算法,将请求的key的对应值设置为请求进入时刻的毫秒级时间戳加自增key的count数值。对于超出初始限流值QPS的请求,统一发送至动态调整模块进行动态限流控制,对于静态的指标:一旦设定就无法改变,例如,serviceID为001时接口调用的情况下的QPS是3000,但是考虑到serviceID为002时的资源使用,实际设置的初始限流值要远小于3000,从而为serviceID为002的请求预留资源。但在serviceID为001的请求超过其设定的初始限流值,而serviceID为002的请求数量较少时,为serviceID为002的请求预留的资源就会造成浪费,从而导致资源利用率降低。在本实施例中,基于动态调整模块,对于超出初始限流值的请求流转到动态调整模块进行二次判断,可以提高资源利用。When responding to dynamic current limiting, the cluster records the timestamp of each tag identifying serviceID, and uses a sliding window algorithm for current limiting control. Set the unique identifier in the cluster as a set sequence collection containing the label keyword key. By setting the key survival time of the cluster and based on the sliding window algorithm, the corresponding value of the requested key is set to the millisecond timestamp of the request entry time plus the count value of the auto-incremented key. For requests that exceed the initial current limit value QPS, they are uniformly sent to the dynamic adjustment module for dynamic current limit control. For static indicators: once set, they cannot be changed. For example, when the serviceID is 001, the QPS when the interface is called is 3000. However, considering the resource usage when serviceID is 002, the actual initial current limit value set is much less than 3000, so that resources are reserved for requests with serviceID 002. However, when the request with serviceID 001 exceeds its set initial current limit value and the number of requests with serviceID 002 is small, the resources reserved for requests with serviceID 002 will be wasted, resulting in reduced resource utilization. In this embodiment, based on the dynamic adjustment module, requests that exceed the initial current limit value are transferred to the dynamic adjustment module for secondary judgment, which can improve resource utilization.

具体地,动态调节模块中设有资源监测表,每个集群中的节点拥有的资源剩余情况映射到资源剩余情况指标,通过设计的资源剩余指标,可以判断请求访问的服务器是否存在可直接使用的资源,或者,选择存在最多可用资源的服务器,提高对可用资源的利用率。Specifically, the dynamic adjustment module is equipped with a resource monitoring table. The remaining resources owned by the nodes in each cluster are mapped to the resource remaining indicators. Through the designed resource remaining indicators, it can be judged whether the server requested for access has any resources that can be used directly. resources, or select the server with the most available resources to increase utilization of available resources.

参照图7,图7为应用于短信平台下的访问请求限流方法的流程示意图,针对微服务框架下的集群中,如短信平台等存在多系统调用的场景,采用设计的标签分类方法和基于标签的动态限流控制器,结合滑动窗口算法,实现更灵活更高效的实时限流。在图7中,引入标签控制位,按照需求对系统或者访问请求的消息体,使用基于标签的颗粒度控制方法对系统或访问请求的消息体进行标签定义。按照标签的使用情况,对于限流控制器中的标签限流表,按标签对初始限流值QPS进行初始值的设定。初始限流值QPS在设置的时候可以进行压测评估,也可以建立模型通过遗传算法进行参数调优。Referring to Figure 7, Figure 7 is a flow chart of the access request current limiting method applied to the SMS platform. In view of the scenario where multiple system calls exist in the cluster under the microservice framework, such as the SMS platform, the designed label classification method and based on The label's dynamic current limiting controller, combined with the sliding window algorithm, achieves more flexible and efficient real-time current limiting. In Figure 7, the label control bit is introduced, and the message body of the system or access request is defined according to the requirements, and the label-based granular control method is used to define labels for the message body of the system or access request. According to the usage of the tag, for the tag current limit table in the current limit controller, set the initial value of the initial current limit value QPS according to the tag. When setting the initial current limit value QPS, pressure testing and evaluation can be performed, and a model can also be established for parameter tuning through genetic algorithms.

进一步地,访问请求的消息体携带标签到达拦截器,拦截访问请求并转发至限流控制器。访问请求的消息体到达限流控制器中,限流控制器根据标签资源表对访问请求的消息体进行限流。限流使用集群记录的每个标签下的时间戳,并采用滑动窗口算法进行限流控制,如果同一个标签的实际请求数量在设定的初始限流值内,则直接正常访问接口响应请求,否则,则将超过初始限流值的访问请求的消息体转发至动态调节模块,使用基于标签的动态限流进行处理。具体地,查询资源监测表,判断请求调用的服务器是否存在可用的剩余资源,若存在则正常访问,若不存在,则继续查询资源监测表,判断最大剩余资源的服务器是否存在可用的剩余资源可以执行请求,如果存在则正常访问,若仍不存在可用的剩余资源,则对访问请求进行降级处理,降低请求的优先级以等待执行。Further, the message body of the access request carries the label and reaches the interceptor, which intercepts the access request and forwards it to the current limiting controller. The message body of the access request reaches the current limiting controller, and the current limiting controller limits the current flow of the message body of the access request according to the tag resource table. Current limiting uses the timestamp under each label recorded by the cluster, and uses a sliding window algorithm for current limiting control. If the actual number of requests for the same label is within the set initial current limiting value, the normal access interface will respond to the request directly. Otherwise, the message body of the access request that exceeds the initial current limit value will be forwarded to the dynamic adjustment module for processing using label-based dynamic current limit. Specifically, the resource monitoring table is queried to determine whether the server requested to be called has available remaining resources. If it exists, access is normal. If not, the resource monitoring table is continued to be queried to determine whether the server with the largest remaining resources has available remaining resources. Execute the request, and if it exists, access it normally. If there are still no remaining resources available, downgrade the access request and lower the priority of the request to wait for execution.

在本实施例中,通过引入标签的概念,并根据集群服务中调用系统量大,请求量大的系统调用特点,设计了相应的标签分类方法,使限流更加的精确和灵活。同时,采用基于标签的动态限流控制器,通过遗传算法或压力测试等手段对同一类标签的初始限流值进行设定,流量进入后通过滑动窗口算法对流量进行动态限流控制,对于同一类标签超出初始限流值的流量,通过动态调节模块进行二次判断,动态调节模块中设有对剩余资源指标进行监测的资源监测表,可以根据请求访问的服务器及其他服务器的资源剩余情况,对超过初始限流值的流量进行动态响应,从而提高对剩余资源的利用率。In this embodiment, by introducing the concept of tags and based on the characteristics of large system calls and large requests in cluster services, a corresponding tag classification method is designed to make the current limit more accurate and flexible. At the same time, a tag-based dynamic current limiting controller is used to set the initial current limiting value of the same type of tags through genetic algorithms or pressure tests. After the traffic enters, the sliding window algorithm is used to dynamically limit the flow. For the same The traffic whose class tag exceeds the initial current limit value will be judged twice through the dynamic adjustment module. The dynamic adjustment module is equipped with a resource monitoring table to monitor the remaining resource indicators. It can be based on the remaining resources of the requested server and other servers. Dynamically respond to traffic exceeding the initial throttling value, thereby improving the utilization of remaining resources.

进一步地,本申请实施例提供的访问请求限流方法,采用基于标签的动态限流控制器,不仅避免了静态限流方式导致的资源利用率低的问题,又避免了完全动态配置导致的请求响应速度慢致使用户体验差的问题,在保证用户体验的同时提升了资源的利用率。Furthermore, the access request current limiting method provided by the embodiment of this application adopts a tag-based dynamic current limiting controller, which not only avoids the problem of low resource utilization caused by the static current limiting method, but also avoids the request caused by completely dynamic configuration. The problem of poor user experience caused by slow response speed improves resource utilization while ensuring user experience.

下面对本申请实施例提供的访问请求限流装置进行描述,下文描述的访问请求限流装置与上文描述的访问请求限流方法可相互对应参照。The access request current limiting device provided by the embodiment of the present application is described below. The access request current limiting device described below and the access request current limiting method described above may be mutually referenced.

参照图8,本申请实施例提供的访问请求限流装置,包括:Referring to Figure 8, the access request current limiting device provided by the embodiment of the present application includes:

请求拦截模块10,用于获取后端服务的访问请求的标签标识;所述标签标识用于指示所述访问请求对应的初始限流值,以及所述访问请求访问的第一目标服务器;The request interception module 10 is used to obtain the tag identification of the access request of the back-end service; the tag identification is used to indicate the initial current limit value corresponding to the access request, and the first target server accessed by the access request;

第一限流模块20,用于确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求;The first current limiting module 20 is used to determine the target request whose number of requests for the access request exceeds the initial current limiting value corresponding to the tag identification;

第二限流模块30,用于查询所述第一目标服务器的资源使用信息,根据所述资源使用信息对所述目标请求进行限流;所述资源使用信息包括处理器资源使用率、磁盘使用率和内存使用率。The second current limiting module 30 is used to query the resource usage information of the first target server, and limit the current flow of the target request according to the resource usage information; the resource usage information includes processor resource usage, disk usage rate and memory usage.

在一个实施例中,所述标签标识还用于指示所述访问请求所需的资源类型,所述资源类型包括处理器资源、内存资源和磁盘资源;所述第二限流模块30,还用于:In one embodiment, the tag identification is also used to indicate the resource type required for the access request, and the resource type includes processor resources, memory resources and disk resources; the second current limiting module 30 also uses At:

根据所述标签标识确定所述目标请求所需的目标资源类型;Determine the target resource type required by the target request according to the tag identification;

根据所述资源使用信息,确定所述第一目标服务器的剩余资源;Determine remaining resources of the first target server according to the resource usage information;

基于所述目标资源类型和所述剩余资源,确定所述第一目标服务器是否存在所述目标请求对应的可用资源;Based on the target resource type and the remaining resources, determine whether the first target server has available resources corresponding to the target request;

若不存在,获取基于所述目标资源类型,查询所述后端服务中是否第二目标服务器;所述第二目标服务器是所述后端服务中除所述第一目标服务器中之外,存在所述目标请求对应的可用资源的服务器;If it does not exist, obtain the target resource type and query whether there is a second target server in the back-end service; the second target server is the one that exists in the back-end service in addition to the first target server. The server of available resources corresponding to the target request;

若所述后端服务中存在第二目标服务器,根据所述第二目标服务器的可用资源对所述目标请求进行限流。If there is a second target server in the backend service, the target request is flow-limited according to the available resources of the second target server.

在一个实施例中,所述标签标识还用于指示所述访问请求的时间戳信息;所述第二限流模块30,还用于:In one embodiment, the tag identification is also used to indicate the timestamp information of the access request; the second current limiting module 30 is also used to:

获取所述目标请求在所述标签标识下的目标时间戳;Obtain the target timestamp of the target request under the tag identification;

根据所述第二目标服务器的可用资源确定窗口尺寸;Determine the window size based on the available resources of the second target server;

按照所述目标时间戳对应的先后顺序对所述目标请求进行排序;Sort the target requests according to the order corresponding to the target timestamp;

根据对所述目标请求的排序顺序,基于所述窗口尺寸采用滑动窗口算法对所述目标请求进行响应,以对所述目标请求进行限流。According to the sorting order of the target requests, a sliding window algorithm is used to respond to the target requests based on the window size to limit the flow of the target requests.

在一个实施例中,根据下列公式查询所述后端服务中的第二目标服务器是否存在所述目标请求对应的可用资源:In one embodiment, query whether the second target server in the backend service has available resources corresponding to the target request according to the following formula:

R=αC+βM+δD;R=αC+βM+δD;

其中,C为处理器使用率、M为内存使用率、D为磁盘使用率、R为资源富裕度,Ei为所述后端服务中除所述第一目标服务器之外的第i各服务器的剩余资源指标值、busness为所述目资源类型对应的资源类型偏好因子、failcount为历史预设时长内的请求失败数量;ε、 α、β和δ均为预设的权重参数。Among them, C is the processor usage, M is the memory usage, D is the disk usage, R is the resource abundance, and E i is the i-th server in the back-end service except the first target server. The remaining resource indicator value, busness is the resource type preference factor corresponding to the target resource type, and fail count is the number of failed requests within the historical preset time period; ε, α, β and δ are all preset weight parameters.

在一个实施例中,所述第一限流模块20,还用于:In one embodiment, the first current limiting module 20 is also used to:

基于所述标签标识对所述访问请求进行分类汇总,将所述标签标识相同的访问请求分类汇总到同一标签分类下;Classify and summarize the access requests based on the label identification, and classify and summarize the access requests with the same label identification under the same label classification;

根据分类汇总结果,确定目标标签分类下的访问请求的请求数量;所述目标标签分类为所述标签标识对应的各标签分类中的任意一个;According to the classification summary results, determine the number of access requests under the target label classification; the target label classification is any one of the label classifications corresponding to the label identification;

若所述请求数量超过所述目标标签分类下的标签标识对应的初始限流值,获取所述目标标签分类下超过所述初始限流值的目标请求。If the number of requests exceeds the initial current limit value corresponding to the tag identifier under the target tag category, obtain the target requests under the target tag category that exceed the initial current limit value.

在一个实施例中,所述访问请求限流装置还包括标签生成模块,用于:In one embodiment, the access request current limiting device further includes a label generation module for:

获取后端服务的访问请求的请求信息;所述请求信息包括所述访问请求访问的第一目标服务器、所述访问请求所需的资源类型和所述访问请求的时间戳信息;Obtain the request information of the access request of the back-end service; the request information includes the first target server accessed by the access request, the resource type required by the access request, and the timestamp information of the access request;

根据所述请求信息生成所述访问请求的标签标识。Generate a label identification of the access request according to the request information.

在一个实施例中,所述访问请求限流装置还包括初始值生成模块,用于:In one embodiment, the access request current limiting device further includes an initial value generation module for:

获取历史访问请求的资源使用信息;Obtain resource usage information of historical access requests;

根据所述资源使用信息确定所述历史访问请求的标签标识对应的初始限流值。The initial current limit value corresponding to the tag identifier of the historical access request is determined according to the resource usage information.

图9示例了一种电子设备的实体结构示意图,如图9所示,该电子设备可以包括:处理器(processor)910、通信接口(Communication Interface)920、存储器(memory)930和通信总线940,其中,处理器910,通信接口920,存储器930通过通信总线940完成相互间的通信。处理器910可以调用存储器930中的计算机程序,以执行访问请求限流方法的步骤,例如包括:Figure 9 illustrates a schematic diagram of the physical structure of an electronic device. As shown in Figure 9, the electronic device may include: a processor (processor) 910, a communication interface (Communication Interface) 920, a memory (memory) 930 and a communication bus 940. Among them, the processor 910, the communication interface 920, and the memory 930 complete communication with each other through the communication bus 940. The processor 910 can call the computer program in the memory 930 to perform the steps of the access request current limiting method, for example, including:

获取后端服务的访问请求的标签标识;所述标签标识用于指示所述访问请求对应的初始限流值,以及所述访问请求访问的第一目标服务器;Obtain the label identification of the access request of the back-end service; the label identification is used to indicate the initial current limit value corresponding to the access request, and the first target server accessed by the access request;

确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求;Determine the target request whose number of requests for the access request exceeds the initial current limit value corresponding to the tag identification;

查询所述第一目标服务器的资源使用信息,根据所述资源使用信息对所述目标请求进行限流;所述资源使用信息包括处理器资源使用率、磁盘使用率和内存使用率。Query the resource usage information of the first target server, and limit the flow of the target request according to the resource usage information; the resource usage information includes processor resource usage, disk usage, and memory usage.

此外,上述的存储器930中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。In addition, the above-mentioned logical instructions in the memory 930 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code. .

另一方面,本申请实施例还提供一种计算机程序产品,所述计算机程序产品包括计算机程序,所述计算机程序可存储在非暂态计算机可读存储介质上,所述计算机程序被处理器执行时,计算机能够执行上述各实施例所提供的访问请求限流方法的步骤,例如包括:On the other hand, embodiments of the present application also provide a computer program product. The computer program product includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. The computer program is executed by a processor. When , the computer can perform the steps of the access request current limiting method provided by the above embodiments, including, for example:

获取后端服务的访问请求的标签标识;所述标签标识用于指示所述访问请求对应的初始限流值,以及所述访问请求访问的第一目标服务器;Obtain the label identification of the access request of the back-end service; the label identification is used to indicate the initial current limit value corresponding to the access request, and the first target server accessed by the access request;

确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求;Determine the target request whose number of requests for the access request exceeds the initial current limit value corresponding to the tag identification;

查询所述第一目标服务器的资源使用信息,根据所述资源使用信息对所述目标请求进行限流;所述资源使用信息包括处理器资源使用率、磁盘使用率和内存使用率。Query the resource usage information of the first target server, and limit the flow of the target request according to the resource usage information; the resource usage information includes processor resource usage, disk usage, and memory usage.

另一方面,本申请实施例还提供一种处理器可读存储介质,所述处理器可读存储介质存储有计算机程序,所述计算机程序用于使处理器执行上述各实施例提供的访问请求限流方法的步骤,例如包括:On the other hand, embodiments of the present application also provide a processor-readable storage medium. The processor-readable storage medium stores a computer program. The computer program is used to cause the processor to execute the access request provided by the above embodiments. The steps of the current limiting method include, for example:

获取后端服务的访问请求的标签标识;所述标签标识用于指示所述访问请求对应的初始限流值,以及所述访问请求访问的第一目标服务器;Obtain the label identification of the access request of the back-end service; the label identification is used to indicate the initial current limit value corresponding to the access request, and the first target server accessed by the access request;

确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求;Determine the target request whose number of requests for the access request exceeds the initial current limit value corresponding to the tag identification;

查询所述第一目标服务器的资源使用信息,根据所述资源使用信息对所述目标请求进行限流;所述资源使用信息包括处理器资源使用率、磁盘使用率和内存使用率。Query the resource usage information of the first target server, and limit the flow of the target request according to the resource usage information; the resource usage information includes processor resource usage, disk usage, and memory usage.

所述处理器可读存储介质可以是处理器能够存取的任何可用介质或数据存储设备,包括但不限于磁性存储器(例如软盘、硬盘、磁带、磁光盘(MO)等)、光学存储器(例如CD、DVD、BD、HVD等)、以及半导体存储器(例如ROM、EPROM、EEPROM、非易失性存储器(NANDFLASH)、固态硬盘(SSD))等。The processor-readable storage medium may be any available media or data storage device that the processor can access, including but not limited to magnetic storage (such as floppy disks, hard disks, tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor memories (such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid state drive (SSD)), etc.

以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are only illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in One location, or it can be distributed across multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Persons of ordinary skill in the art can understand and implement the method without any creative effort.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the part of the above technical solution that essentially contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., including a number of instructions to cause a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or certain parts of the embodiments.

最后应说明的是:以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application, but not to limit it; 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 be Modifications are made to the technical solutions described in the foregoing embodiments, or equivalent substitutions are made to some of the technical features; however, these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions in the embodiments of the present application.

Claims (10)

1.一种访问请求限流方法,其特征在于,包括:1. An access request current limiting method, characterized by including: 获取后端服务的访问请求的标签标识;所述标签标识用于指示所述访问请求对应的初始限流值,以及所述访问请求访问的第一目标服务器;Obtain the label identification of the access request of the back-end service; the label identification is used to indicate the initial current limit value corresponding to the access request, and the first target server accessed by the access request; 确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求;Determine the target request whose number of requests for the access request exceeds the initial current limit value corresponding to the tag identification; 查询所述第一目标服务器的资源使用信息,根据所述资源使用信息对所述目标请求进行限流;所述资源使用信息包括处理器资源使用率、磁盘使用率和内存使用率。Query the resource usage information of the first target server, and limit the flow of the target request according to the resource usage information; the resource usage information includes processor resource usage, disk usage, and memory usage. 2.根据权利要求1所述的访问请求限流方法,其特征在于,所述标签标识还用于指示所述访问请求所需的资源类型,所述资源类型包括处理器资源、内存资源和磁盘资源;所述根据所述资源使用信息对所述目标请求进行限流,包括:2. The access request current limiting method according to claim 1, characterized in that the tag identification is also used to indicate the resource type required for the access request, and the resource type includes processor resources, memory resources and disks. Resources; limiting the target request according to the resource usage information includes: 根据所述标签标识确定所述目标请求所需的目标资源类型;Determine the target resource type required by the target request according to the tag identification; 根据所述资源使用信息,确定所述第一目标服务器的剩余资源;Determine remaining resources of the first target server according to the resource usage information; 基于所述目标资源类型和所述剩余资源,确定所述第一目标服务器是否存在所述目标请求对应的可用资源;Based on the target resource type and the remaining resources, determine whether the first target server has available resources corresponding to the target request; 若不存在,获取基于所述目标资源类型,查询所述后端服务中是否第二目标服务器;所述第二目标服务器是所述后端服务中除所述第一目标服务器中之外,存在所述目标请求对应的可用资源的服务器;If it does not exist, obtain the target resource type and query whether there is a second target server in the back-end service; the second target server is the one that exists in the back-end service in addition to the first target server. The server of available resources corresponding to the target request; 若所述后端服务中存在第二目标服务器,根据所述第二目标服务器的可用资源对所述目标请求进行限流。If there is a second target server in the backend service, the target request is flow-limited according to the available resources of the second target server. 3.根据权利要求2所述的访问请求限流方法,其特征在于,所述标签标识还用于指示所述访问请求的时间戳信息;所述根据所述第二目标服务器的可用资源对所述目标请求进行限流,包括:3. The access request current limiting method according to claim 2, characterized in that the tag identifier is also used to indicate the timestamp information of the access request; the available resources of the second target server are Limit the flow of the above target requests, including: 获取所述目标请求在所述标签标识下的目标时间戳;Obtain the target timestamp of the target request under the tag identification; 根据所述第二目标服务器的可用资源确定窗口尺寸;Determine the window size based on the available resources of the second target server; 按照所述目标时间戳对应的先后顺序对所述目标请求进行排序;Sort the target requests according to the order corresponding to the target timestamp; 根据对所述目标请求的排序顺序,基于所述窗口尺寸采用滑动窗口算法对所述目标请求进行响应,以对所述目标请求进行限流。According to the sorting order of the target requests, a sliding window algorithm is used to respond to the target requests based on the window size to limit the flow of the target requests. 4.根据权利要求2所述的访问请求限流方法,其特征在于,根据下列公式查询所述后端服务中的第二目标服务器是否存在所述目标请求对应的可用资源:4. The access request current limiting method according to claim 2, characterized in that the second target server in the back-end service is queried according to the following formula whether there are available resources corresponding to the target request: R=αC+βM+δD;R=αC+βM+δD; 其中,C为处理器使用率、M为内存使用率、D为磁盘使用率、R为资源富裕度,Ei为所述后端服务中除所述第一目标服务器之外的第i各服务器的剩余资源指标值、busness为所述目资源类型对应的资源类型偏好因子、failcount为历史预设时长内的请求失败数量;ε、 α、β和δ均为预设的权重参数。Among them, C is the processor usage, M is the memory usage, D is the disk usage, R is the resource abundance, and E i is the i-th server in the back-end service except the first target server. The remaining resource indicator value, busness is the resource type preference factor corresponding to the target resource type, and fail count is the number of failed requests within the historical preset time period; ε, α, β and δ are all preset weight parameters. 5.根据权利要求1所述的访问请求限流方法,其特征在于,所述确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求,包括:5. The access request current limiting method according to claim 1, characterized in that determining that the number of requests for the access request exceeds the target request of the initial current limiting value corresponding to the tag identification includes: 基于所述标签标识对所述访问请求进行分类汇总,将所述标签标识相同的访问请求分类汇总到同一标签分类下;Classify and summarize the access requests based on the label identification, and classify and summarize the access requests with the same label identification under the same label classification; 根据分类汇总结果,确定目标标签分类下的访问请求的请求数量;所述目标标签分类为所述标签标识对应的各标签分类中的任意一个;According to the classification summary results, determine the number of access requests under the target label classification; the target label classification is any one of the label classifications corresponding to the label identification; 若所述请求数量超过所述目标标签分类下的标签标识对应的初始限流值,获取所述目标标签分类下超过所述初始限流值的目标请求。If the number of requests exceeds the initial current limit value corresponding to the tag identifier under the target tag category, obtain the target requests under the target tag category that exceed the initial current limit value. 6.根据权利要求1所述的访问请求限流方法,其特征在于,所述获取后端服务的访问请求的标签标识之前,还包括:6. The access request current limiting method according to claim 1, characterized in that before obtaining the tag identification of the access request of the back-end service, it further includes: 获取后端服务的访问请求的请求信息;所述请求信息包括所述访问请求访问的第一目标服务器、所述访问请求所需的资源类型和所述访问请求的时间戳信息;Obtain the request information of the access request of the back-end service; the request information includes the first target server accessed by the access request, the resource type required by the access request, and the timestamp information of the access request; 根据所述请求信息生成所述访问请求的标签标识。Generate a label identification of the access request according to the request information. 7.根据权利要求1所述的访问请求限流方法,其特征在于,所述访问请求限流方法还包括:7. The access request current limiting method according to claim 1, characterized in that the access request current limiting method further includes: 获取历史访问请求的资源使用信息;Obtain resource usage information of historical access requests; 根据所述资源使用信息确定所述历史访问请求的标签标识对应的初始限流值。The initial current limit value corresponding to the tag identifier of the historical access request is determined according to the resource usage information. 8.一种访问请求限流装置,其特征在于,包括:8. An access request current limiting device, characterized by including: 请求拦截模块,用于获取后端服务的访问请求的标签标识;所述标签标识用于指示所述访问请求对应的初始限流值,以及所述访问请求访问的第一目标服务器;A request interception module, used to obtain the tag identification of the access request of the back-end service; the tag identification is used to indicate the initial current limit value corresponding to the access request, and the first target server accessed by the access request; 第一限流模块,用于确定所述访问请求的请求数量超过所述标签标识对应的初始限流值的目标请求;A first current limiting module, configured to determine target requests whose number of access requests exceeds the initial current limiting value corresponding to the tag identification; 第二限流模块,用于查询所述第一目标服务器的资源使用信息,根据所述资源使用信息对所述目标请求进行限流;所述资源使用信息包括处理器资源使用率、磁盘使用率和内存使用率。The second current limiting module is used to query the resource usage information of the first target server and limit the current flow of the target request according to the resource usage information; the resource usage information includes processor resource usage and disk usage. and memory usage. 9.一种电子设备,包括处理器和存储有计算机程序的存储器,其特征在于,所述处理器执行所述计算机程序时实现权利要求1至7任一项所述的访问请求限流方法的步骤。9. An electronic device, comprising a processor and a memory storing a computer program, characterized in that when the processor executes the computer program, the access request current limiting method according to any one of claims 1 to 7 is implemented. step. 10.一种非暂态的可读计算机存储介质,其上存储有计算机程序其特征在于,所述计算机程序被处理器执行时实现权利要求1至7任一项所述的访问请求限流方法的步骤。10. A non-transitory readable computer storage medium on which a computer program is stored. The characteristic is that when the computer program is executed by a processor, the access request current limiting method according to any one of claims 1 to 7 is implemented. A step of.
CN202310914324.5A 2023-07-24 2023-07-24 Access request current limiting methods, devices, equipment and storage media Pending CN117134946A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310914324.5A CN117134946A (en) 2023-07-24 2023-07-24 Access request current limiting methods, devices, equipment and storage media

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310914324.5A CN117134946A (en) 2023-07-24 2023-07-24 Access request current limiting methods, devices, equipment and storage media

Publications (1)

Publication Number Publication Date
CN117134946A true CN117134946A (en) 2023-11-28

Family

ID=88851766

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310914324.5A Pending CN117134946A (en) 2023-07-24 2023-07-24 Access request current limiting methods, devices, equipment and storage media

Country Status (1)

Country Link
CN (1) CN117134946A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119071361A (en) * 2024-10-23 2024-12-03 杭州新中大科技股份有限公司 A method, device, equipment and storage medium for isolating business requests

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119071361A (en) * 2024-10-23 2024-12-03 杭州新中大科技股份有限公司 A method, device, equipment and storage medium for isolating business requests

Similar Documents

Publication Publication Date Title
US20220121384A1 (en) Hot Data Management Method, Apparatus, and System
US11546644B2 (en) Bandwidth control method and apparatus, and device
JP6637620B2 (en) Agent allocation method, apparatus, server and recording medium
WO2021238248A1 (en) Network traffic classification processing method and apparatus, device, and medium
US7437460B2 (en) Service placement for enforcing performance and availability levels in a multi-node system
CN106230997B (en) Resource scheduling method and device
US20110055368A1 (en) Connection Pool Use of Runtime Load Balancing Service Performance Advisories
US9792231B1 (en) Computer system for managing I/O metric information by identifying one or more outliers and comparing set of aggregated I/O metrics
CN112165436B (en) Flow control method, device and system
CN107819797B (en) Access request processing method and device
JP2002245017A (en) Apparatus and method for specifying requested service level for transaction
US10425273B2 (en) Data processing system and data processing method
CN112866132A (en) Dynamic load balancer and method for massive identification
CN113377866A (en) Load balancing method and device for virtualized database proxy service
CN117134946A (en) Access request current limiting methods, devices, equipment and storage media
CN118233469A (en) Computing task scheduling method and system based on delay perception and load balancing
CN114003377A (en) A memory fusing method, device, device and readable medium based on ES service
CN118819819B (en) A multi-database processing method based on load balancing
US20210004308A1 (en) Data processing method and system
CN110932935A (en) Resource control method, apparatus, device and computer storage medium
CN108718285B (en) Flow control method and device of cloud computing cluster and server
CN113472591B (en) Method and device for determining service performance
CN118426937A (en) Port resource allocation method, device, equipment, storage medium and program product
CN109445934B (en) Query request distribution method and system
CN113364648A (en) Flow control method, system, device, service equipment and storage medium

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