Event-driven method, device, equipment, medium and product
By defining task nodes in the IT batch processing system as events and constructing event streams, the problem of low task processing efficiency in the system is solved, unified control and automated processing of task processing are realized, and the processing efficiency and flexibility of the system are improved.
Patent Information
- Application Number
- CN202410365612.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-28
- Publication Date
- 2024-10-18
AI Technical Summary
Existing IT batch processing systems have node idle periods, inconsistent business behaviors, and large storage resource consumption during task processing, resulting in low task processing efficiency.
Define task nodes in the target system as events, and build an event-driven mechanism through event streams and service dependencies to realize automated processing of tasks and separation of hot and cold data, and adjust service dependencies between events to adapt to different business scenarios.
It realizes the unified control behavior of task processing, improves the task processing efficiency of the system, flexibly responds to different business needs, and reduces operation and maintenance costs and storage consumption.
Smart Images

Figure CN118796362A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an event-driven method, device, equipment, medium and product. Background Art
[0002] With the rapid development of Internet technology, operators' services and systems have put forward new requirements such as faster business development, higher system computing speed, and larger system computing capacity. However, the completion status of service nodes in the current information technology (IT) batch processing system needs to wait for all node tasks in the service to be completed before synchronizing the signal to the subsequent service, resulting in idle periods of nodes in the service, different business behaviors of node tasks in a single service, inconsistent control methods, and the continuous increase in the amount of computing data, resulting in the limited storage medium being unable to carry the data relied on by a single computing task, resulting in large consumption of storage resources.
[0003] Therefore, how to improve the task processing efficiency of batch processing systems has become a technical problem that needs to be solved urgently in the industry. Summary of the invention
[0004] The present application provides an event-driven method, apparatus, device, medium and product to solve the technical problem of improving the task processing efficiency of a batch processing system in the prior art.
[0005] In a first aspect, the present application provides an event-driven method, comprising:
[0006] Define each task node in the target system as each event and determine the event responsibility of each event;
[0007] Construct an event flow based on the event responsibilities of each event, and set service dependencies of events in the event flow;
[0008] Each task is executed based on the service dependency and event-driven mechanism.
[0009] In some embodiments, the step of defining each task node in the target system as each event includes:
[0010] Divide the services under any node into sub-services;
[0011] Define the subscription events and output events corresponding to each sub-service to decouple services.
[0012] In some embodiments, the sub-services include order data source collection service, factor data source collection service, data regularization service and calculation engine service; the execution of each task based on the service dependency and event-driven mechanism includes:
[0013] Sending a real-time order message of the pending order to the target system, and generating a to-be-calculated event of the pending order based on the order data collected by the target system;
[0014] Processing the order data to generate a to-be-paid event for the to-be-processed order and a factor calculation event on which the to-be-paid event depends;
[0015] When the factor calculation event is completed, the calculation event of the pending order corresponding to the pending payment event is triggered to perform calculation to execute various tasks.
[0016] In some embodiments, the performing of each task based on the service dependency and event-driven mechanism further includes:
[0017] Defining a workflow for processing the pending orders and monitoring the task processing status of each processing stage in the workflow;
[0018] When a new pending order is received, a command event is sent to a subordinate microservice module of the new pending order based on the event flow, and an event processing result returned by the subordinate microservice module is received;
[0019] The command event is used to control the sub-service module of the lower-level microservice module to execute various tasks of the new order to be processed.
[0020] In some embodiments, the method further comprises:
[0021] Determine the data access frequency of the calculation data corresponding to the first data table based on the number of accesses to the second data table during two accesses to the first data table in the cache layer of the target system; the first data table is a data table corresponding to any calculation data in the task execution process, and the second data table is a data table corresponding to the calculation data other than the any calculation data;
[0022] Dividing the computing data of the cache layer into cold data and hot data based on the data access frequency;
[0023] When the state of the cache layer meets the preset elimination state, the cold data is cleared, and based on the state of the cache layer and the data access frequency of each calculated data, new hot data is sent to the cache layer.
[0024] In some embodiments, when the state of the cache layer meets the preset elimination state, clearing the cold data includes:
[0025] The preset elimination state is set based on the account period of each task, the change of the current natural month, the current cache layer memory capacity and / or the data hit situation of the cache layer;
[0026] When the state of the cache layer meets the preset elimination state, the data to be eliminated is determined based on the memory size of the cold data, the number of calculation dependency factors and / or the business type;
[0027] The data to be eliminated is cleared in the cache layer.
[0028] In a second aspect, the present application provides an event-driven device, comprising:
[0029] The definition module is used to define each task node in the target system as each event and determine the event responsibility of each event;
[0030] A construction module, used to construct an event flow based on the event responsibilities of each event, and set service dependencies of events in the event flow;
[0031] The driver module is used to execute various tasks based on the service dependency and event-driven mechanism.
[0032] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to implement the above method when executing the program through the computer program.
[0033] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which implements the above-mentioned method when executed by a processor.
[0034] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0035] The event-driven method, apparatus, equipment, medium and product provided in the embodiments of the present application define each task node in the target system as an event, determine event responsibilities and construct an event flow, and process each task in the target system through an event-driven mechanism, so that the external control behavior of individual services can be unified, and business can be automatically triggered based on events. The service dependency relationship between events can be adjusted according to specific data processing requirements, and different business scenarios can be responded to more flexibly, thereby improving the task processing efficiency of the target system. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0037] Figure 1 One of the flow charts of the event-driven method provided in the embodiment of the present application;
[0038] Figure 2 A schematic diagram of the structure of the event-driven framework provided in the embodiment of the present application;
[0039] Figure 3 One of the structural schematic diagrams of the event-driven device provided in the embodiment of the present application;
[0040] Figure 4 The second flowchart of the event-driven method provided in the embodiment of the present application;
[0041] Figure 5 A schematic diagram of the data collection process provided in the embodiment of the present application;
[0042] Figure 6 A schematic diagram of a data regularization process provided in an embodiment of the present application;
[0043] Figure 7 A schematic diagram of the process of real-time stream computing provided in an embodiment of the present application;
[0044] Figure 8 A schematic diagram of a flow chart of an event compilation provided in an embodiment of the present application;
[0045] Fig. 9 A schematic diagram of a process for eliminating data provided in an embodiment of the present application;
[0046] Fig.10 A schematic diagram of the LIRS algorithm provided in an embodiment of the present application;
[0047] Fig.11 A schematic diagram of the structure of a never-eliminated data list provided in an embodiment of the present application;
[0048] Fig.12 A schematic diagram of the structure of the running non-elimination list provided in an embodiment of the present application;
[0049] Fig.13 One of the structural diagrams of the list of data that can be eliminated provided in the embodiment of the present application;
[0050] Fig.14 The second structural diagram of the list of data that can be eliminated provided in the embodiment of the present application;
[0051] Fig.15 The third structural diagram of the list of data that can be eliminated provided in the embodiment of the present application;
[0052] Fig.16 A fourth structural diagram of a list of obsolete data provided in an embodiment of the present application;
[0053] Fig.17 A fifth structural diagram of a list of data that can be eliminated provided in an embodiment of the present application;
[0054] Fig.18 The sixth structural diagram of the list of data that can be eliminated provided in the embodiment of the present application;
[0055] Fig.19 A second structural diagram of an event-driven device provided in an embodiment of the present application;
[0056] Fig. 20 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0058] It should be noted that the terms "first", "second" etc. in the present application are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable in appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, the process, method, system, product or equipment comprising a series of steps or modules need not be limited to those steps or modules clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or equipment.
[0059] The event-driven method provided in the embodiment of the present application is applicable to a terminal, which may be various electronic devices having a display screen and supporting web browsing, including but not limited to servers, smart phones, tablet computers, laptop computers, and desktop computers.
[0060] Figure 1A flow chart of the event-driven method provided in the embodiment of the present application is as follows: Figure 1 As shown, the method includes step 110, step 120 and step 130. The steps of the method flow are only a possible implementation of the present application.
[0061] Step 110: define each task node in the target system as each event, and determine the event responsibility of each event.
[0062] Specifically, the execution subject of the event-driven method provided in the embodiment of the present application is an event-driven device, which can be a hardware device independently set in the terminal or a software program running in the terminal.
[0063] The target system can be an IT batch processing system. Tasks refer to specific work or computing processes that need to be completed in the system. Events are specific actions or state changes that occur in the system, which can trigger other operations or cause system responses. Event responsibilities refer to the functions and roles of events in the system.
[0064] Figure 2 This is a schematic diagram of the structure of the event-driven framework provided in the embodiment of the present application. Figure 2 As shown, the embodiment of the present application uses event-driven microservices to replace monolithic applications.
[0065] The embodiment of the present application defines the tasks in the target system as events and determines the event responsibilities of each event. Therefore, the event-level service is programmable and can unify the control behavior of the events at the same time to achieve unified control and management of the services.
[0066] You can also use the smallest granularity to define services, split the original large nodes vertically, use the event-driven mechanism as the control strategy, split the service into multiple events, and replace the original single application with event microservices. Based on the event dimension, separate data from applications, realize stateless services, and decouple data from services.
[0067] Figure 3 One of the structural diagrams of the event-driven device provided in the embodiment of the present application is as follows: Figure 3 As shown, the functional modules of the event-driven device include an event definition module, an event service compilation module, a cold and hot data separation module, a data elimination module, and an event-driven monitoring module. Any multiple modules of the event definition module, the event service compilation module, the cold and hot data separation module, the data elimination module, and the event-driven monitoring module can be combined into one module for implementation, or any one of the modules can be split into multiple modules.
[0068] The event definition module is responsible for defining each task node in the IT batch processing system as an event and dividing the event responsibilities.
[0069] Step 120: construct an event flow based on the event responsibility of each event, and set the service dependency of the events in the event flow.
[0070] Specifically, event flow refers to the continuous process of event transmission and triggering in the system, describing the flow and evolution of events in the system. Event flow can include the generation, transmission, processing and response of events, as well as the relationship and sequence between these links.
[0071] Service dependencies refer to the dependencies between different services or components, describing how a service depends on other services or components to complete its functions. These dependencies can include data dependencies, execution order dependencies, status notification dependencies, etc., to ensure that various services can work in coordination.
[0072] Figure 3 The event service compilation module is responsible for editing and making the service dependency definition in the event flow, which is convenient for building event flows according to different business needs and the event responsibilities of each event. By adjusting the event flow, the data processing order can be freely adjusted.
[0073] also, Figure 3 The hot and cold data separation module in the system is responsible for splitting and refining the computing event dependent data and distinguishing between hot and cold data. The data elimination module is responsible for ensuring that the cache layer and database (Database, DB) have sufficient computing resources when running, and further improving the data hit rate. The event-driven monitoring module is responsible for forming a topology map based on event arrangement, which is used to monitor the status of all events in real time.
[0074] Step 130: Execute each task based on service dependency and event-driven mechanism.
[0075] Specifically, the event-driven mechanism refers to an event-based working mechanism in the system. The system triggers related operations and tasks by monitoring the occurrence and state changes of various events. The event-driven mechanism can be used to decouple the relationship between various components of the system, improve the flexibility and scalability of the system, and also realize real-time monitoring and response.
[0076] This application executes various tasks in the target system through the event-driven mechanism by setting service dependencies.
[0077] In the original task dependency model, different tasks are bound to form a fixed data processing flow, and the data to be processed is calculated and processed, which cannot meet the changing data processing requirements. However, this application introduces the concept of Internet events, defines the events of task nodes, and performs service orchestration, defining different tasks as the same event.
[0078] Using the event-driven mechanism, business development no longer needs to focus on external interactions, but only on the logic within individual services, which makes development faster. Using event-driven rather than synchronous signal calls, and using event services instead of process nodes, the overall task is no longer marked by the completion of a large process node, but by the completion results of a small-grained single business within the service. Using the event dependency relationship between services as a whole can improve business response speed; by defining events to achieve automatic processing of business, it can also save manual operation steps and greatly reduce the labor cost of operation and maintenance.
[0079] The event-driven method provided in the embodiment of the present application defines each task node in the target system as an event, determines event responsibilities and constructs an event flow, and processes each task in the target system through an event-driven mechanism, so that the external control behavior of individual services can be unified, and business can be automatically triggered based on events. The service dependency relationship between events can be adjusted according to specific data processing requirements, and different business scenarios can be responded to more flexibly, thereby improving the task processing efficiency of the target system.
[0080] It should be noted that each implementation method of the present application can be freely combined, the order can be changed, or it can be executed separately, and does not need to rely on or depend on a fixed execution order.
[0081] In some embodiments, step 110 includes:
[0082] Divide the services under any node into sub-services;
[0083] Define the subscription events and output events corresponding to each sub-service to decouple services.
[0084] The sub-services include order data source collection service, factor data source collection service, data regularization service and calculation engine service; step 130 includes:
[0085] Send the real-time order message of the pending order to the target system, and generate the pending calculated events of the pending order based on the order data collected by the target system;
[0086] Process the order data to generate pending payment events for pending orders and factor calculation events on which the pending payment events depend;
[0087] When the factor calculation event is completed, the calculation event of the pending order corresponding to the pending payment event is triggered to perform calculation to execute various tasks.
[0088] Specifically, the event definition module is based on an event-driven communication method, so that services are no longer connected through a "request-response" application programming interface (Application Programming Interface, API), but through event data defined by event flow. The responsibility of producers in the target system is limited to producing a defined amount of data to their respective event streams. Consumers in the target system must be able to extract the data required by their business processes, and if there is no definition of "available data", consumers will not be able to consume.
[0089] In the target system, each service needs to define subscription events (events to be consumed) and output events (production events). The entire computing process of the business in the target system can be split into independent sub-services such as data source collection, factor data source collection, factor calculation, preprocessing, batch pricing, warehousing and bill push, etc., to decouple computing tasks. At the same time, different events are defined for different types of tasks, such as defining a factor data source collection completion event for factor data source collection tasks, and defining a factor calculation event and a factor calculation completion event for factor calculation. Different event modules can flexibly trigger the next event module, and the execution of each computing task is driven by events, realizing distributed streaming real-time computing capabilities and elastic and scalable computing capabilities.
[0090] Figure 4 The second flow chart of the event-driven method provided in the embodiment of the present application is as follows: Figure 4 As shown, the method includes:
[0091] Step 1: Data collection.
[0092] Data source collection can be divided into two parts: order data source collection and calculation factor data source collection. Order data sources are divided into real-time messages and order information tables according to different data source sources. Real-time message data is sent to the target system through the message middleware. The target system collects data sources, filters, and converts protocols through the event agent to generate events to be calculated; the table data of the order is collected regularly through the data extraction, transformation, and loading (ETL) tool, and the order data generation component generates the payment data. The event agent reads the payment order data and converts it into the payment events.
[0093] The factor data source collection is completed through the ETL tool, and the factor data source collection completion event is generated through collection monitoring. This event will be subscribed by the data regularization module to trigger the factor calculation.
[0094] Figure 5 A schematic diagram of the data collection process provided in the embodiment of the present application is as follows: Figure 5As shown, the original data is processed by the ETL tool to generate data to be paid and factor calculation data, and at the same time, events to be paid and factor calculation events are generated. When the factor calculation events that the events to be paid depend on are all completed, the corresponding calculation events will be triggered.
[0095] Step 2: Data regularization.
[0096] Figure 6 A schematic diagram of the data regularization process provided in the embodiment of the present application is as follows: Figure 6 As shown in the figure, a piece of data that the calculation event depends on is defined as a factor. Data regularization is responsible for the processing of factors. The factor calculation event generation component obtains the factor data source collection completion event and generates the factor calculation event according to the factor and data source mapping association rule. The data regularization module drives the processing of factors according to the factor calculation event and outputs the factor calculation completion event to drive the calculation of subsequent remuneration.
[0097] Step 3: Calculate the engine domain.
[0098] Figure 7 A schematic diagram of the process flow of real-time stream computing provided in the embodiment of the present application is shown in FIG. Figure 7 As shown in the figure, the preprocessing event generation component generates calculation preprocessing events based on factor calculation completion events and pending payment events, driving calculations in real time. The calculation engine splits the calculation process of a calculation preprocessing event into three independent sub-service events: preprocessing, batch pricing, and warehousing. The calculation is completed by subscribing to consumption preprocessing events, batch pricing events, and warehousing events, realizing real-time streaming calculations.
[0099] The event-driven method provided in the embodiment of the present application not only splits the original application into several services, but also separates data from services, thereby improving task processing efficiency.
[0100] In some embodiments, step 130 further includes:
[0101] Define the workflow for processing pending orders and monitor the task processing status at each processing stage in the workflow;
[0102] When a new pending order is received, a command event is sent to the subordinate microservice module of the new pending order based on the event flow, and the event processing result returned by the subordinate microservice module is received;
[0103] Among them, the command event is used to control the sub-service module of the lower-level microservice module to execute various tasks of the new pending orders.
[0104] Specifically, the workflow can be referred to as a workflow for short. The workflow describes the execution order and processing logic of tasks, and the event flow is responsible for actually triggering and transmitting the event information required for task execution.
[0105] After the workflow is defined, the event orchestration module controls the execution of the workflow by issuing command events to the lower-level microservices, instructing each subservice to perform tasks according to the order and logic defined by the workflow. At the same time, corresponding events will be generated after each step in the workflow is completed. These events will be passed to other microservices through the event stream, triggering subsequent operations or notifying other parts of the task that they have been completed, thereby promoting the execution of the entire workflow.
[0106] Figure 8 A flow chart of the event compilation provided in the embodiment of the present application, such as Figure 8 As shown in Figure 1, the event orchestration module can flexibly define workflows within a microservice. The orchestrator monitors in real time which processing stages in the workflow have been completed, which processing stages are being processed, and which processing stages have not yet started.
[0107] The composer of the workflow will issue command events to the subordinate microservices, and the subordinate microservices will perform the required tasks and return the results to the composer, usually through event streams to issue requests and responses. The composer does not tell the service how to handle the business, the composer only needs to know whether the service has been completely successful or completely failed. Then, the composer can proceed to the next step according to the logic of the workflow.
[0108] The event-driven method provided in the embodiment of the present application can process data streams in real time by flexibly defining workflows within a microservice, thereby significantly reducing data processing time and improving business processing efficiency.
[0109] In some embodiments, the event-driven method provided by the embodiments of the present application further includes:
[0110] Determine the data access frequency of the calculation data corresponding to the first data table based on the number of accesses to the second data table during two accesses to the first data table in the cache layer of the target system; the first data table is a data table corresponding to any calculation data in the task execution process, and the second data table is a data table corresponding to the calculation data other than any calculation data;
[0111] Divide the computational data of the cache layer into cold data and hot data based on data access frequency;
[0112] When the state of the cache layer meets the preset elimination state, the cold data is cleared, and based on the state of the cache layer and the data access frequency of each calculated data, the new hot data is sent to the cache layer.
[0113] When the cache layer status meets the preset elimination status, clear the cold data, including:
[0114] Set the preset elimination status based on the billing period of each task, the change of the current calendar month, the current cache layer memory capacity and / or the data hit situation of the cache layer;
[0115] When the state of the cache layer meets the preset elimination state, the data to be eliminated is determined based on the memory size of the cold data, the number of calculation dependency factors and / or the business type;
[0116] Clear the data to be eliminated in the cache layer.
[0117] Specifically, the computational data refers to the data required and generated during the execution of the task.
[0118] Figure 3 The hot and cold data separation module in the target system calculates the business solution configuration data and extracts the calculation dependent data. The data is split vertically, and part of the calculation data is marked as hot data through a customized hot and cold data separation strategy, and the hot data is sent to the calculation cache layer. During the calculation process, the calculation factor weight is adjusted in real time to improve the cache hit rate. Data calculation mainly relies on the cache layer and no longer directly accesses the database, dispersing the database pressure, thereby realizing the hot and cold separation of calculation data.
[0119] Fig. 9 A schematic diagram of the process of eliminating data provided in the embodiment of the present application, such as Fig. 9 As shown, the process of eliminating data includes:
[0120] Get the billing period of the computing task, the current natural month, and the current cache layer memory capacity to determine whether to batch eliminate the data that is about to become "cold".
[0121] For example, when the cache layer memory usage exceeds the configured threshold, the data elimination strategy is triggered. When the natural month changes, the weight of the data in the previous month table decreases significantly, triggering the data elimination strategy.
[0122] The cache data weight can be defined based on the remaining number of times the cache data (i.e., the computing data in the cache layer) can be used for computing events, the memory size occupied, the computing event computing cycle, and other dimensions. When the memory usage of the entire cache layer exceeds the configured threshold, cache data with a smaller weight is selected as the data list that can be eliminated in the cache layer.
[0123] Every time the cache misses, a small number of cache layers are randomly eliminated from the list of eliminable data to release cache space in real time, and then a miss event is triggered to calculate the data and send a signal.
[0124] If the cache layer node memory still exceeds the configured threshold after some data is eliminated, the data that can be eliminated will continue to be eliminated.
[0125] When the memory of the cache layer node is lower than the threshold, the hot data is directly triggered to be sent to the cache layer. After the sending is completed, the list of data that can be eliminated is updated.
[0126] LIRS (Low Inter-reference Recency Set) is a cache elimination algorithm. The LIRS algorithm in this application determines the data access frequency of the calculated data by the number of times other data tables are accessed between two accesses to the same data table.
[0127] In the LIRS algorithm, two variables are maintained for different cache data to measure the data access frequency of the data table.
[0128] The inter-reference recency (IRR) is used to record how many different tables have been accessed between two accesses to the same data table. When accessing the data table for the first time, the initial value of IRR is recorded as no maximum (max).
[0129] Recency (R) is used to record how many different tables are accessed from the last access to the first data table to the current access to the first data table.
[0130] Fig.10 The schematic diagram of the LIRS algorithm provided in the embodiment of the present application is as follows: Fig.10 As shown, for data table A, before the second access to table A, tables B, C and D have been queried, so the IRR of table A = 3; at the current time, tables E and F have been accessed, so the R of table A = 2.
[0131] Using the LIRS algorithm, the table area is divided into low IRR (Low IRR, LIR) and high IRR (High IRR, HIR), and data is eliminated by comparing the IRR and R value of each table.
[0132] Among them, IRR is the hot table data area, that is, the hot data area. The smaller the IRR value is, the higher the access frequency of this table is; HIR is the cold table data area, that is, the cold data area. The larger the IRR value is, the lower the access frequency of this table is.
[0133] LIR blocks are usually in the cache layer and no data elimination is performed. When the cache layer host memory is insufficient, the calculated data in the table is eliminated in the HIR area.
[0134] Only part of the calculated data in HIR is sent to the cache layer, so the HIR table data blocks are also divided into resident-HIR and nonresident-HIR:
[0135] Resident-HIR is a collection of cold data sent to the memory database (MDB);
[0136] Nonresident - HIR is a collection of cold data that has not been sent up to the MDB.
[0137] So far, the total amount of table data stored in the cache layer is the number of calculated data in LIR plus the number of calculated data in resident - HIR. When the MDB memory resources are insufficient, the calculated data in resident - HIR will be preferentially eliminated.
[0138] After a new table is sent up, the IRR value in the table data block needs to be updated again, and LIR is replaced according to the situation. Table 1 records the access situations of the table data blocks of each data table.
[0139] Table 1 Access Situations of Table Data Blocks of Each Data Table
[0140] time 1 2 3 4 5 6 7 8 9 10 R IRR A O O O 1 1 B O O 3 1 C O 4 Max D O O 2 3 E O 0 Max
[0141] In Table 1, different letters represent different cache data, and O represents being accessed.
[0142] At time point 10, the R values and IRR values of the table data blocks {A, B, C, D, E} are: R({A, B, C, D, E}) = {1, 3, 4, 2, 0}; IRR({A, B, C, D, E}) = {1, 1, max, 3, max}.
[0143] Assume that the size of the LIR set lirs = 2 and the size of the HIR set lhirs = 1. In the current time block 10, the data of the two sets are: LIR = {A, B}; HIR = {C, D, E}.
[0144] The last accessed table data block is table E: resident - HIR = {E}; nonresident - HIR = {C, D}.
[0145] If table E is accessed again in the next time block, then the R values and IRR values of the current table data blocks {A, B, C, D, E} are: R({A, B, C, D, E}) = {1, 3, 4, 2, 0}; IRR({A, B, C, D, E}) = {1, 1, max, 3, 0}.
[0146] Because IRR(E) < R(B), the tables in LIR and HIR need to be replaced. After replacement, the latest state is: LIR = {A, E}; HIR = {B, C, D}.
[0147] Because table D is the most recently accessed table in the HIR set, so resident - HIR = {D}; nonresident - HIR = {B, C}. Thus, the cold - hot zone replacement operation is completed.
[0148] The LIRS algorithm solves the problem of hot and cold data partitions, but the hit rate is still low in specific business operations. The embodiment of the present application has carried out business-oriented transformation of the elimination algorithm according to specific business logic in the operator field.
[0149] Set the data to never be eliminated. Fig.11 A schematic diagram of the structure of the never-eliminated data list provided in the embodiment of the present application, such as Fig.11 As shown in the figure, in the calculation process, in order to cope with business scenarios such as urgent calculation tasks, a non-elimination table configuration interface is provided, and data that will never be eliminated can be selected according to business needs.
[0150] Set up a running non-elimination list. Fig.12 A schematic diagram of the structure of the running non-elimination list provided in the embodiment of the present application, such as Fig.12 As shown, in order to prevent the data table that the task being calculated depends on from being eliminated during the calculation process, resulting in calculation failure, the calculation data that the task being calculated depends on is screened out during the elimination period, and the data tables of these calculation data are not eliminated.
[0151] Eliminate according to the bill period. Fig.13 One of the structural diagrams of the list of data that can be eliminated provided in the embodiment of the present application is as follows: Fig.13 As shown in the figure, by obtaining the billing period of the computing task, the current natural month and / or the current cache layer memory capacity, it is determined whether to batch eliminate the data that is about to become "cold". The label table in the figure is the data table.
[0152] Eliminate based on the size of the data table, that is, eliminate based on the memory size of the calculated data. Fig.14 The second structural diagram of the list of data that can be eliminated provided in the embodiment of the present application is as follows: Fig.14 As shown, among the cold zone data that can be eliminated, they are sorted from small to large according to the memory size, and the computing data with smaller memory usage is selected for elimination first.
[0153] Eliminate based on the number of uncalculated dependency factors. Fig.15 The third structural diagram of the list of data that can be eliminated provided in the embodiment of the present application is as follows: Fig.15 As shown, according to the business logic, the total number of dependencies calculated for each cached data is calculated, and the elimination weights are set in order from small to large to determine the data to be eliminated.
[0154] Eliminate based on business type. Fig.16 The fourth structural diagram of the list of data that can be eliminated provided in the embodiment of the present application is as follows: Fig.16 As shown, according to the different billing calculation times for different businesses, the business weights at different times are set, and then the business weights for the day are calculated. Fig.17The fifth structural diagram of the list of data that can be eliminated provided in the embodiment of the present application is as follows: Fig.17 As shown, the outgoing weight of each cached data is recorded and sorted from small to large to determine the data to be eliminated.
[0155] Fig.18 The sixth structural diagram of the list of data that can be eliminated provided in the embodiment of the present application is as follows: Fig.18 As shown, the cache data can also be finally sorted according to the judgment criteria such as the outgoing weight, the remaining business volume and the table memory to determine the elimination order. When the memory is insufficient, this is used as the elimination order.
[0156] also, Figure 3 The event-driven monitoring module in the event gateway monitors the status of all events in real time and outputs the task topology map. It can sense the completion status and unfinished status of the events that the current node depends on from any node, as well as the list of untriggered node tasks that the subsequent node depends on. This helps operation and maintenance personnel better control the computing progress of the entire system.
[0157] The event-driven method provided in the embodiment of the present application separates hot and cold data in the overall computing data, and puts the hot data in the hot zone into the cache layer. Through the strategy of separating hot and cold data, the database pressure is reduced and the overall load capacity of the system is improved; by implementing multi-layer strategies according to multi-layer key system business indicators, such as account outgoing weight, remaining business volume, and table memory, a core data elimination strategy is finally formed, the cache data is finally sorted, and the elimination order is determined. In a limited storage medium, unnecessary data storage is reduced, the storage cost of the enterprise is reduced, and greater computing power and carrying capacity are achieved, while also saving a lot of system costs and improving the cache hit rate.
[0158] The event-driven device provided in the embodiment of the present application is described below. The event-driven device described below and the event-driven method described above can be referenced to each other.
[0159] Fig.19 The second structural diagram of the event-driven device provided in the embodiment of the present application is as follows: Fig.19 As shown, the device includes a definition module 1910 , a construction module 1920 and a driving module 1930 .
[0160] The definition module is used to define each task node in the target system as each event and determine the event responsibility of each event;
[0161] The construction module is used to build event streams based on the event responsibilities of each event and set the service dependencies of events in the event stream;
[0162] The driver module is used to perform various tasks based on service dependencies and event-driven mechanisms.
[0163] Specifically, according to an embodiment of the present application, any multiple modules among the definition module, the construction module and the driving module can be combined into one module for implementation, or any one of the modules can be split into multiple modules.
[0164] Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module.
[0165] According to the embodiments of the present application, at least one of the definition module, the building module and the driving module can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware, or in an appropriate combination of any of them.
[0166] Alternatively, at least one of the definition module, the construction module and the driving module may be at least partially implemented as a computer program module, and when the computer program module is executed, the corresponding function may be performed.
[0167] The event-driven device provided in the embodiment of the present application defines each task node in the target system as an event, determines event responsibilities and constructs an event flow, and processes each task in the target system through an event-driven mechanism, so that the external control behavior of individual services can be unified, and business can be automatically triggered based on events. The service dependency relationship between events can be adjusted according to specific data processing requirements, and different business scenarios can be responded to more flexibly, thereby improving the task processing efficiency of the target system.
[0168] In some embodiments, the definition module is specifically used to:
[0169] Divide the services under any node into sub-services;
[0170] Define the subscription events and output events corresponding to each sub-service to decouple services.
[0171] In some embodiments, the sub-services include order data source collection service, factor data source collection service, data regularization service and calculation engine service; the driving module is specifically used for:
[0172] Send the real-time order message of the pending order to the target system, and generate the pending calculated events of the pending order based on the order data collected by the target system;
[0173] Process the order data to generate pending payment events for pending orders and factor calculation events on which the pending payment events depend;
[0174] When the factor calculation event is completed, the calculation event of the pending order corresponding to the pending payment event is triggered to perform calculation to execute various tasks.
[0175] In some embodiments, the driving module is further specifically configured to:
[0176] Define the workflow for processing pending orders and monitor the task processing status at each processing stage in the workflow;
[0177] When a new pending order is received, a command event is sent to the subordinate microservice module of the new pending order based on the event flow, and the event processing result returned by the subordinate microservice module is received;
[0178] Among them, the command event is used to control the sub-service module of the lower-level microservice module to execute various tasks of the new pending orders.
[0179] In some embodiments, the event-driven device further includes a determination module, and the determination module is specifically used to:
[0180] Determine the data access frequency of the calculation data corresponding to the first data table based on the number of accesses to the second data table during two accesses to the first data table in the cache layer of the target system; the first data table is a data table corresponding to any calculation data in the task execution process, and the second data table is a data table corresponding to the calculation data other than any calculation data;
[0181] Divide the computational data of the cache layer into cold data and hot data based on data access frequency;
[0182] When the state of the cache layer meets the preset elimination state, the cold data is cleared, and based on the state of the cache layer and the data access frequency of each calculated data, the new hot data is sent to the cache layer.
[0183] In some embodiments, the determination module includes an elimination submodule, and the elimination submodule is specifically used to:
[0184] Set the preset elimination status based on the billing period of each task, the change of the current calendar month, the current cache layer memory capacity and / or the data hit situation of the cache layer;
[0185] When the state of the cache layer meets the preset elimination state, the data to be eliminated is determined based on the memory size of the cold data, the number of calculation dependency factors and / or the business type;
[0186] Clear the data to be eliminated in the cache layer.
[0187] It should be noted here that the event-driven device provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned event-driven method embodiment, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.
[0188] Fig. 20 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Fig. 20 As shown, the electronic device may include: a processor (processor) 2010, a communication interface (Communication Interface) 2020, a memory (memory) 2030 and a communication bus 2040, wherein the processor 2010, the communication interface 2020, and the memory 2030 communicate with each other through the communication bus 2040. The processor 2010 may call a computer program in the memory 2030 to execute the above method, for example, including:
[0189] Define each task node in the target system as each event and determine the event responsibility of each event;
[0190] Build event streams based on the event responsibilities of each event, and set service dependencies for events in the event streams;
[0191] Execute individual tasks based on service dependencies and event-driven mechanisms.
[0192] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software function modules and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0193] On the other hand, an embodiment of the present application also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the methods provided in the above embodiments.
[0194] On the other hand, an embodiment of the present application further provides a processor-readable storage medium, which stores a computer program, and the computer program is used to enable the processor to execute the methods provided in the above embodiments.
[0195] The processor-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD)), etc.
[0196] The device embodiments described above are merely illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, i.e., they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0197] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0198] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An event-driven approach, It is characterized in that include: Define each task node in the target system as each event and determine the event responsibility of each event; Construct an event flow based on the event responsibilities of each event, and set service dependencies of events in the event flow; Each task is executed based on the service dependency and event-driven mechanism.
2. The event-driven method according to claim 1, It is characterized in that The task nodes in the target system are defined as events, including: Divide the services under any node into sub-services; Define the subscription events and output events corresponding to each sub-service to decouple services.
3. The event-driven method according to claim 2, It is characterized in that The sub-services include order data source collection service, factor data source collection service, data regularization service and calculation engine service; the execution of each task based on the service dependency and event-driven mechanism includes: Sending a real-time order message of the pending order to the target system, and generating a to-be-calculated event of the pending order based on the order data collected by the target system; Processing the order data to generate a to-be-paid event for the to-be-processed order and a factor calculation event on which the to-be-paid event depends; When the factor calculation event is completed, the calculation event of the pending order corresponding to the pending payment event is triggered to perform calculation to execute various tasks.
4. The event-driven method according to claim 3, It is characterized in that The performing of each task based on the service dependency and event-driven mechanism also includes: Defining a workflow for processing the pending orders and monitoring the task processing status of each processing stage in the workflow; When a new pending order is received, a command event is sent to a subordinate microservice module of the new pending order based on the event flow, and an event processing result returned by the subordinate microservice module is received; The command event is used to control the sub-service module of the lower-level microservice module to execute various tasks of the new order to be processed.
5. The event-driven method according to claim 1, It is characterized in that The method further comprises: Determine the data access frequency of the calculation data corresponding to the first data table based on the number of accesses to the second data table during two accesses to the first data table in the cache layer of the target system; the first data table is a data table corresponding to any calculation data in the task execution process, and the second data table is a data table corresponding to the calculation data other than the any calculation data; Dividing the computing data of the cache layer into cold data and hot data based on the data access frequency; When the state of the cache layer meets the preset elimination state, the cold data is cleared, and based on the state of the cache layer and the data access frequency of each calculated data, new hot data is sent to the cache layer.
6. The event-driven method according to claim 5, It is characterized in that When the state of the cache layer meets the preset elimination state, clearing the cold data includes: The preset elimination state is set based on the account period of each task, the change of the current natural month, the current cache layer memory capacity and / or the data hit situation of the cache layer; When the state of the cache layer meets the preset elimination state, the data to be eliminated is determined based on the memory size of the cold data, the number of calculation dependency factors and / or the business type; The to-be-eliminated data is cleared in the cache layer.
7. An event-driven device, It is characterized in that include: The definition module is used to define each task node in the target system as each event and determine the event responsibility of each event; A construction module, used to construct an event flow based on the event responsibilities of each event, and set service dependencies of events in the event flow; The driver module is used to execute various tasks based on the service dependency and event-driven mechanism.
8. An electronic device comprising a memory and a processor, It is characterized in that A computer program is stored in the memory, and the processor is configured to execute the event-driven method according to any one of claims 1 to 6 through the computer program.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the event-driven method according to any one of claims 1 to 6 is implemented.
10. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the event-driven method according to any one of claims 1 to 6 is implemented.
