Event time processing method and device based on Flink adaptive window

By introducing adaptive window technology into Flink, the window size is adjusted according to real-time traffic, which solves the data backlog problem caused by fixed windows, improves processing performance and accuracy, and ensures system stability and tolerance.

CN118740755APending Publication Date: 2024-10-01CHINA UNITECHS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410932510.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

When existing technology handles uneven network traffic, fixed rolling windows lead to data backlog, high memory pressure, long calculation time, and may even lead to memory exhaustion and service suspension, affecting the accuracy and performance of Flink window calculations.

Method used

The adaptive window method based on Flink is used to dynamically adjust the window size according to the real-time traffic size. By defining adaptive window adjustment rules and triggers, it monitors event changes and adjusts the window in a timely manner to ensure that Flink handles the number of events per unit time and avoids waste of resources. Achieve dynamic balancing of computational time.

Benefits of technology

By dynamically adjusting the window size, the system can more flexibly adapt to different data flow modes, improve processing performance, enhance tolerance to out-of-order events, improve data processing accuracy, and ensure stable system operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118740755A_ABST
    Figure CN118740755A_ABST
Patent Text Reader

Abstract

The invention discloses an event time processing method and device based on an Flink adaptive window, and the method comprises the steps: S01, employing kafka as a data source of a real-time flow calculation engine, simulating network traffic at different rates, and generating netflow data in the kafka; s02, defining an adjustment rule of an adaptive window, setting an fps processing threshold value of Flink, and defining a maximum window length and a minimum window length; s03, an Flink processing flow is constructed; s04, establishing a self-adaptive time window trigger to realize a class of DynamicWindows SizeTrigger, inheriting a Trigger class, and rewriting an onElement method and an onProcestingTime method, and carrying out the following steps of: 1, carrying out the Trigger class, so as to obtain a Trigger class, and rewriting the onElement method and the onProcestingTime method; and S05, starting an Flink program, producing data into the kafka at the different rates in the S01, and observing the change of the window output interval. According to the event time processing method and device based on the Flink self-adaptive window, the size of the window is dynamically adjusted according to the real-time flow, unnecessary resource waste is avoided, and therefore dynamic balance of Flink calculation time consumption is achieved, and stable operation of a system is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communications, and in particular to a method and device for event time processing based on Flink adaptive windows. Background Art

[0002] The existing technical method is to use a fixed rolling window. The problem is that when the traffic is uneven, such as during a traffic peak, the traffic may be dozens of times that of a low point (early morning). At this time, using a fixed rolling window will cause too much data to accumulate in the window, which not only puts a lot of pressure on the memory, but also takes a long time to calculate, causing data to accumulate before the Flink window calculation, resulting in data back pressure. The calculation results will have a large deviation, and in serious cases, it will lead to memory exhaustion and service failure.

[0003] When using Flink real-time stream processing of network traffic data, the fluctuation of network traffic data has a great impact on the performance of Flink window calculation. Flink's performance problems directly lead to its back pressure, which ultimately results in inaccurate calculation results and delayed calculation. Summary of the invention

[0004] In order to solve the problems existing in the prior art, the present invention provides an event time processing method and device based on Flink adaptive window, which dynamically adjusts the window size according to the real-time traffic size to avoid unnecessary waste of resources, thereby achieving a dynamic balance of Flink computing time and ensuring the stable operation of the system.

[0005] To achieve the above object, the present invention adopts the following technical solutions:

[0006] In one embodiment of the present invention, a method for event time processing based on Flink adaptive window is proposed, and the method includes:

[0007] S01. Use Kafka as the data source of the real-time stream computing engine, and simulate network traffic at different rates to produce netflow data in Kafka.

[0008] S02. Define the adjustment rules for the adaptive window, set the Flink fps processing threshold, define the maximum window length and the minimum window length. If the fps is greater than the threshold, the window will be reduced, and if the fps is less than the threshold, the window will be increased.

[0009] Furthermore, the window is a rolling time window.

[0010] S03. Build the Flink processing flow, establish input, window, processing, and output modules, and the initial window size is the maximum window size;

