[go: up one dir, main page]

CN117979047A - Media resource allocation method, system and storage medium for live broadcast - Google Patents

Media resource allocation method, system and storage medium for live broadcast Download PDF

Info

Publication number
CN117979047A
CN117979047A CN202410135594.0A CN202410135594A CN117979047A CN 117979047 A CN117979047 A CN 117979047A CN 202410135594 A CN202410135594 A CN 202410135594A CN 117979047 A CN117979047 A CN 117979047A
Authority
CN
China
Prior art keywords
live broadcast
service
target
target live
hash ring
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410135594.0A
Other languages
Chinese (zh)
Inventor
孔祥博
杨磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongke Shitong Hengqi Beijing Technology Co ltd
Original Assignee
Zhongke Shitong Hengqi Beijing Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhongke Shitong Hengqi Beijing Technology Co ltd filed Critical Zhongke Shitong Hengqi Beijing Technology Co ltd
Priority to CN202410135594.0A priority Critical patent/CN117979047A/en
Publication of CN117979047A publication Critical patent/CN117979047A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/21Server components or server architectures
    • H04N21/218Source of audio or video content, e.g. local disk arrays
    • H04N21/2187Live feed
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/24Monitoring of processes or resources, e.g. monitoring of server load, available bandwidth, upstream requests
    • H04N21/2408Monitoring of the upstream path of the transmission network, e.g. client requests
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/25Management operations performed by the server for facilitating the content distribution or administrating data related to end-users or client devices, e.g. end-user or client device authentication, learning user preferences for recommending movies
    • H04N21/262Content or additional data distribution scheduling, e.g. sending additional data at off-peak times, updating software modules, calculating the carousel transmission frequency, delaying a video stream transmission, generating play-lists
    • H04N21/26208Content or additional data distribution scheduling, e.g. sending additional data at off-peak times, updating software modules, calculating the carousel transmission frequency, delaying a video stream transmission, generating play-lists the scheduling operation being performed under constraints

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

本公开提供一种用于直播的媒体资源分配方法、系统、存储介质及电子设备。方法包括:获取多个直播业务,根据业务类型对多个直播业务进行分组,得到多个业务组;根据业务类型,为目标业务组分配初始权重;根据初始权重,将目标业务组生成一致性哈希环,一致性哈希环包括与目标直播业务对应的虚拟节点;通过检测虚拟节点的数量,得到目标直播业务上客户端的连接数量,当连接数量达到阈值时,启动目标直播业务的评估机制;基于目标直播业务的运行状态,评估机制生成状态评分;根据状态评分和初始权重生成动态权重;基于动态权重,构建重设哈希环;根据重设哈希环上的节点分配媒体资源。解决了在直播时媒体资源的均衡负载和分配的问题。

The present disclosure provides a method, system, storage medium and electronic device for allocating media resources for live broadcast. The method includes: obtaining multiple live broadcast services, grouping the multiple live broadcast services according to the service type to obtain multiple service groups; assigning initial weights to the target service group according to the service type; generating a consistent hash ring for the target service group according to the initial weight, and the consistent hash ring includes virtual nodes corresponding to the target live broadcast service; by detecting the number of virtual nodes, the number of connections of the client on the target live broadcast service is obtained, and when the number of connections reaches a threshold, the evaluation mechanism of the target live broadcast service is started; based on the running status of the target live broadcast service, the evaluation mechanism generates a status score; based on the status score and the initial weight, a dynamic weight is generated; based on the dynamic weight, a reset hash ring is constructed; and media resources are allocated according to the nodes on the reset hash ring. The problem of balanced load and allocation of media resources during live broadcast is solved.

Description

用于直播的媒体资源分配方法、系统、存储介质Media resource allocation method, system and storage medium for live broadcast

技术领域Technical Field

本公开涉及计算机技术领域,尤其涉及一种用于直播的媒体资源分配方法、系统、存储介质。The present disclosure relates to the field of computer technology, and in particular to a media resource allocation method, system, and storage medium for live broadcasting.

背景技术Background technique

在一般的互动直播中,观看直播的客户端连接到服务端,调度服务会根据服务集群配置的相关资源计算,返回给客户端最佳的媒体服务接入点。因为媒体服务器相关配置不同,承载能力也不相同,需要一种调度算法去平衡不同媒体服务器的资源分配。In general interactive live broadcast, the client watching the live broadcast connects to the server, and the scheduling service calculates the relevant resources configured in the service cluster and returns the best media service access point to the client. Because the relevant configurations of media servers are different and the carrying capacity is also different, a scheduling algorithm is needed to balance the resource allocation of different media servers.

现有的调度算法,如:轮询法、随机法、最小负载法、最少连接法、一致性哈希法等方式,因为没有充分考虑媒体服务器实时负载情况,存在无法保证媒体资源服务的均衡负载和分配的问题。Existing scheduling algorithms, such as polling, randomization, minimum load, least connection, consistent hashing, etc., do not fully consider the real-time load of the media server, and therefore cannot guarantee the balanced load and distribution of media resource services.

发明内容Summary of the invention

有鉴于此,本公开的目的在于提出一种用于直播的媒体资源分配方法、系统、存储介质及电子设备,解决了在直播时媒体资源的均衡负载和分配的问题。In view of this, the purpose of the present disclosure is to propose a media resource allocation method, system, storage medium and electronic device for live broadcast, which solves the problem of balanced load and allocation of media resources during live broadcast.

为了实现上述公开目的之一,本公开提供了一种用于直播的媒体资源分配方法,所述方法包括:In order to achieve one of the above disclosed purposes, the present disclosure provides a method for allocating media resources for live broadcasting, the method comprising:

获取多个直播业务,根据业务类型对多个所述直播业务进行分组,得到业务组;Acquire multiple live broadcast services, and group the multiple live broadcast services according to service types to obtain a service group;

根据所述业务类型,为目标业务组分配初始权重;According to the business type, assigning an initial weight to the target business group;

根据所述初始权重,将目标业务组生成一致性哈希环,所述一致性哈希环包括与所述目标直播业务对应的虚拟节点,所述目标直播业务为所述目标业务组中的直播业务;According to the initial weight, generating a consistent hash ring for the target service group, the consistent hash ring including a virtual node corresponding to the target live service, the target live service being a live service in the target service group;

通过检测所述虚拟节点的数量,得到所述目标直播业务上客户端的连接数量,当所述连接数量达到阈值时,启动所述目标直播业务的评估机制;By detecting the number of the virtual nodes, the number of client connections on the target live broadcast service is obtained, and when the number of connections reaches a threshold, an evaluation mechanism of the target live broadcast service is started;

基于所述目标直播业务的运行状态,所述评估机制生成状态评分;Based on the running status of the target live broadcast service, the evaluation mechanism generates a status score;

根据状态评分和所述初始权重生成动态权重;generating a dynamic weight according to the state score and the initial weight;

基于所述动态权重,构建重设哈希环;Based on the dynamic weight, construct a reset hash ring;

根据所述重设一致性哈希环上的节点分配媒体资源。Media resources are allocated according to the nodes on the reset consistent hashing ring.

