Data request forwarding method and device, electronic equipment and storage medium

Through the asynchronous non-blocking I/O mode management of data requests by boss threads and work threads, the gateway blocking problem in high concurrency scenarios is solved, and efficient data request processing and resource utilization are achieved.

CN120475075APending Publication Date: 2025-08-12DUXIAOMAN TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510688425.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2025-08-12

AI Technical Summary

Technical Problem

In high concurrency scenarios, the gateway is prone to blockage, resulting in data requests being unable to respond in time.

Method used

The boss thread is used to poll the first data channel, send the data request to the work thread for processing, and send it to the target machine through the second data channel. The priority thread pool and cache queue management requests are used to avoid blocking the boss thread by a single data request and improve thread resource utilization.

Benefits of technology

It improves the efficiency of data request processing, avoids blocking the boss thread by a single data request, and improves the system's concurrent processing capability and resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120475075A_ABST
    Figure CN120475075A_ABST
Patent Text Reader

Abstract

The invention provides a data request forwarding method and device, electronic equipment and a storage medium, a boss thread is adopted to poll a first data channel and a second data channel, under the condition that a data request exists in the first data channel, the data request is sent to work threads for processing, boss thread resources are released immediately, the number of the work threads is usually multiple, and the data request is sent to the second data channel. According to the data request processing method and device, even if the data request processing of one work thread is abnormal, other work threads cannot be affected to process the data request, so that the situation that a single data request blocks the boss thread and further affects the processing of other data requests is avoided, and the data request processing efficiency is improved. In addition, after the current data request is processed by the work thread, another data request can be processed, so that the utilization rate of thread resources is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of gateway technology, and in particular to a data request forwarding method, device, electronic device and storage medium. Background Art

[0002] A gateway, also known as a network connector or protocol converter, enables network interconnection above the network layer. It is a complex network interconnection device used only to connect two networks with different high-level protocols. Gateways can be used to interconnect both wide area networks and local area networks. Specifically, a gateway parses and repackages data requests for a particular network, forwarding them to electronic devices within that network for execution, typically servers or computers.

[0003] In related technologies, when faced with a high number of concurrent scenarios, the gateway is prone to congestion, resulting in an inability to respond to data requests in a timely manner. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a data request forwarding method, device, electronic device, and storage medium to improve request forwarding efficiency and thereby improve data request processing efficiency.

[0005] According to one aspect of the present invention, a data request forwarding method is provided, the method comprising:

[0006] Obtaining a data request and establishing a persistent connection with the sender of the data request;

[0007] Utilize the first boss thread to poll each first data channel, and if there is a data request in the first data channel, send the data request to the first worker thread;

[0008] Parsing the data request using the first worker thread to obtain business scenario information of the data request, the business scenario information including a business identifier to which the data request belongs, an identifier of a target processing model for the data request, and an identifier of a target machine for processing the data request;

[0009] According to the business scenario information of the data request, the data request is sent to a preset priority thread pool, and the data request is sent to the second data channel in sequence, and the corresponding relationship between the second data channel and the long connection information is stored;

[0010] Utilizing the second boss thread to poll the second data channel, and when a data request exists in the second data channel, sending the data request to the target machine according to the business scenario information;

[0011] Obtain the processing result returned by the target machine, determine the persistent connection corresponding to the data request based on the corresponding relationship, and send the processing result to the sender through the persistent connection.

[0012] In a possible embodiment, the priority thread pool is pre-set for model levels of different processing models, and sending the data request to the preset priority thread pool according to the business scenario information of the data request includes:

[0013] Determining the target model level corresponding to the target processing model based on a preset model level classification rule;

[0014] The data request is sent to the priority thread pool corresponding to the target model level.

[0015] In a possible embodiment, the method further includes:

[0016] Detecting whether the number of data requests in the preset priority thread pool reaches a preset concurrency threshold;

[0017] When the number of data requests in the preset priority thread pool reaches a preset concurrency threshold, the data requests are stored in a cache queue.

[0018] In a possible embodiment, the preset concurrency threshold is pre-set for each computer room and model level; the method further includes:

[0019] Detecting whether the target computer room corresponding to the data request and the amount of data requests in the preset priority thread pool have reached the preset concurrency threshold;

[0020] When the amount of data requests in the target computer room or the amount of data requests in the preset priority thread pool reaches the preset concurrency threshold, the data requests are stored in a cache queue.

[0021] According to another aspect of the present invention, a data request forwarding device is provided, the device comprising:

[0022] A first acquisition module is used to obtain a data request and establish a persistent connection with the sender of the data request;

[0023] A first polling module is configured to poll each first data channel using a first boss thread, and if a data request exists in the first data channel, send the data request to a first worker thread;

[0024] a parsing module, configured to parse the data request using the first worker thread to obtain business scenario information of the data request, the business scenario information including a business identifier to which the data request belongs, an identifier of a target processing model for the data request, and an identifier of a target machine for processing the data request;

[0025] A sending module, configured to send the data request to a preset priority thread pool according to the business scenario information of the data request, send the data request to the second data channel in sequence, and store the corresponding relationship between the second data channel and the long connection information;

[0026] a second polling module, configured to poll the second data channel using a second boss thread, and, if a data request exists in the second data channel, send the data request to a target machine according to the business scenario information;

[0027] The second acquisition module is used to obtain the processing result returned by the target machine, determine the long connection corresponding to the data request based on the corresponding relationship, and send the processing result to the sender through the long connection.

[0028] In a possible embodiment, the priority thread pool is pre-set for model levels of different processing models, and sending the data request to the preset priority thread pool according to the business scenario information of the data request includes:

[0029] Determining the target model level corresponding to the target processing model based on a preset model level classification rule;

[0030] The data request is sent to the priority thread pool corresponding to the target model level.

[0031] In a possible embodiment, the device further includes:

[0032] The cache module is used to detect whether the number of data requests in the preset priority thread pool reaches the preset concurrency threshold; when the number of data requests in the preset priority thread pool reaches the preset concurrency threshold, the data request is stored in the cache queue.

[0033] In a possible embodiment, the preset concurrency threshold is pre-set for each computer room and model level; the cache module is used to detect whether the target computer room corresponding to the data request and the data request volume in the preset priority thread pool have reached the preset concurrency threshold;

[0034] When the amount of data requests in the target computer room or the amount of data requests in the preset priority thread pool reaches the preset concurrency threshold, the data requests are stored in a cache queue.

[0035] According to another aspect of the present invention, there is provided an electronic device, comprising:

[0036] processor; and

[0037] Memory for storing programs,

[0038] The program includes instructions, which, when executed by the processor, enable the processor to execute any of the above-mentioned data request forwarding methods.

[0039] According to another aspect of the present invention, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute any of the above-mentioned data request forwarding methods.

[0040] One or more technical solutions provided in the embodiments of the present invention employ a boss thread to poll the first and second data channels. When a data request exists in the first data channel, the data request is sent to the worker thread for processing, immediately releasing the boss thread resources. There are typically multiple worker threads, and even if a worker thread encounters a data request processing exception, it will not affect the processing of data requests by other worker threads. This prevents a single data request from blocking the boss thread and thus affecting the processing of other data requests, thereby improving data request processing efficiency. Furthermore, after a worker thread completes processing the current data request, it can process another data request, improving thread resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Further details, features and advantages of the present invention are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:

[0042] Figure 1 A schematic diagram of a flow chart of a data request forwarding method provided by an embodiment of the present invention;

[0043] Figure 2 A schematic diagram of another flow chart of a data request forwarding method provided in an embodiment of the present invention;

[0044] Figure 3 A schematic structural diagram of a data request forwarding device provided by an embodiment of the present invention;

[0045] Figure 4 A block diagram of an exemplary electronic device capable of implementing the embodiments of the present invention is shown. DETAILED DESCRIPTION

[0046] Embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of protection of the present invention.

