CN116055401A - Message processing method, device, equipment and storage medium - Google Patents

Message processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN116055401A
CN116055401A CN202310193575.9A CN202310193575A CN116055401A CN 116055401 A CN116055401 A CN 116055401A CN 202310193575 A CN202310193575 A CN 202310193575A CN 116055401 A CN116055401 A CN 116055401A
Authority
CN
China
Prior art keywords
consumption
backlog
message
publish
real
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310193575.9A
Other languages
Chinese (zh)
Inventor
李志刚
高锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lenovo Beijing Ltd
Original Assignee
Lenovo Beijing Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Lenovo Beijing Ltd filed Critical Lenovo Beijing Ltd
Priority to CN202310193575.9A priority Critical patent/CN116055401A/en
Publication of CN116055401A publication Critical patent/CN116055401A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/11Identifying congestion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/12Avoiding congestion; Recovering from congestion

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本申请公开了一种消息处理方法、装置、设备及存储介质,其中,所述方法包括:获取发布订阅消息系统的消费积压实时值;基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞;调整所述发布订阅消息系统的系统参数;基于调整后的系统参数完成消息处理。

Figure 202310193575

The present application discloses a message processing method, device, device, and storage medium, wherein the method includes: acquiring the real-time consumption backlog value of the publish-subscribe message system; and determining the consumption backlog real-time value of the publish-subscribe message system Message congestion occurs; adjust system parameters of the publish-subscribe message system; complete message processing based on the adjusted system parameters.

Figure 202310193575

Description

一种消息处理方法、装置、设备及存储介质A message processing method, device, equipment and storage medium

技术领域technical field

本申请实施例涉及大数据处理领域,涉及但不限于一种消息处理方法、装置、设备及存储介质。The embodiment of the present application relates to the field of big data processing, and relates to but not limited to a message processing method, device, equipment and storage medium.

背景技术Background technique

分布式消息系统被广泛用于高性能数据管道、流分析、数据集成和关键任务应用。分布式消息系统中存在业务数据量上升或突发大量消息的场景。在该场景下通道及消费能力达到上限,消息系统能力集中在数据的转发及消息缓存,拥塞状况未反馈给生产方及消费方,从而导致无法对拥塞进行实时控制,会造成生产环境的数据挤压,导致业务处理延迟。Distributed messaging systems are widely used in high-performance data pipelines, streaming analytics, data integration, and mission-critical applications. In the distributed message system, there are scenarios where the volume of business data increases or a large number of messages burst out. In this scenario, the channel and consumption capacity reach the upper limit, and the message system capacity is concentrated on data forwarding and message buffering. The congestion status is not fed back to the producer and consumer, resulting in the inability to control the congestion in real time, which will cause data congestion in the production environment. pressure, resulting in delays in business processing.

发明内容Contents of the invention

有鉴于此,本申请实施例提供一种消息处理方法、装置、设备及存储介质。In view of this, embodiments of the present application provide a message processing method, device, device, and storage medium.

本申请实施例的技术方案是这样实现的:The technical scheme of the embodiment of the application is realized in this way:

第一方面,本申请实施例提供一种消息处理方法,所述方法包括:In the first aspect, the embodiment of the present application provides a message processing method, the method including:

获取发布订阅消息系统的消费积压实时值;Obtain the real-time value of the consumption backlog of the publish-subscribe message system;

基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞;Based on the real-time value of the consumption backlog, it is determined that message congestion occurs in the publish-subscribe message system;

调整所述发布订阅消息系统的系统参数;Adjust system parameters of the publish-subscribe message system;

基于调整后的系统参数完成消息处理。Complete message processing based on the adjusted system parameters.

第二方面,本申请实施例提供一种消息处理装置,所述装置包括:In a second aspect, an embodiment of the present application provides a message processing device, the device comprising:

获取模块,用于获取所述发布订阅消息系统的消费积压实时值;An acquisition module, configured to acquire the real-time value of the consumption backlog of the publish-subscribe message system;

确定模块,用于基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞;A determining module, configured to determine that message congestion occurs in the publish-subscribe message system based on the real-time value of the consumption backlog;

调整模块,用于调整所述发布订阅消息系统的系统参数;An adjustment module, configured to adjust system parameters of the publish-subscribe message system;

消息处理模块,用于基于调整后的系统参数完成消息处理。The message processing module is configured to complete message processing based on the adjusted system parameters.

第三方面,本申请实施例提供一种电子设备,包括存储器和处理器,所述存储器存储有可在处理器上运行的计算机程序,所述处理器执行所述程序时实现上述方法。In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, the memory stores a computer program that can run on the processor, and the processor implements the above method when executing the program.

第四方面,本申请实施例提供一种存储介质,存储有可执行指令,用于处理器执行时,实现上述方法。In a fourth aspect, the embodiment of the present application provides a storage medium storing executable instructions for implementing the above method when executed by a processor.

本申请实施例中,首先获取发布订阅消息系统的消费积压实时值;然后基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞;调整所述发布订阅消息系统的系统参数;最后基于调整后的系统参数完成消息处理。这样,可以增加拥塞控制能力,通过动态检测及拥塞反馈,在确定消息通道产生积压趋势后,调整发布订阅消息系统的系统参数,有效控制消息的生产及消费情况,以缓解消息拥塞情况。In the embodiment of the present application, first obtain the consumption backlog real-time value of the publish-subscribe message system; then based on the consumption backlog real-time value, determine that the publish-subscribe message system has message congestion; adjust the system parameters of the publish-subscribe message system; finally Complete message processing based on the adjusted system parameters. In this way, the congestion control capability can be increased. Through dynamic detection and congestion feedback, after determining the backlog trend of the message channel, adjust the system parameters of the publish-subscribe message system, effectively control the production and consumption of messages, and alleviate message congestion.

附图说明Description of drawings

图1A为本申请实施例提供的一种发布订阅消息系统的示意图;FIG. 1A is a schematic diagram of a publish-subscribe messaging system provided by an embodiment of the present application;

图1B为本申请实施例提供的一种消息处理方法的实现流程示意图;FIG. 1B is a schematic diagram of an implementation flow of a message processing method provided in an embodiment of the present application;

图2为本申请实施例提供的一种确定消息拥塞方法的实现流程示意图;FIG. 2 is a schematic diagram of an implementation flow of a method for determining message congestion provided by an embodiment of the present application;

图3为本申请实施例提供的一种确定消息拥塞方法的实现流程示意图;FIG. 3 is a schematic diagram of an implementation flow of a method for determining message congestion provided by an embodiment of the present application;

图4为本申请实施例提供的一种处理消息的解决方案架构示意图;FIG. 4 is a schematic diagram of a solution architecture for processing messages provided by an embodiment of the present application;

图5为本申请实施例提供的一种消息处理装置的组成结构示意图;FIG. 5 is a schematic structural diagram of a message processing device provided in an embodiment of the present application;

图6为本申请实施例提供的电子设备的一种硬件实体示意图。FIG. 6 is a schematic diagram of a hardware entity of an electronic device provided by an embodiment of the present application.

具体实施方式Detailed ways

为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对申请实施例的具体技术方案做进一步详细描述。以下实施例用于说明本申请,但不用来限制本申请的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the application clearer, the specific technical solutions of the embodiments of the application will be further described in detail below in conjunction with the drawings in the embodiments of the application. The following examples are used to illustrate the present application, but not to limit the scope of the present application.

在以下的描述中,涉及到“一些实施例”,其描述了所有可能实施例的子集,但是可以理解,“一些实施例”可以是所有可能实施例的相同子集或不同子集,并且可以在不冲突的情况下相互结合。In the following description, references to "some embodiments" describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or a different subset of all possible embodiments, and Can be combined with each other without conflict.

