Business processing method and device and computer equipment
By introducing high-level tokens and general tokens into the token bucket and dynamically adjusting their generation and conversion according to the predetermined policies, the problem of indiscriminate handling of requests of different business levels in the prior art is solved, and efficient utilization of system resources and priority processing of high-priority requests are realized.
Patent Information
- Application Number
- CN202411920517.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-03-28
AI Technical Summary
The existing token bucket algorithm current limiting device does not handle requests from different service levels differently, resulting in the system resource utilization rate not high-priority requests and low-priority requests, and manual intervention and adjustment are required.
Adopt a token bucket containing high-level tokens and universal tokens, and dynamically adjust the generation and conversion of high-level tokens and universal tokens according to the predetermined token generation strategy, ensuring that high-level tokens or universal tokens are preferred to obtain high-level tokens or universal tokens and process requests.
The automatic adjustment of token generation strategy is implemented, which improves the utilization rate of system resources, ensures that high-priority requests are prioritized, and reduces the need for manual intervention.
Smart Images

Figure CN119728566A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a business processing method, device and computer equipment. Background Art
[0002] High-concurrency and high-traffic business systems are basically equipped with flow limiting devices on the entry service to protect the system from overload. Through flow limiting, the stability and responsiveness of the service can be ensured, and system crashes or long response times caused by too many requests can be avoided. The flow limiting device generally uses the token bucket algorithm. Its operating principle is that there is a token bucket with a fixed capacity to store tokens. A token generator generates tokens at a set token generation rate and fills them into the token bucket. If the token bucket is full, the token bucket will not be added. When a request arrives, the token is first obtained from the token bucket. If the token bucket has a token, a token is consumed and the request is processed; if there is no token, the request is rejected or the token is waited for. A typical token bucket algorithm flow limiting device usually has one interface, one token bucket, and one token generation rate. All requests get tokens from the same token bucket. This typical flow limiting device treats all requests equally and processes requests of different business levels without distinction. However, production business usually requires that high-level business requests need to be allocated system capabilities for processing first. To solve the above contradictions, some variant token bucket algorithm flow limiting devices have emerged in the industry, such as separating different token buckets and token generation rates according to priority. This method needs to be able to partially solve the problem of capacity tilting towards high-priority requests, but it will result in uneven busy and idle times, and the system capacity cannot be fully utilized. For example, when there are more high-priority requests and fewer low-priority requests in a certain period of time, the low-level token buckets are idle, and the high-priority cannot use the idle system capacity. Vice versa, there are fewer high-priority requests and more low-priority requests, and the low-priority cannot use the idle capacity allocated to the high-priority. The above situation sometimes forces manual intervention to adjust the token bucket ratio and token generation rate of each level to improve the utilization of system capacity, and automatic adjustment cannot be achieved. Summary of the invention
[0003] The embodiments of the present application provide a business processing method, apparatus and computer device to at least solve the technical problem in the related art that business processing efficiency is low due to a single token bucket token generation strategy.
[0004] According to one aspect of an embodiment of the present application, a business processing method is provided, including: receiving a business request, the business request at least including a business level of the business request, wherein the business levels have different processing priorities; obtaining a target token matching the business level from a token bucket based on the business level of the business request, wherein the token bucket includes a high-level token and a general token, the high-level token and the general token match business requests with a high business level, the general token only matches business requests with a low business level, and the number of the high-level tokens is determined according to a predetermined token generation strategy; and processing the business request based on the target token.
[0005] Optionally, a target token matching the service level is obtained from a token bucket based on the service level of the service request, including: when the service request is a service request of the high service level, first searching the high-level token from the token bucket to determine it as the target token; when the service request is a service request of the high service level and there is only the general token in the token bucket, determining that the general token is the target token, wherein, when the high-level token in the token bucket is not within the validity period, converting the high-level token into the general token, the validity period of the high-level token being two units of time.
[0006] Optionally, the predetermined token generation strategy is determined in the following manner: obtaining the token generation rate, the high-level token ratio, the number of the general tokens generated within a unit time, and the number of business requests with a high business level within a previous unit time; determining the number of the high-level tokens generated within a unit time based on the high-level token ratio, the number of business requests with a high business level within the previous unit time, and the token generation rate; determining the number of the general tokens generated within a unit time based on the token generation rate and the number of the high-level tokens generated within the unit time.
[0007] Optionally, the method also includes: when the number of tokens in the token bucket is less than a preset number, first placing the high-level token into the token bucket, until all the generated high-level tokens are placed in the token bucket, and then placing the general token into the token bucket until the number of tokens in the token bucket reaches the preset number or all the tokens generated in the current token generation cycle have been placed in the token bucket; when the number of tokens in the token bucket is equal to the preset number, determining that the number of tokens in the token bucket is full, and stopping placing tokens into the token bucket.
[0008] Optionally, processing the business request based on the target token includes: if the business request obtains the target token, responding to the business request and processing the target business; if the business request does not obtain the target token, returning a rejection message, wherein the rejection message is used to indicate a refusal to process the target business.
[0009] Optionally, the method further includes: obtaining the number of business requests within a unit time length; and when the number of business requests within the unit time length is greater than the token generation rate, determining that the priority of generating the high-level token is greater than the priority of generating the general token.
[0010] Optionally, the method further includes: obtaining the number of business requests within a unit time length; when the number of business requests within the unit time length is less than the token generation rate, determining that the priority of generating the high-level token is less than the priority of generating the general token.
[0011] According to another aspect of an embodiment of the present application, a business processing device is also provided, including: a receiving module, used to receive a business request, the business request at least including the business level of the business request, wherein the processing priorities of the business levels are different; an acquisition module, used to obtain a target token matching the business level from a token bucket based on the business level of the business request, wherein the token bucket includes a high-level token and a general token, the high-level token and the general token match business requests with a high business level, the general token only matches business requests with a low business level, and the number of high-level tokens generated is determined according to a predetermined token generation strategy; a processing module, used to process the business request based on the target token.
[0012] According to another aspect of the embodiment of the present application, a computer device is provided, including: a memory and a processor, wherein the memory is used to store program instructions; and the processor is connected to the memory and is used to execute the above-mentioned business processing method.
[0013] According to another aspect of the embodiments of the present application, a non-volatile storage medium is provided, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-mentioned business processing method by running the computer program.
[0014] According to another aspect of the embodiments of the present application, a computer program product is provided, including computer instructions, which implement the above-mentioned business processing method when executed by a processor.
[0015] In an embodiment of the present application, a business request is received, wherein the business request at least includes the business level of the business request, wherein the processing priorities of the business levels are different; a target token matching the business level is obtained from a token bucket based on the business level of the business request, wherein the token bucket includes a high-level token and a general token, the high-level token and the general token match business requests with high business levels, and the general token only matches business requests with low business levels, and the number of high-level tokens is determined according to a predetermined token generation strategy; the business request is processed based on the target token, thereby achieving the purpose of using the data of interest selected by the user for recommendation and avoiding the use of a large amount of training data, thereby achieving the technical effect of improving and simplifying the recommendation model training process, and then solving the technical problem of low business processing efficiency due to the single token generation strategy of the token bucket in the related technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 is a hardware structure block diagram of a computer terminal for implementing a service processing method according to an embodiment of the present application;
[0018] Figure 2 is a flow chart of a business processing method according to an embodiment of the present application;
[0019] Figure 3 is a flow chart of a token generation method according to an embodiment of the present application;
[0020] Figure 4 is a flow chart of another business processing method according to an embodiment of the present application;
[0021] Figure 5 is a flow chart of another business processing method according to an embodiment of the present application;
[0022] Figure 6 It is a structural diagram of a business processing device according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0025] The information collected in the embodiments of the present application is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or reject automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered.
[0026] In order to solve the problems existing in the related art, the embodiment of the present application provides a business processing method, which can be run on Figure 1 In the computer terminal shown, the computer terminal is explained below.
[0027] The service processing method embodiment provided in the embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal for implementing a service processing method. Figure 1As shown, the computer terminal 10 may include one or more (102a, 102b, ..., 102n are used to illustrate) processors (the processor may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions connected via a wired and / or wireless network. In addition, it may also include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, and a BUS bus. Those skilled in the art can understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0028] It should be noted that the one or more processors and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10. As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0029] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the business processing method in the embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, realizing the above-mentioned business processing method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0030] The transmission module 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission module 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission module 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0031] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 .
[0032] It should be noted that, in some optional embodiments, the above Figure 1 The computer terminal shown may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of hardware elements and software elements. It should be noted that Figure 1 This is merely one example of a particular embodiment and is intended to illustrate the types of components that may be present in the computer terminal described above.
[0033] In the above-mentioned operating environment, an embodiment of the present application provides an embodiment of a business processing method. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0034] Figure 2 is a flow chart of a business processing method according to an embodiment of the present application, such as Figure 2 As shown, the method comprises the following steps:
[0035] Step S202, receiving a service request, wherein the service request at least includes a service level of the service request, wherein the service levels have different processing priorities;
[0036] In step S202, the service level of the service request can be divided according to a predetermined division strategy, for example: according to the processing time limit of the service request, the shorter the processing time limit, the higher the service level; according to the type of service request, for example: according to the type of service request and the service level corresponding to the predetermined different types of service requests, for example: mobile phone re-calling may be classified as the highest priority service; it can also be divided according to resource consumption, for example: according to the degree of consumption of system resources during request processing. Requests with large resource consumption may be classified as higher priority to ensure their smooth execution, but at the same time, the number of concurrency needs to be controlled to avoid system overload. Requests with small resource consumption may be classified as low priority, allowing them to be executed when resources are loose. In actual application scenarios, a level is assigned to each service request, and high-level requests can obtain more processing power or faster processing speed.
[0037] Step S204, obtaining a target token matching the service level from a token bucket based on the service level of the service request, wherein the token bucket contains high-level tokens and general tokens, the high-level tokens and the general tokens match service requests of high service levels, the general tokens only match service requests of low service levels, and the number of the high-level tokens is determined according to a predetermined token generation strategy;
[0038] In step S204, the level of the high-level token is higher than that of the general token. The high-level token can only be used by requests of the level or higher than the token level. Different levels can be set.
[0039] Step S206: Process the service request based on the target token.
[0040] Through the above steps S202 to S206, by receiving a business request, the business request at least includes the business level of the business request, wherein the processing priority of the business level is different; based on the business level of the business request, a target token matching the business level is obtained from a token bucket, wherein the token bucket includes a high-level token and a general token, the high-level token and the general token match the business request of the high business level, the general token only matches the business request of the low business level, and the number of the high-level tokens is determined according to a predetermined token generation strategy; based on the target token, the business request is processed, thereby achieving the purpose of using the user's selected data of interest for recommendation and avoiding the use of a large amount of training data, thereby achieving the technical effect of improving and simplifying the training process of the recommendation model, and then solving the technical problem of low business processing efficiency due to the single token generation strategy of the token bucket in the related technology. The following is a detailed description.
[0041] In some embodiments of the present application, the specific steps of obtaining a target token matching the service level from a token bucket based on the service level of the service request are as follows: when the service request is a service request of the high service level, first search the high-level token from the token bucket to determine it as the target token; when the service request is a service request of the high service level and there is only the general token in the token bucket, determine the general token as the target token, wherein, when the high-level token in the token bucket is not within the validity period, convert the high-level token into the general token, and the validity period of the high-level token is two units of time. It should be noted that the general token is valid for a long time.
[0042] Figure 3 A schematic diagram of a token generation process is shown, such as Figure 3 As shown, it includes: step 1, setting the token generation strategy and the token bucket capacity; step 2, token generation; specifically, the predetermined token generation strategy is determined by the following method: obtaining the token generation rate, the high-level token ratio, the number of the general tokens generated within a unit time and the number of high-level business requests within the previous unit time; determining the number of the high-level tokens generated within a unit time according to the high-level token ratio, the number of high-level business requests within the previous unit time and the token generation rate; determining the number of the general tokens generated within a unit time according to the token generation rate and the number of the high-level tokens generated within the unit time.
[0043] For example, take the token generation rate as TGR, the number of high-level tokens generated per unit time as TCh, the high-level token ratio as P, the number of general tokens generated per unit time as TC0, and the number of high-level service requests in the previous unit time as Sh.
[0044] TCh=min(Sh, TGR*P), taking the smaller one between Sh and TGR*P.
[0045] TC0=TGR-TCh, TC0 is the token generation rate minus the number of high-level tokens.
[0046] It should be noted that the token generation rate is the total number of tokens generated within a unit time, and the number of service requests can be obtained through the service request counter.
[0047] Among them, the validity period of the high-level token is set to two units of time, and the validity period of the general token is long-term.
[0048] Step 3, determine whether the token bucket is full; Step 4, put the token into the token bucket, specifically, when the number of tokens in the token bucket is less than the preset number, first put the high-level token into the token bucket, until all the generated high-level tokens are put into the token bucket, then put the general token into the token bucket, until the number of tokens in the token bucket reaches the preset number or all the tokens generated in the current token generation cycle have been put into the token bucket; when the number of tokens in the token bucket is equal to the preset number, determine that the number of tokens in the token bucket is full, and stop putting tokens into the token bucket. Step 5, wait for the next token generation cycle.
[0049] It is understandable that the duration of the token generation cycle can be set according to the actual application scenario.
[0050] In some embodiments of the present application, the specific steps for processing the business request based on the target token include: if the business request obtains the target token, responding to the business request and processing the target business; if the business request does not obtain the target token, returning a rejection message, wherein the rejection message is used to indicate a refusal to process the target business.
[0051] like Figure 4 As shown, it includes: step 1, obtaining the service level of the current service request, and obtaining the service level of the current request when the service request comes in. Step 2, the request counter accumulates the number of requests, and the request counter accumulates the number of requests per unit time according to the priority level. Step 3, judging whether there is an available token, and querying whether there is an applicable token in the token bucket according to the priority level of the current request. High-priority requests can use high-level tokens or general tokens, and low-priority requests can only use general tokens. If there is an available token, execute step 6; if there is no available token, execute step 4. Step 4, judging whether there is an expired high-level token, if so, execute step 5; if not, directly execute step 8. Step 5, the expired high-level token is changed to a general token, triggering the change of the expired high-level token in the token bucket to a general token. The high-level token expires, indicating that there are surplus high-level tokens generated according to the trend of the number of requests, and it can be degraded to a general token to release the capacity to low-level requests. Step 6, obtaining a token, the current request obtains an applicable token from the token bucket according to the priority level, and the token bucket removes the obtained token accordingly. The high priority level will get the high level token first. If there is no high level token, it will get the general token. The low priority level can only get the general token. Step 7, business processing, the current request gets the token, and it can enter the business system for specific business processing. Step 8, rejection processing, if the current request cannot get the token, it will be directly rejected and the rejection result will be returned to the caller.
[0052] In some other embodiments of the present application, the priority of token generation can also be automatically adjusted, for example: the number of service requests within a unit time is obtained; when the number of service requests within the unit time is greater than the token generation rate, it is determined that the priority of generating the high-level token is greater than the priority of generating the general token. When the number of service requests within the unit time is less than the token generation rate, it is determined that the priority of generating the high-level token is less than the priority of generating the general token.
[0053] When the total request rate exceeds the current limit rate, high-level tokens will be generated first, and high-level requests will be processed first. Under the premise of meeting high-level requests, redundant capabilities can still respond to low-level requests. When the request rate drops, it will automatically resume generating general tokens to meet all levels of requests. When the system capacity supply is tight, high-level business requests will be prioritized; when the system capacity supply is sufficient, it will automatically resume meeting all levels of requests.
[0054] Specifically, when the system capacity is in short supply (high request rate), the request counter records the number of requests of each level in each unit time (for example, 1 second). When the total request rate (i.e., the sum of all level requests) is detected to exceed the flow rate (TGR), the system will pay special attention to the traffic of high-level requests. Generate high-level tokens: According to the formula TCh = min (Sh, TGR*P), the system calculates the number of high-level tokens TCh that need to be generated per unit time. Here Sh is the number of high-level requests in the previous unit time, and P is the ratio of high-level tokens during congestion. This means that under high load, the system will give priority to generating more high-level tokens to prioritize high-level requests. Processing high-priority requests: High-priority requests first try to obtain high-level tokens from the token bucket. Once the acquisition is successful, the business processing is immediately carried out, and the token is removed from the bucket to maintain the dynamic balance of the token bucket. If there are not enough high-level tokens in the token bucket and there are general tokens, the high-priority request will try to obtain the general token for processing. Convert expired high-level tokens: If the traffic of high-priority requests decreases during the validity period of the token, there may be expired high-level tokens in the token bucket. These expired tokens are automatically converted to general tokens, thereby freeing up capacity for low-level requests and improving resource utilization. Serve low-level requests: While processing high-level requests, if the system capacity is redundant (that is, there are unused general tokens in the token bucket), low-level requests can also obtain general tokens for processing. This ensures that even under high load, the system does not completely ignore low-level requests. Reduce high-level token generation when system capacity is sufficient (low request rate): When the total request rate drops below the current limit rate TGR, the system will dynamically adjust the number of high-level tokens generated according to the current request traffic, reduce their generation, and allow more general tokens to be generated. Restore general token generation: As traffic decreases, the system will return to the state of mainly generating general tokens to meet requests of all levels. This usually means that the generation ratio P of high-level tokens will be automatically reduced, or the system will no longer specifically distinguish between token types, and all tokens will be generated as general tokens. Fair allocation of resources: When the system load is low, requests of all levels can obtain enough tokens, so that they can fairly share system resources and process business.
[0055] Figure 5 Another business processing method is shown, such as Figure 5As shown, it includes: the token generator generates tokens based on the token generation strategy, puts them into the token bucket, receives business requests, and performs business processing when the token is obtained. Token generation strategy: It is divided into two parts. The first part is the token generation rate; the second part is the ratio of high-level tokens if congestion occurs. Unit time request counter: It accumulates the number of requests of each priority level in a unit time. This counter accumulates the number of requests of each priority level in a sliding time window. Token generator: Combines the number of requests of each priority level in the previous time unit of the unit time request counter and the "token generation strategy" to generate tokens and put them into the token bucket. Token bucket: It is used to store tokens. Tokens are general tokens or high-level tokens. The capacity is set according to the peak surge value that the system can accept. When the token generator puts a token, if the token bucket is not full, it will be included; if it is full, it will be discarded.
[0056] Figure 6 A service processing device according to an embodiment of the present application includes:
[0057] A receiving module 60, configured to receive a service request, wherein the service request at least includes a service level of the service request, wherein the service levels have different processing priorities;
[0058] an acquisition module 62, configured to acquire a target token matching the service level from a token bucket based on the service level of the service request, wherein the token bucket contains a high-level token and a general token, the high-level token and the general token match the service request of the high service level, the general token only matches the service request of the low service level, and the number of the high-level tokens generated is determined according to a predetermined token generation strategy;
[0059] The processing module 64 is configured to process the service request based on the target token.
[0060] Through the above-mentioned business processing device, by receiving a business request, the business request at least includes the business level of the business request, wherein the processing priority of the business level is different; based on the business level of the business request, a target token matching the business level is obtained from a token bucket, wherein the token bucket contains a high-level token and a general token, the high-level token and the general token match the business request with a high business level, the general token only matches the business request with a low business level, and the number of the high-level tokens is determined according to a predetermined token generation strategy; the business request is processed based on the target token, thereby achieving the purpose of using the user-selected data of interest for recommendation and avoiding the use of a large amount of training data, thereby achieving the technical effect of improving and simplifying the recommendation model training process, and then solving the technical problem of low business processing efficiency due to the single token generation strategy of the token bucket in the related technology.
[0061] The acquisition module 62 includes: an acquisition submodule, which is used to obtain a target token matching the business level from a token bucket based on the business level of the business request, including: when the business request is a business request of the high business level, first searching the high-level token from the token bucket to determine it as the target token; when the business request is a business request of the high business level and there is only the general token in the token bucket, determining that the general token is the target token, wherein, when the high-level token in the token bucket is not within the validity period, converting the high-level token into the general token, the validity period of the high-level token is two units of time.
[0062] The acquisition submodule includes: a determination unit, which is used to obtain the token generation rate, the high-level token ratio, the number of general tokens generated within a unit time and the number of high-level business requests within the previous unit time; determine the number of high-level tokens generated within a unit time according to the high-level token ratio, the number of high-level business requests within the previous unit time and the token generation rate; determine the number of general tokens generated within a unit time according to the token generation rate and the number of high-level tokens generated within the unit time.
[0063] The determination unit also includes: a placing subunit, which is used to place the high-level tokens into the token bucket first when the number of tokens in the token bucket is less than a preset number, until all the generated high-level tokens are placed in the token bucket, and then place the general tokens into the token bucket until the number of tokens in the token bucket reaches the preset number or all the tokens generated in the current token generation cycle have been placed in the token bucket; when the number of tokens in the token bucket is equal to the preset number, determine that the number of tokens in the token bucket is full and stop placing tokens into the token bucket.
[0064] The processing module 64 includes: a processing submodule, which is used to process the business request based on the target token, including: if the business request obtains the target token, responding to the business request and processing the target business; if the business request does not obtain the target token, returning a rejection message, and the rejection message is used to indicate a rejection of processing the target business.
[0065] The above-mentioned device also includes: an adjustment module, used to obtain the number of business requests within a unit time length; when the number of business requests within the unit time length is greater than the token generation rate, determining that the priority of generating the high-level token is greater than the priority of generating the general token.
[0066] The adjustment module includes: an adjustment unit, used to obtain the number of business requests within a unit time; when the number of business requests within the unit time is less than the token generation rate, determining that the priority of generating the high-level token is less than the priority of generating the general token.
[0067] It should be noted that Figure 6 The business processing device shown is used to execute Figure 2 The business processing method shown, therefore the relevant explanations in the above business processing method are also applicable to the business processing device, and will not be repeated here.
[0068] An embodiment of the present application also provides a computer device, including: a memory and a processor, wherein the memory is used to store program instructions; the processor is connected to the memory and is used to execute the above-mentioned business processing method.
[0069] An embodiment of the present application further provides a non-volatile storage medium, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-mentioned business processing method by running the computer program.
[0070] An embodiment of the present application also provides a computer program product, including computer instructions, which, when executed by a processor, implement the steps of the business processing method in the present application.
[0071] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0072] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0073] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0074] 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 over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0075] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0076] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0077] The above are only preferred implementations of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A business processing method, characterized in that: include: receiving a service request, wherein the service request at least includes a service level of the service request, wherein the service levels have different processing priorities; Based on the service level of the service request, a target token matching the service level is obtained from a token bucket, wherein the token bucket contains a high-level token and a general token, the high-level token and the general token match the service request of the high service level, the general token only matches the service request of the low service level, and the number of the high-level token is determined according to a predetermined token generation strategy; The service request is processed based on the target token.
2. The method according to claim 1, characterized in that Acquiring a target token matching the service level from a token bucket based on the service level of the service request includes: In the case where the service request is a service request of the high service level, first searching the high-level token from the token bucket to determine it as the target token; When the service request is a service request of the high service level and there is only the general token in the token bucket, the general token is determined to be the target token, wherein, when the high-level token in the token bucket is not within the validity period, the high-level token is converted into the general token, and the validity period of the high-level token is two units of time.
3. The method according to claim 2, characterized in that The predetermined token generation strategy is determined by: Obtaining the token generation rate, the high-level token ratio, the number of the general tokens generated within a unit time, and the number of high-level service requests within the previous unit time; Determine the number of the high-level tokens generated within a unit time period according to the high-level token ratio, the number of high-level service requests within the previous unit time period, and the token generation rate; The number of the general tokens generated within a unit time period is determined according to the token generation rate and the number of the high-level tokens generated within the unit time period.
4. The method according to claim 3, characterized in that The method further comprises: When the number of tokens in the token bucket is less than a preset number, the high-level token is first placed in the token bucket until all the generated high-level tokens are placed in the token bucket, and then the general token is placed in the token bucket until the number of tokens in the token bucket reaches the preset number or all the tokens generated in the current token generation cycle have been placed in the token bucket; When the number of tokens in the token bucket is equal to the preset number, it is determined that the number of tokens in the token bucket is full, and tokens are stopped from being put into the token bucket.
5. The method according to claim 1, characterized in that Processing the service request based on the target token includes: In the case where the service request obtains the target token, responding to the service request and processing the target service; In the case that the service request fails to obtain the target token, a rejection message is returned, where the rejection message is used to indicate that the processing of the target service is rejected.
6. The method according to claim 1, characterized in that The method further comprises: Get the number of business requests within a unit time; When the number of service requests within the unit time is greater than the token generation rate, it is determined that the priority of generating the high-level token is greater than the priority of generating the general token.
7. The method according to claim 6, characterized in that The method further comprises: Get the number of business requests within a unit time; When the number of service requests within the unit time is less than the token generation rate, it is determined that the priority of generating the high-level token is lower than the priority of generating the general token.
8. A service processing device, characterized in that: include: A receiving module, configured to receive a service request, wherein the service request at least includes a service level of the service request, wherein the service levels have different processing priorities; an acquisition module, configured to acquire a target token matching the service level from a token bucket based on the service level of the service request, wherein the token bucket contains a high-level token and a general token, the high-level token and the general token match the service request of the high service level, the general token only matches the service request of the low service level, and the number of the high-level tokens generated is determined according to a predetermined token generation strategy; A processing module is used to process the service request based on the target token.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory is used to store program instructions; The processor is connected to the memory and is used to execute the business processing method described in any one of claims 1-7.
10. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the business processing method described in any one of claims 1 to 7 is implemented.