[0047] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0048] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description. It should be noted that the concepts of "first", "second", etc. mentioned in the present invention are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0049] It should be noted that the modifications of "one" and "multiple" mentioned in the present invention are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0050] The names of the messages or information exchanged between multiple devices in the embodiments of the present invention are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0051] In related technologies, in an open source environment, there are multiple solutions for online access layer gateways, for example:

[0052] 1. Zuul: Zuul is a high-performance open-source API gateway developed by Netflix that can be used to implement API routing, load balancing, authentication, rate limiting, log tracking, and other functions. Zuul is a JVM-based edge service developed by Netflix, mainly used for intelligent routing, load balancing, security protocol conversion, and service monitoring. Zuul supports multiple protocols, including HTTP (HyperText Transfer Protocol), WebSocket (Network Socket Protocol), TCP (Transmission Control Protocol), and UDP (User Datagram Protocol).

[0053] 2. Zuul 2.0: Zuul 2.0 is Netflix's next-generation API gateway. Compared to the earlier Zuul 1.x version, Zuul 2.0 offers higher performance, richer functionality, and more flexible configuration. While Zuul 1.x uses Netty as its core technology framework, Zuul 2.0 utilizes a new asynchronous, non-blocking API based on Netty and allows users to use Java 8 Lambda expressions for more convenient request and response processing in code.

[0054] 3. Kong: Kong is an open source API gateway and microservices management platform based on Nginx. It helps companies build and manage microservice architecture applications by providing a range of API and microservices management features, while also allowing developers to develop their own custom plugins. Kong supports multiple API protocols, including RESTful, SOAP, and even GraphQL. At the same time, it also provides many core gateway functions, such as request routing, request conversion, request limiting, authentication, authorization, monitoring, logging, traffic management, and more. In addition, Kong has a rich plugin mechanism, allowing users to easily write plugins to implement customized functions.

[0055] However, the above solutions have different disadvantages, as follows:

[0056] 1. Zuul Disadvantages:

[0057] Since it is an online service gateway, online model scoring and offline model query services require low response times in high-concurrency and high-traffic scenarios, while Zuul performs poorly in the same type and has high synchronization costs.

[0058] 2. Disadvantages of Zull 2.0:

[0059] Zuul2.0 is a non-blocking IO mode gateway system developed based on Zuul, but it came out relatively late, has few practical cases, and needs time to be tested. In addition, the high concurrency error rate in practical cases is relatively high, which may reduce the current service stability.

[0060] 3. Kong Disadvantages:

[0061] Kong is a Lua script program running on Nginx. There is a learning cost for its development. More importantly, it is not suitable for script development for customized complex logic functions and cannot meet the needs of fine-grained, multi-dimensional traffic control and fault management.

[0062] In order to meet the gateway requirements in high-concurrency scenarios, embodiments of the present invention provide a request forwarding method, device, electronic device, and storage medium. The request forwarding method provided by the embodiment of the present invention can be applied to any electronic device with data forwarding function, such as a server, computer, or mobile terminal. Specifically, the data request forwarding method provided by the embodiment of the present invention can be implemented by a gateway. The following describes the solution of the present invention with reference to the accompanying drawings:

[0063] Figure 1 A flow chart of a data request forwarding method provided in an embodiment of the present invention may include the following steps:

[0064] S101, obtaining a data request and establishing a long connection with the sender of the data request;

[0065] S102: Utilize the first boss thread to poll each first data channel, and if there is a data request in the first data channel, send the data request to the first worker thread;

[0066] S103: Utilize the first worker thread to parse the data request to obtain business scenario information of the data request, where the business scenario information includes a business identifier of the data request, an identifier of a target processing model of the data request, and an identifier of a target machine for processing the data request.

[0067] S104: Send the data request to a preset priority thread pool according to the business scenario information of the data request, send the data request to the second data channel in order, and store the corresponding relationship between the second data channel and the long connection information;

[0068] S105: Utilize the second boss thread to poll the second data channel, and if a data request exists in the second data channel, send the data request to the target machine according to the business scenario information;

[0069] S106: Obtain the processing result returned by the target machine, determine the persistent connection corresponding to the data request based on the corresponding relationship, and send the processing result to the sender through the persistent connection.

