Service flow limiting method, related device and service flow limiting system

CN120378492AInactive Publication Date: 2025-07-25FLYING FOX INFORMATION TECH TIANJIN CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510858685.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-25
Publication Date
2025-07-25
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

[0003]有鉴于此,本申请提供了一种业务限流方法、相关装置及业务限流系统,用以解决大量并发的用户请求瞬间涌入导致业务服务器因无法承受巨大压力而崩溃的问题,其技术方案如下:

Benefits of technology

[0038] By means of the above technical solution, the business traffic limiting method provided by this application first adopts the reactive framework webFlux to receive user requests for the target business forwarded by the gateway server, and then performs duplicate removal and statistical processing on the received user requests, and sends valid user requests that do not exceed the preset request quantity threshold to the business server for processing the target business. In view of the characteristic of instantaneous high concurrency of the target business, the business traffic limiting method provided by this application uses the webFlux framework that supports a large number of concurrent requests to receive a large number of high-concurrency user requests. Considering that there are duplicate user requests among a large number of high-concurrency user requests, the business traffic limiting method provided by this application performs duplicate removal processing on the received user requests, that is, filters out duplicate user requests. Considering that the target business is a business involving competition for limited resources, the business traffic limiting method provided by this application counts valid user requests (that is, non-duplicate user requests), sends valid user requests that do not exceed the preset request quantity threshold to the business server for processing, and filters out valid user requests that exceed the preset request quantity threshold. Through the above strategy, the pressure on the business server can be effectively reduced, so as to ensure the stable operation of the business server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120378492A_ABST
    Figure CN120378492A_ABST
Patent Text Reader

Abstract

The invention discloses a service flow limiting method, a related device and a service flow limiting system, and relates to the technical field of high-concurrency request processing, and the service flow limiting method comprises the steps: employing a response type framework webFlux, and receiving a user request which is forwarded by a gateway server and aims at a target service; for each received user request, judging whether the user request is a repeated user request or not; if yes, filtering out the user request; if not, determining that the user request is an effective user request, and counting the total number of the current effective user requests; if the total number of the current effective user requests is greater than a preset request number threshold, filtering the user requests; and if the total number of the current effective user requests is smaller than or equal to a preset request number threshold value, sending the user requests to a service server for processing the target service for processing. According to the business flow limiting method disclosed by the invention, the pressure of the business server can be effectively reduced, so that the stable operation of the business server can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of high-concurrency request processing, and particularly relates to a service traffic limiting method, related device, and service traffic limiting system. Background Art

[0002] Currently, there are some services with instantaneous high concurrency and involving competition for limited resources, such as red envelope grabbing services, product flash sale services, etc. For services with instantaneous high concurrency and involving competition for limited resources, a large number of clients may simultaneously send user requests to the service server that processes the service. Furthermore, the service server will receive a large number of concurrent user requests. When a large number of concurrent user requests pour in instantaneously, the service server is very likely to crash due to being unable to bear the huge pressure. Summary of the Invention

[0003] In view of this, this application provides a service traffic limiting method, related device, and service traffic limiting system to solve the problem that the service server crashes due to being unable to bear the huge pressure caused by a large number of concurrent user requests pouring in instantaneously. The technical solutions are as follows:

[0004] In the first aspect of this application, a service traffic limiting method is provided, which is applied to a service flow control server. The service traffic limiting method includes:

[0005] Adopt the reactive framework webFlux to receive user requests for the target service forwarded by the gateway server;

[0006] For each received user request, determine whether the user request is a duplicate user request;

[0007] If it is determined that the user request is a duplicate user request, determine that the user request is an invalid user request and filter out the user request;

[0008] If it is determined that the user request is a non-duplicate user request, determine that the user request is a valid user request and count the total number of current valid user requests;

[0009] If the total number of current valid user requests is greater than the preset request quantity threshold, filter out the user request;

[0010] If the total number of current valid user requests is less than or equal to the preset request quantity threshold, send the user request to the service server that processes the target service so that the service server can process the user request.

[0011] In a possible implementation manner, the service traffic limiting method further includes:

[0012] Receive the processing result of the service server for the user request;

[0013] Send the processing result of the user request to the initiator of the user request.

[0014] In a possible implementation, the sending the user request to the service server that processes the target service includes:

[0015] Send the user request to the service server that processes the target service through the webClient framework.

[0016] In a possible implementation, the determining whether the user request is a duplicate user request includes:

[0017] Write the request identifier of the user request into the redis database through the setnx command;

[0018] If the request identifier of the user request is successfully written into the redis database, determine that the user request is a non-duplicate user request;

[0019] If the request identifier of the user request is not successfully written into the redis database, determine that the user request is a duplicate user request.

[0020] In a possible implementation, the service traffic limiting method further includes:

[0021] If the request identifier of the user request is successfully written into the redis database, set the expiration time of the request identifier of the user request in the redis database through the ex command.

[0022] In a possible implementation, the counting the total number of current valid user requests includes:

[0023] After determining that the user request is a valid user request, send an incrBy command carrying the target service identifier to the redis database, where the incrBy command is used to increment the value of the key-value pair with the target service identifier as the key in the redis database, and the target service identifier is obtained by concatenating a set prefix in front of the service identifier of the target service.