[0011] S04. Establish an adaptive time window trigger implementation class DynamicWindowSizeTri gger, inherit the Trigger class and rewrite the onElement and onProcessingTime methods. The logic of the OnElement method is to monitor the changes of window events and adjust the size of the window in time. The logic of the onProcessingTime method is to dynamically update the scroll window.

[0012] Furthermore, the onElement method is triggered every time an event enters the rolling time window, that is, each netflow data entering the rolling time window will trigger the method.

[0013] Further, the S04 includes:

[0014] S041. Customize a trigger, implement the trigger interface method, and listen for the entry of window events;

[0015] S042, counting the data entering the window per unit time;

[0016] S043, accumulating the number of events in a certain period of time, and dividing it by the time interval to obtain the number of events per unit time, i.e., FPS;

[0017] S044. Compare the FPS value with the defined processing threshold. If it is greater than the threshold, reduce the window appropriately. If it is less than the threshold, increase the window appropriately to ensure the number of events processed by Flink in a unit of time and ensure smooth operation of the business.

[0018] S05. Start the Flink program, produce data to Kafka at different rates as described in S01, and observe the changes in the window output interval.

[0019] Furthermore, in S05, if the window FPS is less than a set threshold and the window time is a set maximum value, the current window execution is maintained without adjustment.

[0020] In one embodiment of the present invention, an event time processing device based on Flink adaptive window is also proposed, and the device includes:

[0021] The data simulation module uses Kafka as the data source of the real-time stream computing engine and simulates network traffic at different rates to produce netflow data in Kafka.

[0022] Adaptive rule module, which defines the adjustment rules of adaptive windows, sets Flink's fps processing threshold, and defines the maximum and minimum window lengths. If the fps is greater than the threshold, the window is reduced, and if the fps is less than the threshold, the window is increased.

[0023] Flink processes the flow to build modules, establish input, window, processing, and output modules, and the initial window size is the maximum window size;

[0024] The trigger module establishes an adaptive time window trigger implementation class DynamicWindowSizeTrigger, inherits the Trigger class and rewrites the onElement and onProcessingTime methods. The logic of the OnElement method is to monitor changes in window events and adjust the size of the window in time. The logic of the onProcessingTime method is to dynamically update the scrolling window.

[0025] The Flink program starts the module, produces data to Kafka at different rates as described in the data simulation module, and observes the changes in the window output interval.

[0026] In one embodiment of the present invention, a computer device is also proposed, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the aforementioned event time processing method based on Flink adaptive window is implemented.

[0027] In one embodiment of the present invention, a computer-readable storage medium is further proposed, which stores a computer program for executing an event time processing method based on Flink adaptive windows.

[0028] Beneficial effects:

[0029] The present invention discloses an event time processing method and device based on Flink adaptive window. By real-time monitoring of the characteristics of data stream, such as the number of elements and data distribution, the window size is dynamically adjusted, so that the system can adapt to different data stream modes more flexibly and improve the processing performance. The concept of event time processing is introduced, and the data is processed according to the event timestamp in the data stream rather than the timestamp when the data enters the system. This feature enhances the system's tolerance to out-of-order events and improves the accuracy of data processing. It is particularly suitable for scenarios where the time when data is generated needs to be considered. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 It is a flow chart of the event time processing method based on Flink adaptive window of the present invention;

[0031] Figure 2It is a structural diagram of an event time processing device based on Flink adaptive window of the present invention;

[0032] Figure 3 It is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0033] The principles and spirit of the present invention will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present invention, and are not intended to limit the scope of the present invention in any way. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.

[0034] Those skilled in the art will appreciate that the embodiments of the present invention may be implemented as a system, device, apparatus, method or computer program product. Therefore, the present disclosure may be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.

[0035] According to an implementation of the present invention, a method and device for event time processing based on Flink adaptive windows are proposed, which dynamically adjust the window size according to the real-time traffic size to avoid unnecessary waste of resources, thereby achieving a dynamic balance of Flink computing time and ensuring the stable operation of the system.

[0036] The principle and spirit of the present invention are explained in detail below with reference to several representative embodiments of the present invention.

[0037] like Figure 1 As shown, the present invention relates to an event time processing method based on Flink adaptive window, the method comprising:

[0038] S01. Use Kafka as the data source of the real-time stream computing engine, and simulate network traffic at different rates to produce netflow data in Kafka.