[0070] In an embodiment of the present invention, a boss thread is used to poll the first and second data channels. When a data request exists in the first data channel, the data request is sent to the worker thread for processing, and the boss thread resources are immediately released. Since there are usually multiple worker threads, even if a worker thread encounters a data request processing exception, it will not affect the processing of data requests by other worker threads. This prevents a single data request from blocking the boss thread and affecting the processing of other data requests, thereby improving data request processing efficiency. Furthermore, after a worker thread finishes processing the current data request, it can process another data request, thereby improving thread resource utilization.

[0071] The above S101-S106 are exemplarily described below:

[0072] The data request in S101 can be any type of data request, such as an http (Hypertext Transfer Protocol) request or an https (Hypertext Transfer Protocol Secure) request. After receiving the data request, the electronic device can establish a long connection with the sender of the data request, wherein the sender of the data request can be identified by the sender's IP address, domain name, etc. The long connection means that after the TCP (Transmission Control Protocol) layer handshake is successful, the connection is not disconnected immediately, and multiple messages (including heartbeats) are interacted on the basis of this connection until either party of the connection actively disconnects. The processing result of the data request can be returned later through the long connection.

[0073] In this embodiment of the present invention, a gateway is established using the Netty framework. Netty is an open-source Java framework that provides an asynchronous, event-driven network application framework and tools for rapidly developing high-performance, highly reliable network servers and client programs. Specifically, Netty's asynchronous functionality is implemented based on NIO (non-blocking I / O), which supports a large number of concurrent connections and enables efficient and scalable network programming.

[0074] Asynchronous non-blocking I / O (Asynchronous Non-Blocking I / O) is an I / O model that maximizes the use of computer resources and improves application throughput and performance. Taking network programming as an example, in the traditional blocking I / O model, each socket connection requires a thread. As the number of connections increases, the number of threads also increases until the system performance limit is reached. Asynchronous non-blocking I / O, on the other hand, takes advantage of event-driven programming. When an application initiates an I / O operation, it does not block waiting for the operation to complete. Instead, it continues to execute the next instruction and returns the result through a callback function when the operation is complete. This avoids thread blocking and waiting, reducing thread switching overhead and system resource usage. At the same time, asynchronous non-blocking I / O can also improve the concurrent processing capabilities of network connections.

[0075] In an embodiment of the present invention, the Netty framework may include a Netty server and a Netty client, wherein the Netty server is used to receive a data request sent by a data request sender, send the data request to the Netty client, and establish a long connection with the sender, and the Netty client is used to forward the data request to a specific electronic device for processing.

[0076] In one possible embodiment, the Netty server may include a buffer and a channel, each of which is preconfigured for different senders. Upon receiving a data request from a sender, the server first sends the data request to the sender's corresponding buffer and then reads the data request from the buffer into the channel. For ease of description, in this embodiment of the present invention, the channel configured for the sender in the Netty server is referred to as the first data channel.

[0077] The Netty server may further include a multiplexer Selector, which may be registered with multiple first data channels and monitor data requests in each of the first data channels. In one possible embodiment, the I / O (Input / Output) events, i.e., data requests, that need to be monitored may be pre-set based on different data senders. For example, the type of data request and the data contained in the data request may be set. The type of data request may be add, modify, delete, or query, etc.

[0078] In one possible embodiment, the selector may include a boss thread and a worker thread. The boss thread is configured to receive a connection request from a sender and create the buffer and first data channel for the sender. The boss thread may poll each first data channel at a preset time period and, if a data request exists in the first data channel, forward the data request to the worker thread for processing.

[0079] In a possible embodiment, the work thread can parse the above-mentioned data request. Specifically, when the above-mentioned data request is an http request, the data request can be parsed by an http parser, and information such as the sender, data type, and service identifier in the data request can be obtained, wherein the sender information can be the sender's IP address, domain name, etc.

