Media resource allocation method, system and storage medium for live broadcast
By grouping and weight allocation of live broadcast services, generating a consistent hash ring, and adjusting weights and resource allocation according to real-time load conditions, the problem of unbalanced media resource allocation in the existing technology is solved, and the stability and high quality of the live broadcast process are achieved.
Patent Information
- Application Number
- CN202410135594.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-31
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2044-01-31
AI Technical Summary
The existing live media resource allocation algorithm fails to fully consider the real-time load situation of the media server, resulting in the inability to ensure the balanced load and allocation of media resource services.
A media resource allocation method for live broadcast is proposed. By acquiring multiple live broadcast services, grouping according to the service type and assigning initial weights, generating a consistent hash ring, detecting the number of client connections, starting an evaluation mechanism, generating status scores and dynamic weights, and rebuilding a hash ring to allocate media resources.
Real-time resource allocation for live broadcast services is realized, resource overload or idleness is avoided, and the stability and quality of the live broadcast process is ensured.
Smart Images

Figure CN117979047B_ABST
Abstract
Description
Technical Field
[0001] 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 Art
[0002] 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.
[0003] 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
[0004] 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.
[0005] 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:
[0006] Acquire multiple live broadcast services, and group the multiple live broadcast services according to service types to obtain a service group;
[0007] According to the business type, assigning an initial weight to the target business group;
[0008] 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;
[0009] 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;
[0010] Based on the running status of the target live broadcast service, the evaluation mechanism generates a status score;
[0011] generating a dynamic weight according to the state score and the initial weight;
[0012] Based on the dynamic weight, construct a reset hash ring;
[0013] Media resources are allocated according to the nodes on the reset consistent hashing ring.
[0014] 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:
[0015] Calculating the product of the initial weight and the cardinality of the virtual node;
[0016] Set the number of the virtual nodes corresponding to the target live broadcast service on the consistent hash ring;
[0017] Map the virtual nodes generated by the target live broadcast service to the consistent hash ring.
[0018] 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:
[0019] Obtaining the running status of the target live broadcast service;
[0020] Processing the running status of the target live broadcast service to obtain an actual load average of the target live broadcast service;
[0021] Preset the corresponding relationship between load mean and segment score;
[0022] The actual load average and the corresponding relationship are matched to obtain a status score of the target live broadcast service.
[0023] 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:
[0024] respectively allocating the calculation ratios of the state score and the initial weight;
[0025] Calculate the state score and the initial weight according to the calculation ratio to obtain the dynamic weight;
[0026] The dynamic weight is smaller than the initial weight.
[0027] 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:
[0028] If the number of connections does not exceed the threshold, it is determined whether the load of the target live broadcast service is uniform;
[0029] In response to the uneven load, setting a temporary weight according to the actual load;
[0030] Based on the temporary weights, a reset hash ring is constructed.
[0031] 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.
[0032] 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.
[0033] Based on the same inventive concept, the present disclosure also provides a media resource allocation system for live broadcast, comprising:
[0034] 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;
[0035] A first allocation module, configured to allocate an initial weight to a target service group according to the service type;
[0036] 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;
[0037] 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 to start an evaluation mechanism for the target live broadcast service when the number of connections reaches a threshold;
[0038] 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;
[0039] A third generation module generates a dynamic weight according to the state score and the initial weight;
[0040] A construction module, for constructing a reset hash ring based on the dynamic weight;
[0041] The second allocation module is used to allocate media resources according to the nodes on the reset consistent hash ring.
[0042] 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.
[0043] 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.
[0044] 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
[0045] 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.
[0046] Figure 1 A flow chart of a method for allocating media resources for live broadcasting provided in one embodiment of the present disclosure;
[0047] Figure 2 A flowchart of constructing a consistent hash ring provided for another embodiment of the present disclosure;
[0048] Figure 3 A flowchart of adding temporary weights provided in another embodiment of the present disclosure;
[0049] Figure 4 A flowchart for obtaining a status score provided in another embodiment of the present disclosure;
[0050] Figure 5 A flow chart for obtaining dynamic weights provided in another embodiment of the present disclosure;
[0051] Figure 6 A flow chart of a method for allocating media resources for live broadcasting provided by another embodiment of the present disclosure;
[0052] Figure 7 A schematic diagram of media resource allocation for live broadcast provided by another embodiment of the present disclosure;
[0053] Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0054] 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.
[0055] 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 cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects.
[0056] 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 participants in live broadcast interactions, while others have up to thousands of participants. Therefore, the media resources occupied by different live broadcast services vary greatly, making it impossible to accurately allocate resources. (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.
[0057] The present disclosure provides a method for allocating media resources for live broadcasting. Figure 1 As shown, the method for allocating media resources for live broadcasting includes the following steps:
[0058] Step S100, obtaining multiple live broadcast services, and grouping the multiple live broadcast services according to service types to obtain a service group.
[0059] 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.
[0060] Step S200: assigning an initial weight to the target service group according to the service type.
[0061] Specifically, the initialization weight is allocated according to the overall configuration and service performance of the target business 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.
[0062] 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.
[0063] 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.
[0064] 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.
[0065] In one possible implementation of the present disclosure, for step S300, Figure 2 As shown, it also includes:
[0066] Step S310, calculating the product of the initial weight and the cardinality of the virtual node;
[0067] Step S320, setting the number of the virtual nodes corresponding to the target live broadcast service on the consistent hash ring;
[0068] Step S330, mapping the virtual nodes generated by the target live broadcast service to the consistent hash ring.
[0069] 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.
[0070] 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.
[0071] 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.
[0072] 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.
[0073] In one possible implementation of the present disclosure, after step S400, as follows Figure 3 As shown, it also includes:
[0074] 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;
[0075] Step S402, in response to the uneven load, setting a temporary weight according to the actual load;
[0076] Step S403: construct a reset consistent hash ring based on the temporary weight.
[0077] 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.
[0078] 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.
[0079] 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.
[0080] 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.
[0081] Step S500: Based on the running status of the target live broadcast service, the evaluation mechanism generates a status score.
[0082] 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.
[0083] In one possible implementation of the present disclosure, for step S500, Figure 4 As shown, it also includes:
[0084] Step S510, obtaining the running status of the target live broadcast service;
[0085] Step S520, processing the running status of the target live broadcast service to obtain the actual load average of the target live broadcast service;
[0086] Step S530, preset the corresponding relationship between the load mean and the segment score;
[0087] Step S540, matching the actual load mean and the corresponding relationship to obtain a status score of the target live broadcast service.
[0088] 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.
[0089] 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.
[0090] 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.
[0091] Step S600, generating a dynamic weight according to the state score and the initial weight.
[0092] 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.
[0093] In one possible implementation of the present disclosure, for step S600, Figure 5 As shown, it also includes:
[0094] Step S610, respectively allocating the calculation ratio of the state score and the initial weight;
[0095] 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.
[0096] 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.
[0097] 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.
[0098] Step S700: construct a reset hash ring based on the dynamic weight.
[0099] Step S800: Allocate media resources according to the nodes on the reset hash ring.
[0100] 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.
[0101] In some specific embodiments of the present disclosure, Figure 6 As shown, another method for allocating resources for live broadcast is proposed, including:
[0102] Step S101, obtaining a target live broadcast service;
[0103] Step S102, obtaining an initial weight according to the target live broadcast service, and generating a corresponding consistent hash ring;
[0104] Step S103, calculating the number of connections of the target live broadcast service;
[0105] Step S104, determining whether the number of connections exceeds a threshold, if so, executing step S105, if not, executing step S107;
[0106] Step S105, starting an evaluation mechanism for the target live broadcast service to obtain a status score for the target live broadcast service;
[0107] Step S106, obtaining a dynamic weight according to the state score and the initial weight;
[0108] Step S107, determining whether a temporary weight needs to be set, if yes, executing step S108, if no, executing step S109;
[0109] Step S108, after resetting the hash ring according to the temporary weight, execute step S1011;
[0110] Step S109, determining whether the dynamic weight is adjusted, if yes, executing step S1010, if not, executing step S1011;
[0111] Step S1010, after resetting the hash ring according to the dynamic weight, execute step S1011;
[0112] Step S1011, allocating media resources according to the reset hash ring.
[0113] like Figure 7 As shown, another embodiment of the present disclosure discloses a media resource allocation system for live broadcast, including:
[0114] 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;
[0115] A first allocation module, configured to allocate an initial weight to a target service group according to the service type;
[0116] 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;
[0117] 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;
[0118] 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;
[0119] A third generation module generates a dynamic weight according to the state score and the initial weight;
[0120] A construction module, for constructing a reset hash ring based on the dynamic weight;
[0121] The second allocation module is used to allocate media resources according to the nodes on the reset hash ring.
[0122] In one possible implementation of the present disclosure, the first generating module includes:
[0123] A first calculation module calculates the product of the initial weight and the cardinality of the virtual node;
[0124] A setting module is used to set the number of virtual nodes corresponding to the target live broadcast service on the consistent hash ring;
[0125] A mapping module maps the virtual nodes generated by the target live broadcast service to a consistent hash ring.
[0126] In one possible implementation of the present disclosure, the second generation module includes:
[0127] A second acquisition module is used to acquire the running status of the target live broadcast service;
[0128] 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;
[0129] Preset module, preset the corresponding relationship between load mean and segment score;
[0130] A matching module matches the actual load mean and the corresponding relationship to obtain a status score of the target live broadcast service.
[0131] In one possible implementation of the present disclosure, the third generation module includes:
[0132] An allocation module, respectively allocating the calculation ratio of the state score and the initial weight;
[0133] 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.
[0134] In one possible implementation of the present disclosure, the following further includes:
[0135] 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;
[0136] A response module, in response to the uneven load, sets a temporary weight according to the actual load;
[0137] The reset module constructs a reset consistent hash ring based on the temporary weight.
[0138] 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.
[0139] Figure 8 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, 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 through the bus 1050 in the device.
[0140] 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.
[0141] 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.
[0142] 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.
[0143] 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.).
[0144] 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 ).
[0145] 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.
[0146] 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.
[0147] 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.
[0148] 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.
[0149] 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.
[0150] 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 the 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.
[0151] 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.
[0152] 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)) may use the embodiments discussed.
[0153] 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
1. A method for allocating media resources for live broadcast, characterized in that: The method comprises: Acquire multiple live broadcast services, and group the multiple live broadcast services according to service types to obtain multiple service groups; 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 a 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; Allocating media resources according to the nodes on the reset hash ring; 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; Matching the actual load mean value with the corresponding relationship to obtain a status score of the target live broadcast service; The generating a dynamic weight according to the state score and the initial weight comprises: 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 less than the initial weight; 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.
2. The method for allocating media resources for live broadcast according to claim 1, characterized in that: According to the initial weight, the target service group generates a consistent hash ring, and the consistent hash ring includes virtual nodes 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; Map the virtual nodes generated by the target live broadcast service to the consistent hash ring.
3. The method for allocating media resources for live broadcast according to claim 1, characterized in that: After obtaining the number of client connections 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.
4. The method for allocating media resources for live broadcast according to claim 3, characterized in that: 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.
5. The method for allocating media resources for live broadcast according to claim 1, characterized in that: 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.
6. A media resource allocation system for live broadcast, characterized in that: The system comprises: 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 multiple service groups; A first allocation module, configured to allocate an initial weight to a target service group according to the service type; A first generating module, configured 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 a 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 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; A second allocation module, configured to allocate media resources according to the nodes on the reset hash ring; 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, matching the actual load mean value with the corresponding relationship to obtain a status score of the target live broadcast service; The third generation module includes: An allocation module, respectively allocating the calculation ratio of the state score and the initial weight; A 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 less than the initial weight; 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.
7. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the media resource allocation method for live broadcast as described in any one of claims 1 to 5.
8. An electronic device, characterized in that: include: Processor and memory; The memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the media resource allocation method for live broadcasting as claimed in any one of claims 1 to 5.
Citation Information
Patent Citations
Load balancing method and device, electronic equipment and storage medium
CN114339135A
Load balancing method and device and electronic equipment
CN115766737A