[0024] The second aspect of this application provides a service traffic limiting device, which is applied to a service flow control server. The service traffic limiting device includes: a user request receiving module, a first user request filtering module, a total number of valid user requests counting module, a second user request filtering module, and a user request sending module;

[0025] The user request receiving module is used to receive, by using the reactive framework webFlux, the user request for the target service forwarded by the gateway server;

[0026] The first user request filtering module is configured to determine, for each user request received by the user request receiving module, whether the user request is a duplicate user request. If it is determined that the user request is a duplicate user request, the user request is determined to be an invalid user request and filtered out. If it is determined that the user request is not a duplicate user request, the user request is determined to be a valid user request;

[0027] The valid user request total quantity statistical module is configured to count the current total quantity of valid user requests when the first user request filtering module determines that the user request is a valid user request;

[0028] The second user request filtering module is configured to filter out the user request when the current total quantity of valid user requests is greater than a preset request quantity threshold;

[0029] The user request sending module is configured to send the user request to the service server that processes the target service when the current total quantity of valid user requests is less than or equal to the preset request quantity threshold, so that the service server processes the user request.

[0030] A third aspect of the present application provides an electronic device, including at least one processor and a memory connected to the processor, wherein:

[0031] The memory is used to store a computer program;

[0032] The processor is configured to execute the computer program so that the electronic device can implement the steps of any of the above service traffic limiting methods.

[0033] A fourth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the steps of any of the above service traffic limiting methods.

[0034] A fifth aspect of the present application provides a service traffic limiting system, including: a gateway server, a service flow control server, and a service server that processes the target service;

[0035] The gateway server is configured to receive user requests for the target service and forward the received user requests to the service flow control server;

[0036] The business flow control server is used to receive user requests forwarded by the gateway server by adopting the reactive framework webFlux. For each received user request, it determines whether the user request is a duplicate user request. If it is determined that the user request is a duplicate user request, it determines that the user request is an invalid user request and filters out the user request. If it is determined that the user request is not a duplicate user request, it determines that the user request is a valid user request, counts the total number of current valid user requests. If the total number of current valid user requests is greater than the preset request quantity threshold, it filters out the user request. If the total number of current valid user requests is less than or equal to the preset request quantity threshold, it sends the user request to the business server for processing the target business;

[0037] The business server is used to receive user requests sent by the business flow control server and process the received user requests.

[0038] By means of the above technical solution, the business traffic limiting method provided by this application first adopts the reactive framework webFlux to receive user requests for the target business forwarded by the gateway server, and then performs duplicate removal and statistical processing on the received user requests, and sends valid user requests that do not exceed the preset request quantity threshold to the business server for processing the target business. In view of the characteristic of instantaneous high concurrency of the target business, the business traffic limiting method provided by this application uses the webFlux framework that supports a large number of concurrent requests to receive a large number of high-concurrency user requests. Considering that there are duplicate user requests among a large number of high-concurrency user requests, the business traffic limiting method provided by this application performs duplicate removal processing on the received user requests, that is, filters out duplicate user requests. Considering that the target business is a business involving competition for limited resources, the business traffic limiting method provided by this application counts valid user requests (that is, non-duplicate user requests), sends valid user requests that do not exceed the preset request quantity threshold to the business server for processing, and filters out valid user requests that exceed the preset request quantity threshold. Through the above strategy, the pressure on the business server can be effectively reduced, so as to ensure the stable operation of the business server. Description of the Drawings

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to the provided drawings.

[0040] Figure 1 It is a schematic diagram of a system architecture related to this application;

[0041] Figure 2 A schematic diagram of a hardware structure of a terminal provided in an embodiment of the present application;

[0042] Figure 3 A schematic diagram of a hardware structure of a server provided in an embodiment of the present application;

[0043] Figure 4 A schematic flowchart of a service traffic limiting method provided in an embodiment of the present application;

[0044] Figure 5 A schematic flowchart of determining whether a user request is a repeated user request provided in an embodiment of the present application;

[0045] Figure 6 A schematic diagram of traffic limiting for user requests of a target service provided in an embodiment of the present application;

[0046] Figure 7 A schematic diagram of the structure of a service traffic limiting device provided in an embodiment of the present application;

[0047] Figure 8 A schematic diagram of the structure of a service traffic limiting system provided in an embodiment of the present application. Detailed implementation manners

[0048] The embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application. The terms used in the implementation part of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0049] The embodiments of the present application will be described below with reference to the accompanying drawings. Those skilled in the art will know that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are equally applicable to similar technical problems.

[0050] The terms "first", "second", etc. in the specification, claims and the above-mentioned drawings of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such terms can be interchanged under appropriate circumstances, which is only a way of distinguishing when describing objects with the same attributes in the embodiments of the present application. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, so that a process, method, system, product or device including a series of units does not have to be limited to those units, but may include other units not clearly listed or inherent to these process, method, product or device.