[0080] In one possible embodiment, the step of the work thread parsing the data request may further include: determining the association model of the data request and the information of the computer room and machine that processes the data request based on the preset correspondence between the business identifier and the processing model, and the correspondence between the business identifier and the computer room and machine. As a possible implementation method, different processing models, computer rooms, and machines that process business-related data requests may be set for different businesses. Specifically, computer rooms and machines may be allocated to each business based on the business processing model and the traffic of business data requests, based on the machine resources in each computer room. The above-mentioned machine resources may include CPU, memory, disk, etc.

[0081] The worker thread can send the data request to the Netty client for further forwarding processing. In one possible embodiment, the step of the worker thread parsing the data request can also include: processing abnormal data requests, which can be requests that lack business identification information, data types, or data values in the data request, or data requests with permission errors. The above permission errors refer to the fact that the sender of the data request does not have the processing permission for the data type or business identification included in the data request.

[0082] Similar to the Netty server architecture, the Netty client also processes requests through NIO. Specifically, the Netty client can establish a secondary data channel with the downstream server and use a boss thread to poll each secondary data channel. If a data request is found in a secondary data channel, it is sent to the worker thread, which then routes the data request. In one possible embodiment, each of these secondary data channels can be set up for different computer rooms or machines.

[0083] In one possible embodiment, the data request in the second data channel may be a data request parsed and repackaged by the first worker thread. The repackaged data request may include the aforementioned service identifier, data type, data value, and other information. The data request may also include a processing model identifier for the data request and an identifier for the computer room and machine that will process the data request. The second worker thread may route the data request to the computer room corresponding to the computer room identifier and the machine corresponding to the machine identifier according to the computer room identifier and machine identifier of the data request.

[0084] In one possible embodiment, different priorities can be set for different services. Specifically, thread pools of different priorities can be pre-divided, where higher-priority thread pools contain more resources. As a possible implementation, since there is a correspondence between processing models and services, the processing model identifier included in the data request can be used to send the data request to the thread pool of the corresponding priority, and the data request can be sent to the Netty client through the thread pool.

[0085] In a possible embodiment, the priority thread pool is pre-set for model levels of different processing models, and sending the data request to the preset priority thread pool according to the business scenario information of the data request includes:

[0086] Determining the target model level corresponding to the target processing model based on a preset model level classification rule;

[0087] The data request is sent to the priority thread pool corresponding to the target model level.

[0088] In one possible embodiment, in order to avoid excessive utilization of machine resources, different concurrency thresholds can be set for different computer rooms. The concurrency thresholds can be set based on the computer room resources. For example, stress tests can be performed on machines in different computer rooms, that is, the concurrency of data requests to be processed by the computer room is gradually increased. When congestion occurs or the efficiency of data request processing decreases, the most recent concurrency of data requests is determined as the concurrency threshold of the computer room.

[0089] The above method may further include: detecting whether the number of data requests in the preset priority thread pool reaches a preset concurrency threshold;

[0090] When the number of data requests in the preset priority thread pool reaches a preset concurrency threshold, the data requests are stored in a cache queue.

[0091] In one possible embodiment, the data resource utilization of the machines in each computer room can be monitored by a monitoring tool. For example, the resource usage of each machine in the cluster can be monitored by the cluster monitoring tool Prometheus, including the number of data processing tasks running on each machine, the resource utilization of each machine, etc. When the number of data processing tasks reaches a preset concurrency threshold or the resource utilization reaches a preset resource utilization, the newly received data request can be stored in the cache queue. Subsequently, the data request can be forwarded to the target machine of the data request in the order in which the data request is added to the cache queue.

[0092] In a possible embodiment, a concurrency threshold can also be set for the thread pools of different priorities. When the concurrency of the thread pool corresponding to the data request reaches the concurrency threshold, the data request can be stored in the cache queue. The method of setting the concurrency threshold for the thread pool is the same as the method of setting the concurrency threshold for different computer rooms, and is not specifically limited here. That is, the embodiment of the present invention can store the data request in the cache queue when the data request in the target computer room or the data request in the preset priority thread pool reaches the preset concurrency threshold.

[0093] In the above cache queue, timeout discard rules can be set to avoid long-term blocking of data requests.

