Subject distribution method and device, computer device and storage medium

By determining the client's consumption capacity as the target topic for allocation, the problem of uneven topic allocation among clients is solved, achieving balanced topic allocation and non-overlapping messages, thus improving the system's stability and efficiency.

CN117354311BActive Publication Date: 2026-08-04BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
Filing Date
2023-09-04
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

In existing technologies, the uneven distribution of topics among clients leads to excessive consumption pressure or overcapacity for some clients, and message overlap cannot be effectively avoided.

Method used

By obtaining the information reported by the client, we determine its target consumption capacity value, and allocate the corresponding number of target topics to the client based on this value, ensuring balanced topic allocation and avoiding message overlap.

Benefits of technology

It achieves balanced topic allocation among clients, avoids overlapping message consumption, and improves system stability and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117354311B_ABST
    Figure CN117354311B_ABST
Patent Text Reader

Abstract

The application relates to a subject distribution method and device, computer equipment and a storage medium. The method comprises the following steps: when obtaining the reporting information of a first client, determining the target consumption capability value of the first client according to the reporting information; and distributing a target subject containing a corresponding message amount to the first client according to the target consumption capability value, wherein the target subject is an unallocated consumption subject in a subject pool, and the target subject is used for enabling the first client to pull messages with a corresponding message amount corresponding to the target consumption capability value for consumption, different clients are provided with corresponding unallocated consumption subjects with corresponding message amounts according to the consumption capability of the clients, and therefore, the subject distribution among the clients is balanced and the messages are not overlapped.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of topic allocation, and more particularly to a topic allocation method, apparatus, computer device, and storage medium. Background Technology

[0002] Typically, clients can subscribe to topics to retrieve the messages they want to consume. However, in many business scenarios, messages cannot be consumed by different clients simultaneously, as this consumption method can lead to message state errors. The existing approach is to introduce third-party middleware to avoid overlapping message consumption, but this increases system complexity and fails to meet the design requirements of a lightweight architecture. Furthermore, this approach cannot allocate messages according to the client's own consumption capacity, which can easily lead to an uneven distribution of topics among clients, resulting in some clients experiencing excessive consumption pressure while others have excess consumption capacity. Summary of the Invention

[0003] This application provides a topic allocation method, apparatus, computer device, and storage medium to solve the problem of how to achieve balanced topic allocation among clients and prevent message overlap.

[0004] In a first aspect, this application provides a topic allocation method, the method comprising:

[0005] When the first client reports information, the target consumption capacity value of the first client is determined based on the reported information. The target consumption capacity value is used to indicate the amount of messages that the operating parameters of the first client can support for consumption.

[0006] Based on the target consumption capacity value, a target topic containing a corresponding message volume is allocated to the first client. The target topic is an unallocated topic to be consumed in the topic pool. The target topic is used to enable the first client to pull messages with a message volume corresponding to the target consumption capacity value for consumption.

[0007] Secondly, this application provides a topic allocation apparatus, the apparatus comprising:

[0008] The capability confirmation module is used to determine the target consumption capacity value of the first client based on the reported information when the first client is received. The target consumption capacity value is used to indicate the amount of messages that the operating parameters of the first client can support for consumption.

[0009] The topic allocation module is used to allocate a target topic containing a corresponding message volume to the first client according to the target consumption capacity value. The target topic is an unallocated topic to be consumed in the topic pool. The target topic is used to enable the first client to pull messages with a message volume corresponding to the target consumption capacity value for consumption.

[0010] Thirdly, this application provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described topic allocation method.

[0011] Fourthly, this application also provides a computer storage medium storing computer-executable instructions for executing the above-described topic allocation method.

[0012] Compared with the prior art, the technical solution provided in this application has the following advantages: When the method provided in this application obtains the reporting information of the first client, it determines the target consumption capacity value of the first client based on the reporting information; according to the target consumption capacity value, it allocates a target topic containing a corresponding message volume to the first client. The target topic is an unallocated topic to be consumed in the topic pool. The target topic is used to enable the first client to pull messages with a message volume corresponding to the target consumption capacity value for consumption. According to the consumption capacity of different clients, it provides them with unallocated consumption topics with a corresponding message volume, thereby achieving balanced topic allocation among clients and preventing message overlap. Attached Figure Description

[0013] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0015] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0016] Figure 1 An application environment diagram of a topic allocation method provided in an embodiment of this application;

[0017] Figure 2 A flowchart illustrating a topic allocation method provided in an embodiment of this application;

[0018] Figure 3 A flowchart illustrating a topic allocation method provided in an embodiment of this application;

