Movatterモバイル変換


[0]ホーム

URL:


CN116527772A - A method, storage medium and device for controlling message sending speed - Google Patents

A method, storage medium and device for controlling message sending speed
Download PDF

Info

Publication number
CN116527772A
CN116527772ACN202310587945.7ACN202310587945ACN116527772ACN 116527772 ACN116527772 ACN 116527772ACN 202310587945 ACN202310587945 ACN 202310587945ACN 116527772 ACN116527772 ACN 116527772A
Authority
CN
China
Prior art keywords
message
priority
messages
sending
sent
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
CN202310587945.7A
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.)
Beijing Yilianda Business Service Co ltd
Original Assignee
Beijing Yilianda Business Service Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Yilianda Business Service Co ltdfiledCriticalBeijing Yilianda Business Service Co ltd
Priority to CN202310587945.7ApriorityCriticalpatent/CN116527772A/en
Publication of CN116527772ApublicationCriticalpatent/CN116527772A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本发明公开了一种控制消息发送速度的方法、存储介质及设备,消息发送方在接收到待发送的消息后,先根据消息的时效性及业务属性,按预设的划分标准,将消息划分优先级,并放入所属优先级对应的消息队列;对各个优先级的消息队列进行发送处理:对各个优先级的消息队列进行发送处理,其中,对于高优先级的消息,在不高于预设的最大发送速率的情况下优先发送,低优先级的消息为高优先级的消息让路。本发明对消息实行分级处理策略,消息优先级越高的消息将优先发送,在不影响整体发送速度的同时保证了消息的时效性。本发明中,消息发送方在分布式环境下采用了统一的消息发送控制机制,可以保证系统整体发送能力被最大可能的利用起来。The invention discloses a method, a storage medium and a device for controlling the sending speed of a message. After receiving the message to be sent, the message sender first divides the message according to the timeliness and business attributes of the message and according to the preset division standard. Priority, and put it into the message queue corresponding to the priority; send processing to the message queue of each priority: send processing to the message queue of each priority, among them, for the message of high priority, no higher than the predetermined In the case of the maximum sending rate set, the priority is sent, and the low-priority message makes way for the high-priority message. The invention implements a hierarchical processing strategy for the messages, and the messages with higher message priority will be sent first, thereby ensuring the timeliness of the messages without affecting the overall sending speed. In the present invention, the message sender adopts a unified message sending control mechanism in a distributed environment, which can ensure that the overall sending capability of the system is utilized to the greatest extent possible.

Description

Translated fromChinese
一种控制消息发送速度的方法、存储介质及设备Method, storage medium and device for controlling message sending speed

技术领域technical field

本发明涉及网络消息传输技术领域,具体涉及一种控制消息发送速度的方法、存储介质及设备。The invention relates to the technical field of network message transmission, in particular to a method, storage medium and equipment for controlling message sending speed.

背景技术Background technique

平台之间发送消息时,按照消息发送的方向,可分为消息接收方和消息发送方。由于消息接收方接收并处理消息的能力是一定的,当消息发送方发送消息的速度超过消息接收方处理消息的速度时,就会造成发送方发送的部分消息在接收方堆积并产生超时的异常情况。所以,消息的发送方应该根据消息接收方的处理能力来控制己方的消息发送速度。When sending messages between platforms, according to the direction of message sending, it can be divided into message receiver and message sender. Since the ability of the message receiver to receive and process messages is certain, when the speed at which the message sender sends messages exceeds the speed at which the message receiver can process messages, some messages sent by the sender will accumulate at the receiver and a timeout exception will occur Condition. Therefore, the message sender should control the message sending speed of its own party according to the processing capability of the message receiver.