[0051] In one possible implementation manner, such as Figure 1As shown, the system architecture involved in this application may include several terminals 101 and a server 102. The several terminals 101 can interact with the server 102 through a network (wired network or wireless network). Among them, the server 102 may include one or more servers ( Figure 1 Including a server as an example for illustration). The several terminals 101 can initiate user requests to the server 102. The server 102 can process the user requests and can feedback the processing results of the user requests to the terminals that initiate the user requests.

[0052] The above terminals can be mobile phones, tablet computers, wearable devices, in-vehicle devices, robots, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), etc. The embodiments of this application do not impose any restrictions on this.

[0053] Figure 2 Shows an optional schematic diagram of the hardware structure of the terminal.

[0054] Refer to Figure 2 As shown, the terminal may include a radio frequency unit 210, a memory 220, an input unit 230, a display unit 240, a camera 250 (optional), an audio circuit 260 (optional), a speaker 261 (optional), a microphone 262 (optional), a headphone jack 263 (optional), a processor 270, an external interface 280, a power supply 290, and other components. Those skilled in the art can understand that Figure 2 This is only an example of the terminal and does not constitute a limitation on the terminal. It may include more or fewer components than shown in the figure, or combine certain components, or different components.

[0055] The input unit 230 can be used to receive input numerical or character information and generate key signal inputs related to the user settings and function control of the terminal. Specifically, the input unit 230 can include a touch screen 231 (optional) and / or other input devices 232. The touch screen 231 can collect touch operations of the user thereon or nearby (such as operations of the user using any suitable object such as a finger, a joint, a stylus, etc. on or near the touch screen), and drive corresponding connection devices according to a preset program. The touch screen can detect the touch action of the user on the touch screen, convert the touch action into a touch signal and send it to the processor 270, and can receive and execute the command sent by the processor 270; the touch signal at least includes contact coordinate information. The touch screen 231 can provide an input interface and an output interface between the terminal and the user. In addition, multiple types such as resistive, capacitive, infrared, and surface acoustic wave can be used to implement the touch screen. In addition to the touch screen 231, the input unit 230 can also include other input devices. Specifically, the other input devices 232 can include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.

[0056] The display unit 240 can be used to display information input by the user or information provided to the user, various menus of the terminal, an interactive interface, file display, and / or the playback of any multimedia file.

[0057] The memory 220 can be used to store instructions and data. The memory 220 mainly includes a storage instruction area and a storage data area. The storage data area can store various data such as multimedia files, texts, etc.; the storage instruction area can store software units such as an operating system, applications, instructions required for at least one function, or their subsets, extended sets. It can also include a non-volatile random access memory; it provides the processor 270 with management of the hardware, software, and data resources in the computing processing device, supports control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.

[0058] The processor 270 is the control center of the terminal. It connects various parts of the entire terminal using various interfaces and lines. By running or executing instructions stored in the memory 220 and invoking data stored in the memory 220, it performs various functions of the terminal and processes data, thereby exercising overall control over the terminal. Optionally, the processor 270 may include one or more processing units; preferably, the processor 270 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communications. It can be understood that the above-mentioned modem processor may not be integrated into the processor 270 either. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be separately implemented on independent chips. The processor 270 can also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process the data and programs in the memory 220, so that each functional module therein executes corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.

[0059] Among them, the memory 220 can be used to store software codes related to the service traffic limiting method. The processor 270 can execute the software codes in the memory 220 or can also schedule other units (such as the above-mentioned input unit 230 and display unit 240) to implement corresponding functions.

[0060] The radio frequency unit 210 (optional) can be used for receiving and sending information or signals during a call. For example, after receiving the downlink information of the base station, it is given to the processor 270 for processing; in addition, it sends the designed uplink data to the base station. Generally, the radio frequency unit 210 includes but is not limited to antennas, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the radio frequency unit 210 can also communicate with network devices and other devices through wireless communication. This wireless communication can use any communication standard or protocol, including but not limited to the Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.

[0061] Among them, in the embodiments of the present application, the radio frequency unit 210 can send data to other devices and can also receive data sent by other devices. It should be understood that the radio frequency unit 210 is optional and can be replaced by other communication interfaces, such as a network interface.

[0062] The terminal further includes a power supply 290 (such as a battery) for powering each component. Preferably, the power supply can be logically connected to the processor 270 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system.

[0063] The terminal further includes an external interface 280. The external interface can be a standard Micro USB interface or a multi-pin connector, and can be used to connect the terminal to other devices for communication and can also be used to connect a charger to charge the terminal.

[0064] Although not shown, the terminal may further include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which will not be elaborated here.

[0065] Next, the product form of the above server will be described.

[0066] Figure 3 A schematic structural diagram of the above server is provided, as Figure 3 shown, the server may include a bus 301, a processing device 302, a communication interface 303, and a storage device 304. The processing device 302, the storage device 304, and the communication interface 303 communicate with each other through the bus 301.

[0067] The bus 301 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 3 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.

[0068] The processing device 302 can be any one or more of processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0069] The storage device 304 can include volatile memory, such as random access memory (RAM). The storage device 304 can also include non-volatile memory, such as read-only memory (ROM), flash memory, a hard disk drive (HDD), or a solid state drive (SSD).