[0019] Figure 4 A flowchart illustrating a topic allocation method provided in an embodiment of this application;

[0020] Figure 5 A flowchart illustrating a topic allocation method provided in an embodiment of this application;

[0021] Figure 6 A flowchart illustrating a topic allocation method provided in an embodiment of this application;

[0022] Figure 7 A flowchart illustrating a topic allocation method provided in an embodiment of this application;

[0023] Figure 8 A flowchart illustrating a topic allocation method provided in an embodiment of this application;

[0024] Figure 9 A structural block diagram of a topic allocation device provided in an embodiment of this application;

[0025] Figure 10 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0026] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0027] The following disclosure provides numerous different embodiments or examples for implementing various structures of the invention. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of the invention. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0028] Figure 1 This diagram illustrates the application environment of a topic allocation method provided in an embodiment of this application. (Refer to...) Figure 1This topic allocation method is applied to a topic allocation system. The system includes a client 110, a central control center service 120, a message queue 130, and a database 150. The client 110 connects to the central control center service 120 and the message queue 130 via a network. The central control center service 120 connects to the database 150 and the developer client 140 via a network. The client 110 can be implemented using any device capable of consuming messages, specifically a terminal or an edge node. A terminal can be a desktop terminal or a mobile terminal, specifically a mobile phone, tablet, or laptop. An edge node can be a CDN node or a home node. A home node is a router or set-top box used by ordinary users to provide download services using idle bandwidth. A CDN node is a node in a content delivery network. A CDN node refers to a network node with fewer intermediate links to the end user, providing better responsiveness and connection speed. A CDN node can act as a cache server to provide data services. The central control center service 120 can be implemented using a standalone server or a server cluster composed of multiple servers.

[0029] like Figure 8 As shown, the developer client 140 (admin) sends topic registration information to the central control center service 120 to register the topic. The topic registration information includes the corresponding message volume. The central control center service 120 saves the topic registration information to the DB database 150 and returns a response signal to the developer client 140. The client 110 sends client registration information to the central control center service 120 to register the client 110. The central control center service 120 then allocates the registered consumption topics to each registered client 110 according to their consumption capacity. Each consumption topic is assigned to only one client 110. The client 110 pulls the messages corresponding to the consumption topic assigned to it by the central control center service 120 from the message queue 130 (MQ) for consumption, thereby preventing the messages contained in the consumption topic from being consumed by different clients 110 at the same time.

[0030] In one embodiment, Figure 2 This is a flowchart illustrating a topic assignment method in one embodiment, with reference to... Figure 2 This provides a topic assignment method. This embodiment mainly applies this method to the above-mentioned topic assignment method. Figure 1 Taking the central control center service 120 as an example, the topic assignment method specifically includes the following steps:

[0031] Step S210: When the reporting information of the first client is obtained, the target consumption capacity value of the first client is determined according to the reporting information. The target consumption capacity value is used to indicate the amount of messages that the operating parameters of the first client can support for consumption.

[0032] Specifically, the first client is any client 110 with messages to be consumed. The reported information includes the operating parameters of the first client, which can be at least one of processor utilization (i.e., CPU utilization), memory usage, disk read / write speed, and network bandwidth usage. Calculating the target consumption capacity value of the first client based on the reported information involves multiplying the values ​​of each operating parameter in the reported information by their corresponding weight coefficients and summing the results. This summates the consumption capacity value, and the target consumption capacity value is the consumption capacity value corresponding to the first client. Different models of client 110 may have different weight coefficients for the same operating parameter. However, the weight coefficients corresponding to different operating parameters of client 110 can be customized according to the actual application. The sum of the weight coefficients for all operating parameters involved in the consumption capacity value calculation is 1. For example, if the consumption capacity value is calculated only based on the CPU utilization and memory usage of client 110, the weight coefficient for CPU utilization is 0.6, and the weight coefficient for memory usage is 0.4. The consumption capacity value is 0.6*X + 0.4*Y, where X is the CPU utilization and Y is the memory usage.

[0033] Step S220: Allocate a target topic containing a corresponding message volume to the first client according to the target consumption capacity value, wherein the target topic is an unallocated topic to be consumed in the topic pool, and the target topic is used to enable the first client to pull messages with a message volume corresponding to the target consumption capacity value for consumption.