当前的处理方式是,消息发送方根据消息接收方的处理能力预设一个最大发送速度,对单位时间内的消息发送数量进行累加,当累计数量达到预设的最大值时,将暂停发送消息,直到下一个单位时间开始重新累加计算发送速度。当消息发送方的应用服务是分布式部署,即存在多个节点同时向消息接收方发送消息时,为保证消息的总发送速度不超过预设最大值,则每个节点的最大发送速度均分总发送速度,即总发送速度M,节点数N,每个节点发送速度应不大于M/N。The current processing method is that the message sender presets a maximum sending speed according to the processing capability of the message receiver, and accumulates the number of messages sent per unit time. When the accumulated number reaches the preset maximum value, the sending of messages will be suspended. Until the next unit time starts to accumulate and calculate the sending speed again. When the application service of the message sender is deployed in a distributed manner, that is, when there are multiple nodes sending messages to the message receiver at the same time, in order to ensure that the total sending speed of messages does not exceed the preset maximum value, the maximum sending speed of each node is divided equally The total sending speed, that is, the total sending speed M, the number of nodes N, the sending speed of each node should not be greater than M/N.

然而实际上每个节点的处理消息的能力是不同的,会造成有些节点消息出现拥堵而有些节点长时间空闲的情况,这样消息发送方整体的消息发送速度会低于接收方的最大消息处理能力,出现资源的浪费。However, in fact, the ability of each node to process messages is different, which will cause some node messages to be congested and some nodes to be idle for a long time, so that the overall message sending speed of the message sender will be lower than the maximum message processing capacity of the receiver , a waste of resources occurs.

发明内容Contents of the invention

针对现有技术的不足,本发明旨在提供一种控制消息发送速度的方法、存储介质及设备。Aiming at the deficiencies of the prior art, the present invention aims to provide a method, storage medium and equipment for controlling message sending speed.

为了实现上述目的,本发明采用如下技术方案:In order to achieve the above object, the present invention adopts the following technical solutions:

一种控制消息发送速度的方法,包括以下步骤:A method for controlling message sending speed, comprising the steps of:

S1、消息发送方在接收到待发送的消息后,先根据消息的时效性及业务属性,按预设的划分标准,将消息划分优先级,并放入所属优先级对应的消息队列;S1. After receiving the message to be sent, the message sender first prioritizes the message according to the timeliness and business attributes of the message and according to the preset classification standard, and puts it into the message queue corresponding to the priority;

S2、对各个优先级的消息队列进行发送处理:S2. Send the message queues of each priority:

高优先级的消息在发送前,先检查当前发送周期已发送的消息数量是否已达到最大发送数量;如果还没有达到,将直接发送,并设置所属优先级的消息标识,表示当前发送周期有高优先级消息需要发送;在发送完成后累计至当前发送周期的已发送消息数量;Before sending high-priority messages, first check whether the number of messages sent in the current sending cycle has reached the maximum number; Priority messages need to be sent; the number of sent messages accumulated to the current sending cycle after sending is completed;

低优先级的消息在发送前,先检查当前发送周期已发送的消息数量是否已达到最大发送数量;如果还没有达到,再检查当前发送周期是否存在更高优先级的消息标识,如果没有则直接发送;如果有,则检查当前发送周期已发送的消息数量是否已达到最大发送数量的预设百分比,如果没有则直接发送,否则将等待至下一个发送周期再进行发送处理;消息发送完成后,累计至当前发送周期的已发送消息数量;如果当前优先级并非是最低优先级,设置所属优先级的消息标识,否则不设置消息标识;Before sending low-priority messages, first check whether the number of messages sent in the current sending cycle has reached the maximum sending number; if not, then check whether there is a higher-priority message identifier in the current sending cycle, if not, directly Send; if there is, check whether the number of messages sent in the current sending cycle has reached the preset percentage of the maximum sending number, if not, send it directly, otherwise it will wait until the next sending cycle before sending; after the message is sent, The number of sent messages accumulated up to the current sending cycle; if the current priority is not the lowest priority, set the message ID of the priority, otherwise do not set the message ID;

S3、在下一个发送周期开始时,将已发送消息数量重置为0,并清空各优先级的消息标识。S3. At the beginning of the next sending cycle, the number of sent messages is reset to 0, and the message identifiers of each priority are cleared.