[0039] S02. Define the adjustment rules for the adaptive window, set the Flink fps processing threshold, define the maximum window length and the minimum window length. If the fps is greater than the threshold, the window will be reduced, and if the fps is less than the threshold, the window will be increased.

[0040] The window is a rolling time window.

[0041] S03. Build the Flink processing flow, establish input, window, processing, and output modules, and the initial window size is the maximum window size;

[0042] S04. Establish an adaptive time window trigger implementation class DynamicWindowSizeTri gger, inherit the Trigger class and rewrite the onElement and onProcessingTime methods. The logic of the OnElement method is to monitor the changes of window events and adjust the size of the window in time. The logic of the onProcessingTime method is to dynamically update the scroll window.

[0043] The onElement method is triggered every time an event enters the rolling time window, that is, each netflow data entering the rolling time window will trigger the method.

[0044] The S04 includes:

[0045] S041. Customize a trigger, implement the trigger interface method, and listen for the entry of window events;

[0046] S042, counting the data entering the window per unit time;

[0047] S043, accumulating the number of events in a certain time period, and dividing it by the time interval to obtain the number of events per unit time, i.e., FPS;

[0048] S044. Compare the FPS value with the defined processing threshold. If it is greater than the threshold, reduce the window appropriately. If it is less than the threshold, increase the window appropriately to ensure the number of events processed by Flink in a unit of time and ensure smooth operation of the business.

[0049] S05. Start the Flink program, produce data to Kafka at different rates as described in S01, and observe the changes in the window output interval.

[0050] In S05, if the window FPS is less than the set threshold and the window time is the set maximum value, the current window execution is maintained without adjustment.

[0051] It should be noted that, although the operations of the method of the present invention are described in a specific order in the above embodiments and the accompanying drawings, this does not require or imply that the operations must be performed in the specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0052] In order to explain the above-mentioned event time processing method based on Flink adaptive window more clearly, it is described in conjunction with a specific embodiment below. However, it should be noted that this embodiment is only for better illustrating the present invention and does not constitute an improper limitation to the present invention.

[0053] Take the traffic analysis based on the destination IP address: 1.1.1.1 as an example. In the laboratory environment, the real-time netflow data in the network is simulated at 1:10000.

[0054] The following steps are involved:

[0055] S01. Use Kafka as the data source of the real-time stream computing engine, and simulate network traffic at different rates to produce netflow data in Kafka. There are two levels: one is 5 FPS (simulating real 50,000 fps), and the other is 60 FPS (simulating real 600,000 fps).

[0056] The default output here is the parsed netflow data, and the netflow data format is as follows:

[0057] FlowRecord:{

[0058] ipVer(ip version);

[0059] String srcAddr (source IP address, such as 192.168.1.1);

[0060] String dstAddr (destination IP address, such as 192.168.1.1);

[0061] long packets (number of packets);

[0062] long octets(byte count);

[0063] int srcPort(source port);

[0064] int dstPort(destination port);

[0065] int protocol(protocol);

[0066] S02. Define the adjustment rules for the adaptive window. To see the effect more intuitively, we set the Flink processing threshold to 30 (i.e. 30w fps). According to this rule, if the fps is greater than 30, the window will be appropriately reduced, and if the fps is less than 30, the window will be appropriately increased. However, the adaptive enlargement or reduction of these windows is not endless, so we also need to define the maximum and minimum window lengths that we can accept in the rules. The windows mentioned here are all rolling time windows, and the parameters are defined as follows:

[0067] private final long maxWindowSize; / / Maximum window size in milliseconds

[0068] private final long minWindowSize; / / Minimum window size in milliseconds

[0069] private long currentWindowSize; / / Current window size in milliseconds

[0070] private final LongAdder count=new LongAdder();

[0071] private final Long triggerUnit = 30l; / / threshold for triggering window changes

[0072] private final Integer timeUnit = 5; / / Calculate the interval of FPS

[0073] private long lastTriggerTimestamp; / / The timestamp of the last trigger calculation

[0074] public DynamicWindowSizeTrigger(long maxWindowSize,longminWindowSize){

[0075] this.maxWindowSize=maxWindowSize*1000;

[0076] this.minWindowSize=minWindowSize*1000;

[0077] this.currentWindowSize = minWindowSize * 1000; / / The initial window size is the maximum window size

[0078] this.lastTriggerTimestamp=0;

[0079] S03. Build the Flink processing flow, establish input, window, processing, and output modules, and the initial window size is the maximum window size. The pseudo code is as follows:

[0080] / / Get the execution environment

[0081] StreamExecutionEnvironment env=StreamExecutionEnvironment.getExecutionEnvironment();

[0082] / / Convenient for testing: Set the parallelism to 1. The production environment is set to the number of partitions of Kafka env.setParallelism(1);

[0083] / / kafka topic

[0084] String topic = "flow_test";

[0085] env.addSource(createKafkaConsumer(env,topic)).map(item->JSON.parseObject((String)item,XFlowRecord.class))

[0086] .keyBy((KeySelector<XFlowRecord,String> )XFlowRecord::getDstAddress) / / Group calculation based on destination IP as key

[0087] .window(TumblingProcessingTimeWindows.of(Time.seconds(60))) / / Define a tumbling window with a length of 60 seconds

[0088] .trigger(new DynamicWindowSizeTrigger(60,1)) / / Implement dynamic window adjustment trigger, the maximum window size is 60s, the minimum window size is 1s

[0089] .apply(new TestFpsByDstIpFunction()) / / Simulate the Flink window calculation module to calculate the FPS size of the destination IP

[0090] .returns(TypeInformation.of(String.class))

[0091] .print();

[0092] env.execute("dynamic-window-test");

[0093] S04. Create an adaptive time window trigger implementation class DynamicWindowSizeTri gger, inherit the Trigger class and rewrite the onElement and onProcessingTime methods. The onElement method is triggered every time an event enters the rolling time window, that is, each netflow data entering the rolling time window will trigger this method. In the onElement method, according to the adaptive window adjustment rules defined in S02, add the logic of adjusting the window size. This logic mainly ensures that in the case of peak traffic, the data in each calculation window will not exceed the threshold we define, ensuring the efficiency of Flink calculation. When the traffic is low, it is not necessary to expand the window. Instead, the window expansion operation is triggered only when the traffic is less than half of the threshold. The logic is as follows:

[0094] / / This method will be called for each element that enters the window

[0095] / **

[0096] *CONTINUE: Indicates that no operation is performed on the window, that is, window calculation is not triggered and elements are not deleted.

[0097] *FIRE: trigger window calculation, but keep window elements

[0098] *PURGE: Do not trigger window calculation, discard the window, and delete the elements of the window.

[0099] *FIRE_AND_PURGE: Trigger window calculation, output the result, and then clear the data in the window and the window.

[0100] * /

[0101] @Override

[0102] public TriggerResult onElement(Object element,long timesta mp,TimeWindow window,TriggerContext ctx)throws Exception

[0103] {

[0104] / / Each time an element is received, check whether the window size needs to be adjusted

[0105] long currentTimestamp=ctx.getCurrentProcessingTime();

[0106] long elapsedMills = (currentTimestamp - lastTriggerTime stamp) / 1000; / / Calculate the number of seconds since the last trigger

[0107] count.increment();

[0108] if (elapsedMills>=timeUnit){

[0109] double fps=count.longValue() / timeUnit;

[0110] / / Update the timestamp of the last trigger

[0111] lastTriggerTimestamp=currentTimestamp;

[0112] count.reset();

[0113] / / Gradually reduce the window size

[0114] if(fps*currentWindowSize>=triggerUnit*maxWindowSize){ / / Here triggerUnit is set to 15

[0115] currentWindowSize=Math.max(minWindowSize,currentWind owSize / 2);

[0116] }

[0117] / / Gradually increase the window size

[0118] if(fps*currentWindowSize <triggerUnit*maxWindowSize / 2){

[0119] currentWindowSize=Math.min(maxWindowSize,currentWindowSize*2);

[0120] }

[0121] System.out.println("Adjusting window size to:"+currentWindowSize);

[0122] }

[0123] / / Update the window size

[0124] ctx.registerProcessingTimeTimer(currentTimestamp+currentWindowSize);

[0125] return TriggerResult.CONTINUE;

[0126] }

[0127] Add business processing to the onProcessingTime method, that is, determine the data with the same key within a 60s period and merge them into memory.

[0128] S05. Start the Flink program, produce data to Kafka at different rates as described in S01, and observe the changes in the window output interval.

[0129] Set the threshold to 30W FPS, the trigger threshold to 20W FPS, and the maximum window duration to 60s to simulate a production rate of 60W FPS. The output is as follows:

[0130] When the threshold is exceeded, the adaptive window is reduced until it reaches the trigger threshold (with the total amount of data in the window as the ruler).

[0131] The total amount of data in the window is the trigger threshold * maximum window duration (20*60=1200W)

[0132] Adaptively adjust the tumbling window down to 30 seconds

[0133] Adjusting window size to:30000 / / 30s

[0134] Window data statistics of target IP [1.1.1.1]: 18 million

[0135] It was found that it still did not meet expectations, so the rolling window was adaptively adjusted down to 15 seconds.

[0136] Adjusting window size to:15000 / / 15s

[0137] Window data statistics of target IP [1.1.1.1]: 9 million

[0138] Window data statistics of target IP [1.1.1.1]: 9 million

[0139] Window data statistics of target IP [1.1.1.1]: 9 million

[0140] Continue to adjust the FPS to 5W, the output is as follows:

[0141] The data in the window is far less than the set threshold data, and the window duration starts to be adaptively expanded. The number of window data statistics for target IP [1.1.1.1] is: 75W

[0142] Adaptively expand the window length to 30s

[0143] Adjusting window size to:30000 / / 30s

[0144] Target IP [1.1.1.1] window data statistics: 1.50W

[0145] It is found that it still does not meet expectations, and the window time is further expanded adaptively.

[0146] Adjusting window size to:60000 / / 60s

[0147] Window data statistics of target IP [1.1.1.1]: 3 million

[0148] Window data statistics of target IP [1.1.1.1]: 3 million

[0149] Window data statistics of target IP [1.1.1.1]: 3 million

[0150] If it is found that although the window data is still less than the set threshold, the window time has reached the set maximum value, the current window execution is maintained without adjustment.

[0151] Based on the same inventive concept, the present invention also proposes an event time processing device based on Flink adaptive window. The implementation of the device can refer to the implementation of the above method, and the repeated parts will not be repeated. The term "module" used below can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0152] Figure 2 Schematic diagram of the structure of the event time processing device based on Flink adaptive window of the present invention. Figure 2 As shown, the device comprises:

[0153] The data simulation module 110 uses Kafka as the data source of the real-time stream computing engine and simulates network traffic at different rates to produce netflow data in Kafka;

[0154] Adaptive rule module 120, defines the adaptive window adjustment rules, sets the Flink fps processing threshold, defines the maximum window length and the minimum window length, reduces the window if the fps is greater than the threshold, and increases the window if the fps is less than the threshold;

[0155] Flink process building module 130, establishes input, window, processing, and output modules, and the initial window size is the maximum window size;

[0156] The trigger module 140 establishes an adaptive time window trigger implementation class DynamicWind owSizeTrigger, inherits the Trigger class and rewrites the onElement and onProcessing Time methods;

[0157] The Flink program starts module 150, produces data to Kafka at different rates as described in the data simulation module, and observes the changes in the window output interval.

[0158] It should be noted that although several modules of the event time processing device based on Flink adaptive window are mentioned in the above detailed description, this division is only exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more modules described above can be concretized in one module. Conversely, the features and functions of one module described above can be further divided into multiple modules for concretization.

[0159] Based on the above invention concept, Figure 3 As shown, the present invention also proposes a computer device 200, including a memory 210, a processor 220, and a computer program 230 stored in the memory 210 and executable on the processor 220. When the processor 220 executes the computer program 230, the aforementioned event time processing method based on Flink adaptive window is implemented.

[0160] Based on the aforementioned inventive concept, the present invention further proposes a computer-readable storage medium, which stores a computer program for executing the aforementioned event time processing method based on Flink adaptive window.

[0161] The present invention discloses an event time processing method and device based on Flink adaptive window. By real-time monitoring of the characteristics of data stream, such as the number of elements and data distribution, the window size is dynamically adjusted, so that the system can adapt to different data stream modes more flexibly and improve the processing performance. The concept of event time processing is introduced, and the data is processed according to the event timestamp in the data stream rather than the timestamp when the data enters the system. This feature enhances the system's tolerance to out-of-order events and improves the accuracy of data processing. It is particularly suitable for scenarios where the time when data is generated needs to be considered.

[0162] Although the spirit and principle of the present invention have been described with reference to several specific embodiments, it should be understood that the present invention is not limited to the disclosed specific embodiments, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and such division is only for the convenience of expression. The present invention is intended to cover various modifications and equivalent arrangements contained in the spirit and scope of the attached claims.

[0163] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0164] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0165] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0166] To provide interaction with a user, the systems and techniques described herein 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 pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the 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 input, voice input, or tactile input).

