[go: up one dir, main page]

HK40042985B - Resource allocation method, device and storage medium - Google Patents

Resource allocation method, device and storage medium Download PDF

Info

Publication number
HK40042985B
HK40042985B HK42021033049.4A HK42021033049A HK40042985B HK 40042985 B HK40042985 B HK 40042985B HK 42021033049 A HK42021033049 A HK 42021033049A HK 40042985 B HK40042985 B HK 40042985B
Authority
HK
Hong Kong
Prior art keywords
token bucket
resources
rate
outflow rate
data processing
Prior art date
Application number
HK42021033049.4A
Other languages
Chinese (zh)
Other versions
HK40042985A (en
Inventor
刘传奇
曾祝青
王银虎
Original Assignee
腾讯科技(深圳)有限公司
Filing date
Publication date
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of HK40042985A publication Critical patent/HK40042985A/en
Publication of HK40042985B publication Critical patent/HK40042985B/en

Links

Description

一种资源分配的方法、装置及存储介质A method, apparatus and storage medium for resource allocation

背景技术Background Technology

目前,为了保护共享资源以及实现多租户间的资源隔离,使用资源分配算法在多租户间合理的分配共享资源。但是多租户间通常存在一定的突发请求,此时若将租户所能分配的资源限定较小,将导致租户的突发请求对应的任务不能及时完成,影响租户的使用体验;若将租户所能分配的资源限定较大,在为多租户进行资源分配时,则多租户同时所需的资源总量将大于共享资源,容易引发共享资源的雪崩效应。Currently, to protect shared resources and achieve resource isolation among multiple tenants, resource allocation algorithms are used to reasonably allocate shared resources among multiple tenants. However, there are often sudden surges in requests among multiple tenants. If the resources that a tenant can be allocated are limited, the tasks corresponding to the sudden requests will not be completed in a timely manner, affecting the user experience. If the resources that a tenant can be allocated are limited, the total amount of resources required by multiple tenants at the same time will exceed the shared resources, which can easily trigger a cascading failure of shared resources.

因此,现有技术中提出了通过令牌桶算法进行共享资源分配,以合理的向各个租户分配资源,解决针对突发资源进行资源分配时所产生的问题。Therefore, existing technologies propose using the token bucket algorithm for shared resource allocation to reasonably distribute resources to each tenant and solve the problems arising from resource allocation in response to sudden resource shortages.

采用令牌桶算法进行资源分配时,用于处理突发请求对应的任务的资源的多少取决与令牌桶的容量。当出现突发请求,在处理突发请求对应的任务时,可以消耗掉令牌桶中所有的资源,未处理完的突发请求对应的任务,则需要以令牌桶生产资源的速率为限逐步处理,出现大量的突发请求时,处理延时较长。When using the token bucket algorithm for resource allocation, the amount of resources allocated to handle tasks corresponding to sudden requests depends on the capacity of the token bucket. When a sudden request occurs, processing the tasks corresponding to the sudden request can consume all the resources in the token bucket. Unprocessed tasks corresponding to sudden requests need to be processed gradually, limited by the rate at which the token bucket produces resources. When there are a large number of sudden requests, the processing delay is relatively long.

因此通过增加令牌桶的容量,减少处理时延,但瞬间消耗掉过多的资源,将超过总资源的承受能力,导致资源的雪崩效应。Therefore, increasing the token bucket capacity can reduce processing latency, but it consumes too many resources instantly, exceeding the total resource capacity and causing a resource avalanche effect.

发明内容Summary of the Invention

本申请提供一种资源分配的方法、装置及存储介质,用以动态分配共享资源,避免共享资源的雪崩效应,减少处理时延。This application provides a method, apparatus, and storage medium for resource allocation, which dynamically allocates shared resources, avoids the avalanche effect of shared resources, and reduces processing latency.

第一方面,本申请实施例提供一种资源分配的方法,该方法包括:In a first aspect, embodiments of this application provide a method for resource allocation, the method comprising:

在资源类型对应的第一令牌桶中,按照预设的流入速率保存最新生成的资源;In the first token bucket corresponding to the resource type, the newly generated resources are saved according to the preset inflow rate;

在确定资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值时,按照第一流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中,第一流出速率不小于流入速率;When the number of remaining resources in the second token bucket corresponding to the resource type does not reach the preset second upper limit, the resources already saved in the first token bucket are transferred to the corresponding second token bucket according to the first outflow rate, and the first outflow rate is not less than the inflow rate.

其中,第二令牌桶中保存的资源,用于分配给接收到的数据处理资源,数据处理请求所需的目标资源符合资源类型。The resources stored in the second token bucket are used to allocate the received data processing resources, and the target resources required by the data processing request conform to the resource type.

第二方面,本申请实施例提供一种资源分配的装置,该装置包括:Secondly, embodiments of this application provide a resource allocation apparatus, the apparatus comprising:

保存模块,用于在资源类型对应的第一令牌桶中,按照预设的流入速率保存最新生成的资源;The storage module is used to store the latest generated resources in the first token bucket corresponding to the resource type according to a preset inflow rate;

转存模块,用于在确定资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值时,按照第一流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中,第一流出速率不小于流入速率;The transfer module is used to transfer the resources already saved in the first token bucket to the corresponding second token bucket according to the first outflow rate when the number of remaining resources in the second token bucket corresponding to the determined resource type has not reached the preset second upper limit value. The first outflow rate is not less than the inflow rate.

其中,第二令牌桶中保存的资源,用于分配给接收到的数据处理请求,数据处理请求所需的目标资源符合资源类型。The resources stored in the second token bucket are used to allocate to received data processing requests, and the target resources required by the data processing requests conform to the resource type.

在一种可能的实现方式中,转存模块还用于:在资源类型对应的第一令牌桶中,按照预设的流入速率保存最新生成的资源之后,在确定资源类型对应的第二令牌桶中的剩余资源数目已达到预设的第二上限值时,按照第二流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中,第二流出速率小于流入速率。In one possible implementation, the transfer module is further configured to: after saving the newly generated resources in the first token bucket corresponding to the resource type at a preset inflow rate, when it is determined that the number of remaining resources in the second token bucket corresponding to the resource type has reached a preset second upper limit, transfer the resources already saved in the first token bucket to the corresponding second token bucket at a second outflow rate, wherein the second outflow rate is less than the inflow rate.

在一种可能的实现方式中,转存模块还用于:在确定资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值之后,在按照第一流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中之前,基于流入速率,从预设的第一流出速率区间中,选取不小于流入速率的一个流出速率,作为第一流出速率。In one possible implementation, the transfer module is further configured to: after determining that the number of remaining resources in the second token bucket corresponding to the resource type has not reached the preset second upper limit value, and before transferring the resources already saved in the first token bucket to the corresponding second token bucket according to the first outflow rate, select an outflow rate not less than the inflow rate from the preset first outflow rate range as the first outflow rate based on the inflow rate.

在一种可能的实现方式中,转存模块还用于:在确定资源类型对应的第二令牌桶中的剩余资源数目已达到预设的第二上限值之后,在按照第二流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中之前,基于流入速率,从预设的第二流出速率区间中,选取小于流入速率的一个流出速率,作为第二流出速率。In one possible implementation, the transfer module is further configured to: after determining that the number of remaining resources in the second token bucket corresponding to the resource type has reached a preset second upper limit, and before transferring the resources already saved in the first token bucket to the corresponding second token bucket according to the second outflow rate, select an outflow rate less than the inflow rate from the preset second outflow rate range based on the inflow rate as the second outflow rate.

在一种可能的实现方式中,第一流出速率区间和第二流出速率区间为相同区间,或者,为不同区间;In one possible implementation, the first outflow rate interval and the second outflow rate interval are the same interval, or they are different intervals.

第一流出速率区间以及第二流出速率区间是流控系统预先配置的。The first outflow rate range and the second outflow rate range are pre-configured by the flow control system.

在一种可能的实现方式中,转存模块具体用于:In one possible implementation, the transfer module is specifically used for:

若第二令牌桶中的剩余资源数目未达到预设的第二上限值,且第一令牌桶中的剩余资源数目不为零,则按照第一流出速率大于流入速率的方式,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中;If the number of remaining resources in the second token bucket does not reach the preset second upper limit, and the number of remaining resources in the first token bucket is not zero, then the resources already saved in the first token bucket are transferred to the corresponding second token bucket in the manner that the first outflow rate is greater than the inflow rate.

若第二令牌桶中的剩余资源数目未达到预设的第二上限值,且第一令牌桶中的剩余资源数目为零,则按照第一流出速率等于流入速率的方式,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中。If the number of remaining resources in the second token bucket does not reach the preset second upper limit, and the number of remaining resources in the first token bucket is zero, then the resources already saved in the first token bucket are transferred to the corresponding second token bucket in accordance with the first outflow rate being equal to the inflow rate.

在一种可能的实现方式中,转存模块还用于:In one possible implementation, the transfer module is also used for:

将第一令牌桶中已保存的资源转存至相应的第二令牌桶中之后,接收到客户端发送的数据处理请求时,基于数据处理请求所需的目标资源的资源类型,确定目标资源关联的第二令牌桶中的剩余资源数目;After transferring the resources already saved in the first token bucket to the corresponding second token bucket, when a data processing request is received from the client, the number of remaining resources in the second token bucket associated with the target resource is determined based on the resource type of the target resource required by the data processing request.

若确定第二令牌桶中的剩余资源数目不小于发送数据处理请求所需的目标资源数目,则从第二令牌桶中的剩余资源中,获取符合目标资源数目的一批资源;If it is determined that the number of remaining resources in the second token bucket is not less than the target number of resources required to send the data processing request, then a batch of resources that meet the target number of resources are obtained from the remaining resources in the second token bucket.

将一批资源分配给数据处理请求,并发送数据处理请求。Allocate a batch of resources to the data processing request and send the data processing request.

第三方面,本申请实施例提供一种资源分配的设备,包括:存储器和处理器,其中,存储器,用于存储计算机指令;处理器,用于执行计算机指令以实现本申请实施例提供的资源分配的方法。Thirdly, embodiments of this application provide a resource allocation device, including: a memory and a processor, wherein the memory is used to store computer instructions; and the processor is used to execute the computer instructions to implement the resource allocation method provided in embodiments of this application.

第四方面,本申请实施例提供一种计算机可读存储介质,计算机可读存储介质存储有计算机指令,计算机指令被处理器执行时实现本申请实施例提供的资源分配的方法。Fourthly, embodiments of this application provide a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the resource allocation method provided in embodiments of this application.

本申请有益效果如下:The beneficial effects of this application are as follows:

本申请实施例提供一种资源分配的方法、装置及存储介质;针对各个资源类型分别设置对应的第一令牌桶和第二令牌桶,且针对资源类型,执行:在资源类型对应的第一令牌桶中,按照预设的流入速率保存资源;并根据第二令牌桶中的剩余资源数目,确定将第一令牌桶中已保存的资源转存至相应的第二令牌桶中的速率。当确定第二令牌桶中的剩余资源数目未达到预设的第二上限值时,按照不小于流入速率的第一流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中,第二令牌桶中保存的资源用于分配给接收到数据处理请求,数据处理请求所需的目标资源符合资源类型。因此,当接收到数据处理请求时,确定数据处理请求所需的目标资源,根据目标资源确定关联的第二令牌桶,消耗第二令牌桶中的资源发送数据处理请求,当接收到小量突发的数据处理请求时,通过消耗第二令牌桶中的所有资源,可及时发送数据处理请求;当接收到大量突发的数据处理请求时,可先消耗第二令牌桶中的所有资源,及时发送部分数据处理请求,之后按照不小于流入速率的第一流出速率及时为第二令牌桶转发资源,以继续发送剩余部分数据处理请求,支持以不小于流入速率的第一流出速率处理突发的数据处理请求,减少处理时延,且平衡共享资源的分配,避免共享资源的雪崩效应。This application provides a method, apparatus, and storage medium for resource allocation. For each resource type, a corresponding first token bucket and second token bucket are set up. For each resource type, the following steps are performed: resources are saved in the first token bucket according to a preset inflow rate; and the rate at which the resources saved in the first token bucket are transferred to the corresponding second token bucket is determined based on the number of remaining resources in the second token bucket. When it is determined that the number of remaining resources in the second token bucket has not reached a preset second upper limit, the resources saved in the first token bucket are transferred to the corresponding second token bucket at a first outflow rate not less than the inflow rate. The resources saved in the second token bucket are used to allocate to received data processing requests, where the target resources required by the data processing requests conform to the resource type. Therefore, when a data processing request is received, the target resources required for the data processing request are determined, and the associated second token bucket is determined based on the target resources. The resources in the second token bucket are consumed to send the data processing request. When a small number of sudden data processing requests are received, all resources in the second token bucket can be consumed to send the data processing request in a timely manner. When a large number of sudden data processing requests are received, all resources in the second token bucket can be consumed first to send part of the data processing request in a timely manner. Then, resources are forwarded to the second token bucket in a timely manner at a first outflow rate not less than the inflow rate to continue sending the remaining data processing requests. This supports processing sudden data processing requests at a first outflow rate not less than the inflow rate, reducing processing latency, balancing the allocation of shared resources, and avoiding the avalanche effect of shared resources.

本申请的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本申请而了解。本申请的目的和其他优点可通过在所写的说明书、权利要求书、以及附图中所特别指出的结构来实现和获得。Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings.

附图说明Attached Figure Description

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

图1为相关技术中进行资源分配的示意图;Figure 1 is a schematic diagram of resource allocation in related technologies;

图2为本申请实施例提供的一种应用场景示意图;Figure 2 is a schematic diagram of an application scenario provided by an embodiment of this application;

图3为本申请实施例提供的一种针对资源类型设置第一令牌桶和第二令牌桶的示意图;Figure 3 is a schematic diagram of setting a first token bucket and a second token bucket for a resource type according to an embodiment of this application;

图4为本申请实施例提供的一种资源分配的方法流程图;Figure 4 is a flowchart of a resource allocation method provided in an embodiment of this application;

图5为本申请实施例提供的一种存储系统的示意图;Figure 5 is a schematic diagram of a storage system provided in an embodiment of this application;

图6为本申请实施例提供的一种发送数据处理请求的时延曲图;Figure 6 is a delay curve of sending a data processing request according to an embodiment of this application;

图7为本申请实施例提供的一种资源分配的装置结构图;Figure 7 is a structural diagram of a resource allocation device provided in an embodiment of this application;

图8为本申请实施例提供的一种计算装置结构图。Figure 8 is a structural diagram of a computing device provided in an embodiment of this application.

具体实施方式Detailed Implementation

为了使本申请的目的、技术方案及有益效果更加清楚明白,以下将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,并不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。To make the objectives, technical solutions, and beneficial effects of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

以下对本申请实施例中的部分用语进行解释说明,以便于本领域技术人员理解。The following explanations of some terms used in the embodiments of this application are provided to facilitate understanding by those skilled in the art.

1、“第一”、“第二”仅用于描述目的,而不能理解为暗示或暗示相对重要性或者隐含指明所指示的技术特征的数目。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征,在本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。1. The terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined with "first" and "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

2、多租户简单来说是指一个单独的实例可以为多个组织服务。多租户技术为共用的数据中心内如何以单一系统架构与服务提供多数客户端相同甚至可定制化的服务,并且仍然可以保障客户的数据隔离。2. In simple terms, multi-tenancy means that a single instance can serve multiple organizations. Multi-tenancy technology addresses how to provide the same or even customizable services to most clients within a shared data center using a single system architecture and services, while still ensuring data isolation for customers.

多租户技术(multi-tenancy technology)或称多重租赁技术,是一种软件架构技术,它是在探讨与实现如何于多用户的环境下共用相同的系统或程序组件,并且仍可确保各用户间数据的隔离性。租户(tenant)是指使用系统或电脑运算资源的用户。Multi-tenancy technology is a software architecture technique that explores and implements how to share the same system or program components in a multi-user environment while still ensuring data isolation between users. A tenant is a user who uses system or computer computing resources.

3、令牌桶算法是网络流量整形(Traffic Shaping)和速率限制(Rate Limiting)中最常使用的一种算法。典型情况下,令牌桶算法用来控制发送到网络上的数据的数目,并允许突发请求的发送。3. The token bucket algorithm is one of the most commonly used algorithms in network traffic shaping and rate limiting. Typically, the token bucket algorithm is used to control the amount of data sent over the network and allows for bursty requests.

令牌桶算法采用恒定的速率源源不断地产生资源。如果资源不被消耗,或者被消耗资源的速率小于产生资源的速率,令牌桶中的资源就会不断增多,持续累积直至令牌桶中的资源数目达到上限值。当令牌桶中的资源数目达到上限值后,新产生的资源,将从令牌桶中溢出,则将令牌桶中的资源丢弃。The token bucket algorithm continuously generates resources at a constant rate. If resources are not consumed, or if the rate of resource consumption is less than the rate of resource generation, the resources in the token bucket will continuously increase, accumulating until the number of resources in the token bucket reaches its upper limit. When the number of resources in the token bucket reaches its upper limit, newly generated resources will overflow from the token bucket, and the resources in the token bucket will be discarded.

4、云技术(Cloud technology)是指在广域网或局域网内将硬件、软件、网络等系列资源统一起来,实现数据的计算、储存、处理和共享的一种托管技术。4. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to realize the computing, storage, processing, and sharing of data.

云技术(Cloud technology)基于云计算商业模式应用的网络技术、信息技术、整合技术、管理平台技术、应用技术等的总称,可以组成资源池,按需所用,灵活便利。云计算技术将变成重要支撑。技术网络系统的后台服务需要大量的计算、存储资源,如视频网站、图片类网站和更多的门户网站。伴随着互联网行业的高度发展和应用,将来每个物品都有可能存在自己的识别标志,都需要传输到后台系统进行逻辑处理,不同程度级别的数据将会分开处理,各类行业数据皆需要强大的系统后盾支撑,只能通过云计算来实现。Cloud technology is a collective term for network technologies, information technologies, integration technologies, management platform technologies, and application technologies applied to the cloud computing business model. It can form resource pools, providing flexible and convenient on-demand access. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will all require robust system support, which can only be achieved through cloud computing.

下面对本申请实施例的设计构思进行简要介绍。The design concept of the embodiments of this application will be briefly introduced below.

本申请是针对多租户共享资源的场景下,进行资源分配的;目前,在多租户共享资源的场景下,为了保证共享资源以及实现多租户间的资源隔离,通常使用资源分配算法为多租户进行资源分配。但是租户间通常存在一定程度的突发请求,如果将租户所能分配的资源限定过小,将导致租户的突发请求不能及时处理;若果将租户所能分配的资源限定过大,将导致多个租户同时需要资源的总量大于共享资源的总量,引发共享资源的雪崩效应,比如网络拥堵。This application addresses resource allocation in multi-tenant shared resource scenarios. Currently, in multi-tenant shared resource scenarios, resource allocation algorithms are typically used to allocate resources among tenants to ensure shared resources and achieve resource isolation between tenants. However, tenants often experience sudden surges in requests. If the resources allocated to a tenant are limited too much, these sudden requests cannot be processed in a timely manner; if the resources allocated to a tenant are limited too much, the total amount of resources needed by multiple tenants simultaneously will exceed the total amount of shared resources, triggering a cascading effect of shared resources, such as network congestion.

针对资源分配算法无法合理为各个租户进行资源分配的问题,相关技术中又给出通过令牌桶算法进行资源分配的方式,通过令牌桶算法进行资源分配时支持一定程度上的突发请求,但能处理的突发请求的多少取决于令牌桶的容量。当出现突发请求时,为处理突发请求瞬间消耗掉令牌桶中剩余的所有资源,但还可能存在未处理的突发请求,针对未处理的突发请求,则需要以资源的生产速率为限逐步处理。To address the issue of resource allocation algorithms failing to allocate resources reasonably to each tenant, related technologies have proposed using a token bucket algorithm for resource allocation. While this algorithm supports a certain degree of burst requests, the number of burst requests it can handle depends on the token bucket's capacity. When a burst request occurs, processing it instantly consumes all remaining resources in the token bucket, but unprocessed burst requests may still exist. These unprocessed burst requests need to be processed incrementally, limited by the resource production rate.

因此,当出现大量的突发请求时,由于令牌桶的容量有限,消耗掉令牌桶中剩余的所有资源也无法处理完所有突发请求,剩余的未处理的突发请求则需要根据令牌桶对应的资源的生产速率对未处理的突发请求进行处理,导致处理时延过高。Therefore, when a large number of sudden requests occur, the token bucket has a limited capacity. Even if all the remaining resources in the token bucket are consumed, it is still not enough to process all the sudden requests. The remaining unprocessed sudden requests need to be processed according to the production rate of the resources corresponding to the token bucket, resulting in excessively high processing latency.

图1示例性的给出了相关技术中一种资源分配的方法,令牌桶算法采用恒定的生产速率产生资源,并将产生的资源放入到令牌桶中,令牌桶有固定的容量,当令牌桶中的资源数目超过令牌桶容量时,新增的资源将从令牌桶中溢出,即丢弃新增的资源;当租户需要使用资源时,将从令牌桶中获取资源。Figure 1 illustrates an exemplary resource allocation method in the related art. The token bucket algorithm generates resources at a constant production rate and puts the generated resources into the token bucket. The token bucket has a fixed capacity. When the number of resources in the token bucket exceeds the capacity of the token bucket, the newly added resources will overflow from the token bucket, that is, the newly added resources will be discarded. When a tenant needs to use resources, it will obtain resources from the token bucket.

因此,通过增加令牌桶的容量可以解决处理大量突发请求带来的处理时延过高的问题。但是通过增加令牌桶的容量,瞬间消耗掉过多的资源,有可能超过总资源的承受能力,导致共享资源的雪崩效应。Therefore, increasing the token bucket capacity can solve the problem of high processing latency caused by a large number of sudden requests. However, increasing the token bucket capacity can consume too many resources at once, potentially exceeding the total resource capacity and causing a cascading failure of shared resources.

有鉴于此,本申请实施例提供一种支持突发请求的资源分配方法,该资源分配方法基于对各个资源类型设置两个令牌桶,即第一令牌桶和第二令牌桶,并通过令牌桶算法进行资源的动态分配,避免共享的雪崩效应,降低处理时延。In view of this, embodiments of this application provide a resource allocation method that supports burst requests. This resource allocation method is based on setting two token buckets for each resource type, namely a first token bucket and a second token bucket, and dynamically allocating resources through the token bucket algorithm to avoid the avalanche effect of sharing and reduce processing latency.

在本申请中,消耗第二资源中的资源发送数据处理请求,因此针对小量的突发请求,通过消耗第二令牌桶中的剩余资源及时处理,针对大量的突发请求,按照不小于流入第一令牌桶中的资源流入速率的流出速率,将第一令牌桶中保存的资源转存至第二令牌桶中,并支持按时间递减的梯度控制策略。In this application, data processing requests are sent by consuming resources in the second token bucket. Therefore, for a small number of burst requests, the remaining resources in the second token bucket are consumed to process them in a timely manner. For a large number of burst requests, the resources stored in the first token bucket are transferred to the second token bucket at an outflow rate that is not less than the inflow rate of resources into the first token bucket. A gradient control strategy that decreases over time is also supported.

在第一时间段内瞬间消耗第二令牌桶中的剩余资源处理突发请求,即在第一时间内以最大速率及时处理突发请求;The remaining resources in the second token bucket are consumed instantly in the first time period to process the sudden requests, that is, to process the sudden requests at the maximum rate in the first time period.

在第二时间段内以大于流入第一令牌桶中的资源对应的流入速率的流出速率,从第一令牌桶中获取资源,并通过消耗获取的资源处理突发请求,因此在第二时间段内处理突发请求的速率与大于流入速率的流出速率成正比,即处理突发请求的时间与大于流入速率的流出速率成正比;During the second time period, resources are acquired from the first token bucket at an outflow rate greater than the inflow rate corresponding to the resources flowing into the first token bucket. Sudden requests are processed by consuming the acquired resources. Therefore, the rate of processing sudden requests during the second time period is proportional to the outflow rate greater than the inflow rate, that is, the time for processing sudden requests is proportional to the outflow rate greater than the inflow rate.

在第三时间段内以等于流入第一令牌桶中的资源对应的流入速率的流出速率,从第一令牌桶中获取资源,并通过消耗获取的资源处理突发请求,因此在第三时间段内处理突发请求的速率与等于流入速率的流出速率成正比,即处理突发请求的时间与等于流入速率的流出速率成正比。During the third time period, resources are acquired from the first token bucket at an outflow rate equal to the inflow rate of the resources flowing into the first token bucket. Sudden requests are processed by consuming the acquired resources. Therefore, the rate at which sudden requests are processed during the third time period is proportional to the outflow rate equal to the inflow rate. In other words, the time for processing sudden requests is proportional to the outflow rate equal to the inflow rate.

因此,本申请中不会一次性分配处理大量突发请求所需的资源,而是按照梯度式流出速率将第一令牌桶中的资源转存至第二令牌桶中,能够较好的平衡共享资源的分配,避免共享资源的雪崩响应;且针对大量突发请求的情况,消耗第二令牌桶中的资源及时处理部分突发请求后,剩余的未处理的突发请求则按照大于第一令牌桶对应的资源的生产速率对未处理的突发请求进行处理,资源生产速率增加,突发请求等待时间减少,因此降低处理时延。Therefore, this application does not allocate the resources required to process a large number of sudden requests all at once. Instead, it transfers the resources in the first token bucket to the second token bucket according to a gradient outflow rate. This can better balance the allocation of shared resources and avoid avalanche response of shared resources. In the case of a large number of sudden requests, after consuming the resources in the second token bucket to process some of the sudden requests in time, the remaining unprocessed sudden requests are processed at a production rate greater than that of the resources corresponding to the first token bucket. As the resource production rate increases, the waiting time of sudden requests decreases, thereby reducing processing latency.

在介绍完本申请实施例的设计思想之后,下面对本申请实施例的技术方案能够适用的应用场景做一些简单介绍。需要说明的是,以下介绍的应用场景仅用于说明本申请实施例而非限定。在具体实施过程中,可以根据实际需要灵活地应用本申请实施例提供的技术方案。After introducing the design concept of the embodiments of this application, the following is a brief introduction to the application scenarios to which the technical solutions of the embodiments of this application can be applied. It should be noted that the application scenarios described below are only for illustrating the embodiments of this application and are not intended to limit the scope. In specific implementation, the technical solutions provided by the embodiments of this application can be flexibly applied according to actual needs.

图2示例性的提供了本申请实施例的一种应用场景示意图,该应用场景中包括终端设备20和服务器21。Figure 2 provides an exemplary application scenario diagram of an embodiment of this application, which includes a terminal device 20 and a server 21.

其中,终端设备20中安装运行有各种客户端,针对各个客户端可以接收用户触发的数据处理请求,终端设备20为用户使用的电子设备,该电子设备可以是个人计算机、手机、平板电脑、笔记本、电子书阅读器等具有一定计算能力并且运行有即时通信类软件及网站或者社交类软件及网站的计算机设备。The terminal device 20 has various clients installed and running. Each client can receive data processing requests triggered by the user. The terminal device 20 is an electronic device used by the user. This electronic device can be a personal computer, mobile phone, tablet computer, laptop computer, e-book reader, or other computer device with certain computing capabilities and running instant messaging software and websites or social networking software and websites.

服务器21可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(Content Delivery Network,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器。Server 21 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN), and big data and artificial intelligence platforms.

在一种可选的实施方式中,终端设备20与服务器21之间可以通过通信网络进行通信。通信网络是有线网络或无线网络。终端设备20以及服务器21可以通过有线或无线通信方式进行直接或间接地连接,本申请在此不做限制。In one alternative implementation, the terminal device 20 and the server 21 can communicate via a communication network. The communication network can be a wired network or a wireless network. The terminal device 20 and the server 21 can be directly or indirectly connected via wired or wireless communication, and this application does not impose any limitations on this.

在一种可能的实现方式中,接收到用户针对一个客户端触发的数据处理请求,当发送该数据处理请求时,为该数据处理请求分配所需的资源,以使数据处理请求顺利发送到服务器。In one possible implementation, a data processing request triggered by a user for a client is received. When the data processing request is sent, the necessary resources are allocated to the data processing request so that the data processing request can be successfully sent to the server.

在一种可能的实现方式中,本申请采用云计算方式为终端设备20提供服务。云计算(cloud computing)是一种计算模式,它将计算请求分布在大量计算机构成的资源池上,其中每个计算机可以作为一个服务器,使各种应用系统能够根据需要获取计算力、存储空间和信息服务。提供资源的网络被称为“云”。“云”中的资源在使用者看来是可以无限扩展的,并且可以随时获取,按需使用,随时扩展,按使用付费。In one possible implementation, this application employs cloud computing to provide services to terminal device 20. Cloud computing is a computing model that distributes computing requests across a resource pool composed of a large number of computers, where each computer can act as a server, enabling various application systems to obtain computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." From the user's perspective, the resources in the "cloud" are infinitely scalable, readily available, on-demand, expandable, and pay-as-you-go.

采用云存储的方式存储服务器中的数据。云存储(cloud storage)是在云计算概念上延伸和发展出来的一个新的概念,分布式云存储系统(以下简称存储系统)是指通过集群应用、网格技术以及分布存储文件系统等功能,将网络中大量各种不同类型的存储设备(存储设备也称之为存储节点)通过应用软件或应用接口集合起来协同工作,共同对外提供数据存储和业务访问功能的一个存储系统。Data on servers is stored using cloud storage. Cloud storage is a new concept that extends and develops from cloud computing. A distributed cloud storage system (hereinafter referred to as a storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to aggregate a large number of storage devices (also called storage nodes) of various types in a network to work together through application software or application interfaces to provide data storage and business access functions.

目前,存储系统的存储方法为:创建逻辑卷,在创建逻辑卷时,就为每个逻辑卷分配物理存储空间,该物理存储空间可能是某个存储设备或者某几个存储设备的磁盘组成。客户端在某一逻辑卷上存储数据,也就是将数据存储在文件系统上,文件系统将数据分成许多部分,每一部分是一个对象,对象不仅包含数据而且还包含数据标识(IDentity,ID)等额外的信息,文件系统将每个对象分别写入该逻辑卷的物理存储空间,且文件系统会记录每个对象的存储位置信息,从而当客户端请求访问数据时,文件系统能够根据每个对象的存储位置信息让客户端对数据进行访问。Currently, the storage method in storage systems is as follows: Logical volumes are created, and during creation, physical storage space is allocated to each logical volume. This physical storage space may consist of a single storage device or the disks of several storage devices. Clients store data on a logical volume, which means storing the data on the file system. The file system divides the data into many parts, each part being an object. Each object contains not only the data but also additional information such as a data identifier (ID). The file system writes each object to the physical storage space of that logical volume, and it records the storage location information of each object. Therefore, when a client requests access to data, the file system can allow the client to access the data based on the storage location information of each object.

存储系统为逻辑卷分配物理存储空间的过程,具体为:按照对存储于逻辑卷的对象的容量估量(该估量往往相对于实际要存储的对象的容量有很大余量)和独立冗余磁盘阵列(Redundant Array ofIndependent Disk,RAID)的组别,预先将物理存储空间划分成分条,一个逻辑卷可以理解为一个分条,从而为逻辑卷分配了物理存储空间。The process by which a storage system allocates physical storage space to a logical volume is as follows: the physical storage space is pre-divided into strips according to the capacity estimate of the objects stored in the logical volume (this estimate often has a large margin relative to the actual capacity of the objects to be stored) and the grouping of Redundant Array of Independent Disks (RAID). A logical volume can be understood as a strip, thus allocating physical storage space to the logical volume.

基于图2的应用场景,下面对本申请实施例中涉及的资源分配的方法进行示例说明。Based on the application scenario in Figure 2, the resource allocation method involved in the embodiments of this application will be illustrated below.

在本申请实施例中,为了保证多租户间的资源隔离,针对各个租户对应的各个资源类型分别设置对应的第一令牌桶和第二令牌桶。如图3所示,图3示例性的提供了本申请实施例中针对任一资源类型设置第一令牌桶和第二令牌桶的示意图。In this embodiment of the application, in order to ensure resource isolation among multiple tenants, a corresponding first token bucket and a second token bucket are set for each resource type corresponding to each tenant. As shown in Figure 3, Figure 3 provides an exemplary schematic diagram of setting a first token bucket and a second token bucket for any resource type in this embodiment of the application.

其中,第一令牌桶和第二令牌桶中保存的资源是相同的。The resources stored in the first token bucket and the second token bucket are the same.

需要说明的是,资源类型包括但不限于带宽资源对应的资源类型、每秒流入流出操作数(Input/Output Oprations Per Second,IOPS)资源对应的资源类型中的至少一种;本申请中的资源包括但不限于存储资源、网络资源中的至少一种。It should be noted that the resource types include, but are not limited to, at least one of the resource types corresponding to bandwidth resources and the resource types corresponding to input/output operations per second (IOPS) resources; the resources in this application include, but are not limited to, at least one of storage resources and network resources.

在一种可能的实现方式中,为各个资源类型设置了对应的第一令牌桶和第二令牌桶后,就需要向第一令牌桶和第二令牌桶中分配资源,以消耗资源发送数据处理请求。In one possible implementation, after setting up corresponding first and second token buckets for each resource type, resources need to be allocated to the first and second token buckets to consume resources to send data processing requests.

下面,以一个资源类型为例,进行举例说明。Below, we will use a resource type as an example to illustrate this.

请参照图4,图4示例性提供了本申请实施例的针对资源类型进行资源分配的方法,该方法应用于各种需要共享资源分配的场景中,该方法包括如下步骤:Please refer to Figure 4, which exemplarily illustrates a method for resource allocation based on resource type according to an embodiment of this application. This method is applicable to various scenarios requiring shared resource allocation and includes the following steps:

步骤S400,在资源类型对应的第一令牌桶中,按照预设的流入速率保存最新生成的资源。Step S400: In the first token bucket corresponding to the resource type, the newly generated resource is saved according to the preset inflow rate.

结合图3进行说明,设针对带宽资源设置了第一令牌桶和第二令牌桶,且按照Rtoken/s的流入速率持续产生带宽资源,并流入到带宽资源对应的第一令牌桶中,R为正整数。Referring to Figure 3, suppose a first token bucket and a second token bucket are set up for bandwidth resources, and bandwidth resources are continuously generated at an inflow rate of Rtoken/s and flow into the first token bucket corresponding to the bandwidth resources, where R is a positive integer.

其中,流入速率就是生产资源的生产速率,是由流控系统通过限制存储性能参数决定的;存储性能参数包括但不限于带宽、IOPS、吞吐量中的至少一种。The inflow rate is the production rate of production resources, which is determined by the flow control system by limiting storage performance parameters; storage performance parameters include, but are not limited to, at least one of bandwidth, IOPS, and throughput.

需要说明的是,令牌桶中的资源也可以称为资源。It should be noted that resources in the token bucket can also be referred to as resources.

步骤S401,在确定资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值时,按照第一流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中,第一流出速率不小于流入速率。Step S401: When it is determined that the number of remaining resources in the second token bucket corresponding to the resource type has not reached the preset second upper limit value, the resources already saved in the first token bucket are transferred to the corresponding second token bucket according to the first outflow rate, and the first outflow rate is not less than the inflow rate.

结合图3进行说明,按照B token/s的流出速率,将第一令牌桶中已保存的带宽资源转存至相应的第二令牌桶中。即流出速率是资源流出第一令牌桶中的流出速率,在本申请中流出速率作为资源流入第二令牌桶中的流入速率,第二令牌桶的容量小于第一令牌桶的容量。Referring to Figure 3, according to the outflow rate of B tokens/s, the bandwidth resources stored in the first token bucket are transferred to the corresponding second token bucket. That is, the outflow rate is the rate at which resources flow out of the first token bucket. In this application, the outflow rate is used as the rate at which resources flow into the second token bucket, and the capacity of the second token bucket is smaller than the capacity of the first token bucket.

由于在发送数据处理请求中,消耗第二资源中的资源,因此第二令牌桶中的剩余资源数目会一直小于预设的第二上限值,且为了降低数据处理请求的时延,需要保证资源流入第二令牌桶中的速率大于等于资源流入第一令牌桶的速率,即需要保证第一令牌桶的流出速率大于等于第一令牌桶的流入速率。Since the resources in the second resource are consumed when sending data processing requests, the number of remaining resources in the second token bucket will always be less than the preset second upper limit value. In order to reduce the latency of data processing requests, it is necessary to ensure that the rate of resources flowing into the second token bucket is greater than or equal to the rate of resources flowing into the first token bucket, that is, it is necessary to ensure that the outflow rate of the first token bucket is greater than or equal to the inflow rate of the first token bucket.

在一种可能的实现方式中,在资源流出第一令牌桶的流出速率不小于资源流入第一令牌桶的流入速率的情况下,当消耗资源的速率小于资源流入第一令牌桶中的流入速率时,消耗资源的速率也小于流出第一令牌桶的流出速率,此时流出速率大于流入速率大于消耗资源的消耗速率,即减少消耗第二令牌桶中的资源数目,因此若继续采用不小于流入速率的第一流出速率持续将第一令牌桶中的资源转存至第二令牌桶中,则一定时间后第二令牌桶中的资源达到上限,继续转存到第二令牌桶中的资源将从第二令牌桶中溢出,即继续转存至第二资源中的资源丢弃,且此时第一令牌桶也不会达到预设的第一上限值,最终造成资源浪费;In one possible implementation, when the outflow rate of resources from the first token bucket is not less than the inflow rate of resources into the first token bucket, when the rate of resource consumption is less than the inflow rate of resources into the first token bucket, the rate of resource consumption is also less than the outflow rate of resources from the first token bucket. At this time, the outflow rate is greater than the inflow rate, which is greater than the consumption rate of resources. This reduces the amount of resources consumed in the second token bucket. Therefore, if the first outflow rate, which is not less than the inflow rate, continues to transfer resources from the first token bucket to the second token bucket, the resources in the second token bucket will reach their upper limit after a certain period of time. Resources that continue to be transferred to the second token bucket will overflow from the second token bucket, which means that resources that continue to be transferred to the second token bucket will be discarded. At this time, the first token bucket will not reach the preset first upper limit value, ultimately resulting in resource waste.

因此,在第一令牌桶中的资源转存至第二令牌桶中时,在确定资源类型对应的第二令牌桶中的剩余资源数目已达到预设的第二上限值时,为了避免资源浪费,按照第二流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中,第二流出速率小于流入速率。Therefore, when resources in the first token bucket are transferred to the second token bucket, if the number of remaining resources in the second token bucket corresponding to the resource type has reached the preset second upper limit, in order to avoid resource waste, the resources already saved in the first token bucket are transferred to the corresponding second token bucket according to the second outflow rate, and the second outflow rate is less than the inflow rate.

因此,本申请实施例中,资源从第一令牌桶中的流出速率与第二令牌桶中的剩余资源数目相关,包括如下情况:Therefore, in this embodiment, the rate at which resources flow out of the first token bucket is related to the number of remaining resources in the second token bucket, including the following situations:

情况一:在第二令牌桶中的剩余资源数目未达到预设的第二上限值时。Scenario 1: When the number of remaining resources in the second token bucket has not reached the preset second upper limit.

由于发送数据处理请求时,消耗第二令牌桶中的资源,因此在确定资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值之后,为了降低处理数据处理请求的时间,需要保证以较大的速率将第一令牌桶中的资源转存至第二令牌桶中,即保证资源流出第一令牌桶中的流出速率要大于等于资源流入第一令牌桶中的流入速率。Since sending a data processing request consumes resources in the second token bucket, after determining that the number of remaining resources in the second token bucket corresponding to the resource type has not reached the preset second upper limit, in order to reduce the time for processing data processing requests, it is necessary to ensure that the resources in the first token bucket are transferred to the second token bucket at a relatively high rate, that is, to ensure that the outflow rate of resources from the first token bucket is greater than or equal to the inflow rate of resources into the first token bucket.

也就是说,获取资源的速率较大,获取发送数据处理请求的目标资源的资源总量的时间减少,因此消耗发送数据处理请求的时间降低。In other words, a higher resource acquisition rate reduces the time required to acquire the total amount of resources needed to send a data processing request, thus reducing the time consumed in sending the data processing request.

由于流入速率是流控系统基于存储性能参数进行设置的,是固定不变的,因此需要根据流入速率,确定不小于流入速率的流出速率。Since the inflow rate is set by the flow control system based on storage performance parameters and is fixed, it is necessary to determine an outflow rate that is not less than the inflow rate.

此时基于流入速率,从预设的第一流出速率区间中,选取不小于流入速率的一个流出速率,作为所述第一流出速率;并按照第一流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中。At this point, based on the inflow rate, an outflow rate not less than the inflow rate is selected from the preset first outflow rate range as the first outflow rate; and according to the first outflow rate, the resources already stored in the first token bucket are transferred to the corresponding second token bucket.

其中,第一流出速率区间是由流控系统预先设置的,第一流出速率区间的上限值大于资源流入第一令牌桶中的流入速率对应的速率值,因此在第一流出速率区间中查找任一大于等于流入速率对应的速率值的流出速率作为第一流出速率。The first outflow rate range is preset by the flow control system. The upper limit of the first outflow rate range is greater than the rate value corresponding to the inflow rate of resources into the first token bucket. Therefore, any outflow rate greater than or equal to the rate value corresponding to the inflow rate is selected as the first outflow rate in the first outflow rate range.

需要说明的是,本申请中第一流出速率区间的下限值可以为0,可以为小于流入速率对应的速率值的正整数,可以为流入速率对应的速率值。It should be noted that the lower limit of the first outflow rate interval in this application can be 0, a positive integer less than the rate value corresponding to the inflow rate, or the rate value corresponding to the inflow rate.

在本申请实施例中,第一流出速率与第一令牌桶中的剩余资源数目相关。In this embodiment of the application, the first outflow rate is related to the number of remaining resources in the first token bucket.

当第一令牌桶中的剩余资源数目不为零时:When the number of remaining resources in the first token bucket is not zero:

由于第一令牌桶中的剩余资源数目不为零,为了加快处理数据处理请求,应提升将第一令牌桶中的资源转存至第二令牌桶中的速率,即按照第一流出速率大于流入速率的方式,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中;Since the number of remaining resources in the first token bucket is not zero, in order to speed up the processing of data processing requests, the rate at which resources in the first token bucket are transferred to the second token bucket should be increased. That is, the resources already saved in the first token bucket should be transferred to the corresponding second token bucket in a manner where the first outflow rate is greater than the inflow rate.

也就是说,当第一令牌桶中有资源剩余时,在第一令牌桶中新增资源的同时将第一令牌桶中的资源转存至第二令牌桶中,此时不仅可以将新增数目的资源全部转存至第二令牌桶中,还可以额外增加令牌桶中剩余的资源,即第一流出速率大于流入速率;In other words, when there are resources remaining in the first token bucket, while adding new resources to the first token bucket, the resources in the first token bucket are transferred to the second token bucket. At this time, not only can all the newly added resources be transferred to the second token bucket, but the remaining resources in the token bucket can also be added, that is, the first outflow rate is greater than the inflow rate.

为了更快处理数据处理请求,优选的,将第一流出速率区间中的上限对应的流出速率作为第一流出速率。To process data processing requests more quickly, preferably, the outflow rate corresponding to the upper limit of the first outflow rate range is used as the first outflow rate.

当第一令牌桶中的剩余资源数目为零:When the number of remaining resources in the first token bucket is zero:

按照第一流出速率等于流入速率的方式,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中;According to the principle that the first outflow rate equals the inflow rate, the resources already stored in the first token bucket are transferred to the corresponding second token bucket;

由于第一令牌桶中的剩余资源数目为零,为了加快处理数据处理请求,最快将第一令牌桶中的资源转存至第二令牌桶中的方式为,第一令牌桶中新增了多少资源,就将新增的资源转存至第二令牌桶中,也就是说第一流出速率等于流入速率。Since the remaining resources in the first token bucket are zero, in order to speed up the processing of data processing requests, the fastest way to transfer the resources in the first token bucket to the second token bucket is to transfer the newly added resources to the second token bucket as much as the first token bucket is added. In other words, the first outflow rate is equal to the inflow rate.

举例说明:For example:

设流入第一令牌桶的流入速率为5资源/秒,第一令牌桶中的剩余资源数目处于达到预设的第一上限值设100资源,第一流出速率区间为[0,10],第二令牌桶中的剩余资源数目达到预设的第二上限值50资源;Let the inflow rate into the first token bucket be 5 resources/second, the remaining number of resources in the first token bucket be at the preset first upper limit value of 100 resources, the first outflow rate range be [0, 10], and the remaining number of resources in the second token bucket be at the preset second upper limit value of 50 resources.

当有大量数据处理请求需要发送时,设发送大量数据处理请求的总共所需的资源为260资源时,最先消耗第二令牌桶中的50资源处理部分数据处理请求,之后从第一流出速率区间中选择最大的流出速率10资源/秒作为第一流出速率将第一令牌桶中的100资源转存至第二令牌桶中,在将第一令牌桶中的资源转存到第二令牌桶中的同时,第一令牌桶还按照5资源/秒的流入速率生成令牌,因此可以按照10资源/秒将第一令牌桶中的资源转存至第二令牌桶中的时间为19秒,此时第一令牌桶中的剩余资源为0,按照10资源/秒转存到第二令牌桶中的资源总共有190资源,此时发送数据处理请求一共消耗了240资源,此时并为将所有数据处理请求发送,剩余的20资源,将按照资源流入第一令牌桶中的流入速率5资源/秒将第一令牌桶中最新生成的资源转存至第二令牌桶中。When a large number of data processing requests need to be sent, assuming the total resources required to send these requests are 260, the first step is to consume 50 resources from the second token bucket to process some of the requests. Then, the highest outflow rate of 10 resources/second is selected from the first outflow rate range as the first outflow rate to transfer 100 resources from the first token bucket to the second token bucket. Simultaneously, the first token bucket generates tokens at an inflow rate of 5 resources/second. Therefore, the time to transfer resources from the first token bucket to the second token bucket at 10 resources/second is 19 seconds. At this point, the remaining resources in the first token bucket are 0, and a total of 190 resources are transferred to the second token bucket at 10 resources/second. Sending the data processing requests has consumed a total of 240 resources. Not all data processing requests are sent at this point. The remaining 20 resources will be used to transfer the newly generated resources from the first token bucket to the second token bucket at an inflow rate of 5 resources/second.

情况二:在第二令牌桶中的剩余资源数目已达到预设的第二上限值时。Scenario 2: When the number of remaining resources in the second token bucket has reached the preset second upper limit.

在本申请实施例中,在资源流出第一令牌桶的流出速率不小于资源流入第一令牌桶的流入速率的情况下,消耗第二令牌桶中的消耗速率小于资源流入第一令牌桶中的流入速率时:In this embodiment of the application, when the outflow rate of resources leaving the first token bucket is not less than the inflow rate of resources into the first token bucket, and the consumption rate of resources in the second token bucket is less than the inflow rate of resources into the first token bucket:

由于资源流入第二令牌桶的流入速率等于资源流出第一令牌桶中的流出速率,资源流出第一令牌桶的流出速率不小于资源流入第一令牌桶的流入速率,因此流入第二令牌桶中的流入速率大于流出第二令牌桶中的流出速率,按照此情况,持续一定时间后第二令牌桶中的资源将达到预设的第二上限值。Since the inflow rate of resources into the second token bucket is equal to the outflow rate of resources out of the first token bucket, and the outflow rate of resources out of the first token bucket is not less than the inflow rate of resources into the first token bucket, the inflow rate into the second token bucket is greater than the outflow rate out of the second token bucket. Under this situation, after a certain period of time, the resources in the second token bucket will reach the preset second upper limit value.

由于令牌桶算法的特性,当第二令牌桶中的剩余资源数目达到预设的第二上限值时,若继续采用资源流出第一令牌桶中的流出速率不小于资源流入第一令牌桶的流入速率,则继续从第一令牌桶中转存的资源将从第二令牌桶中溢出,将无法继续在第二令牌桶中保存,而是将继续保存的资源丢弃,导致第二令牌桶中新增的资源浪费,且第一令牌桶的资源无法达到预设的第一上限值。Due to the characteristics of the token bucket algorithm, when the number of remaining resources in the second token bucket reaches the preset second upper limit, if the outflow rate of resources from the first token bucket is not less than the inflow rate of resources into the first token bucket, the resources that continue to be transferred from the first token bucket will overflow from the second token bucket and will no longer be able to be stored in the second token bucket. Instead, the resources that will continue to be stored will be discarded, resulting in the waste of newly added resources in the second token bucket, and the resources in the first token bucket will not reach the preset first upper limit.

此时为了保证资源不被浪费,以及在消耗资源的消耗流速突然增加时,可及时发送数据处理请求,降低处理时延,本申请实施例中,在第二令牌桶中的剩余资源数目已达到预设的第二上限值后,对第一令牌桶中的资源进行累积,此时可以控制资源流出第一令牌桶的第二流出速率小于资源流入第一令牌桶的流入速率,由于流出速率小于流入速率,持续一定时间后,第一令牌桶的剩余资源数目也可以达到预设的第一上限值。In order to ensure that resources are not wasted and to send data processing requests in a timely manner when the consumption rate of resources suddenly increases, thereby reducing processing latency, in this embodiment of the application, after the number of remaining resources in the second token bucket has reached a preset second upper limit, the resources in the first token bucket are accumulated. At this time, the second outflow rate of resources flowing out of the first token bucket can be controlled to be less than the inflow rate of resources flowing into the first token bucket. Since the outflow rate is less than the inflow rate, after a certain period of time, the number of remaining resources in the first token bucket can also reach a preset first upper limit.

因此,消耗第二令牌桶中的消耗速率小于资源流入第一令牌桶中的流入速率时,在确定资源类型对应的第二令牌桶中的剩余资源数目已达到所述预设的第二上限值之后,基于流入速率,从预设的第二流出速率区间中,选取小于流入速率的一个流出速率,作为第二流出速率,并按照第二流出速率,将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中。Therefore, when the consumption rate in the second token bucket is less than the inflow rate of resources into the first token bucket, after determining that the number of remaining resources in the second token bucket corresponding to the resource type has reached the preset second upper limit, based on the inflow rate, an outflow rate less than the inflow rate is selected from the preset second outflow rate range as the second outflow rate, and the resources already stored in the first token bucket are transferred to the corresponding second token bucket according to the second outflow rate.

其中,第二流出速率区间是由流控系统预先设置的,第二流出速率区间的下限值小于资源流入第一令牌桶中的流入速率对应的速率值,因此在第二流出速率区间中查找任一小于流入速率对应的速率值的流出速率作为第二流出速率。The second outflow rate range is preset by the flow control system. The lower limit of the second outflow rate range is less than the rate value corresponding to the inflow rate of resources into the first token bucket. Therefore, any outflow rate less than the rate value corresponding to the inflow rate is selected as the second outflow rate in the second outflow rate range.

需要说明的是,为了加快第一令牌桶中的剩余资源数目达到预设的第一上限值的时间,在第二令牌桶中的剩余资源数目达到预设的第二上限值时,优选的将第二流出速率控制为0,即不向第二令牌桶中转发资源。It should be noted that, in order to speed up the time when the number of remaining resources in the first token bucket reaches the preset first upper limit, when the number of remaining resources in the second token bucket reaches the preset second upper limit, it is preferable to control the second outflow rate to 0, that is, not to forward resources to the second token bucket.

继针对在第二令牌桶中的剩余资源数目未达到预设的第二上限值时的例子进行说明:The following example illustrates the situation where the remaining resources in the second token bucket have not reached the preset second upper limit:

设当大量的数据处理请求全部发送后,未有数据处理请求到达,此时不需要消耗第二令牌桶中的资源,因此消耗资源的速率为0资源/秒。且当前第一令牌桶中的剩余资源数目为0,第二令牌桶中的资源数目为0,资源按照5资源/秒的流入速度将生成的资源保存到第一令牌桶中。由于消耗第二令牌桶中的资源发送数据处理请求,因此需要保证第二令牌桶中存有剩余资源,故继续按照5资源/秒的第一流出速率将第一令牌桶中最新生成的资源转存至第二令牌桶中,当10秒后,第二令牌桶中的剩余资源数目达到预设的第二上限值50资源,继续转存至第二令牌桶中的资源将被丢弃,且第一令牌桶中剩余资源数目为0。Assume that after a large number of data processing requests have been sent, no further data processing requests arrive. At this point, no resources in the second token bucket need to be consumed, so the resource consumption rate is 0 resources/second. The remaining resources in both the first and second token buckets are 0. Resources are generated and stored in the first token bucket at an inflow rate of 5 resources/second. Since resources in the second token bucket are consumed when sending data processing requests, it is necessary to ensure that there are remaining resources in the second token bucket. Therefore, the latest generated resources in the first token bucket are transferred to the second token bucket at a first outflow rate of 5 resources/second. After 10 seconds, when the remaining resources in the second token bucket reach the preset second upper limit of 50 resources, any further resources transferred to the second token bucket will be discarded, and the remaining resources in the first token bucket will be 0.

从针对在第二令牌桶中的剩余资源数目未达到预设的第二上限值时的例子可知,第一令牌桶中存有剩余资源时处理数据处理请求的时延,相比较第一令牌桶中没有剩余资源时处理数据处理请求的时延小,因此为了加快处理时延以及避免资源浪费,将对第一令牌桶中的资源进行累积,要保证第一令牌桶中有资源剩余,需要保证流入速率大于第二流出速率,为了更快的使第一令牌桶中的剩余资源数目达到预设的第一上限值,优选的第二流出速率为0资源/秒,即没有资源流出第一令牌桶。As can be seen from the example of the number of remaining resources in the second token bucket not reaching the preset second upper limit, the latency of processing data processing requests is smaller when there are remaining resources in the first token bucket compared to the latency when there are no remaining resources in the first token bucket. Therefore, in order to speed up the processing and avoid resource waste, the resources in the first token bucket will be accumulated. To ensure that there are remaining resources in the first token bucket, the inflow rate needs to be greater than the second outflow rate. In order to make the number of remaining resources in the first token bucket reach the preset first upper limit more quickly, the preferred second outflow rate is 0 resources/second, that is, no resources flow out of the first token bucket.

需要说明的是,第一令牌桶对应的预设的第二上限值、第二令牌桶对应的预设的第二上限值、第一流出速率区间以及第二速率流出区间都是通过流控系统进行设置的,且第一流出速率区间和第二流出速率区间为相同区间,或者,为不同区间。It should be noted that the preset second upper limit value corresponding to the first token bucket, the preset second upper limit value corresponding to the second token bucket, the first outflow rate range, and the second outflow rate range are all set by the flow control system, and the first outflow rate range and the second outflow rate range are either the same range or different ranges.

在一种可能的实现方式中,第一令牌桶对应的预设的第二上限值、第二令牌桶对应的预设的第二上限值、流入速率、第一流出速率区间以及第二速率流出区间由存储系统通过流控系统进行设置。In one possible implementation, the preset second upper limit value corresponding to the first token bucket, the preset second upper limit value corresponding to the second token bucket, the inflow rate, the first outflow rate range, and the second outflow rate range are set by the storage system through the flow control system.

下面,以存储系统为云硬盘(Cloud Block Storage,CBS)存储系统为例,图5示例性提供了本申请实施例中一种CBS存储系统示意图;The following example uses a cloud block storage (CBS) system as an example. Figure 5 provides a schematic diagram of a CBS storage system in an embodiment of this application.

从图5中可知,CBS云硬盘是一种在云上广泛使用的分布是存储系统,单个存储集群的云盘数目超过1万块,且云盘中的资源是存储节点分配的,且云存储系统通过流控系统限制每块云盘的带宽、IOPS和吞吐量等性能参数,因此流控系统间接限制了流入速率、第一流出速率区间以及第二速率流出区间,流控系统还限制了第一令牌桶对应的第一上限值和第二令牌桶对应的第二上限值。As shown in Figure 5, CBS cloud disks are a widely used distributed storage system in the cloud. A single storage cluster has more than 10,000 cloud disks, and the resources in the cloud disks are allocated by the storage nodes. The cloud storage system limits the performance parameters of each cloud disk, such as bandwidth, IOPS, and throughput, through a flow control system. Therefore, the flow control system indirectly limits the inflow rate, the first outflow rate range, and the second outflow rate range. The flow control system also limits the first upper limit value corresponding to the first token bucket and the second upper limit value corresponding to the second token bucket.

在本申请实施例中,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中之后,第二令牌桶中保存的资源用于发送数据处理请求时使用。In this embodiment of the application, after the resources already stored in the first token bucket are transferred to the corresponding second token bucket, the resources stored in the second token bucket are used when sending data processing requests.

因此接收到客户端发送的数据处理请求时,基于数据处理请求确定发送数据处理请求时所需的目标资源,并确定目标资源的资源类型,进一步确定数据处理请求所需的目标资源关联的第二令牌桶中的剩余资源数目。Therefore, when a data processing request is received from a client, the target resource required to send the data processing request is determined based on the data processing request, the resource type of the target resource is determined, and the number of remaining resources in the second token bucket associated with the target resource required for the data processing request is further determined.

在确定了第二令牌桶中的剩余资源数目后,将第二令牌桶中的剩余资源数目与发送数据处理请求所需的目标资源数目进行比较,确定第二令牌桶中的剩余资源数目是否不小于发送数据处理资源所需的目标资源数目,即确定第二令牌桶中的剩余资源数目是否满足发送数据处理资源。After determining the number of remaining resources in the second token bucket, the number of remaining resources in the second token bucket is compared with the target number of resources required to send the data processing request. It is then determined whether the number of remaining resources in the second token bucket is not less than the target number of resources required to send the data processing request, that is, whether the number of remaining resources in the second token bucket satisfies the requirement to send the data processing request.

确定第二令牌桶中的剩余资源数目不小于发送数据处理资源所需的目标资源数目:Ensure that the number of remaining resources in the second token bucket is not less than the target number of resources required for sending data processing resources:

在确定第二令牌桶中的剩余资源数目不小于发送数据处理资源所需的目标资源数目后,将从第二令牌桶中的剩余资源中,获取符合目标资源数目的一批资源,并将一批资源分配给数据处理资源,以通过消耗一批资源发送数据处理资源。After determining that the number of remaining resources in the second token bucket is not less than the target number of resources required to send the data processing resources, a batch of resources that meet the target number will be obtained from the remaining resources in the second token bucket, and the batch of resources will be allocated to the data processing resources so as to send the data processing resources by consuming the batch of resources.

比如,发送数据处理请求所需100M带宽,此时带宽对应的第二令牌桶中的剩余带宽为200M,因此将从第二令牌桶中获取100M带宽分配给数据处理请求,以发送数据处理请求。For example, if 100M of bandwidth is required to send a data processing request, and the remaining bandwidth in the second token bucket is 200M, then 100M of bandwidth will be allocated from the second token bucket to the data processing request in order to send the data processing request.

确定第二令牌桶中的剩余资源数目小于发送数据处理资源所需的目标资源数目:It is determined that the number of remaining resources in the second token bucket is less than the target number of resources required for sending data processing resources:

在确定第二令牌桶中的剩余资源数目小于发送数据处理资源所需的目标资源数目后,此时消耗第二令牌桶中的剩余的所有资源,也无法发送数据处理请求,因此需要等待第二令牌桶中的剩余资源数目不小于发送数据处理资源所需的目标资源数目,并从第二令牌桶中的剩余资源中,获取符合目标资源数目的一批资源,并将一批资源分配给数据处理资源,以通过消耗一批资源发送数据处理资源。Once it is determined that the number of remaining resources in the second token bucket is less than the target number of resources required to send the data processing resource, consuming all the remaining resources in the second token bucket will not be able to send the data processing request. Therefore, it is necessary to wait until the number of remaining resources in the second token bucket is not less than the target number of resources required to send the data processing resource, and then obtain a batch of resources that meet the target number from the remaining resources in the second token bucket, and allocate the batch of resources to the data processing resource so as to send the data processing resource by consuming the batch of resources.

比如,发送数据处理请求所需100M带宽,此时带宽对应的第二令牌桶中的剩余带宽为50M,因此需要从第一令牌桶中转存50M带宽至第二令牌桶中后,第二令牌桶中的剩余资源不小于100M带宽时,将从第二令牌桶中获取100M带宽分配给数据处理请求,以发送数据处理请求。For example, if a data processing request requires 100M bandwidth, and the remaining bandwidth in the second token bucket is 50M, then 50M bandwidth needs to be transferred from the first token bucket to the second token bucket. If the remaining resources in the second token bucket are not less than 100M bandwidth, then 100M bandwidth will be obtained from the second token bucket and allocated to the data processing request to send the data processing request.

在本申请实施例中,处理数据处理请求的时间即等待第二令牌桶中的剩余资源数目不小于发送数据处理请求所需的目标资源数目的时间,是由第一令牌桶中的剩余资源数目和第二令牌桶中剩余资源数目决定的;In this embodiment of the application, the time for processing a data processing request, i.e., the time for waiting for the number of remaining resources in the second token bucket to be no less than the target number of resources required to send the data processing request, is determined by the number of remaining resources in the first token bucket and the number of remaining resources in the second token bucket.

当接收到大量的数据处理请求时,处理接收到的各个数据处理请求时,针对任一数据处理请求,将数据处理请求所需的目标资源数目与第二令牌桶中的剩余资源数目进行比较,并根据比较结果发送数据处理请求。When a large number of data processing requests are received, when processing each received data processing request, for any data processing request, the target number of resources required by the data processing request is compared with the number of remaining resources in the second token bucket, and the data processing request is sent according to the comparison result.

当第二令牌桶中的剩余资源数目不小于发送数据处理资源所需的目标资源数目时,可以直接从第二令牌桶中获取目标资源数目的一批资源分配给数据处理请求,并发送数据处理资源。When the number of remaining resources in the second token bucket is not less than the target number of resources required to send data processing resources, a batch of resources of the target number of resources can be directly obtained from the second token bucket, allocated to the data processing request, and the data processing resources can be sent.

当第二令牌桶中的剩余资源数目小于发送数据处理资源所需的目标资源数目,且第一令牌桶中保存的剩余资源数目不为零,此时按照大于流入速率的第一流出速率,将第一令牌桶中已保存的资源转存至第二令牌桶中,直至第二令牌桶中的剩余资源数目不小于数据处理请求所需的资源数目时,获取符合目标资源数目的一批资源分配给数据处理请求,并发送数据处理资源;When the number of remaining resources in the second token bucket is less than the target number of resources required to send data processing resources, and the number of remaining resources stored in the first token bucket is not zero, the resources stored in the first token bucket are transferred to the second token bucket at a first outflow rate greater than the inflow rate. This continues until the number of remaining resources in the second token bucket is not less than the number of resources required for the data processing request. Then, a batch of resources that meet the target number of resources is obtained, allocated to the data processing request, and the data processing resources are sent.

根据从第一令牌桶中获取资源的速率,可以确定发送数据处理请求的等待时间,因此可以确定出发送数据处理请求的速率,以及时长。Based on the rate at which resources are acquired from the first token bucket, the waiting time for sending data processing requests can be determined, thus determining the rate and duration of sending data processing requests.

当第二令牌桶中的剩余资源数目小于发送数据处理资源所需的目标资源数目,且第一令牌桶中保存的剩余资源数目为零,此时按照等于流入速率的第一流出速率,将第一令牌桶中已保存的资源转存至第二令牌桶中,直至第二令牌桶中的剩余资源数目不小于数据处理请求所需的资源数目时,获取符合目标资源数目的一批资源分配给数据处理请求,并发送数据处理资源;When the number of remaining resources in the second token bucket is less than the target number of resources required to send data processing resources, and the number of remaining resources stored in the first token bucket is zero, the resources stored in the first token bucket are transferred to the second token bucket at a first outflow rate equal to the inflow rate. This continues until the number of remaining resources in the second token bucket is not less than the number of resources required for the data processing request. Then, a batch of resources that meet the target number of resources is obtained, allocated to the data processing request, and the data processing resources are sent.

根据从第一令牌桶中获取资源的速率,可以确定发送数据处理请求的等待时间,因此可以确定出发送数据处理请求的速率,以及时长。Based on the rate at which resources are acquired from the first token bucket, the waiting time for sending data processing requests can be determined, thus determining the rate and duration of sending data processing requests.

如图6所示,图6示例性提供了本申请实施例中一种发送大量数据处理资源的时延曲图。As shown in Figure 6, Figure 6 provides an exemplary delay curve for sending a large amount of data processing resources according to an embodiment of this application.

采用极端的方式对图6进行理解,可以理解为:To understand Figure 6 in an extreme way, it can be interpreted as follows:

第一令牌桶和第二令牌桶中的剩余资源都已达到上限,当接收到大量的数据处理请求时,首先消耗了第二令牌桶中剩余的所有资源,发送数据处理请求中第一部分数据处理请求,即立即发送第一部分数据处理请求,因此发送第一部分数据处理请求的时延最短,速率P token/s最大。The remaining resources in both the first and second token buckets have reached their limits. When a large number of data processing requests are received, all the remaining resources in the second token bucket are consumed first, and the first part of the data processing request is sent. That is, the first part of the data processing request is sent immediately. Therefore, the latency of sending the first part of the data processing request is the shortest, and the rate P token/s is the maximum.

发送第一部分数据处理请求后,当接收到的数据处理请求仍存在未发送的数据处理请求时,由于第一令牌桶中的剩余资源数目不为零,按照大于流入速率的第一流出速率将第一令牌桶中的资源转存至第二令牌桶中,转存至第二令牌桶中的资源用于发送数据处理请求中第二部分数据处理请求。因此发送第二部分数据处理请求相比较第一部分数据处理请求需要等待资源符合发送数据处理请求所需的资源后,才可发送数据处理请求,需要等待时间,因此发送第二部分数据处理请求的时延Yms相比发送第一部分数据处理请求的时延Xms,处理时延增加,发送第二部分数据处理请求的速率Q token/s相对第一部分数据处理请求降低;After sending the first part of the data processing request, if there are still unsent data processing requests among the received requests, since the remaining resources in the first token bucket are not zero, the resources in the first token bucket are transferred to the second token bucket at a first outflow rate greater than the inflow rate. The resources transferred to the second token bucket are used to send the second part of the data processing request. Therefore, sending the second part of the data processing request requires waiting for the resources to meet the requirements for sending the data processing request, which requires waiting time. Thus, the latency Yms for sending the second part of the data processing request is higher than the latency Xms for sending the first part of the data processing request, resulting in increased processing latency. The rate Q token/s for sending the second part of the data processing request is lower than that for the first part of the data processing request.

需要说明的是,发送第二部分数据处理请求的速率Q token/s,即第二令牌桶的流入速率,第二令牌桶的流入速率大于第一令牌桶的流入速率,此时Q token/s大于B token/s。It should be noted that the rate at which the second part of the data processing request is sent, Q token/s, is the inflow rate of the second token bucket. The inflow rate of the second token bucket is greater than the inflow rate of the first token bucket. In this case, Q token/s is greater than B token/s.

发送第二部分数据处理请求后,当接收到的数据处理请求仍存在未发送的数据处理请求时,由于第一令牌桶中的剩余资源数目为零,按照等于流入速率的第一流出速率将第一令牌桶中的资源转存至第二令牌桶中,转存至第二令牌桶中的资源用于发送数据处理请求中第三部分数据处理请求。由于转发资源的速率降低,因此发送第三部分数据处理请求的时延Zms相比较发送第二部分数据处理请求的时延Yms,处理时延增加,发送第三部分数据处理请求的速率N token/s相对第二部分数据处理请求降低;After sending the second part of the data processing request, if there are still unsent data processing requests among the received data processing requests, since the remaining resources in the first token bucket are zero, the resources in the first token bucket are transferred to the second token bucket at a first outflow rate equal to the inflow rate. The resources transferred to the second token bucket are used to send the third part of the data processing request. Because the rate of forwarding resources is reduced, the latency Zms for sending the third part of the data processing request is increased compared to the latency Yms for sending the second part of the data processing request, resulting in an increased processing latency. The rate N tokens/s for sending the third part of the data processing request is reduced compared to the second part of the data processing request.

需要说明的是,发送第三部分数据处理请求的速率N token/s,即第二令牌桶的流入速率,第二令牌桶的流入速率等于第一令牌桶的流入速率,此时N token/s等于B token/s。It should be noted that the rate at which the third part of the data processing request is sent, N tokens/s, is the inflow rate of the second token bucket. The inflow rate of the second token bucket is equal to the inflow rate of the first token bucket. At this time, N tokens/s is equal to B tokens/s.

在本申请实施例中,当第三部分数据处理请求未发送完之前,接收到新的数据处理请求,则采用N token/s的速率处理数据处理请求的时延将持续延长。In this embodiment of the application, if a new data processing request is received before the third part of the data processing request has been sent, the latency of processing the data processing request at a rate of N tokens/s will continue to increase.

需要说明的是,第一部分数据处理请求、第二部分数据处理请求、第三部分数据处理请求的总和为接收到的大量数据处理请求。It should be noted that the sum of the first part of the data processing requests, the second part of the data processing requests, and the third part of the data processing requests constitutes the large number of data processing requests received.

在本申请中,当接收到数据处理资源时,消耗第二令牌桶中的资源发送数据处理资源,当接收到小量突发的数据处理资源时,可以通过消耗第二令牌桶中的所有资源,及时发送数据处理资源;当接收到大量突发的数据处理资源时,可以先消耗第二令牌桶中的所有资源,及时发送数据处理资源,同时按照不小于流入速率的第一流出速率及时为第二令牌桶转发资源,支持以不小于流入速率的第一流出速率处理突发的数据处理资源,减少处理时延,且能够较好的平衡共享资源的分配,避免共享资源的雪崩效应。In this application, when data processing resources are received, the resources in the second token bucket are consumed to send the data processing resources. When a small burst of data processing resources is received, all resources in the second token bucket can be consumed to send the data processing resources in a timely manner. When a large burst of data processing resources is received, all resources in the second token bucket can be consumed first to send the data processing resources in a timely manner. At the same time, resources are forwarded to the second token bucket in a timely manner at a first outflow rate not less than the inflow rate. This supports processing bursts of data processing resources at a first outflow rate not less than the inflow rate, reducing processing latency and better balancing the allocation of shared resources, avoiding the avalanche effect of shared resources.

基于同一发明构思,本申请实施例还提供了一种资源分配的装置700,如图7所示,该装置700包括:保存模块701,以及转存模块702;其中:Based on the same inventive concept, this application also provides a resource allocation device 700, as shown in FIG7. The device 700 includes: a storage module 701 and a transfer module 702; wherein:

保存模块701,用于在资源类型对应的第一令牌桶中,按照预设的流入速率保存最新生成的资源;The storage module 701 is used to store the latest generated resources in the first token bucket corresponding to the resource type according to a preset inflow rate;

转存模块702,用于在确定资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值时,按照第一流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中,第一流出速率不小于流入速率;The transfer module 702 is used to transfer the resources already saved in the first token bucket to the corresponding second token bucket according to the first outflow rate when the number of remaining resources in the second token bucket corresponding to the determined resource type has not reached the preset second upper limit value. The first outflow rate is not less than the inflow rate.

其中,第二令牌桶中保存的资源,用于分配给接收到的数据处理请求,数据处理请求所需的目标资源的资源类型包括资源类型。The resources stored in the second token bucket are used to allocate to received data processing requests. The resource type of the target resource required by the data processing request includes the resource type.

在一种可能的实现方式中,转存模块702还用于:In one possible implementation, the transfer module 702 is also used for:

在资源类型对应的第一令牌桶中,按照预设的流入速率保存最新生成的资源之后,在确定资源类型对应的第二令牌桶中的剩余资源数目已达到预设的第二上限值时,按照第二流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中,第二流出速率小于流入速率。After the newly generated resources are saved in the first token bucket corresponding to the resource type according to the preset inflow rate, when it is determined that the number of remaining resources in the second token bucket corresponding to the resource type has reached the preset second upper limit, the resources saved in the first token bucket are transferred to the corresponding second token bucket according to the second outflow rate, where the second outflow rate is less than the inflow rate.

在一种可能的实现方式中,转存模块702还用于:In one possible implementation, the transfer module 702 is also used for:

在确定资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值之后,在按照第一流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中之前,基于流入速率,从预设的第一流出速率区间中,选取不小于流入速率的一个流出速率,作为第一流出速率。After determining that the number of remaining resources in the second token bucket corresponding to the resource type has not reached the preset second upper limit, before transferring the resources already saved in the first token bucket to the corresponding second token bucket according to the first outflow rate, an outflow rate not less than the inflow rate is selected from the preset first outflow rate range based on the inflow rate as the first outflow rate.

在一种可能的实现方式中,转存模块702还用于:In one possible implementation, the transfer module 702 is also used for:

在确定资源类型对应的第二令牌桶中的剩余资源数目已达到预设的第二上限值之后,在按照第二流出速率,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中之前,基于流入速率,从预设的第二流出速率区间中,选取小于流入速率的一个流出速率,作为第二流出速率。After determining that the number of remaining resources in the second token bucket corresponding to the resource type has reached the preset second upper limit, before transferring the resources saved in the first token bucket to the corresponding second token bucket according to the second outflow rate, based on the inflow rate, an outflow rate less than the inflow rate is selected from the preset second outflow rate range as the second outflow rate.

在一种可能的实现方式中,第一流出速率区间和第二流出速率区间为相同区间,或者,为不同区间;In one possible implementation, the first outflow rate interval and the second outflow rate interval are the same interval, or they are different intervals.

第一流出速率区间以及第二流出速率区间是流控系统预先配置的。The first outflow rate range and the second outflow rate range are pre-configured by the flow control system.

在一种可能的实现方式中,转存模块702具体用于:In one possible implementation, the transfer module 702 is specifically used for:

若第二令牌桶中的剩余资源数目未达到预设的第二上限值,且第一令牌桶中的剩余资源数目不为零,则按照第一流出速率大于流入速率的方式,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中;If the number of remaining resources in the second token bucket does not reach the preset second upper limit, and the number of remaining resources in the first token bucket is not zero, then the resources already saved in the first token bucket are transferred to the corresponding second token bucket in the manner that the first outflow rate is greater than the inflow rate.

若第二令牌桶中的剩余资源数目未达到预设的第二上限值,且第一令牌桶中的剩余资源数目为零,则按照第一流出速率等于流入速率的方式,将第一令牌桶中已保存的资源转存至相应的第二令牌桶中。If the number of remaining resources in the second token bucket does not reach the preset second upper limit, and the number of remaining resources in the first token bucket is zero, then the resources already saved in the first token bucket are transferred to the corresponding second token bucket in accordance with the first outflow rate being equal to the inflow rate.

在一种可能的实现方式中,转存模块702还用于:In one possible implementation, the transfer module 702 is also used for:

接收到客户端发送的数据处理请求时,基于数据处理请求所需的目标资源的资源类型,确定目标资源关联的第二令牌桶中的剩余资源数目;When a data processing request is received from a client, the number of remaining resources in the second token bucket associated with the target resource is determined based on the resource type of the target resource required by the data processing request.

若确定第二令牌桶中的剩余资源数目不小于发送数据处理请求所需的目标资源数目,则从第二令牌桶中的剩余资源中,获取符合所述目标资源数目的一批资源;If it is determined that the number of remaining resources in the second token bucket is not less than the target number of resources required to send the data processing request, then a batch of resources that meet the target number of resources are obtained from the remaining resources in the second token bucket.

将一批资源分配给所述数据处理请求,并发送数据处理请求。Allocate a batch of resources to the data processing request and send the data processing request.

为了描述的方便,以上各部分按照功能划分为各单元(或模块)分别描述。当然,在实施本申请时可以把各单元(或模块)的功能在同一个或多个软件或硬件中实现。For ease of description, the above sections are divided into units (or modules) according to their functions and described separately. Of course, in implementing this application, the functions of each unit (or module) can be implemented in one or more software or hardware components.

在介绍了本申请示例性实施方式的资源分配的方法及装置后,接下来介绍本申请的另一示例性实施方式的资源分配的计算设备。After introducing the resource allocation method and apparatus of the exemplary embodiments of this application, the computing device for resource allocation of another exemplary embodiment of this application will be introduced next.

所属技术领域的技术人员能够理解,本申请的各个方面可以实现为系统、方法或程序产品。因此,本申请的各个方面可以具体实现为以下形式,即:完全的硬件实施方式、完全的软件实施方式(包括固件、微代码等),或硬件和软件方面结合的实施方式,这里可以统称为“电路”、“模块”或“系统”。Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

在一种可能的实现方式中,本申请实施例提供的资源分配计算设备可以至少包括处理器和存储器。其中,存储器存储有程序代码,当程序代码被处理器执行时,使得处理器执行本申请中各种示例性实施方式的资源分配方法中的任一步骤。In one possible implementation, the resource allocation computing device provided in this application embodiment may include at least a processor and a memory. The memory stores program code, which, when executed by the processor, causes the processor to perform any step of the resource allocation method in the various exemplary embodiments of this application.

下面参照图8来描述根据本申请的这种实施方式的资源分配计算设备800。如图8的资源分配计算设备800仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。The resource allocation computing device 800 according to this embodiment of the present application will now be described with reference to FIG8. The resource allocation computing device 800 of FIG8 is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present application.

如图8所示,计算设备800的组件可以包括但不限于:上述至少一个处理器801、上述至少一个存储器802、连接不同系统组件(包括存储器802和处理器801)的总线803。As shown in Figure 8, the components of the computing device 800 may include, but are not limited to: at least one processor 801, at least one memory 802, and a bus 803 connecting different system components (including memory 802 and processor 801).

总线803表示几类总线结构中的一种或多种,包括存储器总线或者存储器控制器、外围总线、处理器或者使用多种总线结构中的任意总线结构的局域总线。Bus 803 represents one or more of several bus structures, including a memory bus or memory controller, peripheral bus, processor, or a local bus using any of the various bus structures.

存储器802可以包括易失性存储器形式的可读介质,例如随机存取存储器(RAM)8021和/或高速缓存存储器8022,还可以进一步包括只读存储器(ROM)8023。The memory 802 may include a readable medium in the form of volatile memory, such as random access memory (RAM) 8021 and/or cache memory 8022, and may further include read-only memory (ROM) 8023.

存储器802还可以包括具有一组(至少一个)程序模块8024的程序/实用工具8025,这样的程序模块8024包括但不限于:操作系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。The memory 802 may also include a program/utility 8025 having a set (at least one) of program modules 8024, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

计算设备800也可以与一个或多个外部设备804(例如键盘、指向设备等)通信,还可与一个或者多个使得用户能与计算设备800交互的设备通信,和/或与使得该计算设备800能与一个或多个其它计算装置进行通信的任何设备(例如路由器、调制解调器等等)通信。这种通信可以通过输入/流出(I/O)接口805进行。并且,计算设备800还可以通过网络适配器806与一个或者多个网络(例如局域网(LAN),广域网(WAN)和/或公共网络,例如因特网)通信。如图8所示,网络适配器806通过总线803与用于计算设备800的其它模块通信。应当理解,尽管图8中未示出,可以结合计算设备800使用其它硬件和/或软件模块,包括但不限于:微代码、设备驱动器、冗余处理器、外部磁盘驱动阵列、RAID系统、磁带驱动器以及数据备份存储系统等。The computing device 800 can also communicate with one or more external devices 804 (e.g., keyboard, pointing device, etc.), one or more devices that enable a user to interact with the computing device 800, and/or any device that enables the computing device 800 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via the input/output (I/O) interface 805. Furthermore, the computing device 800 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and/or public networks, such as the Internet) via a network adapter 806. As shown in Figure 8, the network adapter 806 communicates with other modules used in the computing device 800 via a bus 803. It should be understood that, although not shown in Figure 8, other hardware and/or software modules can be used in conjunction with the computing device 800, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

在一些可能的实施方式中,本申请提供的资源分配的方法的各个方面还可以实现为一种程序产品的形式,其包括程序代码,当程序产品在计算机设备上运行时,程序代码用于使计算机设备执行本说明书上述描述的根据本申请各种示例性实施方式的资源分配的方法中的步骤。In some possible implementations, various aspects of the resource allocation method provided in this application may also be implemented in the form of a program product, which includes program code that, when the program product is run on a computer device, causes the computer device to perform the steps in the resource allocation method according to the various exemplary embodiments of this application described above.

程序产品可以采用一个或多个可读介质的任意组合。可读介质可以是可读信号介质或者可读存储介质。可读存储介质例如可以是但不限于电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

本申请的实施方式的短信息的发送控制的程序产品可以采用便携式紧凑盘只读存储器(CD-ROM)并包括程序代码,并可以在计算装置上运行。The SMS sending control program product of the embodiments of this application can be a portable compact disc read-only memory (CD-ROM) and include program code, and can run on a computing device.

可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了可读程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。可读信号介质还可以是可读存储介质以外的任何可读介质,该可读介质可以发送、传播或者传输用于由命令执行系统、装置或者器件使用或者与其结合使用的程序。A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.

可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于无线、有线、光缆、RF等等,或者上述的任意合适的组合。The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

可以以一种或多种程序设计语言的任意组合来编写用于执行本申请操作的程序代码,程序设计语言包括面向对象的程序设计语言—诸如Java、C++等,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。Program code for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages.

应当注意,尽管在上文详细描述中提及了装置的若干单元或子单元,但是这种划分仅仅是示例性的并非强制性的。实际上,根据本申请的实施方式,上文描述的两个或更多单元的特征和功能可以在一个单元中具体化。反之,上文描述的一个单元的特征和功能可以进一步划分为由多个单元来具体化。It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

此外,尽管在附图中以特定顺序描述了本申请方法的操作,但是,这并非要求或者暗示必须按照该特定顺序来执行这些操作,或是必须执行全部所示的操作才能实现期望的结果。附加地或备选地,可以省略某些步骤,将多个步骤合并为一个步骤执行,和/或将一个步骤分解为多个步骤执行。Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and/or one step may be broken down into multiple steps.

显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims (8)

1.一种资源分配的方法,其特征在于,该方法包括:1. A method for resource allocation, characterized in that the method includes: 在资源类型对应的第一令牌桶中,按照预设的流入速率保存最新生成的资源,任一资源类型设置有对应的第一令牌桶和第二令牌桶,其中,第一令牌桶和第二令牌桶中保存的资源是相同的;In the first token bucket corresponding to the resource type, the newly generated resources are stored according to the preset inflow rate. Each resource type is set with a corresponding first token bucket and a second token bucket, wherein the resources stored in the first token bucket and the second token bucket are the same. 在确定所述资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值时,按照第一流出速率,将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中,所述第一流出速率不小于所述流入速率;其中,所述第二令牌桶中保存的资源,用于分配给接收到的数据处理请求,所述数据处理请求所需的目标资源的资源类型包括所述资源类型;以使针对大量的突发请求,按照不小于流入第一令牌桶中的资源流入速率的流出速率,将所述第一令牌桶中保存的资源转存至所述第二令牌桶中;When it is determined that the number of remaining resources in the second token bucket corresponding to the resource type has not reached a preset second upper limit, the resources already stored in the first token bucket are transferred to the corresponding second token bucket according to the first outflow rate, wherein the first outflow rate is not less than the inflow rate; wherein, the resources stored in the second token bucket are used to allocate to received data processing requests, and the resource type of the target resource required by the data processing request includes the resource type; so that for a large number of burst requests, the resources stored in the first token bucket are transferred to the second token bucket at an outflow rate not less than the inflow rate of resources flowing into the first token bucket; 在确定所述资源类型对应的第二令牌桶中的剩余资源数目已达到所述预设的第二上限值时,按照第二流出速率,将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中,所述第二流出速率小于所述流入速率;以使针对小量的突发请求,通过消耗所述第二令牌桶中的剩余资源及时处理,形成按时间递减的梯度控制策略。When it is determined that the number of remaining resources in the second token bucket corresponding to the resource type has reached the preset second upper limit, the resources already stored in the first token bucket are transferred to the corresponding second token bucket according to the second outflow rate, where the second outflow rate is less than the inflow rate; so that small burst requests can be processed in a timely manner by consuming the remaining resources in the second token bucket, forming a gradient control strategy that decreases over time. 2.如权利要求1所述的方法,其特征在于,所述在确定所述资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值之后,在按照第一流出速率,将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中之前,还包括:2. The method as described in claim 1, characterized in that, after determining that the number of remaining resources in the second token bucket corresponding to the resource type has not reached a preset second upper limit value, and before transferring the resources already stored in the first token bucket to the corresponding second token bucket according to the first outflow rate, the method further includes: 基于所述流入速率,从预设的第一流出速率区间中,选取不小于所述流入速率的一个流出速率,作为所述第一流出速率;Based on the inflow rate, an outflow rate not less than the inflow rate is selected from a preset first outflow rate range as the first outflow rate; 在确定所述资源类型对应的第二令牌桶中的剩余资源数目已达到所述预设的第二上限值之后,在按照第二流出速率,将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中之前,还包括:After determining that the number of remaining resources in the second token bucket corresponding to the resource type has reached the preset second upper limit, and before transferring the resources already stored in the first token bucket to the corresponding second token bucket according to the second outflow rate, the process further includes: 基于所述流入速率,从预设的第二流出速率区间中,选取小于所述流入速率的一个流出速率,作为所述第二流出速率。Based on the inflow rate, an outflow rate less than the inflow rate is selected from a preset second outflow rate range as the second outflow rate. 3.如权利要求2所述的方法,其特征在于,所述第一流出速率区间和所述第二流出速率区间为相同区间,或者,为不同区间;3. The method as described in claim 2, wherein the first outflow rate interval and the second outflow rate interval are the same interval or are different intervals; 所述第一流出速率区间以及所述第二流出速率区间是流控系统预先配置的。The first outflow rate range and the second outflow rate range are pre-configured by the flow control system. 4.如权利要求1所述的方法,其特征在于,所述在确定所述资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值时,按照第一流出速率,将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中,具体包括:4. The method as described in claim 1, characterized in that, when it is determined that the number of remaining resources in the second token bucket corresponding to the resource type has not reached a preset second upper limit, the resources already stored in the first token bucket are transferred to the corresponding second token bucket according to the first outflow rate, specifically including: 若所述第二令牌桶中的剩余资源数目未达到预设的第二上限值,且所述第一令牌桶中的剩余资源数目不为零,则按照所述第一流出速率大于所述流入速率的方式,将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中;If the number of remaining resources in the second token bucket does not reach the preset second upper limit value, and the number of remaining resources in the first token bucket is not zero, then the resources already saved in the first token bucket are transferred to the corresponding second token bucket in the manner that the first outflow rate is greater than the inflow rate. 若所述第二令牌桶中的剩余资源数目未达到预设的第二上限值,且所述第一令牌桶中的剩余资源数目为零,则按照所述第一流出速率等于所述流入速率的方式,将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中。If the number of remaining resources in the second token bucket does not reach the preset second upper limit value, and the number of remaining resources in the first token bucket is zero, then the resources already saved in the first token bucket are transferred to the corresponding second token bucket in a manner that the first outflow rate is equal to the inflow rate. 5.如权利要求1所述的方法,其特征在于,所述将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中之后,还包括:5. The method as described in claim 1, characterized in that, after transferring the resources already stored in the first token bucket to the corresponding second token bucket, it further includes: 接收到客户端发送的数据处理请求时,基于所述数据处理请求所需的目标资源的资源类型,确定所述目标资源关联的第二令牌桶中的剩余资源数目;When a data processing request is received from a client, the number of remaining resources in the second token bucket associated with the target resource is determined based on the resource type of the target resource required by the data processing request. 若确定所述第二令牌桶中的剩余资源数目不小于发送所述数据处理请求所需的目标资源数目,则从所述第二令牌桶中的剩余资源中,获取符合所述目标资源数目的一批资源;If it is determined that the number of remaining resources in the second token bucket is not less than the target number of resources required to send the data processing request, then a batch of resources that meet the target number of resources are obtained from the remaining resources in the second token bucket. 将所述一批资源分配给所述数据处理请求,并发送所述数据处理请求。Allocate the batch of resources to the data processing request and send the data processing request. 6.一种资源分配的装置,其特征在于,该装置包括:6. A resource allocation apparatus, characterized in that the apparatus comprises: 保存模块,用于在资源类型对应的第一令牌桶中,按照预设的流入速率保存最新生成的资源,任一资源类型设置有对应的第一令牌桶和第二令牌桶,其中,第一令牌桶和第二令牌桶中保存的资源是相同的;The storage module is used to store the latest generated resources in the first token bucket corresponding to the resource type according to a preset inflow rate. Each resource type is set with a corresponding first token bucket and a second token bucket, wherein the resources stored in the first token bucket and the second token bucket are the same. 转存模块,用于在确定所述资源类型对应的第二令牌桶中的剩余资源数目未达到预设的第二上限值时,按照第一流出速率,将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中,所述第一流出速率不小于所述流入速率;以使针对大量的突发请求,按照不小于流入第一令牌桶中的资源流入速率的流出速率,将所述第一令牌桶中保存的资源转存至所述第二令牌桶中;The transfer module is used to transfer the resources already stored in the first token bucket to the corresponding second token bucket according to a first outflow rate when it is determined that the number of remaining resources in the second token bucket corresponding to the resource type has not reached a preset second upper limit value. The first outflow rate is not less than the inflow rate. This is to enable the transfer of resources stored in the first token bucket to the second token bucket at an outflow rate not less than the inflow rate of resources flowing into the first token bucket in response to a large number of sudden requests. 其中,所述第二令牌桶中保存的资源,用于分配给接收到的数据处理请求,所述数据处理请求所需的目标资源符合所述资源类型;The resources stored in the second token bucket are used to allocate to received data processing requests, wherein the target resources required by the data processing requests conform to the resource type. 所述转存模块还用于:The transfer module is also used for: 在所述资源类型对应的第一令牌桶中,按照预设的流入速率保存最新生成的资源之后,在确定所述资源类型对应的第二令牌桶中的剩余资源数目已达到所述预设的第二上限值时,按照第二流出速率,将所述第一令牌桶中已保存的资源转存至相应的第二令牌桶中,所述第二流出速率小于所述流入速率;以使针对小量的突发请求,通过消耗所述第二令牌桶中的剩余资源及时处理,形成按时间递减的梯度控制策略。After the newly generated resources are saved in the first token bucket corresponding to the resource type at a preset inflow rate, when it is determined that the number of remaining resources in the second token bucket corresponding to the resource type has reached the preset second upper limit, the resources saved in the first token bucket are transferred to the corresponding second token bucket at a second outflow rate, wherein the second outflow rate is less than the inflow rate; so that small burst requests can be processed in a timely manner by consuming the remaining resources in the second token bucket, forming a gradient control strategy that decreases over time. 7.一种资源分配的设备,其特征在于,该设备包括:存储器和处理器,其中,存储器,用于存储计算机指令;处理器,用于执行计算机指令以实现如权利要求1-5任一所述的方法。7. A resource allocation device, characterized in that the device comprises: a memory and a processor, wherein the memory is used to store computer instructions; and the processor is used to execute the computer instructions to implement the method as described in any one of claims 1-5. 8.一种计算机可读存储介质,其特征在于,计算机可读存储介质存储有计算机指令,计算机指令被处理器执行时实现如权利要求1-5任一所述的方法。8. A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer instructions, which, when executed by a processor, implement the method as described in any one of claims 1-5.
HK42021033049.4A 2021-06-11 Resource allocation method, device and storage medium HK40042985B (en)

Publications (2)

Publication Number Publication Date
HK40042985A HK40042985A (en) 2021-09-10
HK40042985B true HK40042985B (en) 2024-05-31

Family

ID=

Similar Documents

Publication Publication Date Title
US11221975B2 (en) Management of shared resources in a software-defined storage environment
JP6290462B2 (en) Coordinated admission control for network accessible block storage
JP5744707B2 (en) Computer-implemented method, computer program, and system for memory usage query governor (memory usage query governor)
US10235047B2 (en) Memory management method, apparatus, and system
US10140236B2 (en) Receiving buffer credits by a plurality of channels of one or more host computational devices for transmitting data to a control unit
CN112600761B (en) Resource allocation method, device and storage medium
CN111190745B (en) A data processing method, device and computer-readable storage medium
CN103562872B (en) The resource allocation of multiple resources of Dual Action system
US10489208B1 (en) Managing resource bursting
WO2013029487A1 (en) Resource allocation method and resource management platform
WO2024016596A1 (en) Container cluster scheduling method and apparatus, device, and storage medium
CN107729559A (en) Method, system, equipment and the storage medium of data base read-write asynchronous access
CN113254095B (en) Task unloading, scheduling and load balancing system and method for cloud edge combined platform
CN112346871A (en) Request processing method and micro-service system
CN114785739B (en) Logical volume service quality control method, device, equipment and medium
CN109002364A (en) Optimization method, electronic device and the readable storage medium storing program for executing of interprocess communication
US11709707B2 (en) Low latency distributed counters for quotas
WO2020259208A1 (en) Memory scheduling method and apparatus, device and storage medium
US20110307636A1 (en) Method and apparatus for dynamically allocating queue depth by initiator
WO2025252044A1 (en) Method for processing storage task, and related device
US11442629B2 (en) I/O performance in a storage system
CN114489463A (en) Method and device for dynamically adjusting QOS (quality of service) of storage volume and computing equipment
HK40042985B (en) Resource allocation method, device and storage medium
CN115914236A (en) Storage space allocation and adjustment method, device, electronic device and storage medium
HK40042985A (en) Resource allocation method, device and storage medium