进一步地,当消息发送方的应用服务是分布式部署时,当前发送周期的已发送消息数量和优先级消息标识存放在第三方缓存数据库中;各个节点对本地各个优先级的消息队列进行发送处理时,从第三方缓存数据库获取当前发送周期的已发送消息数量和优先级消息标识,据此执行步骤S2的发送处理过程。Furthermore, when the application service of the message sender is deployed in a distributed manner, the number of sent messages and priority message identifiers of the current sending cycle are stored in the third-party cache database; each node sends and processes local message queues of each priority , the number of sent messages and priority message identifiers in the current sending cycle are obtained from the third-party cache database, and the sending process of step S2 is executed accordingly.

本发明还提供一种计算机可读存储介质,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现上述方法。The present invention also provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and the above-mentioned method is realized when the computer program is executed by a processor.

本发明还提供一种计算机设备,包括处理器和存储器,所述存储器用于存储计算机程序;所述处理器用于执行所述计算机程序时,实现上述方法。The present invention also provides a computer device, including a processor and a memory, and the memory is used to store a computer program; when the processor is used to execute the computer program, the above method is realized.

本发明的有益效果在于:The beneficial effects of the present invention are:

1)本发明对消息实行分级处理策略,消息优先级越高的消息将优先发送,在不影响整体发送速度的同时保证了消息的时效性。1) The present invention implements a hierarchical processing strategy for messages, and messages with higher message priority will be sent first, which ensures the timeliness of messages without affecting the overall sending speed.

2)本发明中,消息发送方在分布式环境下采用了统一的消息发送控制机制,可以保证系统整体发送能力被最大可能的利用起来。2) In the present invention, the message sender adopts a unified message sending control mechanism in a distributed environment, which can ensure that the overall sending capability of the system is utilized to the greatest extent possible.

具体实施方式Detailed ways

以下将对本发明作进一步的描述,需要说明的是,本实施例以本技术方案为前提,给出了详细的实施方式和具体的操作过程,但本发明的保护范围并不限于本实施例。The present invention will be further described below. It should be noted that this embodiment is based on the technical solution and provides detailed implementation and specific operation process, but the protection scope of the present invention is not limited to this embodiment.

本实施例提供一种控制消息发送速度的方法,包括以下步骤:This embodiment provides a method for controlling message sending speed, including the following steps:

S1、消息发送方在接收到待发送的消息后,先根据消息的时效性及业务属性,按预设的划分标准,将消息划分优先级,并放入所属优先级对应的消息队列。本实施例中,优先级分为高、中、低三档。也可以根据需要划分不同数量的优先级级别。S1. After receiving the message to be sent, the message sender first prioritizes the message according to the timeliness and business attributes of the message and according to the preset classification standard, and puts the message into the message queue corresponding to the priority. In this embodiment, the priority is divided into three levels: high, medium and low. A different number of priority levels can also be assigned as desired.

S2、对各个优先级的消息队列进行发送处理,其中,对于高优先级的消息,在不高于预设的最大发送速率的情况下优先发送,低优先级的消息为高优先级的消息让路。具体过程为:S2. Sending processing to the message queues of each priority, wherein, for high priority messages, they are sent first under the condition of not higher than the preset maximum sending rate, and low priority messages make way for high priority messages . The specific process is:

高优先级的消息在发送前,先检查当前发送周期已发送的消息数量是否已达到最大发送数量;如果还没有达到,将直接发送,并设置所属优先级的消息标识,表示当前发送周期有高优先级消息需要发送;在发送完成后累计至当前发送周期的已发送消息数量。Before sending high-priority messages, first check whether the number of messages sent in the current sending cycle has reached the maximum number; Priority messages need to be sent; the number of sent messages accumulated up to the current sending cycle after the sending is completed.