[0070] The storage device 304 can be used to store software code related to the service traffic limiting method. The processing device 302 can call the software code stored in the storage device 304 or schedule other units to implement corresponding functions.

[0071] The processor 270 in the above terminal and the processing device 302 in the server can be hardware circuits (such as an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, etc.), or a combination of these hardware circuits. For example, it can be a hardware system with the function of executing instructions, such as a CPU, a DSP, etc., or a hardware system without the function of executing instructions, such as an ASIC, an FPGA, etc., or a combination of the above hardware systems without the function of executing instructions and hardware systems with the function of executing instructions.

[0072] The business server for processing target services (services with instantaneous high concurrency and involving competition for limited resources) processes user requests for the target service through the deployed business service. For example, the business server for processing the red envelope grabbing service processes users' red envelope grabbing requests through the deployed red envelope service. The current business service (such as the red envelope service) is based on the Spring MVC framework. To address the problem that a large number of concurrent user requests suddenly flooding in can cause the business server to crash due to the inability to withstand the huge pressure, one current solution is to transform the framework of the business service deployed on the business server into the WebFlux framework. However, the cost and cycle for transforming the framework of the business service from the Spring MVC framework to the WebFlux framework are relatively high, and there are risks. Another current solution is to introduce a filter (Filter) for traffic limiting in the business service (such as the red envelope service). However, introducing the filter requires modifying the original code, and the original code is based on the Spring MVC framework. There is still a bottleneck in service thread resources during high-concurrency requests, and it cannot effectively solve the problem that a large number of concurrent user requests suddenly flooding in can cause the business server to crash.

[0073] In view of the above problems, this application provides a business traffic limiting method with good effects. This business traffic limiting method can effectively solve the problem that a large number of concurrent user requests suddenly flooding in can cause the business server to crash, and it does not require modifying the framework of the business service deployed on the business server, nor does it require modifying the original code of the business service. Next, the business traffic limiting method provided by this application will be introduced through the following embodiments.

[0074] Please refer to Figure 4 , which shows a schematic flowchart of the business traffic limiting method provided by an embodiment of this application. This business traffic limiting method is applied to a business flow control server, and the business flow control server is deployed with a business flow control service. The business flow control server limits the traffic for the target service through the business flow control service. This business traffic limiting method may include:

[0075] Step S401: Use the reactive framework webFlux to receive the user request for the target service forwarded by the gateway server.

[0076] In the embodiment of this application, the target service is a service with instantaneous high concurrency and involving competition for limited resources. For example, the red envelope grabbing service, the product flash sale service, and so on.

[0077] In the embodiment of this application, the user request for the target service carries a user ID and a service ID of the target service. Exemplarily, when the target service is the red envelope grabbing service, the user request for the target service is a red envelope grabbing request carrying a user account and a red envelope order number.

[0078] In the embodiment of the present application, a user request for a target service is initiated by a client. The user request initiated by the client is forwarded to a service flow control server through a gateway server. The service flow control service deployed on the service flow control server uses the reactive framework webFlux to receive the user request forwarded by the gateway server.

[0079] Exemplarily, the target service is a red envelope grabbing service. When a user clicks on a red envelope on the client, the client will initiate a red envelope grabbing request containing the user ID and the red envelope ID. The red envelope grabbing request is forwarded to the service flow control server through the gateway service. The service flow control service deployed on the service flow control server uses the reactive framework webFlux to receive the red envelope grabbing request forwarded by the gateway server.

[0080] It should be noted that WebFlux is a reactive programming framework introduced in Spring Framework 5, which is at the same level as Spring MVC and is designed to handle non-blocking applications with high concurrency and low latency. Given that WebFlux is more suitable for high-concurrency I / O scenarios, the embodiment of the present application uses the reactive framework webFlux to receive a large number of high-concurrency user requests forwarded by the gateway server.

[0081] In addition, it should be noted that the gateway server deploys a gateway service. The gateway server can forward the user request initiated by the client through the gateway service. In the existing solution, the gateway server forwards the user request initiated by the client to the service server that processes the target service through the gateway service. However, in the present application, the gateway service is pre-configured so that the gateway service forwards the user request initiated by the client to the service flow control service deployed on the service flow control server.

[0082] Step S402: For each received user request, determine whether the user request is a duplicate user request.

[0083] For a target service involving the contention for limited resources, the user requests for the target service usually include duplicate user requests. For example, for the red envelope grabbing service, a user may click on the red envelope multiple times, and thus initiate duplicate user requests. If these duplicate user requests are sent to the service server, it will cause meaningless pressure on the service server. In view of this, as Figure 5 shown, this embodiment performs deduplication processing on the received user requests, so that the duplicate user requests are no longer sent to the service server for processing, thereby reducing the pressure on the service server.

[0084] Step S403a: If it is determined that the user request is a duplicate user request, determine that the user request is an invalid user request and filter out the user request.

[0085] For repeated user requests, this embodiment filters them out as invalid user requests to reduce the pressure on the service server.

[0086] Optionally, when determining that the user request is a repeated user request, indication information indicating that the user request is an invalid user request can be fed back to the initiator of the user request.