[0167] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may 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.

[0168] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0169] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0170] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

[0171] Regarding the limitation of the protection scope of the present invention, those skilled in the art should understand that, based on the technical solution of the present invention, various modifications or variations that can be made by those skilled in the art without creative work are still within the protection scope of the present invention.

Claims

1. An event time processing method based on Flink adaptive window, characterized in that: The method includes: S01. Use Kafka as the data source of the real-time stream computing engine, and simulate network traffic at different rates to produce netflow data in Kafka. S02. Define the adaptive window adjustment rules, set Flink's fps processing threshold, define the maximum window length and the minimum window length. If the fps is greater than the threshold, the window will be reduced, and if the fps is less than the threshold, the window will be increased. S03. Build the Flink processing flow, establish input, window, processing, and output modules, and the initial window size is the maximum window size; S04. Establish an adaptive time window trigger implementation class DynamicWindowSizeTrigger, inherit the Trigger class and rewrite the onElement and onProcessingTime methods. The logic of the OnElement method is to monitor the changes of window events and adjust the size of the window in time. The logic of the onProcessingTime method is to dynamically update the scrolling window. S05. Start the Flink program, produce data to Kafka at different rates as described in S01, and observe the changes in the window output interval.

2. The event time processing method based on Flink adaptive window according to claim 1 is characterized in that: The window is a rolling time window.