在以下的描述中,所涉及的术语“第一\第二\第三”仅仅是是区别类似的对象,不代表针对对象的特定排序,可以理解地,“第一\第二\第三”在允许的情况下可以互换特定的顺序或先后次序,以使这里描述的本申请实施例能够以除了在这里图示或描述的以外的顺序实施。In the following description, the term "first\second\third" is only used to distinguish similar objects, and does not represent a specific ordering of objects. Understandably, "first\second\third" Where permitted, the specific order or sequencing may be interchanged such that the embodiments of the application described herein can be practiced in sequences other than those illustrated or described herein.

除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中所使用的术语只是为了描述本申请实施例的目的,不是旨在限制本申请。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.

图1A为本申请实施例提供的一种发布订阅消息系统的示意图,如图1A所示,该示意图包括生产者11、消息通道及消息分区12和消费者13,其中,FIG. 1A is a schematic diagram of a publish-subscribe message system provided by an embodiment of the present application. As shown in FIG. 1A, the schematic diagram includes a producer 11, a message channel, a message partition 12, and a consumer 13, wherein,

在发布订阅消息系统中,消息的生产者(Producer)11称为发布者,消费者(Consumer)13称为订阅者。消息被持久化到消息通道(topic)及消息分区(Partition)12中。消费者可以订阅一个或多个topic,消费者11可以消费该topic中所有的数据,同一条数据可以被多个消费者消费,数据被消费后不会立马删除。In the publish-subscribe message system, the producer (Producer) 11 of the message is called the publisher, and the consumer (Consumer) 13 is called the subscriber. The message is persisted in the message channel (topic) and the message partition (Partition) 12. Consumers can subscribe to one or more topics, consumer 11 can consume all the data in the topic, the same piece of data can be consumed by multiple consumers, and the data will not be deleted immediately after consumption.

分布式消息系统中生产者及消费者自身都互不知道对方的情况。生产者不知道消费者消费发生阻塞,无法减少数据的发送频度;消费者不知道消费跟不上生产,无法弹性调整消费能力。In the distributed message system, the producers and consumers themselves do not know each other's situation. The producer does not know that the consumer's consumption is blocked, and cannot reduce the frequency of data transmission; the consumer does not know that the consumption cannot keep up with the production, and cannot flexibly adjust the consumption capacity.

本申请实施例提供一种消息处理方法,如图1B所示,该方法包括:The embodiment of the present application provides a message processing method, as shown in Figure 1B, the method includes:

步骤S110、获取发布订阅消息系统的消费积压实时值;Step S110, obtaining the real-time value of the consumption backlog of the publish-subscribe message system;

这里,发布订阅是一种消息范式,消息的生产者不会将消息直接发送给特定的消费者。而是将发布的消息分为不同的类别,无需确定哪些订阅者可能存在。同样的,订阅者可以表达对一个或多个类别的兴趣,只接收感兴趣的消息,无需确定哪些发布者存在。举例来说,Kafka是一种高吞吐量的分布式发布订阅消息系统,可以处理消费者在网站中的所有动作流数据。Here, publish-subscribe is a message paradigm, and the producer of the message will not send the message directly to a specific consumer. Instead, the published messages are grouped into different categories without having to determine which subscribers might exist. Likewise, Subscribers can express interest in one or more categories and only receive messages of interest without having to determine which Publishers exist. For example, Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all action stream data of consumers in the website.

消费积压值(LAG),消息中间件服务端中所留存的消息与消费掉的消息之间的差值,即消息堆积量也称之为消费滞后量。Lag取值有正负数和0。Lag取值正数代表kafka数据积压了,往kafka进数据的速度,大于这个数据被消费的速度,供大于求。Lag取值负数,说明供小于求。Lag取值为0,说明生产者和消费者速率基本相当。繁忙的消息系统中LAG一般会大于0,并保持在一个比较恒定的值,表示生产与消费达到一个平衡。Consumption backlog value (LAG), the difference between the messages retained in the message middleware server and the consumed messages, that is, the amount of message accumulation is also called the consumption lag. The value of Lag has positive and negative numbers and 0. A positive Lag value means that Kafka data is backlogged, and the speed at which data is fed to Kafka is greater than the speed at which this data is consumed, indicating that the supply exceeds demand. Lag takes a negative value, indicating that supply is less than demand. The Lag value is 0, indicating that the producer and consumer rates are basically the same. In a busy message system, LAG is generally greater than 0 and remains at a relatively constant value, indicating that production and consumption have reached a balance.

在实施过程中,可以实时获取发布订阅消息系统的消费积压值,即获取到当前用于表征生产消息和消费消息之间差值的消费积压值。During the implementation process, the consumption backlog value of the publish-subscribe message system can be obtained in real time, that is, the consumption backlog value currently used to represent the difference between the production message and the consumption message can be obtained.

步骤S120、基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞;Step S120, based on the real-time value of the consumption backlog, determine that message congestion occurs in the publish-subscribe message system;

这里,由于消费积压实时值可以用于表征生产消息和消费消息之间差值,所以在确定消费积压实时值加大的情况下,可以确定生产的消息数量不能及时进行消费,即该发布订阅消息系统出现消息拥塞。Here, since the real-time value of the consumption backlog can be used to represent the difference between the production message and the consumption message, when the real-time value of the consumption backlog is determined to increase, it can be determined that the number of produced messages cannot be consumed in time, that is, the publish-subscribe message The system is congested with messages.

步骤S130、调整所述发布订阅消息系统的系统参数;Step S130, adjusting the system parameters of the publish-subscribe message system;

这里,发布订阅消息系统的系统参数至少包括消费者数量、分区数量和生产者数量。在实施过程中,可以在确定发布订阅消息系统出现消息拥塞的情况下,调整以上至少一个系统参数,以缓解消息拥塞情况。举例来说,生产者和消费者可以根据拥塞情况,调整数据的发送和数据消费的能力来解决拥塞。Here, the system parameters of the publish-subscribe message system include at least the number of consumers, the number of partitions and the number of producers. During the implementation process, at least one of the above system parameters may be adjusted to alleviate message congestion when it is determined that message congestion occurs in the publish-subscribe message system. For example, producers and consumers can adjust data sending and data consumption capabilities according to congestion conditions to resolve congestion.

步骤S140、基于调整后的系统参数完成消息处理。Step S140, complete message processing based on the adjusted system parameters.

在实施过程中,基于调整后的系统参数完成消息处理,可以有效缓解发布订阅消息系统的消息拥塞情况。During the implementation process, the message processing is completed based on the adjusted system parameters, which can effectively alleviate the message congestion of the publish-subscribe message system.

本申请实施例中,首先获取发布订阅消息系统的消费积压实时值;然后基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞;调整所述发布订阅消息系统的系统参数;最后基于调整后的系统参数完成消息处理。这样,可以增加拥塞控制能力,通过动态检测及拥塞反馈,在确定消息通道产生积压趋势后,调整发布订阅消息系统的系统参数,有效控制消息的生产及消费情况,以缓解消息拥塞情况。In the embodiment of the present application, first obtain the consumption backlog real-time value of the publish-subscribe message system; then based on the consumption backlog real-time value, determine that the publish-subscribe message system has message congestion; adjust the system parameters of the publish-subscribe message system; finally Complete message processing based on the adjusted system parameters. In this way, the congestion control capability can be increased. Through dynamic detection and congestion feedback, after determining the backlog trend of the message channel, adjust the system parameters of the publish-subscribe message system, effectively control the production and consumption of messages, and alleviate message congestion.

在一些实施例中,如图2所示,以上步骤S120“基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞”可以通过以下步骤实现:In some embodiments, as shown in FIG. 2, the above step S120 of "determining that message congestion occurs in the publish-subscribe message system based on the real-time value of the consumption backlog" may be implemented through the following steps:

步骤S210、获取预设的消费积压阈值;Step S210, acquiring a preset consumption backlog threshold;

这里,可以根据发布订阅消息系统的消息处理能力,确定该消费积压阈值。Here, the consumption backlog threshold can be determined according to the message processing capability of the publish-subscribe message system.