[0034] Specifically, the central control center service 120 assigns the message volume to be consumed, which corresponds to the target consumption capacity value, as the target topic to the first client. It controls the first client to pull messages from the message queue 130 within the target topic for consumption. After the target topic is assigned to the first client, its allocation status is updated to "assigned". Therefore, the target topic will not be reassigned to other clients 110, thereby avoiding message overlap between different clients 110. According to the consumption capacity of different clients 110, it provides them with unassigned consumption topics with corresponding message volumes, thereby achieving balanced topic allocation and no message overlap among clients 110.

[0035] In one embodiment, upon receiving a report from a first client, determining the target consumption capacity value of the first client based on the report includes:

[0036] Upon obtaining the client registration information of the first client, the initial consumption capacity value of the first client is determined based on the client registration information, and the registration status of the first client is modified to "registered". Here, the reported information is the client registration information, and the target consumption capacity value is the initial consumption capacity value; or,

[0037] The load index information of the registered first client is obtained periodically according to a preset cycle, and the current consumption capacity value of the first client is determined based on the load index information. The reported information is the load index information, and the target consumption capacity value is the current consumption capacity value.

[0038] Specifically, when the reported information is client registration information, it indicates that the first client is currently an unregistered client 110. After receiving the client registration information, the central control center service 120 changes the registration status of the first client from unregistered to registered. The central control center service 120 only assigns topics to the registered client 110. The client registration information includes the first client's registration request, load configuration data, and callback address. The callback address includes two interface addresses, denoted as the first callback address and the second callback address, corresponding to subscribing to and unsubscribing from topics, respectively, which are used to operate on the current client 110's topics. The load configuration data includes configuration parameters such as processor model, memory model, disk model, and network bandwidth parameters. The initial consumption capacity value of client 110 is calculated based on the load configuration data, that is, the scores corresponding to each configuration parameter are multiplied by their corresponding weight coefficients and then summed to obtain the initial consumption capacity value. The initial consumption capacity value is used to reflect the data processing capabilities supported by the hardware configuration of client 110. The callback address is used to modify the client 110's subscription status for the consumed topics.

[0039] When the reported information is load metric information, that is, when the received load metric information is equivalent to Figure 8 The periodic reporting status indicates that the first client is currently a registered client 110, having already gone through the aforementioned client 110 registration process. Instead, the system periodically monitors the load of the first client. Load metrics include the aforementioned operating parameters. The current consumption capacity of the first client is calculated using the periodically uploaded load metrics information. This is achieved by multiplying the corresponding values ​​of each operating parameter in the load metrics information by their respective weighting coefficients and summing the results. This current consumption capacity value reflects the current load status of the first client. The current consumption capacity values ​​of different clients 110 can be used to determine whether topic allocation is balanced.

[0040] In one embodiment, such as Figure 3As shown, when the target consumption capacity value is the initial consumption capacity value, allocating a target topic containing the corresponding message volume to the first client according to the target consumption capacity value includes:

[0041] Step S211: The ratio between the initial consumption capacity value and the total consumption capacity value is determined as the consumption capacity percentage of the first client, wherein the total consumption capacity value is the sum of the target consumption capacity values ​​of all registered clients 110;

[0042] Step S212: All the topics to be consumed whose sum of message volume percentages equals the consumption capacity percentage are assigned as target topics to the first client, wherein the message volume percentage is the ratio between the message volume contained in the consumption topic and the total message volume contained in all consumption topics in the topic pool.

[0043] Specifically, after the first client successfully registers and joins the client cluster managed by the central control center service 120, it needs to be assigned a consumption topic. The ratio between the first client's initial consumption capacity value and the total consumption capacity value of the corresponding client cluster is calculated to obtain the first client's consumption capacity percentage. Multiplying the total number of messages contained in all topics to be consumed by the consumption capacity percentage gives the number of messages the first client can consume. Topics containing the corresponding number of messages are selected based on the first client's consumption capacity. For example, if the first client's initial consumption capacity value is 0.3, then the number of messages the first client can consume is 0.3 of the total number of messages contained in all topics to be consumed. In this case, the knapsack algorithm is used for topic selection, that is, selecting topics whose message volume percentages equal the initial consumption capacity value. The message volume percentage refers to the ratio between the number of messages contained in the consumption topic and the total number of messages contained in all registered consumption topics. Assuming the message volume percentage of topic 1 is 0.1 and the message volume percentage of topic 2 is 0.2, their sum is exactly 0.3, then topics 1 and 2 can be assigned as target topics to the first client.

[0044] For example, there are three topics, t1, t2, and t3, with message volume percentages of 0.5, 0.3, and 0.2 respectively. There are two clients, 110c1 and c2, with consumption capacity values ​​of 0.5 and 0.5 respectively. In this case, the allocation depends on the consumption capacity value. So, each client 110 is allocated a message volume percentage of 0.5. The allocation result is c1->t1, c2->t2+t3. That is, the 0.5 of t1 is allocated to c1, and the message volume percentages of t2 and t3, which are combined to 0.5, are allocated to c2.