[0094] In one possible embodiment, after the target machine processes the data request and obtains the processing result, the processing result can be returned to the second data channel, and then the processing result can be returned to the sender of the data request through the second data channel. Exemplarily, in an embodiment of the present invention, after establishing the second data channel, the second data channel and the long connection information established with the sender can be stored accordingly. After obtaining the processing result, the corresponding long connection can be determined based on the stored correspondence between the second data channel and the long connection, and the processing result can be returned to the sender through the long connection. The above-mentioned long connection information may include the sender identifier.

[0095] Through the above technical solution, by storing the correspondence between the second data channel and the long connection, the resources on the second data channel can be released after forwarding the data request to forward other data requests, thereby realizing data channel reuse and improving resource utilization.

[0096] like Figure 2 As shown, Figure 2 A flow chart of a data request forwarding method provided in an embodiment of the present invention:

[0097] The Netty server listens for data requests sent from upstream through a listening port, and the Netty server pre-sets a first data channel for different data request senders. The boss thread polls each first data channel, and when it detects that there is a data request in the first data channel, it sends the data request to the work thread for processing. The work thread calls the http parser to parse the http request, and uses the self-written QuickSandHandler to determine the processing model identifier, target computer room identifier, and target machine identifier contained in the data request based on the pre-set corresponding relationships, and uses the serverExceptionHandler to process abnormal data requests. The work thread can send the data request to the preset priority thread pool according to the processing model identifier based on the pre-set different model levels, such as to the low-priority thread pool. A concurrency threshold (current limiting information) is preset for each priority thread pool. When the number of data requests in the preset priority thread pool corresponding to the data request exceeds the concurrency threshold, the data request is stored in the cache queue. Furthermore, different concurrency thresholds can be set for different computer rooms or machines. If the number of data requests in the target computer room or machine corresponding to a data request reaches the corresponding concurrency threshold, the data request can be stored in the cache queue. This concurrency threshold determination can be implemented using a limit filter. Concurrency thresholds and bns (Blockchain Network Service) information can be set and distributed in the database (DB).

[0098] Routefilter can send requests to the second data channel corresponding to the target business. The Netty client can poll each second data channel through the boss thread. When a data request exists in the second data channel, the data request is sent to the worker thread, which then sends the data request to the target machine in the target computer room. When the target machine processes the data request and obtains the processing result, the clientMiddleHandler function can be activated, which sends the processing result to the persistent connection and returns it to the sender. Specifically, the correspondence between the second data channel and the persistent connection information can be stored in the connection pool. The clientMiddleHandler function can determine the persistent connection corresponding to the data request based on the connection pool.

[0099] By applying the embodiments of the present invention, the entire communication process is performed in an asynchronous, non-blocking I / O mode, which is highly advantageous for high-concurrency scenarios and situations requiring the processing of large numbers of requests. Specifically, the non-blocking I / O mode fully utilizes system resources, enabling efficient event-driven request processing. The blocking of a particular request prevents the processing speed of other requests from being affected, thereby improving the system's concurrent processing capabilities.

[0100] Furthermore, compared with traditional blocking I / O, non-blocking I / O can reduce the consumption of thread resources because multiple I / O operations can be processed in one thread, avoiding the situation where each request requires a separate thread. It can also reduce thread switching overhead, reduce system load, and improve overall system performance.

[0101] In addition, since the non-blocking I / O mode can be event-driven, it can respond to requests faster, reduce the waiting time of requests, and improve the response speed of the system. It can also be applied to various types of gateway systems, especially those that need to handle a large number of concurrent requests, high-frequency data interactions, and diverse access systems.

[0102] Based on the same inventive concept, an embodiment of the present invention provides a data request forwarding device, such as Figure 3 As shown, the apparatus 300 may include:

[0103] A first acquisition module 301 is configured to acquire a data request and establish a persistent connection with a sender of the data request;

[0104] A first polling module 302 is configured to poll each first data channel using a first boss thread, and if a data request exists in the first data channel, send the data request to a first worker thread;