步骤S220、确定所述消费积压实时值大于所述消费积压阈值;Step S220, determining that the real-time value of the consumption backlog is greater than the consumption backlog threshold;

在实施过程中,可以将实时获取的消费积压值与该消息积压阈值进行比对,以确定费积压实时值是否大于所述消费积压阈值。在确定消费积压实时值大于所述消费积压阈值的情况下,可以确定发布订阅消息系统的消息处理能力已经无法满足当前的消息生产,举例来说,在业务数据量上升或突发大量消息的场景下,消费积压实时值大于消费积压阈值,通道及消费能力达到上限,会造成生产环境的数据挤压,导致业务处理延迟。During implementation, the consumption backlog value obtained in real time may be compared with the message backlog threshold to determine whether the real-time fee backlog value is greater than the consumption backlog threshold. When it is determined that the consumption backlog real-time value is greater than the consumption backlog threshold, it can be determined that the message processing capability of the publish-subscribe message system cannot meet the current message production. For example, in the scenario where the business data volume increases or a large number of messages burst Under normal circumstances, the real-time value of the consumption backlog is greater than the consumption backlog threshold, and the channel and consumption capacity reach the upper limit, which will cause data squeeze in the production environment and cause business processing delays.

步骤S230、确定所述发布订阅消息系统出现消息拥塞。Step S230, determining that message congestion occurs in the publish-subscribe message system.

本申请实施例中,首先获取预设的消费积压阈值;然后确定所述消费积压实时值大于所述消费积压阈值;确定所述发布订阅消息系统出现消息拥塞。这样,可以基于消费积压阈值,确定消费积压实时值大于消费积压阈值,进一步有效确定发布订阅消息系统出现消息拥塞。In the embodiment of the present application, first obtain the preset consumption backlog threshold; then determine that the consumption backlog real-time value is greater than the consumption backlog threshold; determine that the publish-subscribe message system has message congestion. In this way, based on the consumption backlog threshold, it can be determined that the consumption backlog real-time value is greater than the consumption backlog threshold, and further effectively determine that message congestion occurs in the publish-subscribe message system.

在一些实施例中,以上步骤S210“获取预设的消费积压阈值”可以通过以下步骤实现:In some embodiments, the above step S210 of "obtaining a preset consumption backlog threshold" may be implemented through the following steps:

步骤211、获取单位时间内所述发布订阅消息系统的生产消息数量;Step 211, obtaining the number of production messages of the publish-subscribe message system per unit time;

这里,可以获取单位时间(n分钟)生产消息数量。Here, the number of production messages per unit time (n minutes) can be obtained.

步骤212、获取所述生产消息数量对应的比例阈值;Step 212. Obtain a ratio threshold corresponding to the number of production messages;

这里,可以获取单位时间(n分钟)生产消息数量对应的比例阈值(m%)。Here, a ratio threshold (m%) corresponding to the number of production messages per unit time (n minutes) may be obtained.

在实施过程中,可以先执行步骤211再执行步骤212,还可以先执行步骤212再执行步骤211,也可以同时执行步骤211和步骤212,即对步骤211和步骤212的执行先后顺序不做要求。In the implementation process, step 211 can be performed first and then step 212 can be performed, step 212 can also be performed first and then step 211 can be performed, or step 211 and step 212 can be performed simultaneously, that is, there is no requirement for the order of execution of step 211 and step 212 .

步骤213、将所述生产消息数量与所述比例阈值相乘,得到所述消费积压阈值。Step 213: Multiply the production message quantity by the ratio threshold to obtain the consumption backlog threshold.

这里,可以将生产消息数量与比例阈值相乘,得到所述消费积压阈值。Here, the consumption backlog threshold can be obtained by multiplying the production message quantity by the ratio threshold.

实施过程中,可以利用以下公式(1),确定发生消息系统拥塞:During the implementation process, the following formula (1) can be used to determine the occurrence of message system congestion:

Figure BDA0004108003020000061
Figure BDA0004108003020000061

本申请实施例中,首先获取单位时间内所述发布订阅消息系统的生产消息数量;获取所述生产消息数量对应的比例阈值;然后将所述生产消息数量与所述比例阈值相乘,得到所述消费积压阈值。这样,可以基于单位时间内发布订阅消息系统的生产消息数量确定一个有效的消费积压阈值。In this embodiment of the application, first obtain the production message quantity of the publish-subscribe message system per unit time; obtain the ratio threshold corresponding to the production message quantity; then multiply the production message quantity by the ratio threshold to obtain the The above consumption backlog threshold. In this way, an effective consumption backlog threshold can be determined based on the number of production messages of the publish-subscribe message system per unit time.

在一些实施例中,以上步骤S210“获取预设的消费积压阈值”可以通过以下过程实现:In some embodiments, the above step S210 of "obtaining a preset consumption backlog threshold" may be implemented through the following process:

基于发布订阅消息系统的消息处理能力,确定所述消费积压阈值。The consumption backlog threshold is determined based on the message processing capability of the publish-subscribe message system.

这里,可以在确定LAG值高于配置值(N)的情况下,确定消息系统拥塞。Here, it may be determined that the message system is congested when it is determined that the LAG value is higher than the configured value (N).

实施过程中,可以利用以下公式(2),确定发生消息系统拥塞:During the implementation process, the following formula (2) can be used to determine the occurrence of message system congestion:

LAG > N                                             (2);LAG > N (2);

其中,N为配置值,即消费积压阈值。Among them, N is the configuration value, that is, the consumption backlog threshold.

本申请实施例中,可以基于发布订阅消息系统的消息处理能力,有效确定确定消费积压阈值。In the embodiment of the present application, the consumption backlog threshold can be effectively determined based on the message processing capability of the publish-subscribe message system.

在一些实施例中,如图3所示,在步骤S220“确定所述发布订阅消息系统出现消息拥塞”之前,确定发布订阅消息系统出现消息拥塞的方法还包括:In some embodiments, as shown in FIG. 3 , before step S220 "determining that message congestion occurs in the publish-subscribe messaging system", the method for determining that message congestion occurs in the publish-subscribe messaging system further includes:

步骤S310、相隔单位时间分别获取第一消费积压值和第二消费积压值;Step S310, acquiring the first consumption backlog value and the second consumption backlog value respectively at intervals of unit time;

这里,单位时间可以根据实际情况设置,举例来说,可以设置单位时间为一分钟,也可以设置单位时间为一秒钟。Here, the unit time can be set according to the actual situation, for example, the unit time can be set as one minute, or the unit time can be set as one second.

在实施过程中,可以在x-1时刻获取LAGx-1,在x时刻获取LAGx,即相隔单位时间分别获取第一消费积压值LAGx-1和第二消费积压值LAGxIn the implementation process, LAG x -1 can be obtained at time x-1, and LAG x can be obtained at time x, that is, the first consumption backlog value LAG x-1 and the second consumption backlog value LAG x are respectively obtained at a unit time interval.

步骤S320、将所述第一消费积压值减去所述第二消费积压值,得到消费积压差值;Step S320, subtracting the second consumption backlog value from the first consumption backlog value to obtain a consumption backlog difference;

在实施过程中,可以将LAGx减去LAGx-1,得到消费积压差值。During implementation, LAG x-1 can be subtracted from LAG x to obtain the consumption backlog difference.

步骤S330、将所述消费积压差值除以所述单位时间,得到消费积压斜率值;Step S330, dividing the consumption backlog difference by the unit time to obtain a consumption backlog slope value;

在实施过程中,可以基于以下公式(3)得到消费积压斜率值,实时斜率P即:During the implementation process, the consumption backlog slope value can be obtained based on the following formula (3), and the real-time slope P is:

Figure BDA0004108003020000071
Figure BDA0004108003020000071

其中,LAGx为x时刻的LAG,LAGx-1为x-1时刻的LAG,Tx为x时刻的时间值,Tx-1为x-1时刻的时间值。Wherein, LAG x is the LAG at time x, LAG x-1 is the LAG at time x-1, T x is the time value at time x, and T x-1 is the time value at time x-1.