[0045] In one embodiment, such as Figure 4As shown, after determining the ratio between the initial spending power value and the total spending power value as the spending power percentage of the first client, the method further includes:

[0046] Step S213: Assign each consumption topic whose message volume ratio is equal to the consumption capacity ratio as the target topic to the first client, wherein the target topic is the consumption topic already assigned in the topic pool;

[0047] Step S214: Determine the previous allocation client of the target topic based on the previous allocation record of the target topic;

[0048] Step S215: Modify the subscription status of the previous allocation client for the target topic to unsubscribed by using the first callback address in the client registration information corresponding to the previous allocation client;

[0049] Step S216: Modify the subscription status of the first client for the target topic to "subscribed" using the second callback address in the client registration information corresponding to the first client. The first client that has subscribed to the target topic pulls and consumes messages corresponding to the message volume of the target consumption capacity value.

[0050] Specifically, in the previous embodiment, the target topics were selected from the unassigned message topics, where the sum of the message volume percentages equaled the consumption capacity percentage. In other words, the target topics for the first client were selected from the unassigned message topics. In this embodiment, the target topics are selected from the consumption topics, where the sum of the message volume percentages equals the consumption capacity percentage. In other words, the allocation status of consumption topics in the topic pool is not considered. Instead, the target topics for the first client are selected from all consumption topics in the topic pool. This may result in the selection of an already assigned consumption topic as the target topic.

[0051] To prevent the first client from consuming messages contained in the target topic simultaneously with other clients 110, the previous assigning client of the target topic is determined based on the previous assignment record of the target topic. The previous assigning client is the target subject assigned to the target topic by the central control center service 120 during the last topic assignment. Since the central control center service 120 has assigned the target topic to the first client, it is necessary to control the previous assigning client to unsubscribe from the target topic so that the previous assigning client will not consume the messages contained in the target topic when the first client consumes them. Specifically, the first callback address in the client registration information of the previous assigning client is used to control the previous assigning client to unsubscribe from the target topic, that is, to change the subscription status of the previous assigning client for the target topic from subscribed to unsubscribed. After the previous assigning client unsubscribes from the target topic, the second callback address in the client registration information of the first client is used to control the first client to subscribe to the target topic, that is, to change the subscription status of the first client for the target topic from unsubscribed to subscribed. This ensures that only the first client is subscribed to the target topic at this time, and there will be no message overlap when the first client consumes the messages contained in the target topic.

[0052] When there are many topics, multiple clients can be controlled concurrently to unsubscribe from the target topic, and then multiple clients can be controlled concurrently to subscribe to the target topic. This can improve the efficiency of unsubscribing and subscribing operations and ensure that there is no message overlap consumption.

[0053] In one embodiment, such as Figure 5 As shown, when the target consumption capacity value is the current consumption capacity value, allocating a target topic containing the corresponding message volume to the first client based on the target consumption capacity value includes:

[0054] Step S221: Determine whether the current consumption capacity value is lower than the lower threshold or higher than the upper threshold.

[0055] Step S2221: When the current consumption capacity value is lower than the lower limit of the threshold, the consumption topic with the largest proportion of message volume in the first client's corresponding allocated consumption topic is determined as the first reassignment topic;

[0056] Step S2222: Assign the first reassignment topic to the second client with the highest consumption capacity value among all registered clients 110;

[0057] Step S2223: After modifying the subscription status of the first client for the first redistribution topic to unsubscribed by using the first callback address in the client registration information corresponding to the first client, the consumption topic that the first client has subscribed to is taken as the target topic.

[0058] Specifically, when the target consumption capacity is the current consumption capacity, it is necessary to first determine whether the current consumption capacity can trigger topic redistribution, that is, to determine whether the current consumption capacity is too high or too low. The upper and lower thresholds can be customized according to the actual application scenario. In this embodiment, taking any value between 0 and 100 as an example, the upper threshold is 90 and the lower threshold is 10. If the current consumption capacity is lower than the lower threshold, it indicates that the first client has a high load and poor consumption capacity, which may indicate an imbalance of messages among clients 110, and message redistribution is required.