低优先级的消息在发送前,先检查当前发送周期已发送的消息数量是否已达到最大发送数量;如果还没有达到,再检查当前发送周期是否存在更高优先级的消息标识,如果没有则直接发送;如果有,则检查当前发送周期已发送的消息数量是否已达到最大发送数量的预设百分比,如果没有则直接发送,否则将等待至下一个发送周期再进行发送处理。消息发送完成后,累计至当前发送周期的已发送消息数量;如果当前优先级并非是最低优先级,设置所属优先级的消息标识,否则不设置消息标识。Before sending low-priority messages, first check whether the number of messages sent in the current sending cycle has reached the maximum sending number; if not, then check whether there is a higher-priority message identifier in the current sending cycle, if not, directly Send; if there is, check whether the number of messages sent in the current sending cycle has reached the preset percentage of the maximum sending number, if not, send it directly, otherwise it will wait until the next sending cycle before sending. After the message is sent, the number of sent messages accumulated up to the current sending cycle; if the current priority is not the lowest priority, set the message ID of the priority level, otherwise do not set the message ID.

以设置高、中、低三档优先级为例,中优先级的消息在发送前,先检查当前发送周期的已发送消息数量是否已达到最大发送数量;如果还没有达到,再检查当前发送周期是否存在高优先级的消息标识,如果没有则直接发送;如果有高优先级的消息标识,则检查当前发送周期的已发送消息数量是否已达到最大发送数量的50%,如果没有则直接发送,否则将等待至下一个发送周期。消息发送完成后,累计至当前发送周期的已发送消息数量,并设置中优先级的消息标识。Take setting high, medium, and low priorities as an example. Before sending messages with medium priority, first check whether the number of sent messages in the current sending cycle has reached the maximum number of sending messages; if not, check the current sending cycle again. Whether there is a high-priority message ID, if not, send it directly; if there is a high-priority message ID, check whether the number of sent messages in the current sending cycle has reached 50% of the maximum sending number, if not, send it directly, Otherwise it will wait until the next sending cycle. After the message is sent, accumulate the number of sent messages up to the current sending cycle, and set the message ID of medium priority.

低优先级的消息在发送前,先检查当前发送周期的已发送消息数量是否已达到最大发送数量;如果还没有达到,再检查当前发送周期是否存在高优先级的消息标识或中优先级的消息标识,如果没有则直接发送;如果有高优先级的消息标识或中优先级的消息标识,则检查当前发送周期的已发送消息数量是否已达到最大发送数量的20%,如果没有则直接发送,否则将等待至下一个发送周期;消息发送完成,累计至当前发送周期的已发送消息数量。Before sending low-priority messages, first check whether the number of sent messages in the current sending cycle has reached the maximum sending number; if not, then check whether there are high-priority message identifiers or medium-priority messages in the current sending cycle ID, if there is no message ID, send it directly; if there is a message ID with high priority or a message ID with medium priority, check whether the number of sent messages in the current sending cycle has reached 20% of the maximum number of sent messages, if not, send it directly, Otherwise, it will wait until the next sending cycle; the message sending is completed, and the number of sent messages accumulated up to the current sending cycle.

S3、在下一个发送周期开始时,将已发送消息数量重置为0,并清空各优先级的消息标识。S3. At the beginning of the next sending cycle, the number of sent messages is reset to 0, and the message identifiers of each priority are cleared.

当消息发送方的应用服务是分布式部署时,当前发送周期的已发送消息数量和优先级消息标识存放在Redis等第三方缓存数据库中;各个节点对本地各个优先级的消息队列进行发送处理时,从第三方缓存数据库获取当前发送周期的已发送消息数量和优先级消息标识,据此执行步骤S2的发送处理过程。各个节点采用相同的消息发送速度控制策略,并且根据总的已发送消息数量和优先级消息标识控制发送速度,如此,在部分节点出现故障或者处理较慢时,其他节点可以在最大发送速率范围内继续正常进行消息处理。When the application service of the message sender is deployed in a distributed manner, the number of sent messages and priority message identifiers of the current sending cycle are stored in a third-party cache database such as Redis; when each node sends and processes local message queues of various priorities , acquire the number of sent messages and priority message identifiers in the current sending cycle from the third-party cache database, and execute the sending process of step S2 accordingly. Each node adopts the same message sending speed control strategy, and controls the sending speed according to the total number of sent messages and priority message identification, so that when some nodes fail or process slowly, other nodes can be within the maximum sending rate range Proceed with message processing as normal.