[0087] Step S403b: If it is determined that the user request is a non-repeated user request, then determine that the user request is a valid user request and count the total number of current valid user requests.

[0088] For non-repeated user requests, this embodiment treats them as valid user requests. Each time a valid user request is determined, the total number of current valid user requests is counted.

[0089] Step S404b-a: If the total number of current valid user requests is greater than the preset request quantity threshold, then filter out the user request.

[0090] For a target service involving contention for limited resources, if the excessive valid user requests are handed over to the service server for processing, it will bring meaningless pressure to the service server.

[0091] Taking the red envelope grabbing service as an example, a red envelope can be grabbed by at most 150 people. This means that, in order, the valid red envelope grabbing requests exceeding 150 will not be able to grab the red envelope. If the valid red envelope grabbing requests exceeding 150 are handed over to the service server for processing, it will bring meaningless pressure to the service server.

[0092] In view of this, as Figure 5 shown, this embodiment counts the total number of current valid user requests. If the total number of current valid user requests is greater than the preset request quantity threshold, then filter out the valid user requests exceeding the preset request quantity threshold to avoid imposing meaningless pressure on the service server.

[0093] Exemplarily, the target service is the red envelope grabbing service. Given that a red envelope can be grabbed by at most 150 people, the request quantity threshold can be preset to 150. In actual applications, considering certain influencing factors, quantity redundancy can be carried out. For example, the request quantity threshold is preset to 200. If the total number of current valid red envelope grabbing requests is greater than 200, the valid red envelope grabbing requests exceeding 200 can be filtered out.

[0094] Optionally, if the total number of current valid user requests is greater than the preset request quantity threshold, indication information indicating that the resources have been completely grabbed can be fed back to the initiator of the user request. Taking the red envelope grabbing service as an example, indication information indicating that the red envelope has been completely grabbed is fed back to the initiator of the valid red envelope grabbing requests exceeding the preset request quantity threshold.

[0095] Step S404b-b: If the current total number of valid user requests is less than or equal to the preset request quantity threshold, send the user request to the business server that processes the target service, so that the business server can process the user request.

[0096] For valid user requests that do not exceed the preset request quantity threshold, in this embodiment, they are sent to the business server that processes the target service. After receiving the valid user request, the business server processes the received valid user request and sends the processing result of the valid user request to the service flow control server.

[0097] When sending the valid user request to the business server that processes the target service, the valid user request can be sent to the business server that processes the target service through the webClient framework. It should be noted that WebClient is a non-blocking and reactive HTTP client provided by WebFlux for initiating HTTP requests and processing responses.

[0098] The service traffic limiting method provided by the embodiment of the present application may further include: receiving the processing result of the user request from the business server that processes the target service; sending the processing result of the user request to the initiator of the user request.

[0099] The service traffic limiting method provided by the embodiment of the present application first uses the reactive framework webFlux to receive user requests for the target service forwarded by the gateway server, and then performs deduplication and statistical processing on the received user requests, and sends valid user requests that do not exceed the preset request quantity threshold to the business server that processes the target service for processing. In view of the characteristic of instantaneous high concurrency of the target service, the service traffic limiting method provided by the embodiment of the present application uses the webFlux framework that supports a large number of concurrent requests to receive a large number of high-concurrency user requests. Considering that there are duplicate user requests among a large number of high-concurrency user requests, the service traffic limiting method provided by the embodiment of the present application performs deduplication processing on the received user requests, that is, filters out duplicate user requests. Considering that the resources involved in the target service are limited (for example, the red envelopes in the red envelope grabbing service can only be grabbed by 150 people at most), the service traffic limiting method provided by the embodiment of the present application performs statistics on valid user requests (non-duplicate user requests), and sends valid user requests that do not exceed the preset request quantity threshold to the business server that processes the target service, while filtering out valid user requests that exceed the preset request quantity threshold. Through the above strategy, the pressure on the business server can be effectively reduced, thereby ensuring the stable operation of the business server.

[0100] As mentioned in the above embodiments, in order to reduce the pressure on the service server, duplicate removal processing is performed on the received user requests. When performing duplicate removal processing on the received user requests, it is necessary to determine whether each received user request is a duplicate user request. In another embodiment of the present application, the specific implementation process of determining whether a user request is a duplicate user request is introduced.

[0101] Please refer to Figure 6 , which shows a schematic flow diagram for determining whether a user request is a duplicate user request, and may include:

[0102] Step S601: Write the request identifier of the user request into the redis database through the setnx command.

[0103] Specifically, send a setnx command carrying the request identifier of the user request to the redis database. Among them, the request identifier of the user request includes the user ID and the service ID of the target service.

[0104] It should be noted that the redis database is a high-performance key-value storage system. The setnx command is used to set key-value pairs, and the setting operation will only be executed when the key does not exist.

[0105] When writing the request identifier of the user request into the redis database through the setnx command, use the request identifier of the user request as the specified key, and set the specified key in the redis database through the setnx command. If the specified key already exists in the redis database, the setnx command will not perform any operation. If the specified key does not exist in the redis database, the setnx command will set the specified key in the redis database.