3. The event time processing method based on Flink adaptive window according to claim 1 is characterized in that: The triggering mechanism of the onElement method is: triggered by an event entering the rolling time window, that is, each netflow data entering the rolling time window will trigger the method.

4. The event time processing method based on Flink adaptive window according to claim 1 is characterized in that: The S04 includes: S041. Customize a trigger, implement the trigger interface method, and listen for the entry of window events; S042, counting the data entering the window per unit time; S043, accumulating the number of events in a certain period of time, and dividing it by the time interval to obtain the number of events per unit time, i.e., FPS; S044. Compare the FPS value with the defined processing threshold. If it is greater than the threshold, reduce the window appropriately. If it is less than the threshold, increase the window appropriately to ensure the number of events processed by Flink in a unit of time and ensure smooth operation of the business.

5. The event time processing method based on Flink adaptive window according to claim 1 is characterized in that: In S05, if the window FPS is less than the set threshold and the window time is the set maximum value, the current window execution is maintained without adjustment.

6. An event time processing device based on Flink adaptive window, characterized in that: The device includes: The data simulation module uses Kafka as the data source of the real-time stream computing engine and simulates network traffic at different rates to produce netflow data in Kafka. Adaptive rule module, which defines the adjustment rules of adaptive windows, sets Flink's fps processing threshold, and defines the maximum and minimum window lengths. If the fps is greater than the threshold, the window is reduced, and if the fps is less than the threshold, the window is increased. Flink processes the flow to build modules, establish input, window, processing, and output modules, and the initial window size is the maximum window size; The trigger module establishes an adaptive time window trigger implementation class DynamicWindowSizeTrigger, inherits the Trigger class and rewrites the onElement and onProcessingTime methods. The logic of the OnElement method is to monitor changes in window events and adjust the size of the window in time. The logic of the onProcessingTime method is to dynamically update the scrolling window. The Flink program starts the module, produces data to Kafka at different rates as described in the data simulation module, and observes the changes in the window output interval.

7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the method according to any one of claims 1 to 5.