对于本领域的技术人员来说,可以根据以上的技术方案和构思,给出各种相应的改变和变形,而所有的这些改变和变形,都应该包括在本发明权利要求的保护范围之内。For those skilled in the art, various corresponding changes and modifications can be made according to the above technical solutions and concepts, and all these changes and modifications should be included in the protection scope of the claims of the present invention.

Claims (4)

Translated fromChinese
1.一种控制消息发送速度的方法,其特征在于,包括以下步骤:1. A method for controlling message sending speed, comprising the following steps:S1、消息发送方在接收到待发送的消息后,先根据消息的时效性及业务属性,按预设的划分标准,将消息划分优先级,并放入所属优先级对应的消息队列;S1. After receiving the message to be sent, the message sender first prioritizes the message according to the timeliness and business attributes of the message and according to the preset classification standard, and puts it into the message queue corresponding to the priority;S2、对各个优先级的消息队列进行发送处理:S2. Send the message queues of each priority:高优先级的消息在发送前,先检查当前发送周期已发送的消息数量是否已达到最大发送数量;如果还没有达到,将直接发送,并设置所属优先级的消息标识,表示当前发送周期有高优先级消息需要发送;在发送完成后累计至当前发送周期的已发送消息数量;Before sending high-priority messages, first check whether the number of messages sent in the current sending cycle has reached the maximum number; Priority messages need to be sent; the number of sent messages accumulated to the current sending cycle after sending is completed;低优先级的消息在发送前,先检查当前发送周期已发送的消息数量是否已达到最大发送数量;如果还没有达到,再检查当前发送周期是否存在更高优先级的消息标识,如果没有则直接发送;如果有,则检查当前发送周期已发送的消息数量是否已达到最大发送数量的预设百分比,如果没有则直接发送,否则将等待至下一个发送周期再进行发送处理;消息发送完成后,累计至当前发送周期的已发送消息数量;如果当前优先级并非是最低优先级,设置所属优先级的消息标识,否则不设置消息标识;Before sending low-priority messages, first check whether the number of messages sent in the current sending cycle has reached the maximum sending number; if not, then check whether there is a higher-priority message identifier in the current sending cycle, if not, directly Send; if there is, check whether the number of messages sent in the current sending cycle has reached the preset percentage of the maximum sending number, if not, send it directly, otherwise it will wait until the next sending cycle before sending; after the message is sent, The number of sent messages accumulated up to the current sending cycle; if the current priority is not the lowest priority, set the message ID of the priority, otherwise do not set the message ID;S3、在下一个发送周期开始时,将已发送消息数量重置为0,并清空各优先级的消息标识。S3. At the beginning of the next sending cycle, the number of sent messages is reset to 0, and the message identifiers of each priority are cleared.2.根据权利要求1所述的方法,其特征在于,当消息发送方的应用服务是分布式部署时,当前发送周期的已发送消息数量和优先级消息标识存放在第三方缓存数据库中;各个节点对本地各个优先级的消息队列进行发送处理时,从第三方缓存数据库获取当前发送周期的已发送消息数量和优先级消息标识,据此执行步骤S2的发送处理过程。2. The method according to claim 1, wherein when the application service of the message sender is deployed in a distributed manner, the number of sent messages and priority message identifiers of the current sending cycle are stored in a third-party cache database; When the node sends the local message queues of various priorities, it obtains the number of sent messages and priority message identifiers in the current sending cycle from the third-party cache database, and executes the sending process of step S2 accordingly.3.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1-2任一所述的方法。3. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1-2 is implemented.4.一种计算机设备,其特征在于,包括处理器和存储器,所述存储器用于存储计算机程序;所述处理器用于执行所述计算机程序时,实现权利要求1-2任一所述的方法。4. A computer device, characterized in that it comprises a processor and a memory, and the memory is used to store a computer program; when the processor is used to execute the computer program, the method according to any one of claims 1-2 is realized .
CN202310587945.7A2023-05-242023-05-24 A method, storage medium and device for controlling message sending speedPendingCN116527772A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202310587945.7ACN116527772A (en)2023-05-242023-05-24 A method, storage medium and device for controlling message sending speed

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202310587945.7ACN116527772A (en)2023-05-242023-05-24 A method, storage medium and device for controlling message sending speed