[0106] Step S602a: If the request identifier of the user request is successfully written into the redis database, it is determined that the user request is a non-duplicate user request.

[0107] After sending a setnx command carrying the request identifier of the user request to the redis database, the execution result of the setnx command will be obtained. If the execution result of the setnx command indicates that the setnx command is executed successfully, it means that the request identifier of the user request does not exist in the redis database, and the request identifier of the user request is successfully written into the redis database as a key, that is, the user request is a non-duplicate user request.

[0108] Step S602b: If the request identifier of the user request is not successfully written into the redis database, it is determined that the user request is a duplicate user request.

[0109] If the execution result of the SETNX command indicates that the SETNX command fails to execute, it means that the request identifier requested by the user exists in the Redis database, and the SETNX command does not perform any operation, that is, this user request is a duplicate user request.

[0110] It should be noted that the execution result of the SETNX command is 0 or 1. If the SETNX command is successfully executed, the execution result of the SETNX command is 1. If the SETNX command fails to execute, the execution result of the SETNX command is 0. If the execution result of the SETNX command is 1, it can be determined that this user request is a non-duplicate user request. If the execution result of the SETNX command is 0, it can be determined that this user request is a duplicate user request.

[0111] When sending the SETNX command carrying the request identifier of this user request to the Redis database, the EX command carrying the expiration time can be sent to the Redis database. If the request identifier of this user request is successfully written into the Redis database as a key, the expiration time of the request identifier of this user request in the Redis database can be set through the EX command.

[0112] Exemplarily, the request identifier of a user request is successfully written into the Redis database as a key, and the expiration time is 5s. The expiration time of the request identifier of this user request in the Redis database is set to 5s through the EX command. Setting the expiration time of the request identifier of this user request to 5s means that the request identifier of this user request exists in the Redis database for 5s. During this period, if a user request with the same request identifier is received, it is considered that this user request is a duplicate user request and is filtered out.

[0113] As mentioned in the above embodiment, for a received user request, when it is determined that this user request is a valid user request, the total number of current valid user requests will be counted.

[0114] In a possible implementation manner, the process of counting the total number of current valid user requests may include: after determining that this user request is a valid user request, sending the INCRBY command carrying the target service identifier to the Redis database.

[0115] Wherein, the target service identifier is obtained by concatenating a set prefix in front of the service identifier of the target service, and the INCRBY command is used to increment the value of the key-value pair with the target service identifier as the key in the Redis database by 1.

[0116] A key-value pair with the target service identifier as the key can be set in the Redis database. The initial value of this key-value pair can be 0. For each determined valid user request, the value of the key-value pair with the target service identifier as the key can be incremented by 1 using the INCRBY command. In this way, the value of the key-value pair with the target service identifier as the key in the Redis database is the total number of current valid user requests.

[0117] The above describes the service traffic limiting method provided by the embodiments of the present application. The following will introduce the device for implementing the above service traffic limiting method.

[0118] Please refer to Figure 7 , Figure 7 FIG. 10 is a schematic structural diagram of a service traffic limiting device provided by an embodiment of the present application. The service traffic limiting device is applied to a service flow control server. The service traffic limiting device may include: a user request receiving module 701, a first user request filtering module 702, a total number of valid user requests statistics module 703, a second user request filtering module 704, and a user request sending module 705.

[0119] The user request receiving module 701 is configured to receive, by using the reactive framework WebFlux, user requests for the target service forwarded by the gateway server.

[0120] The first user request filtering module 702 is configured to, for each user request received by the user request receiving module, determine whether the user request is a duplicate user request. If it is determined that the user request is a duplicate user request, it is determined that the user request is an invalid user request and the user request is filtered out. If it is determined that the user request is a non-duplicate user request, it is determined that the user request is a valid user request.

[0121] The total number of valid user requests statistics module 703 is configured to, when the first user request filtering module determines that the user request is a valid user request, count the total number of current valid user requests.

[0122] The second user request filtering module 704 is configured to filter out the user request when the total number of current valid user requests is greater than a preset request quantity threshold.

[0123] The user request sending module 705 is configured to send the user request to the service server that processes the target service when the total number of current valid user requests is less than or equal to a preset request quantity threshold, so that the service server processes the user request.

[0124] In a possible implementation manner, the service traffic limiting device may further include: a request processing result receiving module and a request processing result sending module.

[0125] A request processing result receiving module, configured to receive the processing result of the service server for the user request.

[0126] A request processing result sending module, configured to send the processing result of the user request to the initiator of the user request.

[0127] In a possible implementation manner, when the user request sending module 705 sends the user request to the service server for processing the target service, it is specifically configured to:

[0128] Send the user request to the service server for processing the target service through the webClient framework.

[0129] In a possible implementation manner, when the first user request filtering module 702 determines whether the user request is a duplicate user request, it is specifically configured to:

[0130] Write the request identifier of the user request into the redis database through the setnx command;

[0131] If the request identifier of the user request is successfully written into the redis database, it is determined that the user request is a non-duplicate user request;