步骤S340、获取消费积压斜率阈值;Step S340, acquiring the consumption backlog slope threshold;

在实施过程中,可以基于布订阅消息系统的消息处理能力,确定该消费积压斜率阈值。During implementation, the consumption backlog slope threshold may be determined based on the message processing capability of the subscription message system.

步骤S350、确定至少两个连续所述消费积压斜率值大于所述消费积压斜率阈值。Step S350, determining that at least two consecutive consumption backlog slope values are greater than the consumption backlog slope threshold.

在一些实施例中,可以在确定至少两个连续P的取值高于消费积压斜率阈值的情况下,确定消息系统拥塞。In some embodiments, it may be determined that the message system is congested when it is determined that at least two consecutive values of P are higher than the consumption backlog slope threshold.

本申请实施例中,首先相隔单位时间分别获取第一消费积压值和第二消费积压值;然后将所述第一消费积压值减去所述第二消费积压值,得到消费积压差值;将所述消费积压差值除以所述单位时间,得到消费积压斜率值;获取消费积压斜率阈值;最后确定至少两个连续所述消费积压斜率值大于所述消费积压斜率阈值。这样,可以基于消费积压斜率值确定该发布订阅消息系统出现消息拥塞。In the embodiment of the present application, firstly, the first consumption backlog value and the second consumption backlog value are respectively obtained at intervals of unit time; then the first consumption backlog value is subtracted from the second consumption backlog value to obtain the consumption backlog difference value; Divide the consumption backlog difference by the unit time to obtain the consumption backlog slope value; obtain the consumption backlog slope threshold; finally determine that at least two consecutive consumption backlog slope values are greater than the consumption backlog slope threshold. In this way, it can be determined based on the consumption backlog slope value that message congestion occurs in the publish-subscribe message system.

在一些实施例中,所述系统参数至少包括消费者数量、分区数量和生产者数量,以上步骤S130“调整所述发布订阅消息系统的系统参数”可以通过以下任一步骤实现:In some embodiments, the system parameters include at least the number of consumers, the number of partitions and the number of producers, and the above step S130 "adjusting the system parameters of the publish-subscribe message system" can be implemented by any of the following steps:

步骤131、在确定所述消费者数量小于所述分区数量的情况下,增加所述消费者数量;Step 131. When it is determined that the number of consumers is smaller than the number of partitions, increase the number of consumers;

这里,确定消费者数量小于分区数量,且生产者数量不变的情况下,可以通过增加消费者数量来缓解消息拥塞。Here, if the number of consumers is determined to be smaller than the number of partitions and the number of producers remains unchanged, message congestion can be alleviated by increasing the number of consumers.

步骤132、在确定所述消费者数量等于所述分区数量的情况下,同时增加所述分区数量和所述消费者数量;Step 132, when it is determined that the number of consumers is equal to the number of partitions, increase the number of partitions and the number of consumers at the same time;

这里,确定消费者数量等于分区数量,且生产者数量不变的情况下,可以通过同时增加分区数量和消费者数量来缓解消息拥塞。Here, if the number of consumers is determined to be equal to the number of partitions and the number of producers remains unchanged, message congestion can be alleviated by increasing the number of partitions and the number of consumers at the same time.

举例来说,一个消息队列中会包括至少一个分区,每个分区对应一个工作的消费者(多个分区可以共用消费者,分区的数量决定了工作消费者的上限),所以增加分区意味着扩充了消费者的上限,从而为后续增加消费者奠定基础。For example, a message queue will include at least one partition, and each partition corresponds to a working consumer (multiple partitions can share consumers, and the number of partitions determines the upper limit of working consumers), so adding partitions means expanding The upper limit of consumers is set, thus laying the foundation for the subsequent increase of consumers.

在消息拥塞的情况下,动态增加分区数量,并动态通知消费方,消费方就可以按照最新的分区数量上限增加更多的消费者来增加处理能力,减少拥塞。In the case of message congestion, dynamically increase the number of partitions and dynamically notify the consumer, so that the consumer can add more consumers according to the latest upper limit of the number of partitions to increase processing capacity and reduce congestion.

步骤133、在确定所述生产者数量、所述消费者数量和所述分区数量不变的情况下,降低所述生产者的生产频度。Step 133 , if it is determined that the number of producers, the number of consumers and the number of partitions remain unchanged, reduce the production frequency of the producers.

这里,消费者限于资源不能再增加的情况下,可以通过降低生产者的生产频度来缓解消息拥塞。Here, the consumer is limited to the situation where resources cannot be increased, and the message congestion can be alleviated by reducing the production frequency of the producer.

举例来说,可以将消息拥塞情况告知生产者,对于可以调整发送能力的生产者(比如降低数据采集周期),就可以通过发送减速的方式解决拥堵问题,比如从每秒发送给100个,减少每秒发送10个。这个适用于数据可以被减速发送的场景。For example, the producer can be notified of the message congestion situation. For producers who can adjust the sending capacity (such as reducing the data collection cycle), the congestion problem can be solved by sending a deceleration method, such as sending from 100 per second, reducing Send 10 per second. This applies to scenarios where data can be decelerated.

本申请实施例中,在确定所述消费者数量小于所述分区数量的情况下,增加所述消费者数量;或者,在确定所述消费者数量等于所述分区数量的情况下,同时增加所述分区数量和所述消费者数量;或者,在确定所述生产者数量、所述消费者数量和所述分区数量不变的情况下,降低所述生产者的生产频度。这样,可以有效缓解消息拥塞。In this embodiment of the application, if it is determined that the number of consumers is less than the number of partitions, increase the number of consumers; or, if it is determined that the number of consumers is equal to the number of partitions, increase the number of The number of partitions and the number of consumers; or, in a case where it is determined that the number of producers, the number of consumers, and the number of partitions remain unchanged, reduce the production frequency of the producer. In this way, message congestion can be effectively alleviated.

在一些实施例中,以上步骤S110“获取所述发布订阅消息系统的消费积压实时值”可以通过以下步骤实现:In some embodiments, the above step S110 of "obtaining the real-time value of the consumption backlog of the publish-subscribe message system" may be implemented through the following steps:

步骤111、实时获取所述发布订阅消息系统的生产消息数和已读消息数;Step 111, obtaining the number of produced messages and the number of read messages of the publish-subscribe message system in real time;

在实施过程中,可以获取生产消息数EndOffset和已经读取消息数CommitOffset。During implementation, the number of produced messages EndOffset and the number of read messages CommitOffset can be obtained.

步骤112、将所述生产消息数减去所述已读消息数,得到所述消费积压实时值。Step 112: Subtract the number of read messages from the number of produced messages to obtain the real-time value of the consumption backlog.

在实施过程中,可以利用以下公式(4),得到消费加压实时值:During the implementation process, the following formula (4) can be used to obtain the real-time value of consumption pressure:

Lag=EndOffset-CommitOffset                               (4);Lag=EndOffset-CommitOffset (4);

其中,Lag表示消费积压值,EndOffset表示生产消息数,CommitOffset表示已经读取消息数。Among them, Lag indicates the consumption backlog value, EndOffset indicates the number of produced messages, and CommitOffset indicates the number of read messages.

本申请实施例中,首先实时获取所述发布订阅消息系统的生产消息数和已读消息数;然后将所述生产消息数减去所述已读消息数,得到所述消费积压实时值。这样,可以通过实时获取的生产消息数和已读消息数,得到消费积压实时值。In the embodiment of the present application, the number of produced messages and the number of read messages of the publish-subscribe message system are obtained in real time; then the number of produced messages is subtracted from the number of read messages to obtain the real-time value of the consumption backlog. In this way, the real-time value of the consumption backlog can be obtained by obtaining the number of production messages and the number of read messages obtained in real time.