Publications (1)

Publication NumberPublication Date
CN116527772Atrue CN116527772A (en)2023-08-01

Family

ID=87397623

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202310587945.7APendingCN116527772A (en)2023-05-242023-05-24 A method, storage medium and device for controlling message sending speed

Country Status (1)

CountryLink
CN (1)CN116527772A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN113467969A (en)*2021-06-222021-10-01上海星融汽车科技有限公司Method for processing message accumulation
CN114205762A (en)*2021-12-102022-03-18中国农业银行股份有限公司Short message flow control method, equipment and storage medium
CN115209166A (en)*2021-04-122022-10-18北京字节跳动网络技术有限公司Message sending method, device, equipment and storage medium
CN115834509A (en)*2022-09-272023-03-21中国建设银行股份有限公司 Message processing method, device, storage medium and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN115209166A (en)*2021-04-122022-10-18北京字节跳动网络技术有限公司Message sending method, device, equipment and storage medium
CN113467969A (en)*2021-06-222021-10-01上海星融汽车科技有限公司Method for processing message accumulation
CN114205762A (en)*2021-12-102022-03-18中国农业银行股份有限公司Short message flow control method, equipment and storage medium
CN115834509A (en)*2022-09-272023-03-21中国建设银行股份有限公司 Message processing method, device, storage medium and electronic equipment

Similar Documents

PublicationPublication DateTitle
CN102487494B (en)Short message flow control method and system
CN102223306B (en)A kind of message transmitting method and device
CN111030945A (en)Disaster recovery method, disaster recovery gateway, storage medium, device and system
CN102891809B (en)Multi-core network device message presses interface order-preserving method and system
CN110708234B (en)Message transmission processing method, message transmission processing device and storage medium
CN113726690A (en)Method and system for uploading protocol message, electronic equipment and storage medium
CN107977269B (en)Method, device and equipment for processing timeout event in message forwarding system
CN105991588B (en)A kind of method and device for defending message attack
CN108093047B (en)Data sending method and device, electronic equipment and middleware system
CN116527772A (en) A method, storage medium and device for controlling message sending speed
CN113835611A (en) Storage scheduling method, device and storage medium
CN114500544B (en)Method, system, equipment and medium for balancing load among nodes
CN113934531A (en)High-throughput flow processing method and device
CN118051817A (en)Data processing method, system, device, storage medium and electronic equipment
CN116760775A (en)Message-level self-adaptive network packet-sending queue control method, electronic equipment and storage medium
CN110933699B (en)Packet forwarding method and device
CN115801697A (en) 104 message transmission method and device based on priority queue algorithm
CN113556386A (en)Server scheduling method and device, computer equipment and storage medium
CN115291999A (en)Method and system for dynamically balancing cloud container cluster resources
CN109450818B (en)Method, device, equipment and medium for issuing information of Internet of things
CN113204433A (en)Dynamic allocation method, device, equipment and storage medium for cluster resources
CN108989239B (en)Overload protection method and device, controller and storage medium
CN110300069B (en)Data transmission method, optimization device and system
CN113645324A (en)IP distribution method and system based on queue
CN116436868A (en) A flow control method and device based on thread priority

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp