Network data processing method and device, computer device and storage medium

By establishing a network connection with the client through the main event thread and handling data storage and business logic through the sub-event threads, the performance issues of Go's native network model under high load are resolved, and efficient data processing is achieved.

CN114691331BActive Publication Date: 2026-02-17SHENZHEN KINGDEE MIDDLEWARE
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210321935.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-30
Publication Date
2026-02-17
Estimated Expiration
2042-03-30

AI Technical Summary

Technical Problem

When faced with massive connections and high-frequency requests in a caching system, the number of goroutines in Go's native network model increases linearly, leading to high system resource consumption, performance degradation, and increased data processing latency.

Method used

The main event thread establishes a network connection with the client, and the network data is stored in the cache. The child event thread reads the data and generates a data processing request. The execution engine performs business processing and sends the results back to the client, thus avoiding the need to establish a corresponding coroutine for each network connection.

Benefits of technology

It reduces coroutine scheduling overhead, improves system performance and data processing efficiency, and reduces data processing latency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691331B_ABST
    Figure CN114691331B_ABST
Patent Text Reader

Abstract

The application relates to a network data processing method and device, computer equipment, a storage medium and a computer program product. The method comprises the following steps: a main event thread is used to establish a network connection with a client; if network data sent through the network connection is received, the network data is stored in a cache area; a sub-event thread is used to read the network data from the cache area, and a data processing request is generated according to the network data; a business processing result is obtained by executing an engine to process the data processing request, and the processing result is fed back to the client through the sub-event thread. The method can reduce the delay of data processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a network data processing method, apparatus, computer equipment, storage medium, and computer program product. Background Technology

[0002] With the development of computer technology, network communication technology has been widely applied. Through network communication technology, servers and clients establish network connections and communicate via these connections. In traditional technologies, for the native network model based on the Go language, the server creates a goroutine for each network connection to receive network data and perform business processing. However, when facing application scenarios with massive connections and high-frequency requests in caching systems, the native network model based on Go language requires establishing a large number of network connections, resulting in a linear increase in the number of goroutines. Switching between a large number of goroutines generates enormous scheduling pressure, consumes a large amount of system resources, and consequently leads to a decline in system performance and significant latency in data processing. Summary of the Invention

[0003] Therefore, it is necessary to provide a network data processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can reduce latency in response to the above-mentioned technical problems.

[0004] Firstly, this application provides a network data processing method. The method includes:

[0005] Establish a network connection with the client through the main event thread;

[0006] If network data is received via the network connection, the network data is stored in the buffer.

[0007] The network data is read from the cache through a sub-event thread, and a data processing request is generated based on the network data;

[0008] The execution engine performs business processing on the data processing request, and the processing result obtained from the business processing is fed back to the client through the sub-event thread.

[0009] Secondly, this application also provides a network data processing apparatus. The apparatus includes:

[0010] Establish a module for creating a network connection with the client via the main event thread;

[0011] The storage module, upon receiving network data sent through the network connection, is used to store the network data in a cache area;

[0012] The generation module is used to read the network data from the cache through a sub-event thread and generate a data processing request based on the network data;

[0013] The feedback module is used to perform business processing on the data processing request through the execution engine and to feed back the processing results to the client.

[0014] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0015] Establish a network connection with the client through the main event thread;

[0016] If network data is received via the network connection, the network data is stored in the buffer.

[0017] The network data is read from the cache through a sub-event thread, and a data processing request is generated based on the network data;

[0018] The execution engine performs business processing on the data processing request, and the processing result obtained from the business processing is fed back to the client through the sub-event thread.

[0019] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0020] Establish a network connection with the client through the main event thread;

[0021] If network data is received via the network connection, the network data is stored in the buffer.

[0022] The network data is read from the cache through a sub-event thread, and a data processing request is generated based on the network data;

[0023] The execution engine performs business processing on the data processing request, and the processing result obtained from the business processing is fed back to the client through the sub-event thread.

[0024] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0025] Establish a network connection with the client through the main event thread;

[0026] If network data is received via the network connection, the network data is stored in the buffer.

[0027] The network data is read from the cache through a sub-event thread, and a data processing request is generated based on the network data;

[0028] The execution engine performs business processing on the data processing request, and the processing result obtained from the business processing is fed back to the client through the sub-event thread.

[0029] The aforementioned network data processing methods, apparatus, computer equipment, storage media, and computer program products establish network connections with clients through a main event thread. This main event thread is only responsible for establishing the network connection and not for data read / write operations performed through the network connection. This maximizes the reuse of the main event thread, allowing it to establish network connections with as many clients as possible. After the network connection is established, if network data is received via the network connection, it is stored in a buffer. Sub-event threads read the network data from the buffer, generate data processing requests based on the network data, and the execution engine performs business processing on the data processing requests, then feeds the processing results back to the client. Therefore, processing network data sent via the network connection through sub-event threads after the network connection is established saves the overhead of scheduling coroutines, improves system performance, and reduces data processing latency compared to creating a corresponding coroutine for each network connection and processing the network data through the coroutine. Attached Figure Description

[0030] Figure 1 This is an application environment diagram of a network data processing method in one embodiment;

[0031] Figure 2 This is a flowchart illustrating a network data processing method in one embodiment;

[0032] Figure 3 This is a flowchart illustrating a method for establishing a network connection in one embodiment;

[0033] Figure 4 This is a timing diagram of a network data processing method in one embodiment;

[0034] Figure 5 This is a flowchart illustrating a network data processing method in another embodiment;

[0035] Figure 6 This is a structural block diagram of a network data processing device in one embodiment;

[0036] Figure 7 This is a structural block diagram of a network data processing device in another embodiment;

[0037] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0038] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0039] The network data processing method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, server 104 establishes a network connection with client 102 via a main event thread. If it receives network data sent through the network connection, it stores the network data in a buffer. A sub-event thread reads the network data from the buffer and generates a data processing request based on the network data. The execution engine performs business processing on the data processing request and feeds back the processing result to the client via the sub-event thread. Client 102 can be, but is not limited to, various application software clients. Server 104 can be deployed on a standalone server or in a server cluster consisting of multiple servers.

[0040] In one embodiment, such as Figure 2 As shown, a network data processing method is provided, which is applied to... Figure 1 Taking the server-side as an example, the explanation includes the following steps:

[0041] S202 establishes a network connection with the client through the main event thread.

[0042] The main event thread is a thread created within the main reactor used to handle main events. A main event could be, for example, a request to establish a network connection. The main reactor is a network programming model based on an event loop, used to respond to I / O (Input / Output) events. The main reactor registers the main events and their corresponding callback functions. When a main event occurs, the main reactor calls the callback function corresponding to the event to process it. A network connection is the connection between the server and the client for communication; it can be a network layer I / O connection. For example, when a connection request event occurs, the main reactor calls the callback function corresponding to the connection request event to process the event, thereby establishing a network connection with the client.

[0043] S204: If network data sent via a network connection is received, the network data is stored in the buffer.

[0044] Network data refers to data sent from the client to the server via a network connection, and can be data encapsulated using a communication protocol. Examples of such protocols include RESP (Redis Serialization Protocol) and HTTP (Hypertext Transfer Protocol). The buffer is a memory area used to cache network data, and can be a storage area within the kernel space. After a network connection is established between the server and client, if the client sends network data to the server via the network connection, the operating system stores the network data in the kernel space buffer.

[0045] S206 reads network data from the buffer through a sub-event thread and generates a data processing request based on the network data.

[0046] The sub-event thread is a thread created within the sub-reactor to handle sub-events. Sub-events can be, for example, read or write events. The sub-reactor is a network programming model based on an event loop, used to respond to I / O (Input / Output) events. The sub-reactor registers sub-events and their corresponding callback functions. When a sub-event occurs, the sub-reactor calls the corresponding callback function to process the sub-event. The data processing request is an instruction used to request business processing of network data. For example, it could be a network data storage request or a request to close a URL link.

[0047] In one embodiment, after S206, the method further includes: sequentially sending data processing requests to the execution engine via a sub-event thread, so that the execution engine can perform business processing on the data processing requests. Since the sub-reactor adopts an event-loop-based request processing mechanism, the sub-event thread can send data processing requests to the execution engine sequentially for processing. This allows the execution engine to perform business processing on the received data processing requests sequentially, eliminating the need for locking the execution engine and preventing it from being blocked in the lock queue, thus improving the efficiency of business processing.

[0048] In one embodiment, prior to S206, the method further includes: after the server and client establish a network connection, allocating the network connection to a sub-event thread. The server reads network data from the buffer through the sub-event thread and generates a data processing request based on the network data.

[0049] In one embodiment, S206 specifically includes: reading network data from the cache through a sub-event thread; decapsulating the network data to obtain decapsulated network data; and generating a data processing request based on the decapsulated network data.

[0050] The process involves decapsulating and disassembling data packets to extract the payload. When network data is in the form of encapsulated data packets, the server reads the network data from the buffer via a sub-event thread, decapsulates the network data, extracts the payload, and obtains the decapsulated network data. Then, a data processing request is generated based on the decapsulated network data.

[0051] S208 performs business processing on data processing requests through the execution engine and feeds back the processing results to the client through sub-event threads.

[0052] The execution engine is a component that runs at the business layer and is used to process network data for business purposes. After processing the network data, the execution engine feeds back the processing results to the sub-event thread, which then feeds back the results to the client.

[0053] In one embodiment, S208 specifically includes: performing business processing on the data processing request through the execution engine, encapsulating the processing result, and feeding back the encapsulated processing result to the client through a sub-event thread. Encapsulation is the process of forming data packets according to a communication protocol. When the execution engine performs business processing on the data processing request and obtains a processing result, it encapsulates the processing result according to the communication protocol to obtain the encapsulated processing result, which is data in the form of a data packet.

[0054] In the above embodiments, a main event thread establishes a network connection with the client. This main event thread is only responsible for establishing the network connection and not for data read / write operations performed through the network connection. This maximizes the reuse of the main event thread, allowing it to establish network connections with as many clients as possible. After the network connection is established, if network data is received via the network connection, it is stored in a buffer. A sub-event thread reads the network data from the buffer, generates a data processing request based on the network data, performs business processing on the data processing request through the execution engine, and feeds back the processing result to the client. Therefore, processing the network data sent via the network connection through a sub-event thread after the network connection is established saves the overhead of scheduling coroutines, improves system performance, and reduces data processing latency compared to creating a corresponding coroutine for each network connection and processing the network data through the coroutine.

[0055] In one embodiment, such as Figure 3 As shown, S202 specifically includes the following steps:

[0056] S302 listens to the corresponding communication interface of the client through the main event thread.

[0057] The communication interface is the port used to communicate with the client, such as a Socket communication interface. The main event thread starts a network listener, waiting for the client to send a connection request. In one embodiment, the main event thread listens to the corresponding communication interface of the client using the listen() function.

[0058] In one embodiment, before S302, the process further includes: the main event thread creating an I / O multiplexing object, which may be, for example, an epoll object. The main event thread registers the file descriptor of the Socket communication interface in epoll. S302 specifically includes: the main event thread listening to the communication interface based on the registered file descriptor.

[0059] S304: If a connection request is detected from a client via the communication interface, the client receives the connection request through the request receiver and establishes a network connection with the client.

[0060] The request receiver (Acceptor) is the component used to process connection requests. The request receiver can process connection requests using the `acceptConn()` function, and establish network connections using the `acceptConn()` function.

[0061] In one embodiment, S304 specifically includes: if a client sends a connection request through the communication interface, waking up the first target function; calling the request receiver through the woken-up first target function; receiving the connection request through the request receiver and establishing a network connection with the client.

[0062] The first target function can be the `epoll_wait()` function, or other functions that can implement I / O multiplexing, such as functions called via the `poll` or `select` methods. After the `epoll` object is created, the main event thread calls the `epoll_wait()` function. The `epoll_wait()` function is blocked until the client sends a connection request to the server, waiting for the client to send the connection request. If a connection request is detected from the client through the communication interface, it is determined that a connection request event has occurred. The server wakes up the `epoll_wait()` function, which executes the callback function corresponding to the event that occurred. The callback function then calls the request receiver, which accepts the connection request and establishes a network connection with the client.

[0063] In the above embodiments, the main event thread listens to the communication interface corresponding to the client. If a connection request is detected from the client through the communication interface, the request receiver receives the connection request and establishes a network connection with the client. Therefore, the server can listen to multiple communication interfaces through the main event thread. When an event occurs on a certain communication interface, the sub-event thread processes the event, thereby achieving I / O multiplexing. Compared to achieving I / O multiplexing by creating multiple coroutines, this reduces the overhead of scheduling coroutines and thus reduces data processing latency.

[0064] In one embodiment, before S206, the method further includes: registering a read event corresponding to the client in a sub-event thread; if network data sent through a network connection is received, determining that a read event has occurred and waking up the second target function in the sub-event thread; S206 specifically includes: reading network data from the buffer through the second target function after being woken up.

[0065] A read event occurs when a client sends network data to the server. A sub-event thread creates an I / O multiplexing implementation object, such as an epoll object. The sub-event thread registers a file descriptor for the socket communication interface in epoll and listens for read events on the corresponding communication interface. The second target function can be the epoll_wait() function, or any other function that implements I / O multiplexing, such as functions called via poll or select methods. After creating the epoll object, the sub-event thread calls the epoll_wait() function. The epoll_wait() function is blocked until the client sends network data to the server, waiting for the client to send network data. If the client sends network data through the communication interface, a read event is confirmed. The server then wakes up the epoll_wait() function and executes the callback function corresponding to the read event, reading network data from the buffer.

[0066] In the above embodiment, the server registers read events corresponding to the client in a sub-event thread. If network data sent via the network connection is received, a read event is determined to have occurred, and the second objective function in the sub-event thread is awakened. The awakened second objective function then reads the network data from the buffer. This allows for the reuse of sub-event threads by waking up the second objective function to handle read events after establishing a network connection with the client, thus improving data processing efficiency.

[0067] In one embodiment, before S206, the method further includes: selecting a target sub-event thread that matches the network connection from at least two candidate sub-event threads by requesting the receiver; S206 specifically includes: reading network data from the buffer through the target sub-event thread and generating a data processing request based on the network data.

[0068] The server can create multiple candidate sub-event threads. After the main event thread establishes a network connection with the client through the request receiver, it can select a target sub-event thread from the candidate threads and then bind the target sub-event thread to the established network connection. After binding, the server reads network data from the cache through the target sub-event thread and generates a data processing request based on the network data. The server can select the target sub-event thread from the candidate threads using algorithms such as round-robin, hash, least connections, or random selection.

[0069] In the above embodiments, the server can create multiple sub-event threads. After establishing a network connection, the established network connection is bound to a target sub-event thread selected from the candidate sub-event threads. The target sub-event thread then reads network data from the buffer. This allows multiple sub-event threads to process read events simultaneously, improving data processing efficiency.

[0070] In one embodiment, the network data processing method further includes the following steps: when a system call event occurs, the system call event is stored in the task queue of the sub-event thread; system call events are extracted from the task queue in sequence; and the system call event is processed by the execution engine.

[0071] System call events are manually triggered events, such as epoll events, which can be shutdown events or periodic timed events. The task queue is a first-in-first-out lock-free queue. When a manually triggered epoll event occurs, the `tiger()` function adds the event to the task queue in the child event thread. Then, system call events are sequentially retrieved from the task queue and inserted into the event loop of the child event thread. The execution engine then performs business processing on the system call events.

[0072] In the above embodiments, when a manually triggered epoll event occurs, the epoll event is stored in the task queue of the sub-event thread, and the epoll events are retrieved from the task queue in turn for business processing. By using the task queue, the use of locks in the sub-event thread can be avoided, which improves the efficiency of the sub-event thread in processing events.

[0073] In one embodiment, such as Figure 4As shown, after the server starts, it first starts a sub-reactor. The sub-reactor creates an epoll object and calls its `epoll_wait()` function. After `epoll_wait()` is called, it enters a blocked state, waiting for network read / write events. Then, the server starts a main reactor. The main reactor creates an epoll object and calls its `epoll_wait()` function. This function also enters a blocked state, waiting for a connection request event. The server registers callback functions with the main reactor to handle connection requests. The main reactor starts a network listener. When it detects a client sending a connection request, it determines that a connection request event has occurred, wakes up the `epoll_wait()` function in the main reactor, and executes the registered callback function. This callback function then calls the request receiver, which processes the connection request using the `acceptConn()` function and establishes a network connection with the client by creating a `Connection` object. The request receiver then assigns the established network connection to the sub-reactor. In the sub-reactor's epoll object, a read event bound to the client's socket communication interface is registered to prepare for receiving network data from the client. When the client sends network data, a read event is confirmed, waking up the epoll_wait() function in the sub-reactor. After being awakened, the epoll_wait function executes the callback function registered in the sub-reactor, repeatedly reading network data from the kernel buffer until an EAGAIN error is encountered. When an EAGAIN error is encountered, it indicates that the kernel buffer has been emptied, and network data needs to be retrieved from the client. At this point, a read event bound to the client's socket communication interface is re-registered in the sub-reactor's epoll object to continue processing read events. After re-registering the read event, when the client sends network data through the communication interface, network data continues to be read from the kernel buffer. After the data reading is complete, a write event bound to the client's socket communication interface is registered in the sub-reactor's epoll object to prepare for sending the processing results obtained from the business processing of the network data to the client. The server decapsulates the network data received from the client, generates a data processing request based on the decapsulated data, and sends the request to the execution engine. The execution engine performs business processing on the request and obtains the result. The result is then encapsulated and sent back to the client.

[0074] In one embodiment, such as Figure 5 As shown, the network data processing method includes the following steps:

[0075] S502 listens to the corresponding communication interface of the client through the main event thread.

[0076] S504: If a client sends a connection request through the communication interface, the first target function will be woken up.

[0077] S506 requests the receiver by calling the first target function after wake-up.

[0078] The S508 receives connection requests through a request receiver and establishes a network connection with the client.

[0079] S510, if it receives network data sent through a network connection, stores the network data in the buffer.

[0080] S512, among at least two candidate sub-event threads, selects the target sub-event thread that matches the network connection by requesting the receiver.

[0081] S514, in the target sub-event thread, register the corresponding read event for the client.

[0082] S516: If network data sent via network connection is received, a read event is determined to have occurred, and the second target function in the target sub-event thread is awakened.

[0083] S518 reads network data from the buffer through the second objective function after wake-up, decapsulates the network data, and obtains the decapsulated network data.

[0084] S520 generates a data processing request based on the decapsulated network data.

[0085] S522 performs business processing on data processing requests through the execution engine to obtain the processing results.

[0086] S524 encapsulates the processing result and feeds the encapsulated processing result back to the client through a sub-event thread.

[0087] The specific content of S502 to S524 can be found in the implementation process described above.

[0088] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0089] Based on the same inventive concept, this application also provides a network data processing apparatus for implementing the network data processing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more network data processing apparatus embodiments provided below can be found in the limitations of the network data processing method described above, and will not be repeated here.

[0090] In one embodiment, such as Figure 6 As shown, a network data processing device is provided, including: an establishment module 602, a storage module 604, a generation module 606, and a feedback module 608, wherein:

[0091] Establish module 602 to establish a network connection with the client via the main event thread;

[0092] Storage module 604, if it receives network data sent through a network connection, is used to store the network data in a buffer area;

[0093] The generation module 606 is used to read network data from the buffer through a sub-event thread and generate a data processing request based on the network data.

[0094] Feedback module 608 is used to perform business processing on data processing requests through the execution engine and to feed back the processing results to the client.

[0095] In the above embodiments, a main event thread establishes a network connection with the client. This main event thread is only responsible for establishing the network connection and not for data read / write operations performed through the network connection. This maximizes the reuse of the main event thread, allowing it to establish network connections with as many clients as possible. After the network connection is established, if network data is received via the network connection, it is stored in a buffer. A sub-event thread reads the network data from the buffer, generates a data processing request based on the network data, performs business processing on the data processing request through the execution engine, and feeds back the processing result to the client. Therefore, processing the network data sent via the network connection through a sub-event thread after the network connection is established saves the overhead of scheduling coroutines, improves system performance, and reduces data processing latency compared to creating a corresponding coroutine for each network connection and processing the network data through the coroutine.

[0096] In one embodiment, the establishment module 602 is further configured to:

[0097] The main event thread listens for the corresponding communication interface on the client.

[0098] If a client sends a connection request through the communication interface, the request receiver receives the connection request and establishes a network connection with the client.

[0099] In one embodiment, the establishment module 602 is further configured to:

[0100] If a client sends a connection request through the communication interface, the first target function will be awakened;

[0101] The request receiver is invoked through the first target function call after wake-up;

[0102] The receiver receives connection requests and establishes a network connection with the client.

[0103] In one embodiment, such as Figure 7 As shown, the device also includes:

[0104] Registration module 610 is used to register the read event corresponding to the client in the sub-event thread;

[0105] The determination module 612, if it receives network data sent through the network connection, is used to determine that a read event has occurred and to wake up the second target function in the sub-event thread;

[0106] The generation module 606 is used to read network data from the buffer via the second target function after wake-up.

[0107] In one embodiment, the apparatus further includes:

[0108] The selection module 614 is used to select a target sub-event thread that matches the network connection from at least two candidate sub-event threads by requesting the receiver.

[0109] Module 606 is also used for:

[0110] The target sub-event thread reads network data from the cache and generates a data processing request based on the network data.

[0111] In one embodiment, the generation module 606 is further configured to:

[0112] Read network data from the buffer using a sub-event thread;

[0113] Decapsulate the network data to obtain the decapsulated network data;

[0114] Generate a data processing request based on the decapsulated network data;

[0115] Feedback module 608 is also used for:

[0116] The processing result is encapsulated, and the encapsulated processing result is fed back to the client through a sub-event thread.

[0117] Each module in the aforementioned network data processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0118] In one embodiment, a computer device is provided, which may be a server, on which the aforementioned server-side component is deployed, and its internal structure diagram may be as follows. Figure 8 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores network data processing data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a network data processing method.

[0119] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0120] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to perform the following steps: establishing a network connection with a client via a main event thread; if network data sent via the network connection is received, storing the network data in a buffer; reading the network data from the buffer via a sub-event thread and generating a data processing request based on the network data; performing business processing on the data processing request via an execution engine, and feeding back the processing result obtained from the business processing to the client via the sub-event thread.

[0121] In one embodiment, when the processor executes the computer program, it also performs the following steps: listening to the communication interface corresponding to the client through the main event thread; if it detects that the client has sent a connection request through the communication interface, receiving the connection request through the request receiver and establishing a network connection with the client.

[0122] In one embodiment, when the processor executes the computer program, it further performs the following steps: if a connection request is detected from a client via a communication interface, the first target function is woken up; the request receiver is called through the woken-up first target function; the connection request is received through the request receiver, and a network connection is established with the client.

[0123] In one embodiment, when the processor executes the computer program, it further performs the following steps: registering a read event corresponding to the client in a sub-event thread; if network data sent through the network connection is received, determining that a read event has occurred and waking up the second target function in the sub-event thread; and reading network data from the buffer through the woken-up second target function.

[0124] In one embodiment, when the processor executes the computer program, it further performs the following steps: selecting a target sub-event thread that matches the network connection from at least two candidate sub-event threads by requesting a receiver; and reading network data from a buffer by the target sub-event thread and generating a data processing request based on the network data.

[0125] In one embodiment, when the processor executes the computer program, it also performs the following steps: reading network data from the cache via a sub-event thread; decapsulating the network data to obtain decapsulated network data; generating a data processing request based on the decapsulated network data; encapsulating the processing result and feeding the encapsulated processing result back to the client via the sub-event thread.

[0126] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, it performs the following steps: establishing a network connection with a client through a main event thread; if network data sent through the network connection is received, storing the network data in a buffer; reading the network data from the buffer through a sub-event thread and generating a data processing request based on the network data; performing business processing on the data processing request through an execution engine, and feeding back the processing result obtained from the business processing to the client through the sub-event thread.

[0127] In one embodiment, when the computer program is executed by the processor, it also performs the following steps: listening to the communication interface corresponding to the client through the main event thread; if a connection request is detected from the client through the communication interface, receiving the connection request through the request receiver and establishing a network connection with the client.

[0128] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: if a connection request is detected from a client through a communication interface, the first target function is awakened; the request receiver is called through the awakened first target function; the connection request is received through the request receiver, and a network connection is established with the client.

[0129] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: registering a read event corresponding to the client in a sub-event thread; if network data sent through the network connection is received, determining that a read event has occurred and waking up the second target function in the sub-event thread; and reading network data from the buffer through the woken-up second target function.

[0130] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: selecting a target sub-event thread that matches the network connection from at least two candidate sub-event threads by requesting a receiver; reading network data from a buffer by the target sub-event thread and generating a data processing request based on the network data.

[0131] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: reading network data from the cache via a sub-event thread; decapsulating the network data to obtain decapsulated network data; generating a data processing request based on the decapsulated network data; encapsulating the processing result and feeding the encapsulated processing result back to the client via the sub-event thread.

[0132] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0133] The main event thread establishes a network connection with the client; if network data sent through the network connection is received, the network data is stored in the buffer; the sub-event thread reads the network data from the buffer and generates a data processing request based on the network data; the execution engine performs business processing on the data processing request and feeds back the processing result to the client through the sub-event thread.

[0134] In one embodiment, when the computer program is executed by the processor, it also performs the following steps: listening to the communication interface corresponding to the client through the main event thread; if a connection request is detected from the client through the communication interface, receiving the connection request through the request receiver and establishing a network connection with the client.

[0135] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: if a connection request is detected from a client through a communication interface, the first target function is awakened; the request receiver is called through the awakened first target function; the connection request is received through the request receiver, and a network connection is established with the client.

[0136] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: registering a read event corresponding to the client in a sub-event thread; if network data sent through the network connection is received, determining that a read event has occurred and waking up the second target function in the sub-event thread; and reading network data from the buffer through the woken-up second target function.

[0137] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: selecting a target sub-event thread that matches the network connection from at least two candidate sub-event threads by requesting a receiver; reading network data from a buffer by the target sub-event thread and generating a data processing request based on the network data.

[0138] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: reading network data from the cache via a sub-event thread; decapsulating the network data to obtain decapsulated network data; generating a data processing request based on the decapsulated network data; encapsulating the processing result and feeding the encapsulated processing result back to the client via the sub-event thread.

[0139] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0140] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0141] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0142] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A network data processing method, characterized by, The method comprises: establishing a network connection with a client through a main event thread, assigning the network connection to a sub-event thread; the main event thread is a thread created in a main reactor for processing main events, the main event being a request to establish a network connection event; the main reactor is an event loop-based network programming model for responding to I / O events; if network data sent through the network connection is received, determining that a read event occurs, waking up a second target function in the sub-event thread, and storing the network data in a cache area; through the second target function in the sub-event thread, executing a callback function registered in a sub-reactor, and through the execution of the callback function, cyclically reading the network data from the cache area, unpackaging the network data to obtain unpackaged network data, and generating a data processing request according to the unpackaged network data; the sub-event thread is a thread created in the sub-reactor for processing sub-events, the sub-event being a read event or a write event; the sub-reactor is an event loop-based network programming model for responding to I / O events; wherein the data processing request includes a network data storage request or a close URL link request; the task queue in the sub-event thread is a first-in-first-out lock-free queue; sending the data processing request to an execution engine in sequence through the sub-event thread, so that the execution engine sequentially processes the received data processing request, and feeding back the processing result obtained by the business processing to the client through the sub-event thread; wherein the execution engine is a component running in a business layer, used for business processing of the network data, and the execution engine sequentially processes the received data processing request in a lock-free state.

2. The method of claim 1, wherein, The method further comprises: listening to a communication interface corresponding to the client through the main event thread; if a connection request sent by the client through the communication interface is listened to, receiving the connection request through a request receiver, and establishing a network connection with the client.

3. The method of claim 2, wherein, The method further comprises: if a connection request sent by the client through the communication interface is listened to, waking up a first target function; calling the request receiver through the first target function after waking up; receiving the connection request through the request receiver, and establishing a network connection with the client.

4. The method of claim 1, wherein, The method further comprises: registering a read event corresponding to the client in the sub-event thread.

5. The method of claim 1, wherein, The method further comprises: selecting a target sub-event thread matching the network connection through a request receiver in at least two candidate sub-event threads; reading the network data from the cache area through the sub-event thread, and generating a data processing request according to the network data. reading the network data from the buffer area by the target sub-event thread, and generating a data processing request according to the network data.

6. The method of claim 1, wherein, the feeding back the processing result to the client by the sub-event thread comprises: packaging the processing result, and feeding back the packaged processing result to the client by the sub-event thread.

7. A network data processing device, characterized by The apparatus comprises: a establishing module, configured to establish a network connection with a client by a main event thread, and assign the network connection to a sub-event thread; the main event thread is a thread created in a main reactor, and is configured to process a main event; the main event is an event of requesting to establish a network connection; the main reactor is an event loop-based network programming model, and is configured to respond to I / O events; a storage module, configured to determine that a read event occurs if network data sent through the network connection is received, and wake up a second target function in the sub-event thread, which is configured to store the network data in a buffer area; a generating module, configured to execute a callback function registered in a sub-reactor by the second target function in the sub-event thread, and through the execution of the callback function, cyclically read the network data from the buffer area, unpack the network data to obtain unpacked network data, and generate a data processing request according to the unpacked network data; the sub-event thread is a thread created in the sub-reactor, and is configured to process a sub-event; the sub-event is a read event or a write event; the sub-reactor is an event loop-based network programming model, and is configured to respond to I / O events; wherein, the data processing request comprises a network data storage request or a close URL link request; a task queue in the sub-event thread is a first-in-first-out lock-free queue; a feeding back module, configured to sequentially send the data processing request to an execution engine by the sub-event thread, so that the execution engine sequentially processes the received data processing request, and feeds back a processing result obtained by processing the data processing request to the client; wherein, the execution engine is a component running at a business layer, and is configured to process the network data; when the execution engine sequentially processes the received data processing request, it is in a lock-free state.

8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to implement the steps of the method of any one of claims 1 to 6.

9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 6.

10. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and device of data processing and storage medium

    CN108509298A

  • Server-based event processing method, device and apparatus and medium

    CN109189595A

  • Industrial Internet edge gateway design method supporting Web high concurrent access

    CN112954006A