目前分布式消息系统被广泛用于高性能数据管道、流分析、数据集成和关键任务应用。消息发送和接收一般包括如下步骤:Distributed messaging systems are currently widely used in high-performance data pipelines, streaming analytics, data integration, and mission-critical applications. Message sending and receiving generally includes the following steps:

步骤A、消息通道准备;Step A, message channel preparation;

在消息通道准备阶段,可以先创建好消息通道(topic)及消息分区(Partition)。In the message channel preparation stage, you can first create a message channel (topic) and a message partition (Partition).

步骤B、消息发送数据;Step B, message sending data;

在消息发送数据阶段,生产者发送数据时消息会根据规则将消息发送到指定的消息分区中。In the message sending data stage, when the producer sends data, the message will be sent to the specified message partition according to the rules.

步骤C、消息接收数据;Step C, message receiving data;

在消息接收数据阶段,消费者订阅消息分区,实现消息的并行接收和处理。In the stage of message receiving data, consumers subscribe to message partitions to realize parallel reception and processing of messages.

图4为本申请实施例提供的一种处理消息的解决方案架构示意图,如图4所示,该解决方案架构图包括现有消息系统41和拥塞控制服务42,其中,FIG. 4 is a schematic diagram of a solution architecture for processing messages provided by an embodiment of the present application. As shown in FIG. 4 , the solution architecture diagram includes an existing message system 41 and a congestion control service 42, wherein,

该拥塞控制服务42基于现有消息系统41进行扩展,提供拥塞控制能力,支撑消息发送通路形成闭环。The congestion control service 42 is extended based on the existing messaging system 41 to provide congestion control capabilities and support message sending channels to form a closed loop.

拥塞控制服务42包括消息通道吞吐及堆积信息收集服务421、数据分析及自动调整服务422和上层应用服务423。Congestion control service 42 includes message channel throughput and accumulation information collection service 421 , data analysis and automatic adjustment service 422 and upper layer application service 423 .

消息通道吞吐及堆积信息收集服务421,负责通道监控及基本信息收集,用于实时统计测算生产、消费吞吐及拥塞情况。Message channel throughput and accumulation information collection service 421 is responsible for channel monitoring and basic information collection for real-time statistical calculation of production, consumption throughput and congestion.

数据分析及自动调整服务422,按照策略进行数据分析后,将消息通道的吞吐及堆积情况通知给上层应用。可以感知并调整发送数量及消费能力,还可以自动调整消息通道的分区数量,并将策略调整情况通知“上层应用”。支持多场景消息积压自动识别(按阈值为单位时间生产消息数量的一定比例;按阈值为绝对数量;按堆积走势超过一定的斜率),在确定消息积压的情况下,启动自动调整策略,以调整消息通道(topic)和消息分区(Partition),实现分区自动调整策略,动态增加消息分区的数量。The data analysis and automatic adjustment service 422, after analyzing the data according to the policy, notifies the upper-layer application of the throughput and accumulation of the message channel. It can perceive and adjust the number of sending and consumption capabilities, and can also automatically adjust the number of partitions of the message channel, and notify the "upper layer application" of the policy adjustment. Supports automatic identification of multi-scenario message backlogs (the threshold is a certain percentage of the number of messages produced per unit time; the threshold is an absolute number; the accumulation trend exceeds a certain slope), and when the message backlog is determined, an automatic adjustment strategy is activated to adjust Message channel (topic) and message partition (Partition), realize the partition automatic adjustment strategy, and dynamically increase the number of message partitions.

本申请实施例提供三种策略进行数据分析:The embodiment of this application provides three strategies for data analysis:

策略1:取消费积压阈值为单位时间内生产消息数量的一定比例。举例来说,可以获取单位时间(n分钟)生产消息数量的一定比例(m%)。LAG值高于该消费积压阈值,则确定消息系统拥塞。Strategy 1: The threshold for canceling the consumption backlog is a certain proportion of the number of production messages per unit time. For example, a certain proportion (m%) of the number of production messages per unit time (n minutes) may be acquired. If the LAG value is higher than the consumption backlog threshold, it is determined that the message system is congested.

实施过程中,可以利用以下公式(1),确定发生消息系统拥塞:During the implementation process, the following formula (1) can be used to determine the occurrence of message system congestion:

LAG>n分钟内生产消息数量*m%(1)。LAG>number of messages produced within n minutes*m%(1).

策略2:基于发布订阅消息系统的消息处理能力,确定所述消费积压阈值,即在确定LAG值高于配置值(N)的情况下,确定消息系统拥塞。Strategy 2: Determine the consumption backlog threshold based on the message processing capability of the publish-subscribe message system, that is, determine that the message system is congested when the LAG value is determined to be higher than the configured value (N).

实施过程中,可以利用以下公式(2),确定发生消息系统拥塞:During the implementation process, the following formula (2) can be used to determine the occurrence of message system congestion:

LAG > N                                             (2);LAG > N (2);

其中,N为配置值。Among them, N is the configuration value.

策略3:在消息的按堆积走势超过一定的斜率的情况下,确定消息系统拥塞。Strategy 3: When the accumulation trend of messages exceeds a certain slope, it is determined that the message system is congested.

获取消费积压斜率阈值,基于以下公式(3)得到实时斜率P:Obtain the consumption backlog slope threshold, and obtain the real-time slope P based on the following formula (3):

Figure BDA0004108003020000101
Figure BDA0004108003020000101

其中,LAGx为x时刻的LAG,LAGx-1为x-1时刻的LAG,Tx为x时刻的时间值,Tx-1为x-1时刻的时间值。Wherein, LAG x is the LAG at time x, LAG x-1 is the LAG at time x-1, T x is the time value at time x, and T x-1 is the time value at time x-1.

在一些实施例中,可以在确定P的取值连续M次高于消费积压斜率阈值的情况下,确定消息系统拥塞。In some embodiments, it may be determined that the message system is congested when it is determined that the value of P is higher than the consumption backlog slope threshold for M consecutive times.

这里,策略的配置及开启与否是通过阈值方式配置,通过修改配置的方式上调,一般根据业务需求确定配置值。包括在业务需求分析阶段确定分区的初始值,运行后可以同时使用三个开启的策略的监控数据,在任一策略下确定消息拥塞,则通知上层应用,并增加分区数量和消费者数量。Here, the configuration of the policy and whether it is enabled or not is configured through the threshold method, and is adjusted up by modifying the configuration. Generally, the configuration value is determined according to the business requirements. It includes determining the initial value of the partition during the business requirement analysis stage. After running, the monitoring data of the three enabled strategies can be used at the same time. If message congestion is determined under any strategy, the upper-layer application will be notified, and the number of partitions and consumers will be increased.

以上三个策略是否生效可以通过配置开关开启,即可以同时开启多个。举例来说,策略1和策略2都开启了,在监控中检测到任何一个策略达到了阈值,都会进行调整分区数量和通知上层应用。Whether the above three strategies take effect can be enabled through the configuration switch, that is, more than one can be enabled at the same time. For example, both policy 1 and policy 2 are enabled, and if any policy is detected to have reached the threshold during monitoring, the number of partitions will be adjusted and the upper-layer application will be notified.

上层应用服务423,用于根据策略调整上层消费者数量。The upper layer application service 423 is used to adjust the number of upper layer consumers according to the policy.

本申请实施例中,通道增加拥塞控制能力,通过动态检测及拥塞反馈,使消息发送通路形成闭环,有效控制消息的生产及消费情况。这样,消息通道产生积压趋势后,自动按照策略调整通道容量,支持大消息数据的弹性处理。通道积压感知及调整耗时周期从原来的天或小时级别提升至分钟级别。全程无需重新启动上层应用,无需中断线上业务运行,无需管理员干预。In the embodiment of this application, the channel increases the congestion control capability, and through dynamic detection and congestion feedback, the message transmission path forms a closed loop, effectively controlling the production and consumption of messages. In this way, after the message channel has a backlog trend, the channel capacity is automatically adjusted according to the policy, supporting the flexible processing of large message data. The time-consuming cycle of channel backlog perception and adjustment is increased from the original day or hour level to the minute level. There is no need to restart the upper-layer application in the whole process, no need to interrupt the online business operation, and no need for administrator intervention.