[0105] A parsing module 303 is configured to parse the data request using the first worker thread to obtain business scenario information of the data request, where the business scenario information includes a business identifier to which the data request belongs, an identifier of a target processing model for the data request, and an identifier of a target machine for processing the data request.

[0106] A sending module 304 is configured to send the data request to a preset priority thread pool according to the business scenario information of the data request, send the data request to the second data channel in sequence, and store the corresponding relationship between the second data channel and the long connection information;

[0107] A second polling module 305 is configured to poll the second data channel using a second boss thread, and if a data request exists in the second data channel, send the data request to a target machine according to the business scenario information;

[0108] The second acquisition module 306 is configured to acquire the processing result returned by the target machine, determine the persistent connection corresponding to the data request based on the corresponding relationship, and send the processing result to the sender through the persistent connection.

[0109] In a possible embodiment, the priority thread pool is pre-set for model levels of different processing models, and sending the data request to the preset priority thread pool according to the business scenario information of the data request includes:

[0110] Determining the target model level corresponding to the target processing model based on a preset model level classification rule;

[0111] The data request is sent to the priority thread pool corresponding to the target model level.

[0112] In a possible embodiment, the device further includes:

[0113] The cache module is used to detect whether the number of data requests in the preset priority thread pool reaches the preset concurrency threshold; when the number of data requests in the preset priority thread pool reaches the preset concurrency threshold, the data request is stored in the cache queue.

[0114] In a possible embodiment, the preset concurrency threshold is pre-set for each computer room and model level; the cache module is used to detect whether the target computer room corresponding to the data request and the data request volume in the preset priority thread pool have reached the preset concurrency threshold;

[0115] When the amount of data requests in the target computer room or the amount of data requests in the preset priority thread pool reaches the preset concurrency threshold, the data requests are stored in a cache queue.

[0116] Among them, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in the present invention are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0117] An exemplary embodiment of the present invention further provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor. The memory stores a computer program executable by the at least one processor, wherein the computer program, when executed by the at least one processor, causes the electronic device to perform a method according to an embodiment of the present invention.

[0118] Exemplary embodiments of the present invention further provide a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to perform a method according to an embodiment of the present invention.

[0119] An exemplary embodiment of the present invention further provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor of a computer, the computer is configured to cause the computer to perform a method according to an embodiment of the present invention.

[0120] refer to Figure 4 , a block diagram of an electronic device 400 that can serve as a server or client of the present invention will now be described, which is an example of a hardware device that can be applied to various aspects of the present invention. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0121] like Figure 4 As shown, electronic device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. Various programs and data required for the operation of electronic device 400 can also be stored in RAM 403. Computing unit 401, ROM 402, and RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to bus 404.

[0122] Multiple components within electronic device 400 are connected to I / O interface 405, including an input unit 406, an output unit 407, a storage unit 408, and a communication unit 409. Input unit 406 can be any type of device capable of inputting information into electronic device 400. Input unit 406 can receive input numeric or character information and generate key input signals related to user settings and / or function control of the electronic device. Output unit 407 can be any type of device capable of presenting information and may include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. Storage unit 408 may include, but is not limited to, a magnetic disk or an optical disk. Communication unit 409 allows electronic device 400 to exchange information / data with other devices via computer networks such as the Internet and / or various telecommunication networks and may include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver and / or a chipset, such as a Bluetooth™ device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0123] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above. For example, in some embodiments, the above-mentioned data forwarding method may be implemented as a computer software program that is tangibly included in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 400 via the ROM 402 and / or the communication unit 409. In some embodiments, the computing unit 401 may be configured to perform the above-mentioned data forwarding method in any other appropriate manner (e.g., by means of firmware).

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

[0125] In the context of the present invention, machine-readable medium can be a tangible medium that can contain or store a program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0126] As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., a magnetic disk, an optical disk, a memory, a programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including machine-readable media that receive machine instructions as machine-readable signals. The term "machine-readable signal" refers to any signal used to provide machine instructions and / or data to a programmable processor.