[0132] If the request identifier of the user request is not successfully written into the redis database, it is determined that the user request is a duplicate user request.

[0133] In a possible implementation manner, the service traffic limiting device may further include: an expiration time setting module.

[0134] The expiration time setting module is configured to, when the request identifier of the user request is successfully written into the redis database, set the expiration time of the request identifier of the user request in the redis database through the ex command.

[0135] In a possible implementation manner, when the total number of valid user requests statistics module 7036 statistics the current total number of valid user requests, it is specifically configured to:

[0136] After determining that the user request is a valid user request, send an incrBy command carrying the target service identifier to the redis database, where the incrBy command is used to increment the value of the key-value pair with the target service identifier as the key in the redis database by 1, and the target service identifier is obtained by concatenating a set prefix in front of the service identifier of the target service.

[0137] In view of the characteristic of instantaneous high concurrency of the target service, the service traffic limiting device provided by the embodiment of the present application uses the webFlux framework that supports a large number of concurrent requests to receive a large number of high-concurrency user requests. Considering that there are duplicate user requests among the large number of high-concurrency user requests, the service traffic limiting device provided by the embodiment of the present application performs deduplication processing on the received user requests, that is, filters out the duplicate user requests. Considering that the resources involved in the target service are limited (for example, the red envelopes in the red envelope grabbing service can only be grabbed by 150 people at most), the service traffic limiting device provided by the embodiment of the present application counts the valid user requests (non-duplicate user requests), sends the valid user requests that do not exceed the preset request quantity threshold to the service server for processing the target service, and filters out the valid user requests that exceed the preset request quantity threshold. Through the above strategy, the pressure on the service server can be effectively reduced, so as to ensure the stable operation of the service server.

[0138] The embodiment of the present application also provides an electronic device, which may include: at least one processor and a memory connected to the processor.

[0139] Wherein, the memory is used to store a computer program, and the processor is used to execute the computer program so that the electronic device can implement the steps of the service traffic limiting method provided by the above embodiment.

[0140] The embodiment of the present application also provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can be enabled to implement the steps of the service traffic limiting method provided by the above embodiment.

[0141] The embodiment of the present application also provides a computer program product, including computer-readable instructions. When the computer-readable instructions run on an electronic device, the electronic device is enabled to implement the steps of the service traffic limiting method provided by the above embodiment.

[0142] The embodiment of the present application also provides a service traffic limiting system, as Figure 8 shown, the service traffic limiting system may include: a gateway server 801, a service flow control server 802, and a service server 803 for processing the target service.

[0143] The gateway server 801 is used to receive user requests for the target service and forward the received user requests to the service flow control server 802.

[0144] The service flow control server 802 is used to receive user requests forwarded by the gateway server 801 by adopting the reactive framework webFlux. For each received user request, it determines whether the user request is a duplicate user request. If it is determined that the user request is a duplicate user request, it determines that the user request is an invalid user request and filters out the user request. If it is determined that the user request is a non-duplicate user request, it determines that the user request is a valid user request, counts the total number of current valid user requests. If the total number of current valid user requests is greater than the preset request quantity threshold, it filters out the user request. If the total number of current valid user requests is less than or equal to the preset request quantity threshold, it sends the user request to the service server 803 for processing the target service.

[0145] The service server 803 is used to receive user requests sent by the service flow control server 802 and process the received user requests.

[0146] The gateway server 801 can configure the gateway service. The gateway server 801 can forward user requests for the target service to the service flow control server 802 through the gateway service. The service flow control server 802 can configure the service flow control service. The service flow control server 802 receives user requests forwarded by the gateway server 801 through the service flow control service, and filters out invalid user requests, counts valid user requests, and filters valid user requests exceeding the request quantity threshold for the received user requests. The service server 803 can configure the service. The service server 803 processes the valid user requests filtered by the service flow control service through the service.

[0147] The service server 803 is also used to send the processing result of the received user request to the service flow control server 802.

[0148] The service flow control server 802 is also used to receive the processing result of the user request from the service server 803 and send the processing result of the user request to the initiator of the user request.

[0149] When the service flow control server 802 sends a user request to the service server 803 for processing the target service, it is specifically used to send the user request to the service server 803 for processing the target service through the webClient framework.

[0150] When the service flow control server 802 determines whether a user request is a duplicate user request, it is specifically used to write the request identifier of the user request into the redis database through the setnx command. If the request identifier of the user request is successfully written into the redis database, it is determined that the user request is a non-duplicate user request. If the request identifier of the user request is not successfully written into the redis database, it is determined that the user request is a duplicate user request.

[0151] The traffic control server 802 is further configured to, when the request identifier of the user request is successfully written into the Redis database, set the expiration time of the request identifier of the user request in the Redis database through the EX command.

[0152] When the traffic control server 802 counts the total number of current valid user requests, it is specifically configured to send an INCRBY command carrying the target service identifier to the Redis database after determining that the user request is a valid user request. The INCRBY command is used to increment the value of the key-value pair with the target service identifier as the key in the Redis database by 1. The target service identifier is obtained by concatenating a set prefix in front of the service identifier of the target service.

[0153] In addition, it should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the attached drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that they have a communication connection, which can be specifically implemented as one or more communication buses or signal lines.

[0154] Through the description of the above embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by means of dedicated hardware including application-specific integrated circuits, dedicated CPUs, dedicated memories, dedicated components, etc. Generally, functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structures used to implement the same function can also be various, such as analog circuits, digital circuits or dedicated circuits. However, for this application, in more cases, software program implementation is a better implementation method. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disc of a computer, and includes several instructions for causing a computer device (which can be a personal computer, training device, or network device, etc.) to execute the methods described in various embodiments of this application.

[0155] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product.

[0156] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or a data center that includes one or more integrated available media. The available medium may be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.

Claims

1. A service traffic limiting method, characterized in that, Applied to a service flow control server, the service traffic limiting method includes: Adopting the reactive framework webFlux to receive user requests for a target service forwarded by a gateway server; For each received user request, determining whether the user request is a duplicate user request; If it is determined that the user request is a duplicate user request, determining that the user request is an invalid user request and filtering out the user request; If it is determined that the user request is not a duplicate user request, determining that the user request is a valid user request and counting the total number of current valid user requests; If the total number of current valid user requests is greater than a preset request quantity threshold, filtering out the user request; If the total number of current valid user requests is less than or equal to the preset request quantity threshold, sending the user request to a service server for processing the target service so that the service server processes the user request.

2. The service flow limiting method according to claim 1, wherein It further includes: Receiving the processing result of the service server for the user request; Sending the processing result of the user request to the initiator of the user request.

3. The service flow limiting method according to claim 1, wherein The sending the user request to a service server for processing the target service includes: Sending the user request to a service server for processing the target service through the webClient framework.

4. The service flow limiting method according to claim 1, wherein The determining whether the user request is a duplicate user request includes: Writing the request identifier of the user request into a redis database through the setnx command; If the request identifier of the user request is successfully written into the redis database, determining that the user request is not a duplicate user request; If the request identifier of the user request is not successfully written into the redis database, determining that the user request is a duplicate user request.

5. The service flow limiting method according to claim 4, wherein It further includes: If the request identifier of the user request is successfully written into the redis database, setting the expiration time of the request identifier of the user request in the redis database through the ex command.

6. The service traffic limiting method according to claim 4 or 5, characterized in that, The counting the total number of current valid user requests includes: After determining that the user request is a valid user request, sending an incrBy command carrying the target service identifier to the redis database, where the incrBy command is used to increment by 1 the value of the key-value pair in the redis database with the target service identifier as the key, and the target service identifier is obtained by concatenating a set prefix in front of the service identifier of the target service.

7. A service traffic limiting device, characterized in that, Applied to a service flow control server, the service traffic limiting device includes: a user request receiving module, a first user request filtering module, a total number of valid user requests counting module, a second user request filtering module, and a user request sending module; The user request receiving module is used to adopt the reactive framework webFlux to receive user requests for a target service forwarded by a gateway server; The first user request filtering module is configured to determine, for each user request received by the user request receiving module, whether the user request is a duplicate user request. If it is determined that the user request is a duplicate user request, the user request is determined to be an invalid user request and filtered out. If it is determined that the user request is not a duplicate user request, the user request is determined to be a valid user request; The valid user request total quantity statistics module is configured to, when the first user request filtering module determines that the user request is a valid user request, count the current total quantity of valid user requests; The second user request filtering module is configured to filter out the user request when the current total quantity of valid user requests is greater than a preset request quantity threshold; The user request sending module is configured to, when the current total quantity of valid user requests is less than or equal to the preset request quantity threshold, send the user request to the service server that processes the target service, so that the service server processes the user request.

8. An electronic device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is configured to execute the computer programs so that the electronic device can implement the steps of the service traffic limiting method described in any one of claims 1 to 6.

9. A computer storage medium, characterized in that, The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the steps of the service traffic limiting method described in any one of claims 1 to 6.

10. A service traffic limiting system, characterized in that, It includes: A gateway server, a service traffic control server, and a service server that processes the target service; The gateway server is configured to receive user requests for the target service and forward the received user requests to the service traffic control server; The service traffic control server is configured to use the reactive framework webFlux to receive the user requests forwarded by the gateway server. For each received user request, determine whether the user request is a duplicate user request. If it is determined that the user request is a duplicate user request, the user request is determined to be an invalid user request and filtered out. If it is determined that the user request is not a duplicate user request, the user request is determined to be a valid user request, count the current total quantity of valid user requests. If the current total quantity of valid user requests is greater than a preset request quantity threshold, the user request is filtered out. If the current total quantity of valid user requests is less than or equal to the preset request quantity threshold, the user request is sent to the service server that processes the target service; The service server is configured to receive the user requests sent by the service traffic control server and process the received user requests.

Citation Information

Patent Citations

  • Concurrence processing method and device for prize drawing discount activities

    CN111258768A

  • Flow limiting method and device, equipment and storage medium

    CN112799824A

  • Request processing method, request processing device and electronic equipment

    CN116962517A

  • Concurrent flow limiting method and device, computer equipment and storage medium

    CN119544619A