基于前述的实施例,本申请实施例提供一种消息处理装置,该装置包括所包括的各模块,各模块包括各子模块,各子模块包括单元,可以通过电子设备中的处理器来实现;当然也可通过具体的逻辑电路实现;在实施的过程中,处理器可以为中央处理器(CentralProcessing Unit,CPU)、微处理器(Microprocessor Unit,MPU)、数字信号处理器(DigitalSignal Process,DSP)或现场可编程门阵列(Field Programmable Gate Array,FPGA)等。Based on the aforementioned embodiments, this embodiment of the present application provides a message processing device, the device includes each module included, each module includes each sub-module, each sub-module includes a unit, and can be implemented by a processor in an electronic device; Of course, it can also be realized by a specific logic circuit; in the process of implementation, the processor can be a central processing unit (Central Processing Unit, CPU), a microprocessor (Microprocessor Unit, MPU), a digital signal processor (DigitalSignal Process, DSP) Or Field Programmable Gate Array (Field Programmable Gate Array, FPGA), etc.

图5为本申请实施例提供的消息处理装置的组成结构示意图,如图5所示,所述装置500包括:FIG. 5 is a schematic diagram of the composition and structure of the message processing device provided by the embodiment of the present application. As shown in FIG. 5, the device 500 includes:

获取模块510,用于获取所述发布订阅消息系统的消费积压实时值;An acquisition module 510, configured to acquire the real-time value of the consumption backlog of the publish-subscribe message system;

确定模块520,用于基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞;A determining module 520, configured to determine that message congestion occurs in the publish-subscribe message system based on the real-time value of the consumption backlog;

调整模块530,用于调整所述发布订阅消息系统的系统参数;An adjustment module 530, configured to adjust system parameters of the publish-subscribe messaging system;

消息处理模块540,用于基于调整后的系统参数完成消息处理。The message processing module 540 is configured to complete message processing based on the adjusted system parameters.

在一些实施例中,所述确定模块520包括第一获取子模块、第一确定子模块和第二确定子模块,其中,所述第一获取子模块,用于获取预设的消费积压阈值;所述第一确定子模块,用于确定所述消费积压实时值大于所述消费积压阈值;所述第二确定子模块,用于确定所述发布订阅消息系统出现消息拥塞。In some embodiments, the determination module 520 includes a first acquisition submodule, a first determination submodule and a second determination submodule, wherein the first acquisition submodule is used to acquire a preset consumption backlog threshold; The first determining submodule is configured to determine that the consumption backlog real-time value is greater than the consumption backlog threshold; the second determining submodule is configured to determine that message congestion occurs in the publish-subscribe message system.

在一些实施例中,所述第一获取子模块包括第一获取单元、第二获取单元和乘法单元,其中,所述第一获取单元,用于获取单位时间内所述发布订阅消息系统的生产消息数量;所述第二获取单元,用于获取所述生产消息数量对应的比例阈值;所述乘法单元,用于将所述生产消息数量与所述比例阈值相乘,得到所述消费积压阈值。In some embodiments, the first acquisition submodule includes a first acquisition unit, a second acquisition unit, and a multiplication unit, wherein the first acquisition unit is used to acquire the output of the publish-subscribe messaging system per unit time The number of messages; the second acquisition unit is configured to acquire a ratio threshold corresponding to the number of production messages; the multiplication unit is configured to multiply the number of production messages by the ratio threshold to obtain the consumption backlog threshold .

在一些实施例中,所述第一获取子模块,还用于基于所发布订阅消息系统的消息处理能力,确定所述消费积压阈值。In some embodiments, the first obtaining submodule is further configured to determine the consumption backlog threshold based on the message processing capability of the publish-subscribe message system.

在一些实施例中,所述确定模块520还包括第二获取子模块、第一减法子模块、除法子模块、第三获取子模块和第三确定子模块,其中,所述第二获取子模块,用于相隔单位时间分别获取第一消费积压值和第二消费积压值;所述第一减法子模块,用于将所述第一消费积压值减去所述第二消费积压值,得到消费积压差值;所述除法子模块,用于将所述消费积压差值除以所述单位时间,得到消费积压斜率值;所述第三获取子模块,用于获取消费积压斜率阈值;所述第三确定子模块,用于确定至少两个连续所述消费积压斜率值大于所述消费积压斜率阈值。In some embodiments, the determination module 520 further includes a second acquisition submodule, a first subtraction submodule, a division submodule, a third acquisition submodule and a third determination submodule, wherein the second acquisition submodule , used to obtain the first consumption backlog value and the second consumption backlog value respectively at intervals of unit time; the first subtraction submodule is used to subtract the second consumption backlog value from the first consumption backlog value to obtain the consumption The backlog difference; the division submodule is used to divide the consumption backlog difference by the unit time to obtain the consumption backlog slope value; the third acquisition submodule is used to obtain the consumption backlog slope threshold; the The third determining submodule is configured to determine that at least two consecutive consumption backlog slope values are greater than the consumption backlog slope threshold.

在一些实施例中,所述调整模块530包括第一增加子模块、第二增加子模块和降低子模块,其中,所述第一增加子模块,用于在确定所述消费者数量小于所述分区数量的情况下,增加所述消费者数量;所述第二增加子模块,用于在确定所述消费者数量等于所述分区数量的情况下,同时增加所述分区数量和所述消费者数量;所述降低子模块,用于在确定所述生产者数量、所述消费者数量和所述分区数量不变的情况下,降低所述生产者的生产频度。In some embodiments, the adjustment module 530 includes a first increase submodule, a second increase submodule and a decrease submodule, wherein the first increase submodule is used to determine that the number of consumers is less than the In the case of the number of partitions, increase the number of consumers; the second increasing submodule is used to increase the number of partitions and the number of consumers when it is determined that the number of consumers is equal to the number of partitions Quantity; the reducing submodule is used to reduce the production frequency of the producer under the condition that the quantity of the producer, the quantity of the consumer and the quantity of the partition are determined to be unchanged.

在一些实施例中,所述获取模块510包括第四获取子模块和第二减法子模块,其中,所述第四获取子模块,用于实时获取所述发布订阅消息系统的生产消息数和已读消息数;所述第二减法子模块,用于将所述生产消息数减去所述已读消息数,得到所述消费积压实时值。In some embodiments, the acquisition module 510 includes a fourth acquisition submodule and a second subtraction submodule, wherein the fourth acquisition submodule is used to acquire the number of produced messages and the number of already generated messages of the publish-subscribe message system in real time The number of read messages; the second subtraction submodule is used to subtract the number of read messages from the number of produced messages to obtain the real-time value of the consumption backlog.

以上装置实施例的描述,与上述方法实施例的描述是类似的,具有同方法实施例相似的有益效果。对于本申请装置实施例中未披露的技术细节,请参照本申请方法实施例的描述而理解。The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.

需要说明的是,本申请实施例中,如果以软件功能模块的形式实现上述方法,并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对相关技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得电子设备(可以是手机、平板电脑、笔记本电脑、台式计算机等)执行本申请各个实施例所述方法的全部或部分。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的介质。这样,本申请实施例不限制于任何特定的硬件和软件结合。It should be noted that, in the embodiment of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solutions of the embodiments of the present application or the part that contributes to the related technologies can be embodied in the form of software products. The computer software products are stored in a storage medium and include several instructions to make An electronic device (which may be a mobile phone, a tablet computer, a notebook computer, a desktop computer, etc.) executes all or part of the methods described in various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes such as U disk, mobile hard disk, read-only memory (Read Only Memory, ROM), magnetic disk or optical disk. Thus, embodiments of the present application are not limited to any specific combination of hardware and software.

对应地,本申请实施例提供一种存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述实施例中提供的消息处理方法中的步骤。Correspondingly, an embodiment of the present application provides a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps in the message processing method provided in the foregoing embodiments are implemented.

对应地,本申请实施例提供一种电子设备,图6为本申请实施例提供的电子设备的一种硬件实体示意图,如图6所示,该设备600的硬件实体包括:包括存储器601和处理器602,所述存储器601存储有可在处理器602上运行的计算机程序,所述处理器602执行所述程序时实现上述实施例中提供的消息处理方法中的步骤。Correspondingly, the embodiment of the present application provides an electronic device. FIG. 6 is a schematic diagram of a hardware entity of the electronic device provided in the embodiment of the present application. As shown in FIG. 6 , the hardware entity of the device 600 includes: a memory 601 and a processing The memory 601 stores a computer program that can run on the processor 602, and the processor 602 implements the steps in the message processing method provided in the above-mentioned embodiments when executing the program.

存储器601配置为存储由处理器602可执行的指令和应用,还可以缓存待处理器602以及电子设备600中各模块待处理或已经处理的数据(例如,图像数据、音频数据、语音通信数据和视频通信数据),可以通过闪存(FLASH)或随机访问存储器(Random AccessMemory,RAM)实现。The memory 601 is configured to store instructions and applications executable by the processor 602, and can also cache data to be processed or processed by the processor 602 and various modules in the electronic device 600 (for example, image data, audio data, voice communication data and Video communication data) can be realized by flash memory (FLASH) or random access memory (Random Access Memory, RAM).

这里需要指出的是:以上存储介质和设备实施例的描述,与上述方法实施例的描述是类似的,具有同方法实施例相似的有益效果。对于本申请存储介质和设备实施例中未披露的技术细节,请参照本申请方法实施例的描述而理解。It should be pointed out here that: the descriptions of the above storage medium and device embodiments are similar to the descriptions of the above method embodiments, and have similar beneficial effects to those of the method embodiments. For technical details not disclosed in the storage medium and device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.

应理解,说明书通篇中提到的“一个实施例”或“一实施例”意味着与实施例有关的特定特征、结构或特性包括在本申请的至少一个实施例中。因此,在整个说明书各处出现的“在一个实施例中”或“在一实施例中”未必一定指相同的实施例。此外,这些特定的特征、结构或特性可以任意适合的方式结合在一个或多个实施例中。应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。It should be understood that reference throughout the specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic related to the embodiment is included in at least one embodiment of the present application. Thus, appearances of "in one embodiment" or "in an embodiment" in various places throughout the specification are not necessarily referring to the same embodiment. Furthermore, the particular features, structures or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that, in various embodiments of the present application, the sequence numbers of the above-mentioned processes do not mean the order of execution, and the execution order of the processes should be determined by their functions and internal logic, and should not be used in the embodiments of the present application. The implementation process constitutes any limitation. The serial numbers of the above embodiments of the present application are for description only, and do not represent the advantages and disadvantages of the embodiments.

需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It should be noted that, in this document, the term "comprising", "comprising" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or apparatus comprising a set of elements includes not only those elements, It also includes other elements not expressly listed, or elements inherent in the process, method, article, or device. Without further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus comprising that element.

在本申请所提供的几个实施例中,应该理解到,所揭露的设备和方法,可以通过其它的方式实现。以上所描述的设备实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,如:多个单元或组件可以结合,或可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的各组成部分相互之间的耦合、或直接耦合、或通信连接可以是通过一些接口,设备或单元的间接耦合或通信连接,可以是电性的、机械的或其它形式的。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or May be integrated into another system, or some features may be ignored, or not implemented. In addition, the coupling, or direct coupling, or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical or other forms of.

上述作为分离部件说明的单元可以是、或也可以不是物理上分开的,作为单元显示的部件可以是、或也可以不是物理单元;既可以位于一个地方,也可以分布到多个网络单元上;可以根据实际的需要选择其中的部分或全部单元来实现本实施例方案的目的。The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed to multiple network units; Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各实施例中的各功能单元可以全部集成在一个处理单元中,也可以是各单元分别单独作为一个单元,也可以两个或两个以上单元集成在一个单元中;上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can be used as a single unit, or two or more units can be integrated into one unit; the above-mentioned integration The unit can be realized in the form of hardware or in the form of hardware plus software functional unit.

本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:移动存储设备、只读存储器(Read Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps to realize the above method embodiments can be completed by hardware related to program instructions, and the aforementioned programs can be stored in computer-readable storage media. When the program is executed, the execution includes The steps of the foregoing method embodiments; and the foregoing storage media include: removable storage devices, read-only memory (Read Only Memory, ROM), magnetic disks or optical disks and other media that can store program codes.

或者,本申请上述集成的单元如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对相关技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得电子设备(可以是手机、平板电脑、笔记本电脑、台式计算机等)执行本申请各个实施例所述方法的全部或部分。而前述的存储介质包括:移动存储设备、ROM、磁碟或者光盘等各种可以存储程序代码的介质。Alternatively, if the above-mentioned integrated units of the present application are realized in the form of software function modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solutions of the embodiments of the present application or the part that contributes to the related technologies can be embodied in the form of software products. The computer software products are stored in a storage medium and include several instructions to make An electronic device (which may be a mobile phone, a tablet computer, a notebook computer, a desktop computer, etc.) executes all or part of the methods described in various embodiments of the present application. The aforementioned storage medium includes various media capable of storing program codes such as removable storage devices, ROMs, magnetic disks or optical disks.

本申请所提供的几个方法实施例中所揭露的方法,在不冲突的情况下可以任意组合,得到新的方法实施例。The methods disclosed in several method embodiments provided in this application can be combined arbitrarily to obtain new method embodiments under the condition of no conflict.

本申请所提供的几个产品实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的产品实施例。The features disclosed in several product embodiments provided in this application can be combined arbitrarily without conflict to obtain new product embodiments.

本申请所提供的几个方法或设备实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的方法实施例或设备实施例。The features disclosed in several method or device embodiments provided in this application can be combined arbitrarily without conflict to obtain new method embodiments or device embodiments.

以上所述,仅为本申请的实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above is only the embodiment of the present application, but the scope of protection of the present application is not limited thereto. Anyone familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, and should covered within the scope of protection of this application. Therefore, the protection scope of the present application should be determined by the protection scope of the claims.

Claims (10)

1.一种消息处理方法,所述方法包括:1. A message processing method, said method comprising: 获取发布订阅消息系统的消费积压实时值;Obtain the real-time value of the consumption backlog of the publish-subscribe message system; 基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞;Based on the real-time value of the consumption backlog, it is determined that message congestion occurs in the publish-subscribe message system; 调整所述发布订阅消息系统的系统参数;Adjust system parameters of the publish-subscribe message system; 基于调整后的系统参数完成消息处理。Complete message processing based on the adjusted system parameters. 2.如权利要求1所述的方法,所述基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞,包括:2. The method according to claim 1, wherein determining that message congestion occurs in the publish-subscribe message system based on the real-time value of the consumption backlog comprises: 获取预设的消费积压阈值;Obtain the preset consumption backlog threshold; 确定所述消费积压实时值大于所述消费积压阈值;determining that the consumption backlog real-time value is greater than the consumption backlog threshold; 确定所述发布订阅消息系统出现消息拥塞。It is determined that message congestion occurs in the publish-subscribe message system. 3.如权利要求2所述的方法,所述获取预设的消费积压阈值,包括:3. The method according to claim 2, said obtaining a preset consumption backlog threshold, comprising: 获取单位时间内所述发布订阅消息系统的生产消息数量;Obtain the number of production messages of the publish-subscribe message system described in the unit time; 获取所述生产消息数量对应的比例阈值;Obtain a ratio threshold corresponding to the number of production messages; 将所述生产消息数量与所述比例阈值相乘,得到所述消费积压阈值。The consumption backlog threshold is obtained by multiplying the production message quantity by the ratio threshold. 4.如权利要求2所述的方法,所述获取预设的消费积压阈值,包括:4. The method according to claim 2, said acquiring a preset consumption backlog threshold comprises: 基于所发布订阅消息系统的消息处理能力,确定所述消费积压阈值。The consumption backlog threshold is determined based on the message processing capability of the publish-subscribe message system. 5.如权利要求2所述的方法,在所述确定所述发布订阅消息系统出现消息拥塞之前,所述方法还包括:5. The method according to claim 2, before determining that message congestion occurs in the publish-subscribe message system, the method further comprises: 相隔单位时间分别获取第一消费积压值和第二消费积压值;Acquiring the first consumption backlog value and the second consumption backlog value respectively at intervals of unit time; 将所述第一消费积压值减去所述第二消费积压值,得到消费积压差值;subtracting the second consumption backlog value from the first consumption backlog value to obtain a consumption backlog difference; 将所述消费积压差值除以所述单位时间,得到消费积压斜率值;Divide the consumption backlog difference by the unit time to obtain the consumption backlog slope value; 获取消费积压斜率阈值;Obtain the consumption backlog slope threshold; 确定至少两个连续所述消费积压斜率值大于所述消费积压斜率阈值。It is determined that at least two consecutive values of the consumption backlog slope are greater than the consumption backlog slope threshold. 6.如权利要求1所述的方法,所述系统参数至少包括消费者数量、分区数量和生产者数量,所述调整所述发布订阅消息系统的系统参数,包括:6. The method according to claim 1, wherein the system parameters at least include the number of consumers, the number of partitions and the number of producers, and the adjustment of the system parameters of the publish-subscribe message system includes: 在确定所述消费者数量小于所述分区数量的情况下,增加所述消费者数量;If it is determined that the number of consumers is less than the number of partitions, increasing the number of consumers; 或者,or, 在确定所述消费者数量等于所述分区数量的情况下,同时增加所述分区数量和所述消费者数量;In the case of determining that the number of consumers is equal to the number of partitions, simultaneously increasing the number of partitions and the number of consumers; 或者,or, 在确定所述生产者数量、所述消费者数量和所述分区数量不变的情况下,降低所述生产者的生产频度。When it is determined that the number of producers, the number of consumers and the number of partitions remain unchanged, the production frequency of the producers is reduced. 7.如权利要求1所述的方法,所述获取所述发布订阅消息系统的消费积压实时值,包括:7. The method according to claim 1, said obtaining the consumption backlog real-time value of said publish-subscribe messaging system, comprising: 实时获取所述发布订阅消息系统的生产消息数和已读消息数;Obtaining the number of produced messages and the number of read messages of the publish-subscribe message system in real time; 将所述生产消息数减去所述已读消息数,得到所述消费积压实时值。The real-time value of the consumption backlog is obtained by subtracting the number of read messages from the number of produced messages. 8.一种消息处理装置,所述装置包括:8. A message processing device, said device comprising: 获取模块,用于获取所述发布订阅消息系统的消费积压实时值;An acquisition module, configured to acquire the real-time value of the consumption backlog of the publish-subscribe message system; 确定模块,用于基于所述消费积压实时值,确定所述发布订阅消息系统出现消息拥塞;A determining module, configured to determine that message congestion occurs in the publish-subscribe message system based on the real-time value of the consumption backlog; 调整模块,用于调整所述发布订阅消息系统的系统参数;An adjustment module, configured to adjust system parameters of the publish-subscribe messaging system; 消息处理模块,用于基于调整后的系统参数完成消息处理。The message processing module is configured to complete message processing based on the adjusted system parameters. 9.一种电子设备,包括存储器和处理器,所述存储器存储有可在处理器上运行的计算机程序,所述处理器执行所述程序时实现权利要求1至7任一项所述方法中的步骤。9. An electronic device, comprising a memory and a processor, the memory stores a computer program that can run on the processor, and the processor implements the method according to any one of claims 1 to 7 when executing the program A step of. 10.一种存储介质,存储有可执行指令,用于引起处理器执行时,实现权利要求1至7任一项所述的方法中的步骤。10. A storage medium, storing executable instructions for causing a processor to implement the steps in the method according to any one of claims 1 to 7 when executed.
CN202310193575.9A 2023-02-28 2023-02-28 Message processing method, device, equipment and storage medium Pending CN116055401A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310193575.9A CN116055401A (en) 2023-02-28 2023-02-28 Message processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310193575.9A CN116055401A (en) 2023-02-28 2023-02-28 Message processing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116055401A true CN116055401A (en) 2023-05-02

Family

ID=86118372

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310193575.9A Pending CN116055401A (en) 2023-02-28 2023-02-28 Message processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116055401A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117453759A (en) * 2023-12-19 2024-01-26 深圳竹云科技股份有限公司 Service data processing method, device, computer equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107423141A (en) * 2017-06-20 2017-12-01 北京小度信息科技有限公司 Information processing method and device
CN108270662A (en) * 2017-12-26 2018-07-10 微梦创科网络科技(中国)有限公司 A kind of message distributing method, device and equipment
CN111290908A (en) * 2020-01-15 2020-06-16 四川万益能源科技有限公司 Kafka data consumption backlog condition monitoring and alarming method
CN115567477A (en) * 2022-09-19 2023-01-03 上海星起源新能源科技有限公司 Method, equipment and storage medium for processing message accumulation

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107423141A (en) * 2017-06-20 2017-12-01 北京小度信息科技有限公司 Information processing method and device
CN108270662A (en) * 2017-12-26 2018-07-10 微梦创科网络科技(中国)有限公司 A kind of message distributing method, device and equipment
CN111290908A (en) * 2020-01-15 2020-06-16 四川万益能源科技有限公司 Kafka data consumption backlog condition monitoring and alarming method
CN115567477A (en) * 2022-09-19 2023-01-03 上海星起源新能源科技有限公司 Method, equipment and storage medium for processing message accumulation

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117453759A (en) * 2023-12-19 2024-01-26 深圳竹云科技股份有限公司 Service data processing method, device, computer equipment and storage medium
CN117453759B (en) * 2023-12-19 2024-04-02 深圳竹云科技股份有限公司 Service data processing method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
US12073265B2 (en) Event handling in distributed event handling systems
CN107197015B (en) Message processing method and device based on message queue system
CN107391271B (en) Message queue system-based delayed task triggering method and device
CN110808922B (en) Message processing method and device, storage medium and electronic equipment
EP2863306B1 (en) Predictive auto scaling engine
US20210368225A1 (en) Method and system for setting video cover
US12058285B2 (en) Suppressing indications of events in user interfaces
WO2023103419A1 (en) Message queue-based method and apparatus for sending 5g messages in batches, and electronic device
CN116055401A (en) Message processing method, device, equipment and storage medium
CN111200606A (en) Deep learning model task processing method, system, server and storage medium
CN115277557B (en) Broadcast processing method, device, electronic equipment and storage medium
CN113835905B (en) Message queue load balancing method and device, electronic equipment and medium
CN112689166A (en) Method and system for flexibly increasing and decreasing CDN hot content in real time
CN114978998B (en) A flow control method, device, terminal and storage medium
CN114760283A (en) Playing parameter configuration method and device
CN119225982B (en) Event push method, device, storage medium and program product
CN104486134A (en) Method and device for monitoring file transmission backlog
CN113094171B (en) Data processing method, device, electronic equipment and storage medium
CN114020494B (en) Payment status processing method and device
CN113453043B (en) Video scheduling optimization method and device, computer equipment and storage medium
HK40013104A (en) Load balancing method and device for distributed service cluster and electronic equipment
CN118295826A (en) Message queue configuration method, related method, device, system and storage medium
WO2025060461A1 (en) Iot technology-based message pushing method, and apparatus
CN118450177A (en) Communication method, communication device, electronic equipment and computer readable medium
CN116783919A (en) Method and apparatus for using uninterrupted controller by Local Area Network (LAN) utilizing local cloud

Legal Events

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