[0127] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0128] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0129] Computer systems may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The client and server relationship arises through computer programs running on the respective computers and having a client-server relationship to each other.

Claims

1. A data request forwarding method, characterized in that: The method comprises: Obtaining a data request and establishing a persistent connection with the sender of the data request; Utilize the first boss thread to poll each first data channel, and if there is a data request in the first data channel, send the data request to the first worker thread; Parsing the data request using the first worker thread to obtain business scenario information of the data request, the business scenario information including a business identifier to which the data request belongs, an identifier of a target processing model for the data request, and an identifier of a target machine for processing the data request; According to the business scenario information of the data request, the data request is sent to a preset priority thread pool, and the data request is sent to the second data channel in sequence, and the corresponding relationship between the second data channel and the long connection information is stored; Utilize the second boss thread to poll the second data channel, and when there is a data request in the second data channel, send the data request to the target machine according to the business scenario information; Obtain the processing result returned by the target machine, determine the persistent connection corresponding to the data request based on the corresponding relationship, and send the processing result to the sender through the persistent connection.

2. The method according to claim 1, characterized in that The priority thread pool is pre-set for model levels of different processing models, and sending the data request to the preset priority thread pool according to the business scenario information of the data request includes: Determining the target model level corresponding to the target processing model based on a preset model level classification rule; The data request is sent to the priority thread pool corresponding to the target model level.

3. The method according to claim 1, characterized in that The method further comprises: Detecting whether the number of data requests in the preset priority thread pool reaches a preset concurrency threshold; When the number of data requests in the preset priority thread pool reaches a preset concurrency threshold, the data requests are stored in a cache queue.

4. The method according to claim 3, characterized in that The preset concurrency threshold is pre-set for each computer room and model level; the method further includes: Detecting whether the target computer room corresponding to the data request and the amount of data requests in the preset priority thread pool have reached the preset concurrency threshold; When the amount of data requests in the target computer room or the amount of data requests in the preset priority thread pool reaches the preset concurrency threshold, the data requests are stored in a cache queue.

5. A data request forwarding device, characterized in that: The device comprises: A first acquisition module is used to obtain a data request and establish a persistent connection with the sender of the data request; A first polling module is configured to poll each first data channel using a first boss thread, and if a data request exists in the first data channel, send the data request to a first worker thread; a parsing module, configured to parse the data request using the first worker thread to obtain business scenario information of the data request, the business scenario information including a business identifier to which the data request belongs, an identifier of a target processing model for the data request, and an identifier of a target machine for processing the data request; A sending module, configured to send the data request to a preset priority thread pool according to the business scenario information of the data request, send the data request to the second data channel in sequence, and store the corresponding relationship between the second data channel and the long connection information; a second polling module, configured to poll the second data channel using a second boss thread, and, if a data request exists in the second data channel, send the data request to a target machine according to the business scenario information; The second acquisition module is used to obtain the processing result returned by the target machine, determine the long connection corresponding to the data request based on the corresponding relationship, and send the processing result to the sender through the long connection.

6. The device according to claim 5, characterized in that The priority thread pool is pre-set for model levels of different processing models, and sending the data request to the preset priority thread pool according to the business scenario information of the data request includes: Determining the target model level corresponding to the target processing model based on a preset model level classification rule; The data request is sent to the priority thread pool corresponding to the target model level.

7. The device according to claim 5, characterized in that The device further comprises: The cache module is used to detect whether the number of data requests in the preset priority thread pool reaches the preset concurrency threshold; when the number of data requests in the preset priority thread pool reaches the preset concurrency threshold, the data request is stored in the cache queue.

8. The device according to claim 7, characterized in that The preset concurrency threshold is pre-set for each computer room and model level; the cache module is used to detect whether the target computer room corresponding to the data request and the data request volume in the preset priority thread pool have reached the preset concurrency threshold; When the amount of data requests in the target computer room or the amount of data requests in the preset priority thread pool reaches the preset concurrency threshold, the data requests are stored in a cache queue.

9. An electronic device comprising: processor; as well as Memory for storing programs, The program includes instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 4.

10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 4.