Anti-backlog processing method, system and device for market information

By establishing a unified market data gateway and optimizing the message structure, combined with the TCP reconnection mechanism, the problem of long data transmission and backlog in the market data push system is solved, and efficient market data transmission and processing are achieved.

CN118540185APending Publication Date: 2024-08-23民生证券股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410622786.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-20
Publication Date
2024-08-23

Smart Images

  • Figure CN118540185A
    Figure CN118540185A
Patent Text Reader

Abstract

The invention belongs to the technical field of data processing, and particularly discloses a market information anti-backlog processing method, system and device, and the method comprises the following steps: 1) building a market information data gateway which is used for carrying out the unified receiving and pushing processing of market information data, so as to reduce the transmission time consumption of a conventional data transmission link; 2) establishing long connection, optimizing front and rear end interface definitions, adding a colomn address array in an interface, and realizing rapid data positioning in a subsequent transmission process by utilizing address mapping; data compression and transmission are realized by utilizing dataList, and a front end realizes rapid data analysis and display according to column address mapping information; and (3) establishing a disconnection and reconnection mechanism, acquiring the market information queue length in real time by utilizing a java reflection mechanism, setting a threshold value, and after the message queue length exceeds the threshold value, ensuring that the front end can still complete real-time acquisition, analysis and display of the latest market information data in a massive market information data scene by introducing a TCP reconnection mechanism at the front end and the rear end, so that the problem of message backlog is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a method, system and device for preventing market information from backlog. Background Art

[0002] In financial transactions, the real-time and accuracy of market data are crucial for traders. Real-time and accurate data can help traders capture market dynamics, quickly assess market changes, and make market forecasts, so as to adjust trading strategies in a timely manner and reduce potential risks, thereby gaining a competitive advantage in the fiercely competitive financial market.

[0003] At present, most of the market data push systems used by traders first receive market source data through the front-end, then send messages to message queues (such as kafka, etc.) for asynchronous consumption, and then push them to high-speed caches (such as redis, etc.) to achieve active notification and fast query. In this type of push system, market data needs to pass through many link nodes before finally reaching the front end for parsing and display, and when there is a massive amount of market data, it is easy to cause message backlogs, resulting in stagnation of front-end market parsing and display. In short, this type of market data push system has the following shortcomings: 1. The data transmission link is long and the data transmission time is high; 2. The data structure design in the message body is not perfect, and the transmission of the corresponding market data volume requires a large network overhead; 3. In the extreme case of massive market data, the front-end processing capacity is insufficient and it is difficult to keep up with the speed of data influx, resulting in message backlogs and affecting trading decisions. Summary of the invention

[0004] The purpose of the present invention is to overcome the above-mentioned deficiencies in the prior art and to provide a method, system and device for preventing backlog of market information, which can effectively shorten the data transmission time, reduce network overhead and adapt to massive data.

[0005] The technical solution adopted by the present invention to solve the technical problem is: A first aspect of the present invention provides a method for preventing market information from being overstocked, the method comprising the following steps: S1. Establish a unified market data gateway Establish a market data gateway to uniformly receive and push market data. Define different topics in the market data gateway, use topics to classify market data, and realize the reception and push of market data of different categories. S2. Establish full-duplex long-distance communication connection The front-end establishes full-duplex long connection communication with the back-end service through the WebSocket protocol to ensure real-time two-way transmission of data; S2-1. Optimize the front-end and back-end message structures Introduce column address array and datalist (datalist is a commonly used data link structure) in the front-end and back-end interfaces to complete data request and transmission; S2-2. First market data return The backend service adds a column array to the first message returned to the frontend, which stores all the market data headers returned this time, and transmits the corresponding market data values ​​in the datalist. The data value position in the datalist corresponds one-to-one to the market data header index in the column array. S2-3. Subsequent market data return When the subsequent market data is returned, the index of the column array is used as the address mapping for market data transmission and front-end parsing. The back-end service only transmits the datalist, and the column address array is empty. The front-end uses the first recorded column array index as the address mapping, parses the market data value in the datalist to the corresponding market data header, and then displays it on the front-end. S3. Establish a disconnection and reconnection mechanism When the length of the market data queue exceeds the threshold, TCP reconnection is performed to ensure that the front end obtains the latest market data in real time and parses and displays it.

[0006] Furthermore, in step S1, the market data gateway, as an independent module, directly connects to the backend service, that is, the market data gateway uses a single-node device instead of the traditional multi-node device of market source-kafka-redis-backend service to shorten the market data transmission link and reduce the data transmission time.

[0007] Furthermore, in step S1, topic can be a self-defined numeric code or a string with semantic information; it can be used to classify and identify market data, realize the push of receiving market data of different categories, and decouple the market data classification processing logic from the backend service, reducing the program complexity of the backend service. In the same system instance, topic is unique.

[0008] Furthermore, in step S3, the reflection mechanism of Java is used to obtain the length of the market message queue in real time, and to monitor in real time whether the queue length exceeds a threshold.

[0009] Furthermore, in step S3, step S2 is executed again when reconnecting to clear the backlog data and restore the normal data flow, thereby avoiding message backlog and stagnation of front-end market display.

[0010] The second aspect of the present invention provides a market information backlog prevention processing system, which is used to implement the above method, and includes: Market data gateway module, used for unified reception and push of market data; The long connection communication module is used to establish a TCP long connection between the front-end and the back-end to achieve real-time transmission of market data; The queue length monitoring module is used to obtain the queue length of market information in real time and determine whether the queue length exceeds the threshold; The disconnection and reconnection module is used to disconnect the current connection and reconnect when the length of the market message queue exceeds the threshold.

[0011] Furthermore, the market data gateway module is used to define different topics to classify (mark) market data, so as to facilitate the separate reception and push of market data of different categories; Furthermore, the queue length monitoring module uses the reflection mechanism of Java to obtain the queue length of the market information in real time, and monitors in real time whether the queue length exceeds a threshold.

[0012] A third aspect of the present invention provides a market information backlog prevention processing device, comprising a market data gateway, a processor, a memory, and a program stored in the memory for implementing the above method.

[0013] Compared with the prior art, the present invention has the following beneficial effects: 1. The present invention shortens the transmission path of market data messages, and replaces the traditional long link transmission of market source-kafka-redis-backend service through the market data gateway. Financial market data is only processed uniformly through the market data gateway, and there is no intervention of other middleware (such as kafka redis, etc.). Financial market data can be directly pushed to the backend service from the data source through the market data gateway; shortens the transmission time. Through experiments and tests, it is found that the transmission time can be shortened from 70ms to about 10ms; 2. The present invention optimizes the front-end and back-end message structures. By introducing the column address array and datalist data structure, data compression transmission can be achieved. Compared with the traditional<key, value> The data transmission in this form saves about 50% of network overhead and memory usage. 3. The present invention introduces a TCP reconnection mechanism. By introducing the TCP reconnection mechanism, if the backlog length of the market data queue exceeds a preset threshold, the TCP connection can be automatically disconnected and an attempt can be made to reconnect. After reconnection, the process of sending the column address array and returning the data is repeated; thereby clearing the backlog of data and restoring the normal data flow to avoid message backlogs and stagnation of front-end market display, effectively reducing the probability of the backlog of front-end market data. According to test results, the probability of the backlog problem tends to 0. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 It is a schematic diagram of the overall idea of ​​the system of the present invention; Figure 2 It is a specific schematic diagram of the process of the present invention; Figure 3 It is a schematic diagram of the connection relationship of the device of the present invention; Figure 4 It is a comparative schematic diagram of the front-end and back-end interfaces before and after optimization in the present invention; DETAILED DESCRIPTION

[0015] The present invention will be further described in detail below in conjunction with specific embodiments and application scenarios. Methods or functional components not specifically described in the embodiments are all prior art. Example

[0016] like Figure 1-4 As shown, the market information backlog prevention processing method of the present invention specifically includes the following steps: Step 1: Build an independent market data gateway to uniformly receive and push market data from different sources. Different topics can be defined in the market data gateway to process different types of market data. A topic can be a custom numeric code or a string with semantic information to ensure the uniqueness of the topic. Step 2: The market data gateway directly connects to the backend service and pushes the market data of different topics to the backend service for subsequent processing; Step 3: The front-end establishes a TCP persistent connection with the back-end service through the WebSocket protocol for real-time transmission of market data. After the persistent connection is established, the front-end sends a request message to the back-end service based on the market data field that the user has subscribed to. The back-end service prepares the market data that meets the requirements based on the market data field in the request message; Step 4: When the backend service returns market data to the frontend for the first time, the column address array and datalist market data are transmitted in the interface message; the column array contains all the market data header information transmitted this time, and the datalist contains the specific market data value, where the data value in the datalist corresponds to the market data header position in the column array one by one; Step 5: When the subsequent market data is returned, the column array index is used as the address mapping for market data transmission and front-end parsing. The back-end service only transmits the datalist, and the column address array is empty.

[0017] Step 6: Use the Java reflection mechanism to obtain the length of the market quotation message queue in real time. At the same time, set a threshold and monitor in real time whether the length of the message queue exceeds the preset threshold. If it does not exceed the threshold, the front end continues to receive market quotation data and parses and displays the market quotation data according to the column address mapping information. If it exceeds the threshold, introduce the front-end and back-end TCP reconnection mechanism. After TCP reconnection, the message transmission between the front end and the back end repeats the above steps 3-5.

[0018] As Figure 3 shown, in steps 1-2, the market quotation data gateway, as an important component of this invention, from the market quotation source to the back-end service, the transmission of market quotation data only passes through this one link node of the market quotation data gateway, thus greatly reducing the transmission link of market quotation data and effectively reducing the transmission time consumption.

[0019] As Figure 4 shown, in steps 4-5, define the front-end and back-end messages. According to the comparison before and after optimizing the interface definition, it can be known that in the traditional front-end and back-end message transmission, the <key, value> form is directly used in the message body for transmission. The key part is used to transmit the data header, and the value part is used to transmit the data value. As a result, every time market quotation data is transmitted, a large amount of data header information is included in the message body. In the scenario of transmitting a large amount of market quotation data, it greatly increases the network overhead and memory occupancy, making the transmission and processing efficiency of market quotation data relatively low. While this invention adopts the optimized message definition. When the market quotation data is transmitted for the first time, the data header is stored in the column array, and the market quotation data value is stored in the datalist, where the position of the data value in the datalist corresponds one by one to the market quotation data header index in the column array.

[0020] Exemplarily: Assume that the name of the market quotation data bond is "24 Guokai 03", the bond code is "240203.IB", and the term is "4.8Y". Then the traditional message format transmission form: {"bondName":"24 Guokai 03", "code":"240203.IB", "term":"4.80Y"}; There are two transmission forms of the optimized message format of this invention.

[0021] When the market quotation data is returned for the first time, the message transmission form is: {"data": {"240203.IB": ["24 Guokai 03","240203.IB","4.80Y"]}, "columns":["bondName","code","term"]}; The transmission form of subsequent new market quotation data is: {"data": {"240203.IB": ["24 Guokai 03", "240203.IB", "4.80Y"]}, "columns": []}。

[0022] It can be inferred from this that during the process of transmitting a large amount of data, in addition to the data header information being included in the message body when the first market data is returned in the present invention, only the market data value is transmitted during subsequent message transmissions, and there is no need to transmit the data header information. The front end only needs to parse and display the new market data according to the column address mapping information, which greatly reduces the network overhead and memory occupancy of message transmission and effectively improves the processing efficiency of market data.

[0023] To implement the above method, a corresponding market message anti-backlog processing system is established. The system includes: a market data gateway module for defining different topics to classify market data and uniformly receiving and pushing market data; a long connection communication module for establishing a TCP long connection between the front end and the back end to achieve real-time transmission of market data; a queue length monitoring module for using the reflection mechanism of Java to obtain the length of the market message queue in real time and monitoring in real time whether the queue length exceeds the threshold; a disconnection and reconnection module for disconnecting the current connection and reconnecting when the length of the market message queue exceeds the threshold.

[0024] The above are only some embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have combinations and variations of the foregoing various technical features. Without departing from the spirit and scope of the present invention, improvements, variations, equivalent replacements made by those skilled in the art, or the application of the structure or method of the present invention to other fields to achieve the same effect all fall within the protection scope of the present invention.

Claims

1. A method for preventing backlog of market information, characterized in that: The following steps are involved: S1. Establish a unified market data gateway The market data gateway receives and pushes the market data in a unified manner. Different topics are defined in the market data gateway, and market data is classified by topic to realize the reception and push of market data of different categories. S2. Establish full-duplex long-distance communication connection The front-end establishes full-duplex long connection communication with the back-end service through the WebSocket protocol to ensure real-time two-way transmission of data; S2-1. Optimize the front-end and back-end message structures Introduce column address array and datalist in the front-end and back-end interfaces to complete data request and transmission; S2-2. First market data return The backend service adds a column array to the first message returned to the frontend, which stores all the market data headers returned this time, and transmits the corresponding market data values ​​in the datalist. The data value position in the datalist corresponds one-to-one to the market data header index in the column array. S2-3. Subsequent market data return When the subsequent market data is returned, the index of the column array is used as the address mapping for market data transmission and front-end parsing. The back-end service only transmits the datalist, and the column address array is empty. The front end uses the first recorded column array index as the address mapping to parse the market data value in the datalist to the corresponding data header, and then displays it on the front end; S3. Establish a disconnection and reconnection mechanism When the length of the market data queue exceeds the threshold, TCP reconnection is performed to ensure that the front end obtains the latest market data in real time and parses and displays it.

2. The method for preventing market information from backlog according to claim 1, characterized in that: In step S1, the market data gateway, as an independent module, directly connects to the backend service, that is, the market data gateway uses a single node device instead of the traditional multi-node device of market source-kafka-redis-backend service to shorten the market data transmission link and reduce the data transmission time.

3. The method for preventing market information from backlog according to claim 1, characterized in that: In step S1, the topic is a self-defined numeric code or a character string with semantic information. In the same system instance, the topic is unique.

4. The method for preventing market information from backlog according to claim 1, characterized in that: In step S3, the reflection mechanism of Java is used to obtain the length of the market message queue in real time, and to monitor in real time whether the queue length exceeds the threshold.

5. The method for preventing market information from backlog according to claim 1, characterized in that: In step S3, step S2 is executed again when reconnecting to clear the backlog data and restore the normal data flow to avoid message backlog and stagnation of front-end market display.

6. A market information backlog prevention processing system, used to implement the method according to any one of claims 1 to 5, characterized in that: include: Market data gateway module, used for unified reception and push of market data; The long connection communication module is used to establish a TCP long connection between the front-end and the back-end to achieve real-time transmission of market data; The queue length monitoring module is used to obtain the queue length of market information in real time and determine whether the queue length exceeds the threshold; The disconnection and reconnection module is used to disconnect the current connection and reconnect when the length of the market message queue exceeds the threshold.

7. The market information backlog prevention processing system according to claim 6 is characterized by: The market data gateway module is used to define different topics to classify market data, so as to realize the separate reception and push of market data of different categories.

8. The market information backlog prevention processing system according to claim 6 is characterized by: The queue length monitoring module uses the reflection mechanism of Java to obtain the queue length of the market message in real time, and monitors in real time whether the queue length exceeds a threshold.

9. A device for preventing backlog of market information, characterized in that: It comprises a market data gateway, a processor, a memory and a program stored in the memory for implementing the method according to any one of claims 1 to 5.