Method and apparatus for transmitting data in batches
By adopting an adaptive data batch transmission method that dynamically adjusts queue capacity and batch sending strategy based on quantity and time conditions, the high overhead of data transmission between server nodes is solved, improving the balance between system throughput and response time and adapting to traffic changes.
Patent Information
- Application Number
- PCT/CN2025/072212
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-05-29
- Filing Date
- 2025-01-14
- Publication Date
- 2025-12-04
AI Technical Summary
Existing data transmission methods result in high overhead of CPU resources and network bandwidth when transmitting data between server nodes, affecting system performance and throughput. Furthermore, existing batch processing strategies cannot effectively adapt to changes in traffic, leading to poor response time or throughput.
An adaptive data batch transmission method is adopted, which optimizes data transmission in real time by dynamically adjusting queue capacity and batch sending strategy, combined with quantity and time conditions. This includes triggering batch sending based on quantity and time conditions, and optimizing queue capacity through timers and scaling mechanisms to adapt to traffic changes.
It improves the dynamic balance between system throughput and response time, adapts to different traffic scenarios, reduces sensitivity to traffic changes, and optimizes CPU and network resource utilization.
Smart Images

Figure CN2025072212_04122025_PF_FP_ABST
Abstract
Description
Data batch transmission method and device
[0001] Cross-reference to Related Applications
[0002] This application claims priority to Chinese Patent Application No. 202410679409.4, filed May 29, 2024, the entire contents of which are incorporated herein by reference. TECHNICAL FIELD
[0003] Embodiments of the present disclosure relate to the field of computer technology, and in particular, to a data batch transmission method and device. BACKGROUND
[0004] When data is transmitted between server nodes (such as master-slave replication between nodes, or write between computing nodes and storage nodes, etc.), if each received request is converted into a transmission request to other nodes, then for most scenarios, a large amount of network and middleware custom protocol stack processing, system calls, etc. will consume most of the CPU resources. In addition, in the network layer, the transport layer, the session layer and the application layer of each node, the computing cost of processing requests at the sender and the receiver is also high. Individually, each of these costs seems trivial. However, they add up to an overhead that cannot be ignored. In addition, even if the impact of these overheads on latency seems acceptable, in terms of throughput, they will adversely affect the performance of the system.
[0005] Therefore, in general, for the communication of a backend server, batching multiple small messages into a single larger message can reduce the amortized overhead of each message, thereby improving the throughput of the system, which is a common strategy.
[0006] Existing general batching schemes can be divided into quantity-based strategies and time-based strategies. In the quantity-based scheme, a batch message is sent only after a given number of application messages have been accumulated (or the total size of the accumulated messages reaches a certain limit). When the application receives few requests, the response time for the request becomes very large. In fact, the system has enough CPU and network bandwidth to handle the load, but it is not put into use. The quantity-based scheme alone is sometimes difficult to accumulate to the threshold that can be processed. In the time-based scheme, batch messages are periodically performed, and all messages accumulated since the last batch are packaged together for processing. If the batch time threshold is set too high, the delay will also increase, and when the application communication is sparse, this will not have a positive impact on the throughput of the system. If the time threshold is set too small, then batch processing is rarely performed. SUMMARY
[0007] Embodiments of the present disclosure provide a data batch transmission method and device.
[0008] In a first aspect, embodiments of the present disclosure provide a data batch transmission method, comprising: in response to receiving a transmission request of a target message, determining queue information of a queue corresponding to a destination address of the target message, wherein the queue corresponding to the destination address is established in advance, and the queue information comprises: a number of messages in the queue, a queue capacity, and a creation time of a first message in the queue; in response to a sum of the number of messages in the queue and a number of the target message being greater than the queue capacity, or a difference between a current time and the creation time of the first message exceeding a maximum waiting time, batch sending the messages in the queue and the target message to the destination address; and dynamically adjusting the queue capacity according to a time interval of message batch sending and / or a sending quantity.
[0009] In some embodiments, the method further comprises: timing checking whether the difference between the current time and the creation time of the first message exceeds the maximum waiting time; and in response to the difference exceeding the maximum waiting time, batch sending the messages in the queue to the destination address.
[0010] In some embodiments, the method further comprises: if the timing checking triggers the batch sending of the messages, timing checking again whether the difference between the current time and the creation time of the first message exceeds the maximum waiting time after an interval of the maximum waiting time.
[0011] In some embodiments, the method further comprises: if the timing checking does not trigger the batch sending of the messages, calculating an expected checking time according to the creation time of the first message in the queue, the maximum waiting time, and a current time; and in response to the current time reaching the expected checking time, checking whether the difference between the current time and the creation time of the first message exceeds the maximum waiting time.
[0012] In some embodiments, the method further comprises: setting a trigger time of a timer according to an average message processing time; and in response to the current time reaching the trigger time, batch sending the messages in the queue to the destination address.
[0013] In some embodiments, the method further comprises: if other messages are received during processing of the target message, refreshing the trigger time of the timer according to the average message processing time.
[0014] In some embodiments, the dynamically adjusting the queue capacity according to the time interval of message batch sending and / or the sending quantity comprises: if the time interval is less than the maximum waiting time, increasing a queue expansion counter by 1; and in response to the queue expansion counter reaching an expansion and contraction threshold, expanding the queue capacity.
[0015] In some embodiments, the dynamically adjusting the queue capacity according to the time interval of the batch sending of messages and / or the number of sending comprises: if the number of sending is less than the number of messages in the queue, a shrinkage counter of the queue is incremented by 1; and in response to the shrinkage counter reaching a shrinkage threshold, the queue capacity is shrunk.
[0016] In some embodiments, the dynamically adjusting the queue capacity according to the time interval of the batch sending of messages and / or the number of sending comprises: if a difference between the current time and a time of last adjustment of the queue capacity is greater than a shrinkage minimum time interval, the queue capacity is dynamically adjusted according to the time interval of the batch sending of messages and / or the number of sending.
[0017] In some embodiments, the method further comprises: if the sum of the number of messages in the queue and the number of target messages is less than or equal to the queue capacity, or a difference between the current time and a creation time of a first message in the queue does not exceed a maximum waiting time, storing the target messages into the queue.
[0018] In a second aspect, embodiments of the present disclosure provide a data batch transmission apparatus, comprising: a determination unit configured to, in response to receiving a transmission request of a target message, determine queue information of a queue corresponding to a destination address of the target message, wherein the queue corresponding to the destination address is established in advance, and the queue information comprises: a number of messages in the queue, a queue capacity, and a creation time of a message in the queue; a sending unit configured to, in response to a sum of the number of messages in the queue and the number of target messages being greater than the queue capacity, or a difference between the current time and the creation time of a first message in the queue exceeding a maximum waiting time, batch sending the messages in the queue and the target messages to the destination address; and an adjustment unit configured to dynamically adjust the queue capacity according to a time interval of the batch sending of messages and / or the number of sending.
[0019] In some embodiments, the apparatus further comprises a timing unit configured to: time check whether the difference between the current time and the creation time of the first message in the queue exceeds the maximum waiting time; and if the maximum waiting time is exceeded, batch sending the messages in the queue to the destination address.
[0020] In some embodiments, the timing unit is further configured to: time check whether the difference between the current time and the creation time of the first message in the queue exceeds the maximum waiting time; and if the maximum waiting time is exceeded, batch sending the messages in the queue to the destination address.
[0021] In some embodiments, the timing unit is further configured to: if the timing check does not trigger the batch sending of messages, calculate an expected check time according to the creation time of the first message in the queue, the maximum waiting time, and the current time; and in response to the current time reaching the expected check time, check whether the difference between the current time and the creation time of the first message in the queue exceeds the maximum waiting time.
[0022] In some embodiments, the device further comprises a timing unit configured to: set a trigger time of a timer according to the average message processing time; and in response to the current time reaching the trigger time, batch send the messages in the queue to the destination address.
[0023] In some embodiments, the timing unit is further configured to: if other messages are received during the processing of the target messages, refresh the trigger time of the timer according to the average message processing time.
[0024] In some embodiments, the adjusting unit is further configured to: if the time interval is less than the maximum waiting time, increase a queue expansion counter by 1; and in response to the queue expansion counter reaching an expansion and contraction threshold, expand the queue capacity.
[0025] In some embodiments, the adjusting unit is further configured to: if the sending quantity is less than the number of messages in the queue, increase a queue contraction counter by 1; and in response to the queue contraction counter reaching the expansion and contraction threshold, contract the queue capacity.
[0026] In some embodiments, the adjusting unit is further configured to: if the difference between the current time and the time of the last adjustment of the queue capacity is greater than an expansion and contraction minimum time interval, dynamically adjust the queue capacity according to the time interval and / or the sending quantity of the batch sending of messages.
[0027] In some embodiments, the device further comprises a storage unit configured to: if the sum of the number of messages in the queue and the number of target messages is less than or equal to the queue capacity, or the difference between the current time and the creation time of the first message in the queue does not exceed the maximum waiting time, store the target messages into the queue.
[0028] In a third aspect, embodiments of the present disclosure provide an electronic device, comprising: one or more processors; a storage device having one or more computer programs stored thereon, when the one or more computer programs are executed by the one or more processors, causing the one or more processors to implement the method of any one of the first aspect or the second aspect.
[0029] In a fourth aspect, an embodiment of the present disclosure provides a computer readable medium having stored thereon a computer program, wherein the computer program, when executed by a processor, implements the method according to any one of the first aspect or the second aspect.
[0030] The data batch transmission method and device provided by the embodiments of the present disclosure can adapt to most scenarios by adjusting the size of the batch through an adaptive strategy according to real-time traffic. Meanwhile, the strategy is applicable to a wide range of scenarios and does not depend on specific hardware and experience parameters. Through the batch strategy, higher throughput can be obtained at the same CPU utilization. The adaptive strategy can make a trade-off between throughput and response time. The adaptive batch processing strategy based on observation always predicts future values with past values, which leads to the problems that the adaptive strategy is not sensitive to real-time traffic changes and the effect on sparse traffic at the critical point of the adaptive strategy is not obvious.
[0031] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become apparent through the following description. BRIEF DESCRIPTION OF DRAWINGS
[0032] Other features, objects, and advantages of the present disclosure will become more apparent from the following detailed description of non-limiting embodiments with reference to the drawings:
[0033] Fig. 1 is an exemplary system architecture diagram to which one embodiment of the present disclosure can be applied;
[0034] Fig. 2 is a flowchart of one embodiment of a data batch transmission method according to the present disclosure;
[0035] Fig. 3 is a schematic diagram of one application scenario of the data batch transmission method according to the present disclosure;
[0036] Fig. 4 is a flowchart of another embodiment of the data batch transmission method according to the present disclosure;
[0037] Fig. 5 is a structural schematic diagram of one embodiment of a data batch transmission device according to the present disclosure;
[0038] Fig. 6 is a structural schematic diagram of a computer system of an electronic device suitable for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION
[0039] The present disclosure will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only intended to explain the related application, but not to limit the application. In addition, it should be noted that, for the convenience of description, only the parts related to the application are shown in the drawings.
[0040] It should be noted that the embodiments in the present disclosure and the features in the embodiments can be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0041] Figure 1 shows an exemplary system architecture to which the embodiments of the data batch transmission method or the data batch transmission device of the present disclosure can be applied.
[0042] Figure 1 takes a message system with separated computing and storage as an example. A minimum cluster consists of 1 computing node (broker) and 3 storage nodes (stores). In the message system, the partitions of a topic logically have only one, and the corresponding data is stored in three copies, respectively, in the three storage nodes. For each partition, the master copy is in which node at the current time, which is determined by the replica election algorithm of the storage node. For each partition, only the node where the master copy is located provides read and write.
[0043] In Figure 1, partition1 of topicA is stored in storeGroup1, and partition2 is stored in storeGroup3; and the master nodes of storeGroup1 and storeGroup3 are in different store nodes at this time. When the client sends a message to the broker, the broker needs to do a series of calculations and processing, and finally writes the message itself and the calculated index result to the corresponding storage node. Since a write involves a lot of resources such as system calls, context switching, protocol stack serialization, etc., for messages to be written to the same remote storage node, a batch processing strategy is attempted to improve throughput. Therefore, the following technical solution is designed.
[0044] In the description of the scheme, the abbreviations that may be involved and their corresponding Chinese meanings are shown in the following table. Lowercase represents a variable, which may change in value as the system runs; uppercase is a constant, whose value does not change after the system starts.
[0045] Table 1
[0046] It should be understood that the number of computing nodes, topic partitions and storage nodes in Figure 1 is only illustrative. Depending on the implementation needs, there can be any number of computing nodes, topic partitions and storage nodes.
[0047] With reference to Figure 2, a flow 200 of one embodiment of the data batch transmission method according to the present disclosure is shown. The data batch transmission method comprises the following steps:
[0048] Step 201, in response to receiving a transmission request of a target message, determining the queue information of the queue corresponding to the destination address of the target message.
[0049] In the embodiment, the execution subject of the data batch transmission method (for example, the broker (computing node) shown in FIG. 1) can receive the transmission request of the target message sent by the client through a wired connection mode or a wireless connection mode. The transmission request can include the destination address (address of the storage node) of the target message.
[0050] The application simultaneously adopts a quantity-based and time-based strategy, and designs an aggregator. When the application layer of the computing node attempts to send a transmission request to the storage node, the transmission request is intercepted by the aggregator first, and a queue for temporarily storing the to-be-sent message can be established in advance according to the address of the storage node. The queue information includes: the number of messages in the queue, the queue capacity, and the creation time of the message in the queue. If the received message does not trigger batch processing, the message is stored in the queue, the number of messages in the queue is accumulated, and the creation time of the message in the queue is recorded. The capacity of each queue is dynamically changed.
[0051] The queue is a bounded queue that can automatically adapt according to the number of messages, waiting time, and the like, as shown in FIG. 3. aggCount represents the number of messages in the queue that are temporarily stored and waiting for batch processing, currentCapacity represents the queue capacity of the current queue (according to the number condition, the batch processing is performed when the queue is full), MIN_CAPACITY and MAX_CAPACITY represent the minimum / maximum capacity allowed for expansion and contraction of the queue capacity in the adaptive strategy below. MIN_CAPACITY and MAX_CAPACITY can be set according to the memory resources of the computing node and the number of storage nodes. The value of currentCapacity can be dynamically adjusted between MIN_CAPACITY and MAX_CAPACITY.
[0052] In step 202, in response to the sum of the number of messages in the queue and the number of target messages being greater than the queue capacity, or the difference between the current time and the creation time of the first message in the queue exceeding the maximum waiting time, the messages in the queue and the target message are batched and sent to the destination address.
[0053] In the embodiment, for a queue, one of the number condition or the time condition is met, and then batch processing can be performed.
[0054] 1. Processing rule based on the number condition:
[0055] Triggering occasion: The number condition is checked when there is a new message, and batch processing is performed immediately if the number condition is met
[0056] Trigger condition: the accumulated number aggCount plus the number of messages in the current request exceeds the queue capacity currentCapacity
[0057] 2. Time-based processing rule:
[0058] Trigger time: there is a new message or a periodic check task
[0059] Trigger condition: the difference between the current time and the creation time of the first message in the queue exceeds the maximum waiting time (lingerMs).
[0060] In some optional implementations of the embodiment, the method further comprises: periodically scheduling a timing check task to check whether the difference between the current time and the creation time of the first message in the queue exceeds the maximum waiting time; and if the difference exceeds the maximum waiting time, triggering batch sending of the messages in the queue to the destination address. For example, the timing check task can be scheduled to check once every second whether the difference between the current time and the creation time of the first message in the queue exceeds the maximum waiting time, and if the difference exceeds the maximum waiting time, triggering batch sending of the messages in the queue to the destination address. This can overcome the problem that in the number-based scheme, when the application receives few requests, the response time for the requests becomes very large, but in fact the system has sufficient CPU and network bandwidth to handle the load, but does not play a role. The number-based scheme alone can even sometimes fail to accumulate to the threshold at which batch processing can be performed.
[0061] In some optional implementations of the embodiment, the method further comprises: if the timing check task triggers batch sending of the messages, executing the timing check task again after an interval of the maximum waiting time. The check task can not be scheduled periodically, and fixed periodic scheduling can cause a certain time window. If batch processing is triggered each time the task is executed, the task will be scheduled again after an interval of lingerMs.
[0062] In some optional implementations of the embodiment, the method further comprises: if the timing check task does not trigger batch sending of the messages, calculating an expected check time based on the creation time of the first message in the queue, the maximum waiting time, and the current time; and in response to the current time reaching the expected check time, executing the timing check task.
[0063] If batch processing is not triggered, the expected time when the expected time (the creation time of the first message + the maximum waiting time - the current time) will be calculated, and the check will be performed at that time point.
[0064] After introducing both the number-based and time-based strategies, the most basic problem of batch processing is solved.
[0065] When the traffic is large, the number condition is met, batch processing is performed, and the throughput is increased
[0066] When the traffic is small, the time condition is met, and the response time is guaranteed to be within a controllable range
[0067] In step 203, the queue capacity is dynamically adjusted according to the time interval and / or the number of messages in the batch.
[0068] In this embodiment, since the CPU, memory, network, and other machines deployed by the system are different, it is difficult to find a suitable threshold. To solve this problem, the observation mechanism and the adaptive queue length expansion mechanism are introduced to dynamically adapt the parameters to the actual traffic.
[0069] The observation method trace is called to record the sending time point and batch size at each batch execution, and the batch size is dynamically adjusted according to the sending interval and the number of conditions. For example, if the sending interval (the current batch execution time minus the last execution time) is less than the maximum waiting time for multiple times, it means that the number condition is triggered, and the traffic is large, so the queue capacity needs to be expanded. If the number of messages is less than the current queue capacity for multiple times, it means that the time condition is triggered, and the traffic is small, so the queue capacity needs to be reduced.
[0070] In some optional implementations of the embodiment, if the time interval is less than the maximum waiting time, the expansion counter of the queue is incremented by 1; and in response to the expansion counter reaching the expansion / reduction threshold, the queue capacity is expanded.
[0071] If the sending interval (the current batch execution time minus the last execution time) is less than the maximum waiting time, it means that this batch is triggered by the number condition, and the queue expansion counter expend is incremented by 1. When expend grows to resizeThreshold, it means that the number condition is met for consecutive resizeThreshold times, and the traffic is large, so it is checked whether the capacity can be expanded. Note that the maximum length of the queue expansion cannot exceed the set maximum value MAX_CAPACITY.
[0072] In some optional implementations of the embodiment, if the number of messages is less than the number of messages in the queue, the contraction counter of the queue is incremented by 1; and in response to the contraction counter reaching the expansion / reduction threshold, the queue capacity is reduced.
[0073] If the sending quantity is less than the current queue length, it indicates that this batch processing is triggered by the time condition, and the queue narrowing counter narrow is increased by 1. When narrow grows to resizeThreshold, it means that the time condition is met for consecutive resizeThreshold times, and at this time, the traffic is small, and it is checked whether the queue can be narrowed. It is noted that the maximum length of the queue expansion cannot exceed the set minimum value MIN_CAPACITY.
[0074] It is noted that the expansion and narrowing of the queue can be in multiples of 2 (i.e., 1, 2, 4, 8, 16, 32,...), so in order to avoid frequent expansion and narrowing, the condition for triggering the expansion counter to grow is that the sending interval (the current batch processing time minus the last execution time) is less than half of the maximum waiting time (i.e., if the traffic does not change, the expansion will still be triggered by the quantity condition, and will not cause narrowing). Similarly, the condition for triggering the narrowing counter to grow is that the number of messages waiting for processing in the queue is less than or equal to half of the current queue length.
[0075] In some optional implementations of the embodiment, if the difference between the current time and the time of the last adjustment of the queue capacity is greater than the expansion and narrowing minimum time interval, the queue capacity is dynamically adjusted according to the message batch sending time interval and / or the sending quantity.
[0076] In order to avoid frequent expansion and narrowing caused by the fluctuation of traffic, the expansion and narrowing counter is reset to zero and starts counting from the beginning as long as one round does not meet the condition before triggering the expansion and narrowing. At the same time, the last time of adjusting the queue capacity lastResizeTime and the minimum interval of adjusting the queue capacity RESIZE_INTERVAL are recorded to ensure that the expansion or narrowing is performed at least RESIZE_INTERVAL.
[0077] The method provided by the above embodiment of the present disclosure adjusts the batch size through an adaptive strategy according to real-time traffic, and adapts to most scenarios. At the same time, the strategy is widely applicable and does not depend on specific hardware and experience parameters. A dynamic balance is achieved in throughput and delay.
[0078] In some optional implementations of the embodiment, the method further includes: if the sum of the number of messages in the queue and the number of target messages is less than or equal to the queue capacity, or the difference between the current time and the creation time of the first message in the queue does not exceed the maximum waiting time, the target message is stored in the queue. If the trigger time of batch processing is not reached, the received target message is stored in the queue according to the destination address.
[0079] Referring again to Figure 3, which is a schematic diagram of an application scenario of the data batch transmission method according to this embodiment, in the application scenario of Figure 3, after receiving a transmission request for a target message, the computing node determines the queue corresponding to the message based on the destination address of the target message. It queries the number of messages in the queue (aggCount). If aggCount plus the number of target messages is greater than the current queue capacity (currentCapacity), then the messages in the queue and the target message are sent in batches to the destination address. Otherwise, it checks whether the difference between the current time and the creation time of the first message in the queue exceeds the maximum waiting time. If it does, then the messages in the queue and the target message are sent in batches to the destination address. Each batch transmission records the transmission time and quantity to determine the transmission time interval and transmission quantity. If the transmission time interval is less than the maximum waiting time, it indicates that batch processing is triggered by a quantity condition. If the transmission quantity is less than the queue capacity, it indicates that batch processing is triggered by a time condition. If batch processing is triggered by a quantity condition multiple times consecutively, it indicates that the queue capacity is too small. To reduce the number of batch processing operations, the queue needs to be expanded, but the queue capacity cannot exceed the maximum value MAX_CAPACITY. If batch processing is triggered multiple times consecutively by time conditions, it indicates that the queue capacity is too large. In order to reduce the waiting time, the queue needs to be shrunk, but the queue capacity cannot be less than the minimum value MIN_CAPACITY.
[0080] Referring further to Figure 4, a flow 400 of another embodiment of the data bulk transfer method is shown. Flow 400 of this data bulk transfer method includes the following steps:
[0081] Step 401: In response to receiving a transmission request for the target message, determine the queue information of the queue corresponding to the destination address of the target message.
[0082] Step 401 is basically the same as step 201, so it will not be described again.
[0083] Step 402: Set the trigger time of the timer based on the average message processing time.
[0084] In this embodiment, the batch strategy described above can already be adaptively adjusted according to traffic. However, to avoid frequent adjustments, this application reduces the system's sensitivity to traffic by setting a scaling-up / scaling-down counter and a minimum scaling-up / scaling-down interval. Therefore, if the system suddenly switches from high traffic to low traffic, and if RESIZE_INTERVAL is set to 10s and resizeThreshold is set to 3, it will take at least 30 seconds for the user to experience lower latency.
[0085] Another scenario is that, in order to maximize throughput, lingerMs is usually set to be slightly less than the maximum delay that users can tolerate. If the user traffic is intermittent and does not trigger the queue shrink, each request may wait for lingerMs before being batched. Therefore, it is desirable to have a strategy to further optimize this scenario.
[0086] Therefore, the application introduces a timer-based adaptive processing, which is timer-preposed. For example, a computing node of a message system, assuming that the average message processing time is 300 microseconds when the computing layer load is high, and then the message needs to be written to the storage node. A timer is added before the calculation, and for each request, the timer corresponding to the remote server to which the request can be sent is set to trigger after the current time + 300 microseconds. When the timer reaches the specified time, the batch processing operation is performed.
[0087] Step 403, in response to the current time reaching the trigger time, the messages in the queue are batched and sent to the destination address.
[0088] In this embodiment, if a subsequent message comes in during the processing of the first message, the current time of the timer will be constantly refreshed, and after the processing of the first message is completed, the subsequent message will not be sent but will be waited for.
[0089] If no subsequent message comes in during the processing of the first message, the timer will trigger a batch processing at the specified time, at which time the first message has two states
[0090] 1) Just processed a short time ago, avoiding waiting for lingerMs to send
[0091] 2) Added to the waiting queue later than the timer trigger time, which degenerates to the scheme in steps 404-405. However, since the processing time is generally faster than the average message processing time when the load is high, the probability of this scenario is very low.
[0092] Step 404, in response to the sum of the number of messages in the queue and the number of target messages being greater than the queue capacity, or the difference between the current time and the creation time of the first message in the queue exceeding the maximum waiting time, the messages in the queue and the target messages are batched and sent to the destination address.
[0093] Step 405, dynamically adjusting the queue capacity according to the time interval and / or the number of message batch sending.
[0094] Steps 404-405 are basically the same as steps 203-204, and therefore will not be described again.
[0095] The adaptive batch processing based on observation always predicts future values with past values, and there is a delay between the reaction of traffic changes and the batch processing mechanism, so it is not sensitive to sharp changes in traffic (we also want to be less sensitive to avoid frequent adjustments). Therefore, a pre-timer is introduced to help us observe as soon as possible whether there are subsequent requests that can be batched under sparse traffic, thereby reducing response time under sparse traffic.
[0096] With further reference to FIG. 5, as an implementation of the method shown in the above figures, the present disclosure provides an embodiment of a data batch transmission device, which corresponds to the method embodiment shown in FIG. 2, and the device can be applied to various electronic devices.
[0097] As shown in FIG. 5, the data batch transmission device 500 of the present embodiment includes a determination unit 501, a sending unit 502, and an adjustment unit 503. The determination unit 501 is configured to determine the queue information of a queue corresponding to the destination address of a target message in response to receiving a transmission request of the target message, wherein the corresponding queue is established in advance according to the destination address, and the queue information includes the number of messages in the queue, the queue capacity, and the creation time of the messages in the queue. The sending unit 502 is configured to batch send the messages in the queue and the target message to the destination address in response to the sum of the number of messages in the queue and the number of target messages being greater than the queue capacity, or the difference between the current time and the creation time of the first message in the queue exceeding the maximum waiting time. The adjustment unit 503 is configured to dynamically adjust the queue capacity according to the time interval and / or the number of message batch sending.
[0098] In the present embodiment, the specific processing of the determination unit 501, the sending unit 502, and the adjustment unit 503 of the data batch transmission device 500 can refer to steps 201, 202, and 203 in the corresponding embodiment of FIG. 2.
[0099] In some optional implementations of the present embodiment, the device further includes a timing unit (not shown in the figure) configured to: periodically check whether the difference between the current time and the creation time of the first message in the queue exceeds the maximum waiting time; and if the maximum waiting time is exceeded, batch send the messages in the queue to the destination address.
[0100] In some optional implementations of the present embodiment, the timing unit is further configured to: if the message batch sending is triggered by a task, perform the timing check task again after a maximum waiting time interval.
[0101] In some optional implementations of the embodiment, the timing unit is further configured to: if the batch sending of messages is not triggered, calculate an expected checking time according to the creation time of the first message in the queue, the maximum waiting time, and the current time; and perform the timing checking task in response to the current time reaching the expected checking time.
[0102] In some optional implementations of the embodiment, the device further comprises a timing unit (not shown in the drawings) configured to: set a trigger time of a timer according to the average message processing time; and in response to the current time reaching the trigger time, batch send the messages in the queue to the destination address.
[0103] In some optional implementations of the embodiment, the timing unit is further configured to: if other messages are received during the processing of the target messages, refresh the trigger time of the timer according to the average message processing time.
[0104] In some optional implementations of the embodiment, the adjusting unit 503 is further configured to: if the time interval is less than the maximum waiting time, increase a queue expansion counter by 1; and in response to the queue expansion counter reaching an expansion and contraction threshold, expand the queue capacity.
[0105] In some optional implementations of the embodiment, the adjusting unit 503 is further configured to: if the sending quantity is less than the number of messages in the queue, increase a queue contraction counter by 1; and in response to the queue contraction counter reaching the expansion and contraction threshold, contract the queue capacity.
[0106] In some optional implementations of the embodiment, the adjusting unit 503 is further configured to: if the difference between the current time and the time of the last adjustment of the queue capacity is greater than an expansion and contraction minimum time interval, dynamically adjust the queue capacity according to the time interval and / or the sending quantity of the batch sending of messages.
[0107] In some optional implementations of the embodiment, the device further comprises a storage unit (not shown in the drawings) configured to: if the sum of the number of messages in the queue and the number of target messages is less than or equal to the queue capacity, or the difference between the current time and the creation time of the first message in the queue does not exceed the maximum waiting time, store the target messages into the queue.
[0108] It should be noted that in the technical solutions of the present disclosure, the collection, collection, updating, analysis, processing, use, transmission, storage, etc. of user personal information involved in the technical solutions comply with relevant laws and regulations, are used for legal purposes, and do not violate public order and good customs. Necessary measures are taken for user personal information to prevent illegal access to user personal information data, and the security of user personal information, network security and national security are maintained.
[0109] According to the embodiments of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0110] An electronic device includes one or more processors; a storage device having stored thereon one or more computer programs that, when executed by the one or more processors, cause the one or more processors to implement the method of flow 200 or 400.
[0111] A computer readable medium having stored thereon a computer program, wherein the computer program is executed by a processor to implement the method of flow 200 or 400.
[0112] FIG. 6 shows a schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit the implementations of the present disclosure described and / or claimed in this document.
[0113] As shown in FIG. 6, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to computer programs stored in a read-only memory (ROM) 602 or loaded into a random access memory (RAM) 603 from a storage unit 608. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0114] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a magnetic disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through computer networks, such as the Internet, and / or various telecommunication networks.
[0115] The computing unit 601 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 601 performs various methods and processes described above, such as the road zone planning method. For example, in some embodiments, the road zone planning method can be implemented as a computer software program, which is tangibly embodied in a machine-readable medium, such as the storage unit 608. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded onto the RAM 603 and executed by the computing unit 601, one or more steps of the road zone planning method described above can be performed. Alternatively, in other embodiments, the computing unit 601 can be configured to perform the road zone planning method by any other appropriate means, such as by means of firmware.
[0116] Various implementations of the systems and techniques described above herein can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0117] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine as a standalone software package, or entirely on a remote machine or server.
[0118] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0119] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0120] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0121] The computer system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server is generally established using computer programs running on the respective computers and having a client-server relationship to each other. The servers can be distributed servers, or servers combined with blockchain. The servers can also be cloud servers, or intelligent cloud computing servers or intelligent cloud hosts with artificial intelligence technology.
[0122] It should be understood that various forms of flow shown above can be used with orders of steps rearranged, added, or deleted steps. For example, the steps described in the present disclosure can be executed in parallel, in sequence, or in different orders, as long as the desired results of the technical solutions of the present disclosure can be achieved, and the present disclosure is not limited herein.
[0123] The specific implementation described above does not constitute a limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements, and improvements within the spirit and principles of the present disclosure should be included in the protection scope of the present disclosure.
Claims
1. A data batch transmission method, comprising: determining queue information of a queue corresponding to a destination address of a target message in response to receiving a transmission request of the target message, wherein the queue corresponding to the destination address is established in advance, and the queue information comprises a number of messages in the queue, a queue capacity, and a creation time of a first message in the queue; in response to a sum of the number of messages in the queue and a number of the target message being greater than the queue capacity, or a difference between a current time and the creation time of the first message exceeding a maximum waiting time, transmitting the messages in the queue and the target message to the destination address in batch; dynamically adjusting the queue capacity according to a time interval and / or a number of message batch transmissions.
2. The method of claim 1, wherein, The method further comprises: timing checking whether the difference between the current time and the creation time of the first message exceeds the maximum waiting time; in response to the difference exceeding the maximum waiting time, transmitting the messages in the queue to the destination address in batch.
3. The method of claim 2, wherein, The method further comprises: timing checking again whether the difference between the current time and the creation time of the first message exceeds the maximum waiting time after the maximum waiting time.
4. The method of claim 2, wherein, The timing checking whether the difference between the current time and the creation time of the first message exceeds the maximum waiting time comprises: timing checking whether the difference between the current time and the creation time of the first message exceeds the maximum waiting time; in response to the difference not exceeding the maximum waiting time, calculating an expected checking time according to the creation time of the first message, the maximum waiting time, and the current time; in response to the current time reaching the expected checking time, checking whether the difference between the current time and the creation time of the first message exceeds the maximum waiting time.
5. The method of claim 1, wherein, Before determining the queue information of the queue corresponding to the destination address of the target message, the method further comprises: setting a trigger time of a timer according to an average message processing time; in response to the current time reaching the trigger time, transmitting the messages in the queue corresponding to the destination address of the target message to the destination address in batch.
6. The method of claim 5, wherein, The method further comprises: in response to receiving a transmission request of another message having the same destination address during processing of the target message, refreshing the trigger time of the timer according to the average message processing time.
7. The method of claim 1, wherein, The dynamically adjusting the queue capacity according to the time interval and / or the number of message batch transmissions comprises: in response to the time interval of message batch transmission being less than the maximum waiting time, increasing a capacity expansion counter of the queue by 1; in response to the capacity expansion counter reaching a capacity expansion and contraction threshold, expanding the queue capacity.
8. The method of claim 1, wherein, The dynamically adjusting the queue capacity according to the time interval and / or the number of message batch transmissions comprises: in response to the number of message batch transmission being less than the number of messages in the queue, increasing a capacity contraction counter of the queue by 1; in response to the capacity contraction counter reaching the capacity expansion and contraction threshold, contracting the queue capacity.
9. The method of claim 1, wherein, The dynamically adjusting the queue capacity according to the time interval and / or the number of message batch transmissions comprises: In response to a difference between a current time and a time of last adjustment of the queue capacity being greater than a minimum time interval for adjusting the queue capacity, the queue capacity is dynamically adjusted according to a time interval and / or a number of message batch transmissions.
10. The method of any one of claims 1-9, wherein, The method further includes: In response to a sum of a number of messages in the queue and a number of the target messages being less than or equal to the queue capacity, or a difference between a current time and a creation time of a first message in the queue not exceeding a maximum waiting time, the target messages are stored into the queue. 11.A data batch transmission apparatus, comprising: a determination unit configured to, in response to receiving a transmission request of target messages, determine queue information of a queue corresponding to a destination address of the target messages, wherein the corresponding queue is established in advance according to the destination address, and the queue information comprises a number of messages in the queue, a queue capacity, and a creation time of a message in the queue; a sending unit configured to, in response to a sum of a number of messages in the queue and a number of the target messages being greater than the queue capacity, or a difference between a current time and a creation time of a first message in the queue exceeding a maximum waiting time, batch transmit the messages in the queue and the target messages to the destination address; an adjustment unit configured to dynamically adjust the queue capacity according to a time interval and / or a number of message batch transmissions. 12.An electronic device, comprising: one or more processors; a storage device having stored thereon one or more computer programs, when the one or more computer programs are executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-10.
13. A computer readable medium having stored thereon a computer program, wherein, The computer program, when executed by a processor, implements the method of any one of claims 1-10.
Citation Information
Patent Citations
Batch task processing method and system
CN108536532A
Message queue management method and device
CN113138860A
Service processing method and device
CN113742389A
Batch processing method, device and equipment based on Kserve and medium
CN114647497A
Method and system for self-managing and controlling message queues
US20230385137A1