作为本公开一实施方式的进一步改进,所述根据初始权重,将目标业务组生成一致性哈希环,所述一致性哈希环包括与所述目标直播业务对应的虚拟节点,包括:As a further improvement of an implementation mode of the present disclosure, the target service group is generated into a consistent hash ring according to the initial weight, and the consistent hash ring includes a virtual node corresponding to the target live service, including:

计算所述初始权重和所述虚拟节点的基数的乘积;Calculating the product of the initial weight and the cardinality of the virtual node;

设置所述目标直播业务在所述一致性哈希环上对应的所述虚拟节点的数量;Set the number of the virtual nodes corresponding to the target live broadcast service on the consistent hash ring;

将所述目标直播业务生成的虚拟节点映射到一致性哈希环上。The virtual nodes generated by the target live broadcast service are mapped to the consistent hash ring.

作为本公开一实施方式的进一步改进,所述基于所述目标直播业务的运行状态,所述评估机制生成状态评分,包括:As a further improvement of an embodiment of the present disclosure, the evaluation mechanism generates a status score based on the running status of the target live broadcast service, including:

获取所述目标直播业务的运行状态;Obtaining the running status of the target live broadcast service;

处理所述目标直播业务的运行状态,得到所述目标直播业务的实际负载均值;Processing the running status of the target live broadcast service to obtain an actual load average of the target live broadcast service;

预设负载均值和分段分数的对应关系;Preset the corresponding relationship between load mean and segment score;

匹配所述实际负载均值和所述对应关系,得到所述目标直播业务的状态评分。The actual load mean value and the corresponding relationship are matched to obtain a status score of the target live broadcast service.

作为本公开一实施方式的进一步改进,所述根据状态评分和所述初始权重生成动态权重,包括:As a further improvement of an embodiment of the present disclosure, the generating of the dynamic weight according to the state score and the initial weight includes:

分别分配所述状态评分和所述初始权重的计算比例;respectively allocating the calculation ratios of the state score and the initial weight;

按所述计算比例计算所述状态评分和所述初始权重,得到所述动态权重;Calculate the state score and the initial weight according to the calculation ratio to obtain the dynamic weight;

其中,所述动态权重小于所述初始权重。Wherein, the dynamic weight is smaller than the initial weight.

作为本公开一实施方式的进一步改进,所述得到所述目标直播业务上客户端的连接数量之后,还包括:As a further improvement of an implementation mode of the present disclosure, after obtaining the number of connections of the client on the target live broadcast service, the method further includes:

所述连接数量未超过阈值,则判断目标直播业务的负载是否均匀;If the number of connections does not exceed the threshold, it is determined whether the load of the target live broadcast service is uniform;

响应于所述负载不均匀,根据实际负载设置临时权重;In response to the uneven load, setting a temporary weight according to the actual load;

基于所述临时权重,构建重设哈希环。Based on the temporary weights, a reset hash ring is constructed.

作为本公开一实施方式的进一步改进,所述临时权重的优先级大于所述动态权重的优先级,所述动态权重的优先级大于所述初始权重的优先级。As a further improvement of an embodiment of the present disclosure, the priority of the temporary weight is greater than the priority of the dynamic weight, and the priority of the dynamic weight is greater than the priority of the initial weight.

作为本公开一实施方式的进一步改进,所述目标直播业务的运行状态包括CPU核心数、当前内存占用情况、当前带宽使用情况和当前用户数量其中至少一项。As a further improvement of an implementation mode of the present disclosure, the running status of the target live broadcast service includes at least one of the number of CPU cores, current memory occupancy, current bandwidth usage and the current number of users.

基于相同的发明构思,本公开还提供了一种用于直播的媒体资源分配系统,包括:Based on the same inventive concept, the present disclosure also provides a media resource allocation system for live broadcast, including:

第一获取模块,用于获取多个直播业务,根据业务类型对多个所述直播业务进行分组,得到业务组;A first acquisition module is used to acquire multiple live broadcast services, and group the multiple live broadcast services according to service types to obtain a service group;

第一分配模块,用于根据所述业务类型,为目标业务组分配初始权重;A first allocation module, configured to allocate an initial weight to a target service group according to the service type;

第一生成模块,用于根据所述初始权重,将目标业务组生成单独的一致性哈希环,所述一致性哈希环包括与所述目标直播业务一一对应的虚拟节点,所述目标直播业务为所述目标业务组中的直播业务;A first generating module is used to generate a separate consistent hash ring for the target service group according to the initial weight, wherein the consistent hash ring includes virtual nodes corresponding to the target live service one by one, and the target live service is a live service in the target service group;

检测模块,用于通过检测所述虚拟节点的数量,得到所述目标直播业务上的客户端连接数量,当所述连接数量达到阈值时,启动所述目标直播业务的评估机制;A detection module, configured to obtain the number of client connections on the target live broadcast service by detecting the number of the virtual nodes, and start an evaluation mechanism for the target live broadcast service when the number of connections reaches a threshold;

第二生成模块,用于基于所述目标直播业务的运行状态,所述评估机制生成状态评分;A second generating module, configured to generate a status score based on the running status of the target live broadcast service by the evaluation mechanism;

第三生成模块,根据状态评分和所述初始权重生成动态权重;A third generation module generates a dynamic weight according to the state score and the initial weight;

构建模块,用于基于所述动态权重,构建重设哈希环;A construction module, for constructing a reset hash ring based on the dynamic weight;

第二分配模块,用于根据所述重设一致性哈希环上的节点分配媒体资源。The second allocation module is used to allocate media resources according to the nodes on the reset consistent hash ring.

基于同样的发明构思,本公开还提供了一种非暂态计算机可读存储介质,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令用于使计算机执行上述任一所述的用于直播的媒体资源分配方法。Based on the same inventive concept, the present disclosure also provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute any of the above-mentioned media resource allocation methods for live broadcast.

基于同样的发明构思,本公开还提供了一种电子设备,包括:处理器和存储器;所述存储器存储有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行如上述任一所述用于直播的媒体资源分配方法的步骤。Based on the same inventive concept, the present disclosure also provides an electronic device, including: a processor and a memory; the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any of the above-mentioned media resource allocation methods for live broadcast.

相对于现有技术,本发明的技术效果在于:本公开将观看人数相差较大的直播业务进行分类,避免不同的直播业务之间媒体资源分配的差距过大;通过实时的综合评估目标直播业务,结合预设的初始权重和实时更新的状态评分,对目标直播业务进行节点分配,保证目标直播业务资源不过载,不空闲,节省了目标直播业务的资源,保证直播过程的稳定性和质量要求。Compared with the prior art, the technical effect of the present invention is that: the present invention classifies live broadcast services with large differences in the number of viewers, so as to avoid excessive differences in the allocation of media resources between different live broadcast services; through real-time comprehensive evaluation of the target live broadcast service, combined with the preset initial weight and the real-time updated status score, the target live broadcast service is allocated nodes to ensure that the resources of the target live broadcast service are not overloaded or idle, thus saving the resources of the target live broadcast service and ensuring the stability and quality requirements of the live broadcast process.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本公开或相关技术中的技术方案,下面将对实施方式或相关技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本公开的实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the present disclosure or related technologies, the drawings required for use in the implementation methods or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only implementation methods of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

图1为本公开一实施方式提供的一种用于直播的媒体资源分配方法流程图;FIG1 is a flow chart of a method for allocating media resources for live broadcasting provided by an embodiment of the present disclosure;

图2为本公开另一实施方式提供的构建一致性哈希环的流程图;FIG2 is a flowchart of constructing a consistent hash ring provided by another embodiment of the present disclosure;

图3为本公开另一实施方式提供的增设临时权重的流程图;FIG3 is a flow chart of adding temporary weights provided by another embodiment of the present disclosure;

图4为本公开另一实施方式提供的得到状态评分的流程图;FIG4 is a flow chart of obtaining a status score provided by another embodiment of the present disclosure;

图5为本公开另一实施方式提供的得到动态权重的流程图;FIG5 is a flow chart of obtaining dynamic weights provided by another embodiment of the present disclosure;

图6为本公开另一实施方式提供的用于直播的媒体资源分配方法流程图;FIG6 is a flow chart of a method for allocating media resources for live broadcasting provided by another embodiment of the present disclosure;

图7为本公开另一实施方式提供的用于直播的媒体资源分配的示意图;FIG7 is a schematic diagram of media resource allocation for live broadcasting provided by another embodiment of the present disclosure;

图8为本公开实施方式提供的一种电子设备硬件结构示意图。FIG8 is a schematic diagram of a hardware structure of an electronic device provided in an embodiment of the present disclosure.

具体实施方式Detailed ways

以下将结合附图所示的具体实施方式对本发明进行详细描述。但这些实施方式并不限制本发明,本领域的普通技术人员根据这些实施方式所做出的结构、方法、或功能上的变换均包含在本发明的保护范围内。The present invention will be described in detail below in conjunction with the specific embodiments shown in the accompanying drawings. However, these embodiments do not limit the present invention, and any structural, methodological, or functional changes made by a person skilled in the art based on these embodiments are all within the scope of protection of the present invention.

实施方式需要说明的是,除非另外定义,本公开实施方式使用的技术术语或者科学术语应当为本公开所属领域内具有一般技能的人士所理解的通常意义。本公开实施方式中使用的“第一”、“第二”以及类似的词语并不表示任何顺序、数量或者重要性,而只是用来区分不同的组成部分。“包括”或者“包含”等类似的词语意指出现该词前面的元件或者物件涵盖出现在该词后面列举的元件或者物件及其等同,而不排除其他元件或者物件。Embodiments It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the embodiments of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprising" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects.

现有的直播业务中的媒体资源分配具有多个问题:(1)不同的业务使用的媒体资源不同,比如有的业务参与直播互动的人数比较少,有的业务参与直播互动的人数多到上千人,因此不同直播业务占用的媒体资源差异较大,无法精确的分配资源。(2)媒体CPU核心数或内存等不同,导致承载能力不同,无法适当的进行资源分配。(3)当媒体资源服务进行动态扩容时,服务资源如果使用轮询法或随机法,则无法迅速为服务集群进行分担。(4)如遇到特殊情况,比如服务异常等,媒体服务负载差异较大需要人工介入时,现在负载均衡策略也无法满足。There are many problems with the allocation of media resources in existing live broadcast services: (1) Different services use different media resources. For example, some services have relatively few people participating in live broadcast interactions, while others have up to thousands of people participating in live broadcast interactions. Therefore, the media resources occupied by different live broadcast services vary greatly, and resources cannot be accurately allocated. (2) The number of media CPU cores or memory varies, resulting in different carrying capacities, making it impossible to allocate resources appropriately. (3) When the media resource service is dynamically expanded, if the service resources use polling or random methods, they cannot be quickly shared by the service cluster. (4) In special circumstances, such as service anomalies, when the media service load varies greatly and requires manual intervention, the current load balancing strategy cannot meet the requirements.

本公开实施方式提供一种用于直播的媒体资源分配方法,如图1所示,用于直播的媒体资源分配方法包括如下步骤:The embodiment of the present disclosure provides a method for allocating media resources for live broadcasting. As shown in FIG1 , the method for allocating media resources for live broadcasting includes the following steps:

步骤S100,获取多个直播业务,根据业务类型对多个所述直播业务进行分组,得到业务组。Step S100, obtaining multiple live broadcast services, and grouping the multiple live broadcast services according to service types to obtain a service group.

具体的,负载策略需要根据业务类型进行服务节点分配,不同类型的直播业务或不同级别的直播业务之间的观看人数差距较大,同时为了做业务隔离,对于直播类型或观看数量相近的直播业务进行分组,分到同一个业务组中,在同一个业务组中分配媒体资源。避免负载差距过大的目标直播业务共同分配媒体资源。Specifically, the load strategy needs to allocate service nodes according to the business type. The number of viewers of different types of live broadcast services or different levels of live broadcast services varies greatly. At the same time, in order to isolate the services, live broadcast services with similar types or similar number of viewers are grouped and assigned to the same business group, and media resources are allocated to the same business group. This avoids the target live broadcast services with large load differences from jointly allocating media resources.

步骤S200,根据所述业务类型,为目标业务组分配初始权重。Step S200: assigning an initial weight to the target service group according to the service type.

具体的,根据目标业务组的整体配置和服务性能分配初始化权重。其中的整体配置和服务性能包括但不限于观看数量级,预设的直播视频质量要求,CPU资源、内存和设置的质量参数等。Specifically, the initialization weight is allocated according to the overall configuration and service performance of the target service group, wherein the overall configuration and service performance include but are not limited to the viewing level, the preset live video quality requirements, CPU resources, memory and set quality parameters, etc.

步骤S300,根据所述初始权重,每个业务组生成单独的一致性哈希环,所述一致性哈希环包括与所述目标直播业务对应的虚拟节点。Step S300: Based on the initial weight, each service group generates a separate consistent hash ring, and the consistent hash ring includes a virtual node corresponding to the target live broadcast service.

具体的,对于分布式存储,不同机器上存储不同对象的数据,我们使用哈希函数建立从数据到服务器之间的映射关系。一致性哈希环是一种虚拟环结构,将整个哈希值空间组织成一个虚拟的圆环,通过哈希函数将节点映射到一致性哈希环上,从而每个节点就能确定其在一致性哈希环上的位置。Specifically, for distributed storage, different machines store data of different objects. We use hash functions to establish a mapping relationship from data to servers. The consistent hash ring is a virtual ring structure that organizes the entire hash value space into a virtual ring. The nodes are mapped to the consistent hash ring through the hash function, so that each node can determine its position on the consistent hash ring.

哈希环具有一定的平衡性、单调性、平滑性和稳定性。其中平衡性是指一致性哈希环尽可能让数据尽可能分散到所有节点上,避免造成极其不均匀;单调性是指要求在新增或者减少节点的时候,原有的结果绝大部分不受影响,而新增的数据尽可能分配到新加的节点;平衡性是指对于增加节点或者减少节点,应该能够平滑过渡;稳定性是指当某个节点宕机时,只有该节点的数据会被重新定位到其他节点,从而只需要迁移该节点的数据即可。The hash ring has certain balance, monotonicity, smoothness and stability. Balance means that the consistent hash ring distributes data to all nodes as much as possible to avoid extremely uneven distribution; monotonicity means that when adding or reducing nodes, the original results are mostly unaffected, and the new data is distributed to the newly added nodes as much as possible; balance means that there should be a smooth transition for adding or reducing nodes; stability means that when a node goes down, only the data of that node will be relocated to other nodes, so only the data of that node needs to be migrated.

本公开一种可实现方式中,对于步骤S300,如图2所示,还包括:In one possible implementation of the present disclosure, step S300, as shown in FIG2 , further includes:

步骤S310,计算初始权重和虚拟节点的基数的乘积;Step S310, calculating the product of the initial weight and the cardinality of the virtual node;

步骤S320,设置目标直播业务在所述一致性哈希环上对应的所述虚拟节点的数量;Step S320, setting the number of the virtual nodes corresponding to the target live broadcast service on the consistent hash ring;

步骤S330,将所述目标直播业务生成的虚拟节点映射到一致性哈希环上。Step S330, mapping the virtual nodes generated by the target live broadcast service to the consistent hash ring.

具体的,当构建一致性哈希环时,根据初始权重与虚拟节点基数相乘所得结果,设置目标直播业务在一致性哈希环上对应的虚拟节点的数量,并按照设置数量将目标直播业务生成的虚拟节点映射到一致性哈希环上。Specifically, when building a consistent hash ring, the number of virtual nodes corresponding to the target live broadcast service on the consistent hash ring is set according to the result obtained by multiplying the initial weight by the virtual node base, and the virtual nodes generated by the target live broadcast service are mapped to the consistent hash ring according to the set number.

需要说明得是,其中虚拟节点的基数是指一个实际节点对应了若干个虚拟节点的数量。引入虚拟节点的目的是为了解决一致性哈希环中节点数量较少导致的数据分布不均匀问题。通过增加虚拟节点的数量,可以提高哈希环上节点的分布密度,从而提高数据分布的均匀性。It should be noted that the cardinality of virtual nodes refers to the number of virtual nodes corresponding to one actual node. The purpose of introducing virtual nodes is to solve the problem of uneven data distribution caused by a small number of nodes in the consistent hash ring. By increasing the number of virtual nodes, the distribution density of nodes on the hash ring can be increased, thereby improving the uniformity of data distribution.

步骤S400,通过检测所述虚拟节点的数量,得到所述目标直播业务上客户端的连接数量,当所述连接数量达到阈值时,启动所述目标直播业务的评估机制。Step S400, by detecting the number of the virtual nodes, the number of client connections on the target live broadcast service is obtained, and when the number of connections reaches a threshold, an evaluation mechanism for the target live broadcast service is started.

具体的,虚拟节点的数量和目标直播业务中客户端的连接数量对应,更具体为,虚拟节点的数量和目标直播业务中客户端的连接数量一一对应;根据不同的业务类型,为客户端的连接数量设定一个阈值,在未超过阈值时,初始权重即可代表该目标直播业务所占用的负载,当连接数量超过阈值时,则需要再启动目标直播业务的评估机制,重新分配媒体资源。Specifically, the number of virtual nodes corresponds to the number of client connections in the target live broadcast service, more specifically, the number of virtual nodes corresponds to the number of client connections in the target live broadcast service one by one; according to different service types, a threshold is set for the number of client connections. When the threshold is not exceeded, the initial weight can represent the load occupied by the target live broadcast service. When the number of connections exceeds the threshold, it is necessary to restart the evaluation mechanism of the target live broadcast service and reallocate media resources.

本公开一种可实现方式中,对于步骤S400之后,如图3所示,还包括:In one possible implementation of the present disclosure, after step S400, as shown in FIG3 , the following is further included:

步骤S401,所述连接数量未超过阈值,则判断目标直播业务的负载是否均匀;Step S401, if the number of connections does not exceed the threshold, it is determined whether the load of the target live broadcast service is uniform;

步骤S402,响应于所述负载不均匀,根据实际负载设置临时权重;Step S402, in response to the uneven load, setting a temporary weight according to the actual load;

步骤S403,基于所述临时权重,构建重设一致性哈希环。Step S403: construct a reset consistent hash ring based on the temporary weight.

具体的,本实施例中引入了临时权重的概念,默认情况下临时权重不起作用,即目标直播业务的负载均匀分布时,属于默认情况;当目标直播业务遇到特殊极端情况时,会导致负载不均匀时,可按照负载需求调整临时权重。Specifically, the concept of temporary weights is introduced in this embodiment. By default, temporary weights do not work, that is, when the load of the target live broadcast service is evenly distributed, it is the default case; when the target live broadcast service encounters special extreme conditions, which will cause uneven load, the temporary weights can be adjusted according to the load requirements.

在具体实施例中,一致性哈希环将依据临时权重进行调整,可用于自动负载无法满足特殊情况时的人工介入;另外还可以将临时权重设置为零,在整个集群中被设置为零的业务组暂时不接收新的请求,当业务组负载缓解后可重置临时权重,或恢复为动态权重的调整状态。In a specific embodiment, the consistent hash ring will be adjusted based on the temporary weight, which can be used for manual intervention when the automatic load cannot meet special circumstances; in addition, the temporary weight can be set to zero, and the business group set to zero in the entire cluster will temporarily not receive new requests. When the business group load is alleviated, the temporary weight can be reset, or restored to the dynamic weight adjustment state.

本公开一种可实现方式中,所述临时权重的优先级大于所述动态权重的优先级,所述动态权重的优先级大于所述初始权重的优先级。In an implementation manner of the present disclosure, the priority of the temporary weight is greater than the priority of the dynamic weight, and the priority of the dynamic weight is greater than the priority of the initial weight.

具体在,临时权重的优先级大于动态权重和初始权重,在极端情况下,使用临时权重时,初始权重和动态权重会暂时失效,避免目标直播业务过载;动态权重的优先级大于初始权重,当客户端的连接数量大于初始权重的负载能力时,才引入动态权重的概念,因此在具有动态权重时,动态权重的值才能保证媒体资源的分配均匀。Specifically, the priority of temporary weight is greater than dynamic weight and initial weight. In extreme cases, when temporary weight is used, initial weight and dynamic weight will be temporarily invalid to avoid overloading of target live broadcast business. The priority of dynamic weight is greater than initial weight. When the number of client connections is greater than the load capacity of initial weight, the concept of dynamic weight is introduced. Therefore, when there is dynamic weight, the value of dynamic weight can ensure the uniform distribution of media resources.

步骤S500,基于所述目标直播业务的运行状态,所述评估机制生成状态评分。Step S500: Based on the running status of the target live broadcast service, the evaluation mechanism generates a status score.

具体的,动态权重的生成过程中,首先要生成状态评分,状态评分体现了目标直播业务的运行状况,根据其运行状况分配动态权重。Specifically, in the process of generating dynamic weights, a status score must first be generated. The status score reflects the operating status of the target live broadcast service, and a dynamic weight is allocated based on its operating status.

本公开一种可实现方式中,对于步骤S500,如图4所示,还包括:In one possible implementation of the present disclosure, step S500, as shown in FIG4 , further includes:

步骤S510,获取所述目标直播业务的运行状态;Step S510, obtaining the running status of the target live broadcast service;

步骤S520,处理所述目标直播业务的运行状态,得到所述目标直播业务的实际负载均值;Step S520, processing the running state of the target live broadcast service to obtain the actual load average of the target live broadcast service;

步骤S530,预设负载均值和分段分数的对应关系;Step S530, preset the corresponding relationship between the load mean and the segment score;

步骤S540,匹配所述实际负载均值和所述对应关系,得到所述目标直播业务的状态评分。Step S540, matching the actual load mean and the corresponding relationship to obtain a status score of the target live broadcast service.

具体的,根据各个目标直播业务上报组的运行状态,经过计算、分析和评估可以综合得出各个目标直播业务的负载均值。提前预设负载均值与分段分数的对应关系,负载均值由小到大对应有由小到大的评分,将实际运行得到的负载均值和分段分数对应,即可得到各个目标直播业务的状态评分。Specifically, according to the operating status of each target live broadcast service reporting group, the load average of each target live broadcast service can be comprehensively obtained through calculation, analysis and evaluation. The corresponding relationship between the load average and the segment score is preset in advance. The load average from small to large corresponds to the score from small to large. The load average obtained from actual operation and the segment score are matched to obtain the status score of each target live broadcast service.

本公开一种可实现方式中,目标直播业务的运行状态包括CPU核心数、当前内存占用情况、当前带宽使用情况和当前用户数量其中至少一项。In one implementable manner of the present disclosure, the running status of the target live broadcast service includes at least one of the number of CPU cores, current memory occupancy, current bandwidth usage, and the current number of users.

目标直播业务的CPU核心数,直播设备的内存占用情况,直播主体的宽带网速和观看直播的观众数量都影响着目标直播业务的运行状态,都可以作为评判目标直播业务的运行状态的参数。The number of CPU cores of the target live broadcast service, the memory usage of the live broadcast device, the broadband speed of the live broadcast subject and the number of viewers watching the live broadcast all affect the operating status of the target live broadcast service and can be used as parameters to judge the operating status of the target live broadcast service.

步骤S600,根据状态评分和所述初始权重生成动态权重。Step S600, generating a dynamic weight according to the state score and the initial weight.

具体的,目标直播业务的状态评分和该目标直播业务的初始权重共同生成动态权重,其中初始权重中包含了目标直播业务中固定的要求和状态,如硬件设备的参数或预设的直播需求等,状态评分中包含了目标直播业务在运行过程中动态变化的参数,综合目标直播业务的固定需求状态和动态的运行状况,可以在运行稳定的同时,保证运行质量。Specifically, the status score of the target live broadcast service and the initial weight of the target live broadcast service jointly generate a dynamic weight, wherein the initial weight includes the fixed requirements and status of the target live broadcast service, such as the parameters of the hardware equipment or the preset live broadcast requirements, etc. The status score includes the dynamically changing parameters of the target live broadcast service during operation. The fixed demand status and dynamic operating conditions of the target live broadcast service are combined to ensure the operation quality while ensuring stable operation.

本公开一种可实现方式中,对于步骤S600,如图5所示,还包括:In one possible implementation of the present disclosure, step S600, as shown in FIG5 , further includes:

步骤S610,分别分配所述状态评分和所述初始权重的计算比例;Step S610, respectively allocating the calculation ratio of the state score and the initial weight;

步骤S620,按所述计算比例计算所述状态评分和所述初始权重,得到所述动态权重;其中,所述动态权重小于所述初始权重。Step S620, calculating the state score and the initial weight according to the calculation ratio to obtain the dynamic weight; wherein the dynamic weight is smaller than the initial weight.

具体的,状态评分的比例占一部分,初始权重的比例占另一部分,如状态评分的比例为α,初始权重的比例为β,则α+β=1,则动态权重为A=αB+βC;其中,B为状态评分,C为初始权重。Specifically, the proportion of the state score accounts for one part, and the proportion of the initial weight accounts for another part. For example, if the proportion of the state score is α and the proportion of the initial weight is β, then α+β=1, and the dynamic weight is A=αB+βC; among them, B is the state score and C is the initial weight.

其中,动态权重小于初始权重,以防个别直播业务的动态权重无限提升,超出初始权重后引起其他的负载问题。Among them, the dynamic weight is smaller than the initial weight to prevent the dynamic weight of individual live broadcast services from increasing infinitely and causing other load problems after exceeding the initial weight.

步骤S700,基于所述动态权重,构建重设哈希环。Step S700: construct a reset hash ring based on the dynamic weight.

步骤S800,根据所述重设哈希环上的节点分配媒体资源。Step S800: Allocate media resources according to the nodes on the reset hash ring.

具体的,在调整了动态权重之后,根据动态权重对一致性哈希环进行重新构建,以达到下次客户端连接会按照动态权重来分配目标直播业务的接入点,达到依据目标直播业务进行媒体资源分配的目的。Specifically, after adjusting the dynamic weight, the consistent hash ring is reconstructed according to the dynamic weight, so that the next time the client connects, the access point of the target live broadcast service will be allocated according to the dynamic weight, thereby achieving the purpose of allocating media resources according to the target live broadcast service.

在本公开的一些具体实施例中,如图6所示,提出了另一种用于直播的灭提资源分配方法,包括:In some specific embodiments of the present disclosure, as shown in FIG6 , another method for allocating resources for live broadcast is proposed, including:

步骤S101,获取目标直播业务;Step S101, obtaining a target live broadcast service;

步骤S102,根据目标直播业务,获取初始权重,并生成对应的一致性哈希环;Step S102, obtaining an initial weight according to the target live broadcast service, and generating a corresponding consistent hash ring;

步骤S103,计算目标直播业务的连接数量;Step S103, calculating the number of connections of the target live broadcast service;

步骤S104,判断连接数量是否超过阈值,如超过阈值,则执行步骤S105,如不超过阈值,则执行步骤S107;Step S104, determining whether the number of connections exceeds a threshold, if so, executing step S105, if not, executing step S107;

步骤S105,启动目标直播业务的评估机制,得到目标直播业务的状态评分;Step S105, starting an evaluation mechanism for the target live broadcast service to obtain a status score for the target live broadcast service;

步骤S106,根据状态评分和初始权重,得到动态权重;Step S106, obtaining a dynamic weight according to the state score and the initial weight;

步骤S107,判断是否需要设置临时权重,如需要设置,则执行步骤S108,如不需要设置,则执行步骤S109;Step S107, determining whether a temporary weight needs to be set, if yes, executing step S108, if no, executing step S109;

步骤S108,按照临时权重重置哈希环后,执行步骤S1011;Step S108, after resetting the hash ring according to the temporary weight, execute step S1011;

步骤S109,判断动态权重是否调整,如是则执行步骤S1010,如否则执行步骤S1011;Step S109, determining whether the dynamic weight is adjusted, if yes, executing step S1010, if not, executing step S1011;

步骤S1010,根据动态权重重置哈希环后,执行步骤S1011;Step S1010, after resetting the hash ring according to the dynamic weight, execute step S1011;

步骤S1011,根据重置哈希环分配媒体资源。Step S1011, allocating media resources according to the reset hash ring.

如图7所示,本公开另一实施例公开了一种用于直播的媒体资源分配系统,包括:As shown in FIG. 7 , another embodiment of the present disclosure discloses a media resource allocation system for live broadcast, including:

第一获取模块,用于获取多个直播业务,根据业务类型对多个所述直播业务进行分组,得到业务组;A first acquisition module is used to acquire multiple live broadcast services, and group the multiple live broadcast services according to service types to obtain a service group;

第一分配模块,用于根据所述业务类型,为目标业务组分配初始权重;A first allocation module, configured to allocate an initial weight to a target service group according to the service type;

第一生成模块,用于根据所述初始权重,将目标业务组生成一致性哈希环,所述一致性哈希环包括与所述目标直播业务对应的虚拟节点,所述目标直播业务为所述目标业务组中的直播业务;A first generating module is used to generate a consistent hash ring for the target service group according to the initial weight, wherein the consistent hash ring includes a virtual node corresponding to the target live service, and the target live service is a live service in the target service group;

检测模块,用于通过检测所述虚拟节点的数量,得到所述目标直播业务上客户端的连接数量,当所述连接数量达到阈值时,启动所述目标直播业务的评估机制;A detection module, configured to obtain the number of client connections on the target live broadcast service by detecting the number of virtual nodes, and to start an evaluation mechanism for the target live broadcast service when the number of connections reaches a threshold;

第二生成模块,用于基于所述目标直播业务的运行状态,所述评估机制生成状态评分;A second generating module, configured to generate a status score based on the running status of the target live broadcast service by the evaluation mechanism;

第三生成模块,根据状态评分和所述初始权重生成动态权重;A third generation module generates a dynamic weight according to the state score and the initial weight;

构建模块,用于基于所述动态权重,构建重设哈希环;A construction module, for constructing a reset hash ring based on the dynamic weight;

第二分配模块,用于根据所述重设哈希环上的节点分配媒体资源。The second allocation module is used to allocate media resources according to the nodes on the reset hash ring.

本公开一种可实现方式中,第一生成模块包括:In one possible implementation of the present disclosure, the first generation module includes:

第一计算模块,计算初始权重和虚拟节点的基数的乘积;A first calculation module calculates the product of the initial weight and the cardinality of the virtual node;

设置模块,设置目标直播业务在所述一致性哈希环上对应的所述虚拟节点的数量;A setting module is used to set the number of virtual nodes corresponding to the target live broadcast service on the consistent hash ring;

映射模块,将所述目标直播业务生成的虚拟节点映射到一致性哈希环上。A mapping module maps the virtual nodes generated by the target live broadcast service to a consistent hash ring.

本公开一种可实现方式中,第二生成模块包括:In one possible implementation of the present disclosure, the second generation module includes:

第二获取模块,获取所述目标直播业务的运行状态;A second acquisition module is used to acquire the running status of the target live broadcast service;

处理模块,处理所述目标直播业务的运行状态,得到所述目标直播业务的实际负载均值;A processing module, processing the running state of the target live broadcast service, and obtaining an actual load average of the target live broadcast service;

预设模块,预设负载均值和分段分数的对应关系;Preset module, preset the corresponding relationship between load mean and segment score;

匹配模块,匹配所述实际负载均值和所述对应关系,得到所述目标直播业务的状态评分。A matching module matches the actual load mean and the corresponding relationship to obtain a status score of the target live broadcast service.

本公开一种可实现方式中,第三生成模块包括:In one possible implementation of the present disclosure, the third generation module includes:

分配模块,分别分配所述状态评分和所述初始权重的计算比例;An allocation module, which allocates the calculation ratio of the state score and the initial weight respectively;

第二计算模块,按所述计算比例计算所述状态评分和所述初始权重,得到所述动态权重;其中,所述动态权重小于所述初始权重。The second calculation module calculates the state score and the initial weight according to the calculation ratio to obtain the dynamic weight; wherein the dynamic weight is smaller than the initial weight.

本公开的一种可实现方式中,还包括:In one possible implementation of the present disclosure, the following further includes:

判断模块,所述连接数量未超过阈值,则判断目标直播业务的负载是否均匀;The judgment module judges whether the load of the target live broadcast service is uniform if the number of connections does not exceed the threshold;

响应模块,响应于所述负载不均匀,根据实际负载设置临时权重;A response module, in response to the uneven load, sets a temporary weight according to the actual load;

重设模块,基于所述临时权重,构建重设一致性哈希环。The reset module constructs a reset consistent hash ring based on the temporary weight.

本系统将观看人数相差较大的目标直播业务进行分类,避免不同的目标直播业务之间媒体资源分配的差距过大;通过实时的综合评估目标直播业务,对目标直播业务进行节点分配,保证目标直播业务资源不过载,不空闲,节省了目标直播业务的资源,保证直播过程的稳定性。This system classifies target live broadcast services with large differences in the number of viewers to avoid excessive disparity in media resource allocation between different target live broadcast services; through real-time comprehensive evaluation of target live broadcast services, nodes are allocated to target live broadcast services to ensure that the resources of the target live broadcast services are not overloaded or idle, thus saving the resources of the target live broadcast services and ensuring the stability of the live broadcast process.

图8示出了本实施方式所提供的一种更为具体的电子设备硬件结构示意图,该设备可以包括:处理器1010、存储器1020、输入/输出接口1030、通信接口1040和总线1050。其中处理器1010、存储器1020、输入/输出接口1030和通信接口1040通过总线1050实现彼此之间在设备内部的通信连接。8 shows a more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment, and the device may include: a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input/output interface 1030, and the communication interface 1040 are connected to each other in communication within the device through the bus 1050.

处理器1010可以采用通用的CPU(Central Processing Unit,中央处理器)、微处理器、应用专用集成电路(Application Specific Integrated Circuit,ASIC)、或者一个或多个集成电路等方式实现,用于执行相关程序,以实现本说明书实施方式所提供的技术方案。The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the implementation methods of this specification.

存储器1020可以采用ROM(Read Only Memory,只读存储器)、RAM(Random AccessMemory,随机存取存储器)、静态存储设备,动态存储设备等形式实现。存储器1020可以存储操作系统和其他应用程序,在通过软件或者固件来实现本说明书实施方式所提供的技术方案时,相关的程序代码保存在存储器1020中,并由处理器1010来调用执行。The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

输入/输出接口1030用于连接输入/输出模块,以实现信息输入及输出。输入输出/模块可以作为组件配置在设备中(图中未示出),也可以外接于设备以提供相应功能。其中输入设备可以包括键盘、鼠标、触摸屏、麦克风、各类传感器等,输出设备可以包括显示器、扬声器、振动器、指示灯等。The input/output interface 1030 is used to connect the input/output module to realize information input and output. The input/output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

通信接口1040用于连接通信模块(图中未示出),以实现本设备与其他设备的通信交互。其中通信模块可以通过有线方式(例如USB、网线等)实现通信,也可以通过无线方式(例如移动网络、WIFI、蓝牙等)实现通信。The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).

总线1050包括通路,在设备的各个组件(例如处理器1010、存储器1020、输入/输出接口1030和通信接口1040)之间传输信息。The bus 1050 includes pathways that transmit information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input/output interface 1030 , and the communication interface 1040 ).

需要说明的是,尽管上述设备仅示出了处理器1010、存储器1020、输入/输出接口1030、通信接口1040以及总线1050,但是在具体实施过程中,该设备还可以包括实现正常运行所必需的其他组件。此外,本领域的技术人员可以理解的是,上述设备中也可以仅包含实现本说明书实施方式方案所必需的组件,而不必包含图中所示的全部组件。It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input/output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the implementation scheme of this specification, and does not necessarily include all the components shown in the figure.

上述实施方式的电子设备用于实现前述任一实施方式中相应的用于直播的媒体资源分配方法,并且具有相应的方法实施方式的有益效果,在此不再赘述。The electronic device of the above-mentioned implementation mode is used to implement the corresponding media resource allocation method for live broadcast in any of the above-mentioned implementation modes, and has the beneficial effects of the corresponding method implementation mode, which will not be repeated here.

基于同一发明构思,与上述任意实施方式方法相对应的,本公开还提供了一种非暂态计算机可读存储介质,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令用于使所述计算机执行如上任一实施方式所述的用于直播的媒体资源分配方法。Based on the same inventive concept, corresponding to any of the above-mentioned implementation methods, the present disclosure also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the media resource allocation method for live broadcast as described in any of the above implementation methods.

本实施方式的计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be achieved by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

上述实施方式的存储介质存储的计算机指令用于使所述计算机执行如上任一实施方式所述的用于直播的媒体资源分配方法,并且具有相应的方法实施方式的有益效果,在此不再赘述。The computer instructions stored in the storage medium of the above-mentioned implementation manner are used to enable the computer to execute the media resource allocation method for live broadcast as described in any of the above-mentioned implementation manners, and have the beneficial effects of the corresponding method implementation manners, which will not be repeated here.

所属领域的普通技术人员应当理解:以上任何实施方式的讨论仅为示例性的,并非旨在暗示本公开的范围(包括权利要求)被限于这些例子;说明书的这种叙述方式仅仅是为清楚起见,本领域技术人员应当将说明书作为一个整体,在本公开的思路下,以上实施方式或者不同实施方式中的技术特征之间也可以进行适当组合,步骤可以以任意顺序实现,并存在如上所述的本公开实施方式的不同方面的许多其它变化,为了简明它们没有在细节中提供。Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present disclosure (including the claims) is limited to these examples. This narrative style of the specification is only for the sake of clarity, and those skilled in the art should take the specification as a whole. Under the concept of the present disclosure, the above embodiments or technical features in different embodiments may be appropriately combined, the steps may be implemented in any order, and there are many other variations of different aspects of the embodiments of the present disclosure as described above, which are not provided in detail for the sake of simplicity.

另外,为简化说明和讨论,并且为了不会使本公开实施方式难以理解,在所提供的附图中可以示出或可以不示出与集成电路(IC)芯片和其它部件的公知的电源/接地连接。此外,可以以框图的形式示出装置,以便避免使本公开实施方式难以理解,并且这也考虑了以下事实,即关于这些框图装置的实施方式的细节是高度取决于将要实施本公开实施方式的平台的(即,这些细节应当完全处于本领域技术人员的理解范围内)。在阐述了具体细节(例如,电路)以描述本公开的示例性实施方式的情况下,对本领域技术人员来说显而易见的是,可以在没有这些具体细节的情况下或者这些具体细节有变化的情况下实施本公开实施方式。因此,这些描述应被认为是说明性的而不是限制性的。In addition, to simplify the description and discussion, and in order not to make the embodiments of the present disclosure difficult to understand, the known power/ground connections to the integrated circuit (IC) chips and other components may or may not be shown in the provided figures. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present disclosure difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present disclosure will be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). Where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present disclosure, it is obvious to those skilled in the art that the embodiments of the present disclosure can be implemented without these specific details or with changes in these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.

尽管已经结合了本公开的具体实施方式对本公开进行了描述,但是根据前面的描述,这些实施方式的很多替换、修改和变型对本领域普通技术人员来说将是显而易见的。例如,其它存储器架构(例如,动态RAM(DRAM))可以使用所讨论的实施方式。Although the present disclosure has been described in conjunction with specific embodiments of the present disclosure, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) can use the embodiments discussed.

本公开实施方式旨在涵盖落入所附权利要求的宽泛范围之内的所有这样的替换、修改和变型。因此,凡未脱离本公开实施方式的精神和原则,所做的任何省略、修改、等同替换、改进等,均应包含在本公开的保护范围之内。The embodiments of the present disclosure are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made without departing from the spirit and principles of the embodiments of the present disclosure shall be included in the scope of protection of the present disclosure.

Claims (10)

1. A method for media resource allocation for live broadcast, the method comprising:
Acquiring a plurality of live broadcast services, and grouping the live broadcast services according to service types to obtain a plurality of service groups;
According to the service type, an initial weight is allocated to a target service group;
generating a consistency hash ring from the target service group according to the initial weight, wherein the consistency hash ring comprises virtual nodes corresponding to target live services, and the target live services are live services in the target service group;
Obtaining the connection quantity of the clients on the target live broadcast service by detecting the quantity of the virtual nodes, and starting an evaluation mechanism of the target live broadcast service when the connection quantity reaches a threshold value;
Generating a state score by the assessment mechanism based on the running state of the target live service;
Generating a dynamic weight according to the state score and the initial weight;
Building a reset hash ring based on the dynamic weights;
and distributing media resources according to the nodes on the reset hash ring.
2. The method for media resource allocation for live broadcast according to claim 1, wherein the generating a consistent hash ring for the target service group according to the initial weight, the consistent hash ring including a virtual node corresponding to the target live service, comprises:
calculating the product of the initial weight and the cardinality of the virtual node;
setting the number of the virtual nodes corresponding to the target live broadcast service on the consistency hash ring;
And mapping the virtual node generated by the target live broadcast service to a consistent hash ring.
3. The method for media resource allocation for live as in claim 1, wherein the evaluation mechanism generates a status score based on the operational status of the target live service, comprising:
acquiring the running state of the target live broadcast service;
Processing the running state of the target live broadcast service to obtain the actual load average value of the target live broadcast service;
presetting a corresponding relation between a load mean value and a segmentation score;
And matching the actual load mean value with the corresponding relation to obtain the state score of the target live broadcast service.
4. The method of claim 1, wherein generating dynamic weights from the status scores and the initial weights comprises:
respectively distributing the calculated proportion of the state scores and the initial weights;
Calculating the state score and the initial weight according to the calculated proportion to obtain the dynamic weight;
wherein the dynamic weight is less than the initial weight.
5. The method for media resource allocation for live broadcast according to claim 3, wherein after obtaining the number of connections of the client on the target live broadcast service, the method further comprises:
Judging whether the load of the target live broadcast service is uniform or not if the number of the connections does not exceed a threshold value;
setting temporary weights according to actual loads in response to the uneven loads;
based on the temporary weights, a reset hash ring is constructed.
6. The method of claim 5, wherein the temporary weight has a priority greater than a priority of the dynamic weight, and wherein the dynamic weight has a priority greater than a priority of the initial weight.
7. The method for media resource allocation for live broadcast according to claim 3, wherein the running state of the target live broadcast service includes at least one of a CPU core number, a current memory occupancy condition, a current bandwidth usage condition, and a current user number.
8. A media resource distribution system for live broadcast, the system comprising:
the first acquisition module is used for acquiring a plurality of live broadcast services, and grouping the live broadcast services according to the service type to obtain a plurality of service groups;
the first allocation module is used for allocating initial weights to the target service groups according to the service types;
The first generation module is used for generating a consistency hash ring for the target service group according to the initial weight, wherein the consistency hash ring comprises virtual nodes corresponding to the target live service, and the target live service is the live service in the target service group;
The detection module is used for obtaining the connection quantity of the client on the target live broadcast service by detecting the quantity of the virtual nodes, and starting an evaluation mechanism of the target live broadcast service when the connection quantity reaches a threshold value;
the second generation module is used for generating a state score based on the running state of the target live broadcast service by the evaluation mechanism;
the third generation module generates dynamic weights according to the state scores and the initial weights;
A building module for building a reset hash ring based on the dynamic weights;
And the second distribution module is used for distributing media resources according to the nodes on the reset consistency hash ring.
9. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the media resource allocation method for live broadcast of any of claims 1 to 7.
10. An electronic device, comprising: a processor and a memory;
The memory stores a computer program which, when executed by the processor, causes the processor to perform the steps of the media resource allocation method for live broadcast according to any of claims 1 to 7.
CN202410135594.0A 2024-01-31 2024-01-31 Media resource allocation method, system and storage medium for live broadcast Pending CN117979047A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410135594.0A CN117979047A (en) 2024-01-31 2024-01-31 Media resource allocation method, system and storage medium for live broadcast

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410135594.0A CN117979047A (en) 2024-01-31 2024-01-31 Media resource allocation method, system and storage medium for live broadcast

Publications (1)

Publication Number Publication Date
CN117979047A true CN117979047A (en) 2024-05-03

Family

ID=90845481

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410135594.0A Pending CN117979047A (en) 2024-01-31 2024-01-31 Media resource allocation method, system and storage medium for live broadcast

Country Status (1)

Country Link
CN (1) CN117979047A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102075425A (en) * 2008-12-16 2011-05-25 中国移动通信集团北京有限公司 Business allocation method and load balancer
US20180013822A1 (en) * 2015-03-31 2018-01-11 Huawei Technologies Co., Ltd. Service request processing method, related apparatus, and system
CN107770096A (en) * 2017-12-11 2018-03-06 国网河南省电力公司信息通信公司 A kind of SDN/NFV network dynamic resource allocation algorithms based on load balancing
CN114339135A (en) * 2020-09-25 2022-04-12 浙江宇视科技有限公司 Load balancing method and device, electronic equipment and storage medium
CN115766737A (en) * 2023-01-09 2023-03-07 北京微吼时代科技有限公司 Load balancing method and device and electronic equipment
CN115801791A (en) * 2022-10-27 2023-03-14 北京天空卫士网络安全技术有限公司 Method for realizing load balance and load balancer
CN116647563A (en) * 2023-05-30 2023-08-25 中国银行股份有限公司 Load balancing method, device and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102075425A (en) * 2008-12-16 2011-05-25 中国移动通信集团北京有限公司 Business allocation method and load balancer
US20180013822A1 (en) * 2015-03-31 2018-01-11 Huawei Technologies Co., Ltd. Service request processing method, related apparatus, and system
CN107770096A (en) * 2017-12-11 2018-03-06 国网河南省电力公司信息通信公司 A kind of SDN/NFV network dynamic resource allocation algorithms based on load balancing
CN114339135A (en) * 2020-09-25 2022-04-12 浙江宇视科技有限公司 Load balancing method and device, electronic equipment and storage medium
CN115801791A (en) * 2022-10-27 2023-03-14 北京天空卫士网络安全技术有限公司 Method for realizing load balance and load balancer
CN115766737A (en) * 2023-01-09 2023-03-07 北京微吼时代科技有限公司 Load balancing method and device and electronic equipment
CN116647563A (en) * 2023-05-30 2023-08-25 中国银行股份有限公司 Load balancing method, device and storage medium

Similar Documents

Publication Publication Date Title
CN109032801B (en) Request scheduling method, system, electronic equipment and storage medium
US9544346B1 (en) Systems and methods for selecting a node for media streaming
CN110445866B (en) Task migration and cooperative load balancing method in mobile edge computing environment
US20170126583A1 (en) Method and electronic device for bandwidth allocation based on online media services
CN111464649B (en) Access request source returning method and device
US8959177B1 (en) Automated selection of a content provider
CN110222013B (en) Method, system, equipment and storage medium for determining cluster storage capacity
CN108667882B (en) Load balancing method and device based on dynamic weight adjustment and electronic equipment
CN109413147B (en) Service node management method, device, equipment and computer readable storage medium
CN109960565B (en) Cloud platform, and virtual machine scheduling method and device based on cloud platform
CN115134368A (en) Load balancing method, device, equipment and storage medium
US20090144404A1 (en) Load management in a distributed system
WO2017075967A1 (en) Bandwidth allocation method and system for on-line media service
CN110233840B (en) Service processing method, device, equipment and storage medium
CN110493317B (en) Method for processing cloud platform resource fragments and related equipment
CN115766737A (en) Load balancing method and device and electronic equipment
CN116302477A (en) Dynamic allocation method and system of performance resources and related components
CN117979047A (en) Media resource allocation method, system and storage medium for live broadcast
CN115168017B (en) Task scheduling cloud platform and task scheduling method thereof
CN115842828A (en) Gateway load balancing control method, device, equipment and readable storage medium
CN111988388A (en) Flow distribution method and device, electronic equipment and storage medium
CN103501342B (en) Point to point network uploads data, the method and device of downloading data
CN116546028A (en) Service request processing method and device, storage medium and electronic equipment
CN110708374B (en) Distribution method and distribution device of edge nodes and readable storage medium
CN118075272A (en) Data processing method, device, electronic equipment and readable storage medium

Legal Events

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