[0059] The consumption topic with the largest message volume among the assigned consumption topics for the first client is designated as the first reassignment topic. This means the central control center service 120 needs to reassign the topic with the most messages among the multiple consumption topics allocated to the first client to other clients 110, thereby reducing the load on the first client. Specifically, the first reassignment topic is assigned to the second client with the highest consumption capacity value among all registered clients 110. A high consumption capacity value indicates that the second client has excess consumption capacity. The first reassignment topic that the heavily loaded first client needs to consume is transferred to the second client with excess consumption capacity, thus balancing the message volume between the first and second clients.

[0060] To prevent both the first and second clients from consuming messages contained in the first reassigned topic simultaneously after it has been reassigned to the second client, it is necessary to first unsubscribe from the first reassigned topic through the first callback address in the client registration information of the first client. That is, to change the first client's subscription status for the first reassigned topic from subscribed to unsubscribed, and then transfer the assigned consumption topic corresponding to the first client to achieve topic reassignment for the first client. After the first client unsubscribes from the first reassigned topic, the subscribed consumption topic corresponding to the first client will be used as its target topic.

[0061] In one embodiment, such as Figure 5 As shown, after changing the subscription status of the first client for the first redistribution topic to unsubscribed, the method further includes:

[0062] Step S2224: Modify the subscription status of the second client for the first redistribution topic to "subscribed" using the second callback address in the client registration information corresponding to the second client.

[0063] Specifically, after the central control center service 120 controls the first client to unsubscribe from the first redistribution topic, the second client then subscribes to the first redistribution topic through the second callback address in the client registration information. This changes the second client's usage status for the first redistribution topic from unsubscribed to subscribed, ensuring that only one client 110 subscribes to the first redistribution topic, thus preventing the messages contained in the first redistribution topic from being consumed by both the first and second clients simultaneously.

[0064] In one embodiment, such as Figure 6 As shown, after determining whether the current consumption capacity value is lower than the lower threshold or higher than the upper threshold, the method further includes:

[0065] Step S2231: When the current consumption capacity value is higher than the upper limit of the threshold, among the consumption topics subscribed to by the third client with the lowest consumption capacity value, the consumption topic with the largest proportion of message volume is determined as the second reassignment topic.

[0066] Step S2232: Modify the subscription status of the third client for the second redistribution topic to unsubscribed by using the first callback address in the client registration information corresponding to the third client;

[0067] Step S2233: After modifying the subscription status of the first client for the second redistribution topic to "subscribed" using the second callback address in the client registration information corresponding to the first client, the consumption topic that the first client has subscribed to is taken as the target topic.

[0068] Specifically, if the current consumption capacity is higher than the upper limit of the threshold, it means that the first client has excess consumption capacity, and there may be an imbalance in message consumption among clients 110. In this case, the central control center service 120 selects the client 110 with the lowest consumption capacity value among all registered clients 110 as the third client, and selects the consumption topic with the largest message volume ratio among the consumption topics subscribed to by the third client as the second reassignment topic. The third client refers to the client 110 with the highest load in the client cluster monitored by the central control center service 120. The topic with the most messages in the topic to be consumed by the third client is selected as the second reassignment topic. In other words, the topic with the largest consumption burden of the third client is used as the second reassignment topic and redistributed to the first client with excess consumption capacity.

[0069] Topic reallocation requires first controlling the third client to unsubscribe from the second reassigned topic. This is done by unsubscribing from the second reassigned topic through the first callback address in the third client's registration information, changing the third client's subscription status from subscribed to unsubscribed. Then, the first client subscribes to the second reassigned topic through the second callback address in the first client's registration information. This means that if the second reassigned topic is not subscribed to, the first client's subscription status is changed from unsubscribed to subscribed, ensuring that only one client 110 is subscribed to the second reassigned topic at any given time.

[0070] Based on the current consumption capacity of the first client, additional consumption topics are allocated to it to achieve topic reallocation for the first client. After the first client subscribes to the second reassigned topic, the consumption topic already subscribed to by the first client is used as its corresponding target topic.

[0071] When the central control center service 120 determines that the current consumption capacity value is lower than the lower limit of the threshold or higher than the upper limit of the threshold, it generates corresponding alarm information to remind the back-end staff that the consumption messages between the various clients 110 are unbalanced. The alarm information can be used as a query record for subsequent queries.

[0072] In one embodiment, such as Figure 7 As shown, after determining whether the current consumption capacity value is lower than the lower threshold or higher than the upper threshold, the method further includes:

[0073] Step S2241: When the current consumption capacity value is between the lower threshold and the upper threshold, and / or when the number of topic reassignments within a preset time period reaches a preset number, the reassignment of the corresponding target topic to the first client based on the current consumption capacity value is rejected. The number of topic reassignments refers to the number of times topic reassignment is performed based on the load index information of client 110.

[0074] Specifically, if the current consumption capacity value is between the upper and lower thresholds, it means that the message consumption of client 110 under the supervision of the central control center service 120 is in a balanced state and no topic reallocation is required. Therefore, the corresponding target topic will not be reallocated based on the current consumption capacity value as the first client.

[0075] The central control center service 120 accumulates topic reassignment counts after redistributing topics based on the load metrics of different clients 110. However, this count does not include the number of times topics were assigned to clients 110 during their initial registration. Each topic reassignment involves a subscription / unsubscription process, requiring a recalculation of the consumption capacity values ​​of each client 110. Therefore, in large client clusters, multiple repeated topic reassignments can cause system instability. For example, a low consumption capacity value might trigger a reassignment, which could then lead to low consumption capacity values ​​on other client 110 nodes, triggering another topic reassignment. Therefore, limiting the number of topic reassignments within a preset timeframe ensures stable system operation; for example, no more than two topic reassignments per 10 minutes. Alternatively, registering a new client 110 can distribute topic traffic.

[0076] In one embodiment, the second client or the third client is a registered non-designated client 110, and the designated client 110 does not participate in topic reassignment.

[0077] Specifically, during topic reassignment, only registered non-designated clients 110 are reassigned, while designated clients 110 do not participate in topic reassignment. Designated clients 110 are pre-configured clients 110 to ensure that topic reassignment does not interfere with their message consumption process. For example, for important users' clients 110, to ensure stable message consumption, dynamic topic reassignment by other clients 110 should not interfere with their message consumption.

[0078] Based on the above method, client 110 periodically sends load indicator data, while the central control center service 120 summarizes and calculates the load indicator data. According to the redistribution watermark rules set by the central control center service 120 (i.e., determining whether it is below the lower threshold or above the upper threshold), topics can be redistributed, reducing the message consumption pressure on individual client 110. Based on the periodically reported load indicator data, dynamic planning and matching of topics and clients are achieved, realizing self-balancing of message consumption capacity.

[0079] Figure 2-8 This is a flowchart illustrating a topic assignment method in one embodiment. It should be understood that, although... Figure 2-8 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 2-8At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.

[0080] In one embodiment, such as Figure 9 As shown, a topic allocation device is provided, comprising:

[0081] The capability verification module 310 is used to determine the target consumption capability value of the first client based on the reported information when the first client is received.

[0082] The topic allocation module 320 is used to allocate a target topic containing a corresponding message volume to the first client according to the target consumption capacity value. The target topic is an unallocated topic to be consumed in the topic pool. The target topic is used to enable the first client to pull messages with a message volume corresponding to the target consumption capacity value for consumption.

[0083] In one embodiment, the capability verification module 310 is further configured to:

[0084] Upon obtaining the client registration information of the first client, the initial consumption capacity value of the first client is determined based on the client registration information, and the registration status of the first client is modified to "registered". Here, the reported information is the client registration information, and the target consumption capacity value is the initial consumption capacity value; or,

[0085] The load index information of the registered first client is obtained periodically according to a preset cycle, and the current consumption capacity value of the first client is determined based on the load index information. The reported information is the load index information, and the target consumption capacity value is the current consumption capacity value.

[0086] In one embodiment, the topic assignment module 320 is further configured to:

[0087] The ratio between the initial consumption capacity value and the total consumption capacity value is determined as the consumption capacity percentage of the first client, wherein the total consumption capacity value is the sum of the target consumption capacity values ​​of all registered clients 110;

[0088] Each topic to be consumed whose sum of message volume percentages equals the consumption capacity percentage is assigned as the target topic to the first client, wherein the message volume percentage is the ratio between the message volume contained in the consumption topic and the total message volume contained in all consumption topics in the topic pool.

[0089] In one embodiment, the topic assignment module 320 is further configured to:

[0090] Each consumption topic whose message volume percentage equals the consumption capacity percentage is assigned as the target topic to the first client, wherein the target topic is the consumption topic already assigned in the topic pool;

[0091] The previous assigning client of the target topic is determined based on the previous assignment record of the target topic;

[0092] By using the first callback address in the client registration information corresponding to the previous allocation client, the subscription status of the previous allocation client for the target topic is changed to unsubscribed;

[0093] By using the second callback address in the client registration information corresponding to the first client, the subscription status of the first client for the target topic is modified to "subscribed". The first client that has subscribed to the target topic pulls and consumes messages corresponding to the message volume of the target consumption capacity value.

[0094] In one embodiment, the topic assignment module 320 is further configured to:

[0095] Determine whether the current consumption capacity value is lower than the lower threshold or higher than the upper threshold;

[0096] When the current consumption capacity value is lower than the lower threshold, the consumption topic with the largest message volume among the first client's assigned consumption topics is determined as the first reassignment topic;

[0097] The first reassignment topic is assigned to the second client with the highest spending power value among all registered clients 110;

[0098] By using the first callback address in the client registration information corresponding to the first client, the subscription status of the first client for the first redistribution topic is changed to unsubscribed, and the consumption topic that the first client has subscribed to is taken as the target topic.

[0099] In one embodiment, the topic assignment module 320 is further configured to:

[0100] By using the second callback address in the client registration information corresponding to the second client, the subscription status of the second client for the first redistribution topic is modified to "subscribed".

[0101] In one embodiment, the topic assignment module 320 is further configured to:

[0102] When the current consumption capacity value is higher than the upper limit of the threshold, among the consumption topics subscribed to by the third client with the lowest consumption capacity value, the consumption topic with the largest proportion of message volume is determined as the second reassignment topic;

[0103] By using the first callback address in the client registration information corresponding to the third client, the subscription status of the third client for the second redistribution topic is changed to unsubscribed;

[0104] By using the second callback address in the client registration information corresponding to the first client, the subscription status of the first client for the second redistribution topic is changed to "subscribed", and the consumption topic that the first client has subscribed to is taken as the target topic.

[0105] In one embodiment, the topic assignment module 320 is further configured to:

[0106] When the current consumption capacity value is between the lower and upper limits of the threshold, and / or when the number of topic reassignments within a preset time period reaches a preset number, the reassignment of the corresponding target topic to the first client based on the current consumption capacity value is refused. The number of topic reassignments refers to the number of times topic reassignment is performed based on the load index information of client 110.

[0107] In one embodiment, the second client or the third client is a registered non-designated client 110, and the designated client 110 does not participate in topic reassignment.

[0108] like Figure 10 As shown, this application provides a computer device including a processor 711, a communication interface 712, a memory 713, and a communication bus 714, wherein the processor 711, the communication interface 712, and the memory 713 communicate with each other through the communication bus 714.

[0109] Memory 713 is used to store computer programs;

[0110] In one embodiment of this application, when the processor 711 executes the program stored in the memory 713, it implements the topic allocation method provided in any of the foregoing method embodiments.

[0111] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0112] In one embodiment, the topic allocation apparatus provided in this application can be implemented as a computer program, which can be implemented as follows: Figure 10 It runs on the computer device shown. The computer device's memory can store the various program modules that make up the topic allocation device, for example, Figure 9 The capability verification module 310 and the topic allocation module 320 are shown. The computer program, composed of these various program modules, causes the processor to execute the steps in the topic allocation methods of the various embodiments of this application described in this specification.

[0113] Figure 10 The computer device shown can be used as follows Figure 9 The capability verification module 310 in the illustrated topic allocation device determines the target consumption capability value of the first client based on the reported information received from the first client. The computer device can then allocate a target topic containing a corresponding message volume to the first client based on the target consumption capability value via the topic allocation module 320. The target topic is an unallocated topic in the topic pool, and it is used to enable the first client to pull and consume messages corresponding to the target consumption capability value.

[0114] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the topic assignment method provided in any of the foregoing method embodiments.

[0115] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0116] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0117] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.

[0118] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A topic allocation method, characterized in that, The method includes: When the first client reports information, the target consumption capacity value of the first client is determined based on the reported information. The target consumption capacity value is used to indicate the amount of messages that the operating parameters of the first client can support for consumption. According to the target consumption capacity value, a target topic containing a corresponding message volume is allocated to the first client. The target topic is an unallocated topic to be consumed in the topic pool. The target topic is used to enable the first client to pull messages with a message volume corresponding to the target consumption capacity value for consumption. When the target consumption capacity value is the initial consumption capacity value, the first client is allocated a target topic containing the corresponding message volume based on the target consumption capacity value, including: The ratio between the initial consumption capacity value and the total consumption capacity value is determined as the consumption capacity percentage of the first client, wherein the total consumption capacity value is the sum of the target consumption capacity values ​​of all registered clients; Each topic to be consumed whose sum of message volume percentages equals the consumption capacity percentage is assigned as the target topic to the first client, wherein the message volume percentage is the ratio between the message volume contained in the consumption topic and the total message volume contained in all consumption topics in the topic pool.

2. The method according to claim 1, characterized in that, Upon receiving the report information from the first client, the target consumption capacity value of the first client is determined based on the report information, including: Upon obtaining the client registration information of the first client, the initial consumption capacity value of the first client is determined based on the client registration information, and the registration status of the first client is modified to "registered". Here, the reported information is the client registration information, and the target consumption capacity value is the initial consumption capacity value; or, The load index information of the registered first client is obtained periodically according to a preset cycle, and the current consumption capacity value of the first client is determined based on the load index information. The reported information is the load index information, and the target consumption capacity value is the current consumption capacity value.

3. The method according to claim 2, characterized in that, After determining the ratio between the initial spending power value and the total spending power value as the spending power percentage of the first client, the method further includes: Each consumption topic whose message volume percentage equals the consumption capacity percentage is assigned as the target topic to the first client, wherein the target topic is the consumption topic already assigned in the topic pool; The previous assigning client of the target topic is determined based on the previous assignment record of the target topic; By using the first callback address in the client registration information corresponding to the previous allocation client, the subscription status of the previous allocation client for the target topic is changed to unsubscribed; By using the second callback address in the client registration information corresponding to the first client, the subscription status of the first client for the target topic is modified to "subscribed". The first client that has subscribed to the target topic pulls and consumes messages corresponding to the message volume of the target consumption capacity value.

4. The method according to claim 2, characterized in that, When the target consumption capacity value is the current consumption capacity value, allocating a target topic containing the corresponding message volume to the first client based on the target consumption capacity value includes: Determine whether the current consumption capacity value is lower than the lower threshold or higher than the upper threshold; When the current consumption capacity value is lower than the lower threshold, the consumption topic with the largest message volume among the first client's assigned consumption topics is determined as the first reassignment topic; The first reassignment topic is assigned to the second client with the highest spending power value among all registered clients; By using the first callback address in the client registration information corresponding to the first client, the subscription status of the first client for the first redistribution topic is changed to unsubscribed, and the consumption topic that the first client has subscribed to is taken as the target topic.

5. The method according to claim 4, characterized in that, After changing the subscription status of the first client for the first redistribution topic to unsubscribed, the method further includes: By using the second callback address in the client registration information corresponding to the second client, the subscription status of the second client for the first redistribution topic is modified to "subscribed".

6. The method according to claim 4, characterized in that, After determining whether the current consumption capacity value is lower than the lower threshold or higher than the upper threshold, the method further includes: When the current consumption capacity value is higher than the upper limit of the threshold, among the consumption topics subscribed to by the third client with the lowest consumption capacity value, the consumption topic with the largest proportion of message volume is determined as the second reassignment topic; By using the first callback address in the client registration information corresponding to the third client, the subscription status of the third client for the second redistribution topic is changed to unsubscribed; By using the second callback address in the client registration information corresponding to the first client, the subscription status of the first client for the second redistribution topic is changed to "subscribed", and the consumption topic that the first client has subscribed to is taken as the target topic.

7. The method according to claim 4, characterized in that, After determining whether the current consumption capacity value is lower than the lower threshold or higher than the upper threshold, the method further includes: When the current consumption capacity value is between the lower and upper limits of the threshold, and / or when the number of topic reassignments within a preset time period reaches a preset number, the reassignment of the corresponding target topic to the first client based on the current consumption capacity value is refused. The number of topic reassignments refers to the number of times topic reassignment is performed based on the client's load index information.

8. The method according to claim 6, characterized in that, The second client or the third client is a registered non-designated client; designated clients do not participate in topic reassignment.

9. A topic allocation device, characterized in that, The device includes: The capability confirmation module is used to determine the target consumption capacity value of the first client based on the reported information when the first client is received. The target consumption capacity value is used to indicate the amount of messages that the operating parameters of the first client can support for consumption. The topic allocation module is used to allocate a target topic containing a corresponding message volume to the first client according to the target consumption capacity value. The target topic is an unallocated topic to be consumed in the topic pool. The target topic is used to enable the first client to pull messages with a message volume corresponding to the target consumption capacity value for consumption. When the target consumption capacity value is the initial consumption capacity value, the first client is allocated a target topic containing the corresponding message volume based on the target consumption capacity value, including: The ratio between the initial consumption capacity value and the total consumption capacity value is determined as the consumption capacity percentage of the first client, wherein the total consumption capacity value is the sum of the target consumption capacity values ​​of all registered clients; Each topic to be consumed whose sum of message volume percentages equals the consumption capacity percentage is assigned as the target topic to the first client, wherein the message volume percentage is the ratio between the message volume contained in the consumption topic and the total message volume contained in all consumption topics in the topic pool.

10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.