Flow control method and device based on section

Through the section-based flow control method, the performance overhead and logic maintenance problems of flow control method in high concurrency scenarios are solved, flexibility and efficiency are achieved, delay is reduced and business efficiency is improved.

CN119094452AActive Publication Date: 2024-12-06CHINA CONSTRUCTION BANK +1

Patent Information

Application Number
CN202411183946.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-27
Publication Date
2024-12-06
Estimated Expiration
2044-08-27

AI Technical Summary

Technical Problem

The prior art flow control method introduces large performance overhead and delays in high concurrency scenarios, and the flow control logic needs to be embedded in business code, resulting in dispersed code logic and difficult maintenance, which can easily introduce errors or cause system downtime.

Method used

Using a section-based flow control method, the flow control logic is extracted from the business code through section-oriented programming technology, defined and managed as a separate section, dynamically adjust the section-based strategy, and use efficient algorithms and data structures to achieve traffic with minimal performance overhead control and decouple from business code.

Benefits of technology

It realizes the flexibility and dynamic adjustment capabilities of high concurrent flow control, reduces latency, improves business efficiency, and has the characteristics of low intrusion, dynamics, flexibility and high performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119094452A_ABST
    Figure CN119094452A_ABST
Patent Text Reader

Abstract

The invention discloses a section-based flow control method and device, which can be used in the field of financial science and technology, and the method comprises the steps: obtaining a service request sent by a user, the service request comprising a request transaction code and a flow control annotation; matching a corresponding target flow control section according to the request transaction code and the flow control annotation; the target flow control section is woven into the service request, and based on the target flow control logic in the target flow control section, the section strategy can be dynamically adjusted according to the flow change, so that the flexibility and the dynamic adjustment capability are improved; according to the flow control method based on the section, an efficient algorithm and a data structure are adopted, and flow control is achieved with the minimum performance overhead; according to the method and the system, the flow is accurately controlled without modifying the original code, so that the delay is reduced, the service efficiency is improved, and the method and the system have the characteristics of low invasiveness, dynamism, flexibility and high performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of flow control technology and can be used in the field of financial technology, and in particular to a flow control method and device based on a slice. Background Art

[0002] With the rapid development of the Internet and the increase in business needs, high-concurrency traffic management has become a key issue to ensure system stability and provide a good user experience. In the related art, traffic control is usually implemented through the Nginx reverse proxy server according to the configuration file, but the traffic control function in the related art is relatively basic and is only suitable for simple static restriction scenarios. In high-concurrency scenarios, the traffic control methods in the related art will introduce large performance overhead and delay; in addition, the traffic control methods in the related art usually need to embed traffic control logic in the business code, making the code logic scattered and difficult to maintain. When the flow control logic needs to be adjusted or added, the original code needs to be modified and redeployed, which is easy to introduce errors or cause system downtime, resulting in low business efficiency.

[0003] This section is intended to provide a background or context to the embodiments of the invention recited in the claims. No admission is made that the description herein is prior art by inclusion in this section. Summary of the invention

[0004] The embodiment of the present invention provides a flow control method based on a slice, which realizes high-concurrency flow control based on a slice, can dynamically adjust the slice strategy according to the flow change, and improves flexibility and dynamic adjustment capability; the flow control method based on a slice adopts an efficient algorithm and data structure to realize flow control with minimal performance overhead; it is decoupled from the business code, does not need to modify the original code, realizes precise control of the flow, thereby reducing delay and improving business efficiency, and has the characteristics of low intrusion, dynamics, flexibility, and high performance. The method includes:

[0005] Get the business request sent by the user, which includes the request transaction code and flow control annotation;

[0006] Through the preset annotation section correspondence relationship, according to the flow control annotation, the corresponding flow control section is determined;

[0007] Through the preset transaction attribution platform correspondence relationship, according to the requested transaction code, the corresponding transaction attribution platform number is determined;

[0008] Through the preset corresponding relationship of the belonging platform aspect, according to the transaction belonging platform number, the flow control aspect is adjusted in parameters to generate the target flow control aspect. The target flow control aspect is the flow control logic based on aspect-oriented programming technology.

[0009] The target flow control aspect is woven into the business request, and the flow of the business request is controlled based on the target flow control logic in the target flow control aspect.

[0010] Preferably, the method further comprises:

[0011] Annotation definition operation that receives input;

[0012] Define operations according to annotations and construct flow control annotations. Flow control annotations are used to identify business requests for flow control.

[0013] Preferably, the method further comprises:

[0014] Aspect definition operations that receive input;

[0015] According to the aspect definition operation, a flow control aspect is constructed. The flow control aspect includes flow control strategies and flow restriction conditions.

[0016] Preferably, the target flow control logic includes a token limit quantity and a token limit rate, and the service request includes a token request quantity and a token request rate;

[0017] Weave the target flow control aspect into the business request, and perform flow control on the business request based on the target flow control logic in the target flow control aspect, including:

[0018] Based on the token bucket algorithm, flow control is performed on the token request quantity and token request rate according to the token limit quantity and token limit rate to generate a flow control result.

[0019] Preferably, based on the token bucket algorithm, according to the token limit quantity and the token limit rate, flow control is performed on the token request quantity and the token request rate to generate a flow control result, including:

[0020] Determine whether the number of token requests is less than or equal to the token limit number, and whether the token request rate is less than or equal to the token limit rate;

[0021] If both are yes, a flow control result of the business request passing is generated;

[0022] If at least one of them is no, query for service requests that exceed the token limit quantity and / or exceed the token limit rate;

[0023] Generate a flow control result of a failed business request based on the queried business request;

[0024] For business requests that do not exceed the token limit quantity and token limit rate, a flow control result of the business request passing is generated.

[0025] Preferably, the target flow control logic includes a flow restriction condition, the flow restriction condition includes a maximum number of requests per second threshold, and the service request includes a maximum number of requests per second;

[0026] Weave the target flow control aspect into the business request, and perform flow control on the business request based on the target flow control logic in the target flow control aspect, including:

[0027] Determine whether the maximum number of requests per second in the business request is less than or equal to the maximum number of requests per second threshold;

[0028] If so, generate a flow control result for the service request to pass;

[0029] If not, query the business requests that exceed the maximum number of requests per second threshold;

[0030] Generate a flow control result of a failed business request based on the queried business request;

[0031] For business requests that do not exceed the maximum number of requests per second, a flow control result is generated for the business requests to pass.

[0032] Preferably, the target flow control logic includes a flow restriction condition, the flow restriction condition includes a concurrent connection number threshold, and the service request includes a concurrent connection number;

[0033] Weave the target flow control aspect into the business request, and perform flow control on the business request based on the target flow control logic in the target flow control aspect, including:

[0034] Determine whether the number of concurrent connections in the service request is less than or equal to the concurrent connection number threshold;

[0035] If so, generate a flow control result for the service request to pass;

[0036] If not, a flow control result indicating that the service request failed is generated.

[0037] Preferably, the target flow control logic includes a flow restriction condition, the flow restriction condition includes a total request number threshold, and the service request includes a total request number;

[0038] Weave the target flow control aspect into the business request, and perform flow control on the business request based on the target flow control logic in the target flow control aspect, including:

[0039] Determine whether the total number of requests in the service request is less than or equal to the total number of requests threshold;

[0040] If so, generate a flow control result for the service request to pass;

[0041] If not, query the business requests that exceed the total request count threshold;

[0042] Generate a flow control result of a failed business request based on the queried business request;

[0043] For business requests that do not exceed the total request number threshold, a flow control result of the business request passing is generated.

[0044] Preferably, the method further comprises:

[0045] Obtain monitoring data through the preset monitor list;

[0046] Determine whether the monitored data complies with the preset flow control section adjustment rules;

[0047] If yes, update the flow control section according to the flow control section adjustment rule and the monitoring data to generate an updated flow control section;

[0048] If not, repeat the steps of obtaining monitoring data through the preset monitor list.

[0049] Preferably, the listener list includes a system load listener, the monitoring data includes a CPU usage rate, and the flow control aspect adjustment rule includes a usage rate token coefficient correspondence;

[0050] According to the flow control section adjustment rule, the flow control section is updated according to the monitoring data to generate an updated flow control section, including:

[0051] By using the usage rate token coefficient correspondence relationship, the corresponding token coefficient is determined according to the CPU usage rate;

[0052] According to the determined token coefficient, the token parameters in the flow control section are updated to generate an updated flow control section.

[0053] Preferably, the listener list includes a configuration change listener, and the monitoring data includes configuration token parameters;

[0054] According to the flow control section adjustment rule, the flow control section is updated according to the monitoring data to generate an updated flow control section, including:

[0055] Update the token parameters in the flow control section to the monitored configuration token parameters and generate an updated flow control section.

[0056] Preferably, the listener list includes time listeners, the monitoring data includes monitoring time, and the flow control aspect adjustment rule includes a time token parameter correspondence;

[0057] According to the flow control section adjustment rule, the flow control section is updated according to the monitoring data to generate an updated flow control section, including:

[0058] Through the time token parameter correspondence, the corresponding token parameters are determined according to the monitoring time;

[0059] The token parameters in the flow control section are updated to the determined token parameters, and an updated flow control section is generated.

[0060] The embodiment of the present invention further provides a flow control device based on a section, the device comprising:

[0061] A service request acquisition unit, used to acquire a service request sent by a user, wherein the service request includes a request transaction code and a flow control annotation;

[0062] A section determination unit, used to determine a corresponding flow control section according to a flow control annotation through a preset annotation section correspondence relationship;

[0063] A platform number determination unit, used to determine the corresponding transaction belonging platform number according to the request transaction code through a preset transaction belonging platform correspondence relationship;

[0064] The target aspect determination unit is used to adjust the parameters of the flow control aspect according to the transaction belonging platform number through the preset belonging platform aspect correspondence relationship, and generate the target flow control aspect, which is the flow control logic based on aspect-oriented programming technology;

[0065] The flow control unit is used to weave the target flow control aspect into the business request and perform flow control on the business request based on the target flow control logic in the target flow control aspect.

[0066] An embodiment of the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned slice-based flow control method when executing the computer program.

[0067] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned slice-based flow control method is implemented.

[0068] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the above-mentioned slice-based flow control method is implemented.

[0069] The aspect-based flow control method and device provided by the embodiment of the present invention obtains a service request sent by a user, wherein the service request includes a request transaction code and a flow control annotation; through a preset annotation aspect correspondence relationship, according to the flow control annotation, a corresponding flow control aspect is determined; through a preset transaction belonging platform correspondence relationship, according to the request transaction code, a corresponding transaction belonging platform number is determined; through a preset belonging platform aspect correspondence relationship, according to the transaction belonging platform number, parameters of the flow control aspect are adjusted to generate a target flow control aspect, and the target flow control aspect is a flow control aspect based on aspect-oriented programming technology. logic; weave the target flow control aspect into the business request, and perform flow control on the business request based on the target flow control logic in the target flow control aspect, implement high-concurrency flow control based on the aspect, and dynamically adjust the aspect strategy according to flow changes, thereby improving flexibility and dynamic adjustment capabilities; the aspect-based flow control method uses efficient algorithms and data structures to control flow with minimal performance overhead; it is decoupled from the business code and does not require modification of the original code, thereby achieving precise control of flow, thereby reducing latency and improving business efficiency, and is characterized by low intrusion, dynamism, flexibility, and high performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0071] Figure 1 A flow chart of a flow control method based on a slice provided by an embodiment of the present invention;

[0072] Figure 2 A flow chart of another slice-based flow control method provided by an embodiment of the present invention;

[0073] Figure 3 A schematic structural diagram of a flow control device based on a section provided in an embodiment of the present invention;

[0074] Figure 4 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0075] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.

[0076] The information collected in the technical solution of this 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 relevant data comply with the relevant laws, regulations and standards of relevant countries and 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 refuse.

[0077] The acquisition, transmission, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.

[0078] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.

[0079] It is worth noting that the technical solution provided in this application provides users with corresponding operation entrances for them to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered.

[0080] In order to facilitate the understanding of the technical solution provided by the present application, the relevant contents of the technical solution of the present application are first explained below. In computer programming, aspect is a concept in aspect-oriented programming (AOP for short). Aspect-oriented programming is a programming paradigm that allows developers to separate cross-cutting concerns (such as logging, transaction management, security, etc.) from business logic, thereby improving the modularity and maintainability of the code. The aspect-based flow control method extracts the flow control logic from the business code and defines and manages it as a separate aspect. Aspects are modules that dynamically enhance requests and can be transparently woven into the request processing process at runtime.

[0081] The aspect-based high-concurrency flow control method combines the aspect programming concept and the characteristics of flow control, providing a flexible, scalable and low-coupling solution that can effectively solve the performance impact and logic writing and maintenance problems in traditional flow control methods, and provide dynamic, flexible and high-performance flow control capabilities; in high-concurrency scenarios, it can ensure the stability, reliability and good user experience of the system.

[0082] The following uses a slice-based flow control device as an example to illustrate the implementation process of the slice-based flow control method provided by the embodiment of the present invention. It is understandable that the execution subject of the slice-based flow control method provided by the embodiment of the present invention includes but is not limited to a slice-based flow control device.

[0083] Figure 1 A flow chart of a flow control method based on a slice provided by an embodiment of the present invention is as follows: Figure 1 As shown, the method includes:

[0084] Step 101: Obtain a service request sent by a user, where the service request includes a request transaction code and a flow control annotation.

[0085] Step 102: Determine the corresponding flow control section according to the flow control annotation through the preset annotation section correspondence relationship.

[0086] Step 103: Determine the corresponding transaction platform number according to the requested transaction code through the preset transaction platform correspondence relationship.

[0087] Step 104: Through the preset corresponding relationship of the belonging platform aspect, according to the transaction belonging platform number, the parameters of the flow control aspect are adjusted to generate the target flow control aspect. The target flow control aspect is the flow control logic based on the aspect-oriented programming technology.

[0088] Step 105: weave the target flow control aspect into the business request, and perform flow control on the business request based on the target flow control logic in the target flow control aspect.

[0089] In the technical solution provided by the embodiment of the present invention, a business request sent by a user is obtained, and the business request includes a request transaction code and a flow control annotation; through the preset annotation aspect correspondence relationship, according to the flow control annotation, the corresponding flow control aspect is determined; through the preset transaction belonging platform correspondence relationship, according to the request transaction code, the corresponding transaction belonging platform number is determined; through the preset belonging platform aspect correspondence relationship, according to the transaction belonging platform number, the flow control aspect is parameter adjusted to generate a target flow control aspect, and the target flow control aspect is a flow control logic based on aspect-oriented programming technology; the target flow control aspect is woven into the business request, and based on the target flow control logic in the target flow control aspect, the business request is flow controlled, and high-concurrency flow control is achieved based on the aspect, and the aspect strategy can be dynamically adjusted according to the flow change, thereby improving flexibility and dynamic adjustment capabilities; the aspect-based flow control method adopts efficient algorithms and data structures to achieve flow control with minimal performance overhead; it is decoupled from the business code, and there is no need to modify the original code, so as to achieve precise control of the flow, thereby reducing delay and improving business efficiency, and has the characteristics of low intrusion, dynamics, flexibility and high performance.

[0090] Figure 2 A flow chart of another aspect-based flow control method provided by an embodiment of the present invention is as follows: Figure 2 As shown, the method includes:

[0091] Step 201: Receive input annotation definition operation.

[0092] In the embodiment of the present invention, each step is performed by a section-based flow control device.

[0093] In the embodiment of the present invention, the annotation definition operation is input by the developer when designing the annotation. In programming, an annotation is a special tag used to provide metadata for program elements (such as classes, methods, variables, etc.), such as the permitted request rate. Metadata is data that describes data, which allows the program to obtain information about the program itself at compile time or runtime.

[0094] Step 202: construct a flow control annotation according to the annotation definition operation.

[0095] For example, the annotation definition operation includes the permitted request rate, and the custom-built flow control annotation is @RateLimited, which indicates that flow control is required.

[0096] In the embodiment of the present invention, annotation is a mechanism for Java language to provide metadata for code, which can be used for classes, methods, variables, parameters, etc. Flow control annotation is used to identify business requests that need flow control. The annotation can be attached to the controller class or method to indicate the request code that needs flow control. The main purpose of flow control annotation is to mark which methods need to be processed by flow control logic.

[0097] It is worth noting that annotations are non-invasive and do not directly affect the logic of the program, but can be used by the compiler or runtime environment to change or enhance the behavior of the program.

[0098] Step 203: Receive input of a slice definition operation.

[0099] In the embodiment of the present invention, the aspect definition operation is the flow control logic input by the developer when designing the flow control aspect. The aspect definition operation can define an aspect class, which will use the defined annotations to determine which methods need flow control.

[0100] Step 204: construct a flow control aspect according to the aspect definition operation, and the flow control aspect includes a flow control strategy and flow restriction conditions.

[0101] In the embodiment of the present invention, a section is created to implement the flow control logic through the section definition operation, and the flow control section is woven into the request processing process marked by the flow control annotation (@RateLimited).

[0102] In an embodiment of the present invention, the flow control aspect defines the flow control strategy and flow limitation conditions. The flow control strategy includes but is not limited to the leaky bucket algorithm, the token bucket algorithm or other suitable algorithms and their internal parameters; the flow limitation conditions include but are not limited to the maximum number of requests per second, the number of concurrent connections, and the total number of requests.

[0103] In the embodiment of the present invention, the flow control aspect is an application of aspect-oriented programming (AOP) and is used to manage and control the flow in the application program to ensure the stability and responsiveness of the system.

[0104] The present invention adopts efficient algorithms and data structures to achieve flow control with minimal performance overhead. For example, a leaky bucket algorithm or a token bucket algorithm is used to limit the request frequency without additional lock operations, thereby improving the system throughput and response time.

[0105] Step 205: Obtain the service request sent by the user.

[0106] In the embodiment of the present invention, the service request is a Hypertext Transfer Protocol (HTTP) request sent by a user, and the service request includes but is not limited to a request transaction code and a flow control annotation. The request transaction code is used to uniquely identify a service request, and the flow control annotation is used to identify that flow control needs to be performed on the service request.

[0107] It is worth noting that the system has a unified entrance and can automatically forward the request transaction code to the corresponding processing logic; even if the system entrance is not unified, the aspect can customize the applied content and obtain the required application code through precise matching and / or fuzzy matching.

[0108] Step 206: Determine the corresponding flow control section according to the flow control annotation through the preset annotation section correspondence relationship.

[0109] In the embodiment of the present invention, the annotation-facet correspondence relationship is the correspondence relationship between annotations and facets, and the relationship between annotations and facets is many-to-many, that is, one annotation can correspond to multiple facets, and one facet can correspond to multiple annotations.

[0110] In the embodiment of the present invention, the aspect is applied to the code marked with an annotation, indicating that the logic of this aspect is uniformly performed in this part of the code.

[0111] For example, there are three aspects, namely Aspect A, Aspect B and Aspect C. Aspect A is used to record request time, Aspect B is used for flow control, and Aspect C is used for authentication; annotations are used to mark the relevant aspects used in this section of code. The corresponding annotation for Aspect A is defined as @TimeUsed, the corresponding annotation for Aspect B is defined as @RateLimited, and the corresponding annotation for Aspect C is defined as @RequestAuth. If the current business request requires flow control and recording of request time, add the annotations @TimeUsed and @RateLimited to the code of the business request to call the corresponding aspect to implement the corresponding function. At this time, this section of code has the system-level global unified recording time and flow control functions, which not only does not require repeated development to simplify labor costs, but also avoids errors such as omissions in repeated copying of code.

[0112] For example, define an annotation @RequestProcess, which includes three functions: recording request time annotation @TimeUsed, flow control annotation @RateLimited, and authentication annotation @RequestAuth. If the annotation @RequestProcess is added to the code of the business request, the code will call and execute the flow control aspect, authentication aspect, and time-consuming aspect at the same time, thereby achieving functional enhancement.

[0113] It is worth noting that the specific content of the annotation aspect correspondence can be set according to actual needs, and the embodiment of the present invention does not limit this. The embodiment of the present invention takes flow control as an example to design flow control annotations and flow control aspects. In actual applications, different functional enhancements can also be achieved based on the aspect concept.

[0114] Step 207: Determine the corresponding transaction platform number according to the requested transaction code through the preset transaction platform correspondence relationship.

[0115] In the embodiment of the present invention, the transaction belonging platform correspondence is the correspondence between the request transaction code and the transaction belonging platform. Specifically, the request transaction code of the service request is matched with the request transaction code in the transaction belonging platform correspondence to determine the corresponding transaction belonging platform number. The transaction belonging platform number can uniquely identify a transaction belonging platform.

[0116] In the embodiment of the present invention, the system distinguishes different tenants according to the transaction belonging platform, and different users under the same tenant belong to the same traffic control aspect, so as to prevent individual tenants from monopolizing system resources for a long time.

[0117] It is worth noting that the specific content of the transaction attribution platform correspondence relationship can be set according to actual needs, and the embodiment of the present invention does not limit this.

[0118] Step 208: Through the preset corresponding relationship between the belonging platform sections and according to the transaction belonging platform number, the parameters of the flow control section are adjusted to generate the target flow control section.

[0119] In the embodiment of the present invention, the corresponding relationship between the belonging platform aspects is the corresponding relationship between the transaction belonging platform and the aspects, the transaction belonging platform corresponds to the aspects, and the aspects include the flow control aspects.

[0120] It is worth noting that the specific content of the corresponding relationship between the attribution platform aspects can be set according to actual needs, and the embodiment of the present invention does not limit this. The embodiment of the present invention takes flow control as an example to design the flow control aspect, that is, the transaction attribution platform corresponds to the flow control aspect. In actual applications, different functional enhancements can also be achieved based on the aspect concept.

[0121] In the embodiment of the present invention, the target flow control aspect is the flow control logic based on aspect-oriented programming technology. The flow control logic can be set in a variety of ways, including but not limited to user level and system time. Specifically, a flow control aspect class (RateLimitAspect class) is defined, and multiple aspects with different business functions can be defined on the RateLimitAspect class, so that the flow control aspect can be adjusted in parameters to generate the target flow control aspect. The parameters that need to be adjusted include but are not limited to the maximum number of requests per second, the number of concurrent connections, and the total number of requests. Specifically, based on the user level, the maximum number of requests per second corresponding to different user levels can be set; based on the system time, the maximum number of requests per second corresponding to different system time periods can be set. The system time period includes a low-peak time period at night and a peak time period during the day. The specific time points for dividing the system time periods can be set according to actual needs, and the embodiment of the present invention does not limit this.

[0122] For example, a default-level tenant is allowed to make 10 requests per second, and a high-level user is allowed to make 100 requests per second. The target traffic control aspect can be determined by the transaction platform number corresponding to the business request, that is, the user level is judged to distinguish the number of requests per second allowed for this tenant.

[0123] In the embodiment of the present invention, the corresponding relationship of the belonging platform aspect is a mapping named RateLimiterMap maintained inside the aspect, which stores the mapping relationship between method names and rate limiter (RateLimiter) instances, and uses a concurrent hash map (ConcurrentHashMap) to ensure thread safety. Among them, ConcurrentHashMap is a class in the Java collection framework, which implements the ConcurrentMap interface and is one of the thread-safe implementations of Map. ConcurrentHashMap allows multiple threads to read and write simultaneously without explicit synchronization measures.

[0124] Step 209: weave the target flow control aspect into the business request, and perform flow control on the business request based on the target flow control logic in the target flow control aspect.

[0125] In the embodiment of the present invention, the target flow control aspect is bound to the code of the business request by using aspect weaving technology. When the aspect logic is executed later, the target flow control aspect will intercept and process the business request that needs to be limited, and decide whether to allow the request to continue to execute or queue according to the control logic.

[0126] In the embodiment of the present invention, the aspect logic is executed before the service function code of the service request is executed. Taking flow control as an example, the target flow control logic in the target flow control aspect is executed before the service function code of the service request is executed.

[0127] In the embodiment of the present invention, taking the token bucket algorithm as an example, the target flow control logic includes a token limit quantity and a token limit rate, and the service request includes a token request quantity and a token request rate.

[0128] Step 209 specifically includes: based on the token bucket algorithm, according to the token limit quantity and the token limit rate, flow control is performed on the token request quantity and the token request rate to generate a flow control result.

[0129] Specifically, step 2091 determines whether the number of token requests is less than or equal to the token limit number, and whether the token request rate is less than or equal to the token limit rate. If both are yes, execute step 2092; if at least one is no, execute step 2093.

[0130] In the embodiment of the present invention, the token limit quantity and the token limit rate are preset in the target flow control logic, and the embodiment of the present invention does not limit this.

[0131] Specifically, if the number of token requests is less than or equal to the token limit number, and the token request rate is less than or equal to the token limit rate, it indicates that the business request has not met the flow control standard, and continue to execute step 2092; if the number of token requests is greater than the token limit number, or the token request rate is greater than the token limit rate, it indicates that the business request has met the flow control standard, and continue to execute step 2093.

[0132] For example: if the token limit rate is 10 tokens per second and the platform can obtain tokens in the target flow control section, the platform to which it belongs obtains tokens. If the platform obtains 9 tokens in this second and does not exceed the token limit rate, it indicates that the business request has not reached the flow control standard, and step 2092 is continued; if the platform attempts to obtain the 11th token in this second and exceeds the token limit rate, it indicates that the business request has reached the flow control standard, and step 2093 is continued.

[0133] Step 2092: Generate a flow control result for the service request, and this step ends.

[0134] In the embodiment of the present invention, if the service request does not meet the flow control standard, the service request is allowed to pass, and a flow control result of the service request passing is generated for subsequent service function code for continuing to execute the service request.

[0135] Step 2093: Query the service requests that exceed the token limit quantity and / or exceed the token limit rate.

[0136] For example, if the token limit rate is that the platform can obtain 10 tokens per second, and the platform attempts to obtain the 11th token in this second, then the business request corresponding to the 11th token is a business request that exceeds the token limit rate.

[0137] Step 2094: Generate a flow control result of a failed service request based on the queried service request.

[0138] In an embodiment of the present invention, if the token limit rate is that the platform can obtain 10 tokens per second, the business request corresponding to the 11th token is a business request that exceeds the token limit rate. The first 10 business requests are allowed to pass, the 11th business request is intercepted, and a flow control result of business request failure is generated for the 11th business request.

[0139] Step 2095: For service requests that do not exceed the token limit quantity and token limit rate, a flow control result of the service request passing is generated.

[0140] In an embodiment of the present invention, if the token limit rate is that the platform can obtain 10 tokens per second, the business request corresponding to the 11th token is a business request that exceeds the token limit rate. The first 10 business requests are allowed to pass, and a flow control result of the business request passing is generated for the first 10 business requests.

[0141] As another optional solution, the target flow control logic includes a flow restriction condition, the flow restriction condition includes a maximum request number threshold per second, and the service request includes a maximum request number per second.

[0142] Step 209 specifically includes:

[0143] Step 3091, determine whether the maximum number of requests per second in the business request is less than or equal to the maximum number of requests per second threshold; if so, execute step 3092; if not, execute step 3093.

[0144] In the embodiment of the present invention, the maximum request number threshold per second is preset in the target flow control logic, and the embodiment of the present invention does not limit this.

[0145] Specifically, if the maximum number of requests per second in the business request is less than or equal to the maximum number of requests per second threshold, it indicates that the business request has not met the flow control standard, and step 3092 continues to be executed; if the maximum number of requests per second in the business request is greater than the maximum number of requests per second threshold, it indicates that the business request has met the flow control standard, and step 3093 continues to be executed.

[0146] For example: the maximum request number threshold per second is 8, and the number of requests in the business request this second is 6, which does not exceed the maximum request number threshold per second, indicating that the business request does not meet the flow control standard, and continue to execute step 3092; the number of requests in the business request this second is 10, which exceeds the maximum request number threshold per second, indicating that the business request has met the flow control standard, and continue to execute step 3093.

[0147] Step 3092: Generate a flow control result for the service request. This step ends.

[0148] In the embodiment of the present invention, if the service request does not meet the flow control standard, the service request is allowed to pass, and a flow control result of the service request passing is generated for subsequent service function code for continuing to execute the service request.

[0149] Step 3093: Query the business requests that exceed the maximum number of requests per second threshold.

[0150] For example, if the maximum request number threshold per second is 8, and the number of requests in the service request per second is 10, then the 9th and 10th service requests are service requests that exceed the maximum request number threshold per second.

[0151] Step 3094: Generate a flow control result of a failed service request based on the queried service request.

[0152] In an embodiment of the present invention, if the maximum request number threshold per second is 8, the 9th and 10th business requests are business requests that exceed the maximum request number threshold per second, the first 8 business requests are allowed to pass, the 9th and 10th business requests are intercepted, and a flow control result of business request failure is generated for the 9th and 10th business requests.

[0153] Step 3095: For business requests that do not exceed the maximum number of requests per second, a flow control result of the business request passing is generated, and this step ends.

[0154] In an embodiment of the present invention, if the maximum request number threshold per second is 8, the 9th and 10th service requests are service requests that exceed the maximum request number threshold per second, the first 8 service requests are allowed to pass, and a flow control result of the service request passing is generated for the first 8 service requests.

[0155] As another optional solution, the target flow control logic includes a flow restriction condition, the flow restriction condition includes a concurrent connection number threshold, and the service request includes the concurrent connection number.

[0156] Step 209 specifically includes:

[0157] Step 4091: Determine whether the number of concurrent connections in the service request is less than or equal to the concurrent connection number threshold. If so, execute step 4092; if not, execute step 4093.

[0158] In the embodiment of the present invention, the concurrent connection quantity threshold is preset in the target flow control logic, and the embodiment of the present invention does not limit this.

[0159] Specifically, if the number of concurrent connections in the service request is less than or equal to the concurrent connection number threshold, it indicates that the service request has not met the flow control standard, and step 4092 is continued; if the number of concurrent connections in the service request is greater than the concurrent connection number threshold, it indicates that the service request has met the flow control standard, and step 4093 is continued.

[0160] Step 4092: Generate the flow control result of the service request passing, and this step ends.

[0161] In the embodiment of the present invention, if the service request does not meet the flow control standard, the service request is allowed to pass, and a flow control result of the service request passing is generated for subsequent service function code for continuing to execute the service request.

[0162] Step 4093: Generate a flow control result of a failed service request, and this step ends.

[0163] In the embodiment of the present invention, if the service request has reached the flow control standard, the service request is intercepted and a flow control result of failure of the service request is given.

[0164] As another optional solution, the target flow control logic includes a flow restriction condition, the flow restriction condition includes a total request number threshold, and the service request includes a total request number.

[0165] Step 209 specifically includes:

[0166] Step 5091: determine whether the total number of requests in the business request is less than or equal to the total number of requests threshold. If so, execute step 5092; if not, execute step 5093.

[0167] In the embodiment of the present invention, the total request number threshold is preset in the target flow control logic, and the embodiment of the present invention does not limit this.

[0168] Specifically, if the total number of requests in the business request is less than or equal to the total number of requests threshold, it indicates that the business request has not met the flow control standard, and step 5092 is continued; if the total number of requests in the business request is greater than the total number of requests threshold, it indicates that the business request has met the flow control standard, and step 5093 is continued.

[0169] Step 5092: Generate a flow control result for the service request, and this step ends.

[0170] In the embodiment of the present invention, if the service request does not meet the flow control standard, the service request is allowed to pass, and a flow control result of the service request passing is generated for subsequent service function code for continuing to execute the service request.

[0171] Step 5093: Query the business requests that exceed the total request number threshold.

[0172] For example, if the total request count threshold is 20, and the total request count in the service request is 22, then the 21st and 22nd service requests are service requests that exceed the total request count threshold.

[0173] Step 5094: Generate a flow control result of a failed service request based on the queried service request.

[0174] In an embodiment of the present invention, if the total request number threshold is 20, the 21st and 22nd service requests are service requests that exceed the total request number threshold, the first 20 service requests are allowed to pass, the 21st and 22nd service requests are intercepted, and a flow control result of service request failure is generated for the 21st and 22nd service requests.

[0175] Step 5095: For the service requests that do not exceed the total request number threshold, a flow control result of the service request passing is generated, and this step ends.

[0176] In an embodiment of the present invention, if the total request number threshold is 20, the 21st and 22nd service requests are service requests that exceed the total request number threshold, the first 20 service requests are allowed to pass, and a flow control result of the service request passing is generated for the first 20 service requests.

[0177] For example, there are two methods, processRequest and processLimitedRequest. If the @RateLimited annotation is used on the processLimitedRequest method, the business request whose request address is processLimitedRequest will be subject to flow control. It is necessary to determine whether to allow the business request to be executed according to the flow control logic in the flow control aspect. The flow control logic is implemented in the flow control aspect (RateLimitAspect). For example, regular requests need to obtain a token, which is released after successful acquisition. If the acquisition fails, it will be intercepted and a notification message of flow control will be returned.

[0178] The present invention adopts the aspect programming method to decouple the flow control logic from the business logic. By making the flow control-related code independent of the business function, developers can focus on the development and maintenance of the core business logic, improving the maintainability and scalability of the code. At the same time, this architecture mode also makes the system easier to expand horizontally and develop collaboratively.

[0179] Step 210: Obtain monitoring data through a preset monitor list.

[0180] In an embodiment of the present invention, the listener list (listeners) includes but is not limited to system load listeners, configuration change listeners, time listeners and rate change listeners (DynamicRateProvider). Among them, DynamicRateProvider is injected into the flow control aspect to obtain dynamically changing rate limit data. By marking the init method with the @PostConstruct annotation, it can be executed immediately after the object is created. The rate change listener (DynamicRateProvider) is registered through this method, and the onRateChange method is called for processing when the rate changes. The onRateChange method is used to update the rate limit of a specific method. When a new rate setting is received, the rate of the corresponding RateLimiter will be adjusted.

[0181] It is worth noting that each listener is registered with the configuration manager through the init method in order to monitor changes in the rate limit configuration.

[0182] Furthermore, the limitRequest method is marked as a method that checks for certain conditions (i.e., marked with the @RateLimited annotation) before execution. This method checks whether the request is allowed to proceed according to the dynamic rate limit, and if the request exceeds the limit, an alert is triggered and an exception is thrown.

[0183] In an embodiment of the present invention, the monitoring data includes central processing unit (CPU) usage, configuration token parameters, monitoring time and dynamically changing rate limit data; the system load listener is used to monitor the CPU usage, the configuration change listener is used to monitor the configuration token parameters, the time listener is used to obtain the monitoring time, and the rate change listener is used to monitor the dynamically changing rate limit data.

[0184] Step 211, determine whether the monitored data meets the preset flow control section adjustment rules, if so, execute step 212; if not, execute step 210.

[0185] In an embodiment of the present invention, the flow control aspect adjustment rule is a mechanism for dynamically adjusting and managing flow control, allowing developers to modify aspect definitions and restriction parameters at runtime, thereby flexibly adjusting flow control strategies according to actual needs, such as: increasing or decreasing the number of requests per second, dynamically adjusting the number of concurrent connections, etc.

[0186] Specifically, the parameter values ​​in the flow control logic are saved in combination with the database to dynamically refresh. When the business request traffic undertaken by the system is too large, the parameter values ​​in the flow control logic are reduced to reduce the pressure on the system. When the pressure on the system is reduced, the parameter values ​​in the flow control logic are increased to make the flow control of the request system smoother.

[0187] In the embodiment of the present invention, the flow control section adjustment rule can be set according to actual needs, and the embodiment of the present invention does not limit this. If the monitored data meets the preset flow control section adjustment rule, it indicates that the parameter value in the flow control logic needs to be adjusted and updated, and step 212 is continued; if the monitored data does not meet the preset flow control section adjustment rule, it indicates that the parameter value in the flow control logic does not need to be adjusted and updated, and step 210 is continued to monitor.

[0188] Taking the parameter value in the flow control logic as a token parameter as an example, as an optional solution, the flow control aspect adjustment rule includes the usage token coefficient correspondence and the time token parameter correspondence. The usage token coefficient correspondence is the correspondence between the CPU usage and the token coefficient, and the time token parameter correspondence is the correspondence between the system time and the token parameter.

[0189] Specifically, the monitored CPU usage is matched with the CPU usage in the corresponding relationship of the usage token coefficient. If the match is successful, it indicates that the flow control aspect adjustment rules are met, and step 212 is continued; if the match fails, it indicates that the flow control aspect adjustment rules are not met, and step 210 is continued.

[0190] Specifically, the monitored listening time is matched with the system time in the corresponding relationship of the time token parameter. If the match is successful, it indicates that the flow control aspect adjustment rules are met, and step 212 is continued; if the match fails, it indicates that the flow control aspect adjustment rules are not met, and step 210 is continued.

[0191] Step 212: According to the flow control section adjustment rule, the flow control section is updated according to the monitoring data to generate an updated flow control section.

[0192] In the embodiment of the present invention, the listener list includes system load listeners, the monitoring data includes central processing unit usage, and the flow control aspect adjustment rule includes usage token coefficient correspondence.

[0193] Step 2121: Determine the corresponding token coefficient according to the CPU usage rate through the usage rate token coefficient correspondence relationship.

[0194] Specifically, when the rate change listener (DynamicRateProvider) detects a rate change, the CPU usage detected by the system load listener is matched with the CPU usage in the usage token coefficient to determine the corresponding token coefficient.

[0195] As an optional scheme, the corresponding relationship between the usage rate and the token coefficient is: when the CPU usage rate is greater than 50%, the corresponding token coefficient is 0.5; when the CPU usage rate is less than or equal to 50% and greater than 10%, the corresponding token coefficient is 0.8; when the CPU usage rate is continuously less than or equal to 10% within 1 minute, the corresponding token coefficient is 1.

[0196] Step 2122: Update the token parameters in the flow control section according to the determined token coefficient to generate an updated flow control section.

[0197] In the embodiment of the present invention, the token coefficient is multiplied by the token parameter in the flow control section to obtain an updated token parameter; the updated token parameter is applied to the flow control section to generate an updated flow control section.

[0198] For example: By default, the business request obtains 10 tokens per second. When the system CPU usage exceeds 50%, all token parameters are multiplied by the token coefficient of 0.5. At this time, by default, the business request is only allowed to make 5 requests per second; when the system CPU usage drops below 20%, the token coefficient is 0.8. At this time, by default, the business request is only allowed to make 8 requests per second; when the system CPU usage continues to be lower than 10% for 1 minute, the token coefficient is 1. At this time, by default, the business request can obtain 10 tokens per second.

[0199] Furthermore, the onRateChange method is configured to be called when the corresponding configuration item in the database changes. The onRateChange method is used to notify all registered listeners that the rate has changed. When the system load listener detects that the CPU usage change meets the flow control aspect adjustment rules, it actively calls the onRateChange method to notify the system to change the flow control token parameters.

[0200] In an embodiment of the present invention, the listener list also includes a configuration change listener, and the listening data includes configuration token parameters. The configuration change listener is used to listen to the token parameter configuration in the manual active update database and refresh the saved configuration token parameters. Step 212 specifically includes: when the rate change listener (DynamicRateProvider) listens to the rate change, that is, the configuration token parameters change, the token parameters in the flow control section are updated to the listened configuration token parameters, and the updated flow control section is generated.

[0201] In the embodiment of the present invention, the database configuration is dynamically read and the default value is set through the rate change listener (DynamicRateProvider), thereby realizing the capability of dynamic configuration update, so that the parameter values ​​in the flow control logic such as the rate limit value or the token parameter can be changed without restarting the application.

[0202] Furthermore, the onRateChange method is configured to be called when the corresponding configuration item in the database changes. The onRateChange method is used to notify all registered listeners that the rate has changed. When the configuration change listener detects that the token parameter configuration has changed, it actively calls the onRateChange method to notify the system to change the flow control token parameters.

[0203] In the embodiment of the present invention, the listener list also includes a time listener, the monitoring data includes the monitoring time, and the flow control aspect adjustment rule includes the time token parameter correspondence. The time change monitoring can be triggered once every hour, and the token parameters are switched during the night low peak period and the day peak period corresponding to the preset system time when the monitoring time is.

[0204] Step 212 specifically includes:

[0205] Step 3121: Determine the corresponding token parameters according to the monitoring time through the time token parameter correspondence.

[0206] In the embodiment of the present invention, the listening time monitored by the system load listener is matched with the system time in the time token parameter correspondence relationship to determine the corresponding token parameter.

[0207] Step 3122: Update the token parameters in the flow control section to the determined token parameters, and generate an updated flow control section.

[0208] In the embodiment of the present invention, the determined token parameters are applied to the flow control section to generate an updated flow control section.

[0209] The present invention supports dynamic adjustment of flow control parameters and customizable flow control strategies. System administrators can flexibly adjust restriction parameters such as request frequency, number of concurrent connections, etc. according to actual needs, and dynamically optimize flow control without interrupting system operation. At the same time, developers can also customize flow control strategies according to specific business scenarios and needs to adapt to different business needs and provide higher flexibility and scalability.

[0210] Furthermore, the onRateChange method is configured to be called when the corresponding configuration item in the database changes. The onRateChange method is used to notify all registered listeners that the rate has changed. When the time listener detects that the listening time change meets the flow control aspect adjustment rule, it actively calls the onRateChange method to notify the system to change the flow control token parameters.

[0211] Furthermore, a warning condition for abnormal traffic is set in the traffic control aspect (RateLimitAspect), and the warning condition can be set according to actual needs, which is not limited in the embodiment of the present invention.

[0212] As an optional solution, a warning SMS is sent when the CPU usage is higher than 80%.

[0213] As another optional solution, if an event starts at 10 o'clock, the number of business requests allowed to pass through a specific interface per second can be set to 0, and the user who initiated the request with a flow control of 0 can be analyzed before flow control, and the analyzed user can be added to the exception list to prohibit the user from participating in the event.

[0214] It is worth mentioning that in addition to the warning SMS, the warning also needs to record the number of requests for each platform. For example, the request threshold configured by a high-level user is 200 times per second, but the business it requests is complex. In the future, you can consider reducing the number of interfaces allowed per second. In addition to the platform, you can also target the interface, that is, reduce the number of tokens allowed to be obtained per second for interfaces with complex business logic, and increase the number of tokens allowed to be obtained per second for interfaces with simple business logic.

[0215] Furthermore, through traffic control strategies such as logging, indicator collection, and threshold setting, the request traffic in the system can be monitored in real time, abnormal traffic and abnormal behavior can be discovered in a timely manner, and early warnings can be triggered and countermeasures can be taken. While ensuring system performance, it can flexibly and accurately control and manage the traffic of business requests. It is decoupled from the business code and dynamically adjustable, has good scalability and is easy to maintain.

[0216] This application can effectively protect the system from sudden large traffic shocks by accurately limiting and controlling business requests in the system. When processing high-concurrency requests, the system's resource allocation can be more reasonable to ensure that each request can be properly processed and responded to, thereby ensuring the stable operation of the system; the aspect-based high-concurrency flow control uses a high-performance flow control algorithm, such as implementing a token bucket algorithm. These algorithms can quickly and accurately limit and process requests in high-concurrency scenarios, ensuring that the system has high throughput and low latency characteristics. By effectively managing system resources, common problems such as resource overload and performance degradation can be avoided. Therefore, this application has advantages in accurately limiting and controlling requests, decoupling business logic, high-performance flow control algorithms, and dynamically adjusting parameters. By providing stable, maintainable, and efficient solutions, it provides a powerful, reliable, and efficient technical foundation for processing high-concurrency request scenarios.

[0217] In the scheme of the embodiment of the present invention, a business request sent by a user is obtained, and the business request includes a request transaction code and a flow control annotation; through the preset annotation aspect correspondence relationship, according to the flow control annotation, the corresponding flow control aspect is determined; through the preset transaction belonging platform correspondence relationship, according to the request transaction code, the corresponding transaction belonging platform number is determined; through the preset belonging platform aspect correspondence relationship, according to the transaction belonging platform number, the flow control aspect is parameter adjusted to generate a target flow control aspect, and the target flow control aspect is a flow control logic based on aspect-oriented programming technology; the target flow control aspect is woven into the business request, and based on the target flow control logic in the target flow control aspect, the business request is flow controlled, and high-concurrency flow control is achieved based on the aspect, and the aspect strategy can be dynamically adjusted according to the flow change, thereby improving flexibility and dynamic adjustment capabilities; the aspect-based flow control method adopts efficient algorithms and data structures to achieve flow control with minimal performance overhead; it is decoupled from the business code, and does not need to modify the original code, so as to achieve precise control of the flow, thereby reducing delay and improving business efficiency, and has the characteristics of low intrusion, dynamics, flexibility and high performance.

[0218] The present invention also provides a flow control device based on a slice, as described in the following embodiments. Since the principle of solving the problem by the device is similar to that of the flow control method based on a slice, the implementation of the device can refer to the implementation of the flow control method based on a slice.

[0219] Figure 3 A schematic diagram of the structure of a flow control device based on a slice according to an embodiment of the present invention is provided, wherein the device is used to execute the flow control method based on a slice, such as Figure 3 As shown, the device includes: a service request acquisition unit 11, a section determination unit 12, a platform number determination unit 13, a target section determination unit 14 and a traffic control unit 15.

[0220] The service request acquisition unit 11 is used to acquire the service request sent by the user, and the service request includes a request transaction code and a flow control annotation.

[0221] The section determination unit 12 is used to determine the corresponding flow control section according to the flow control annotation through the preset annotation section correspondence relationship.

[0222] The platform number determination unit 13 is used to determine the corresponding transaction belonging platform number according to the request transaction code through the preset transaction belonging platform correspondence relationship.

[0223] The target aspect determination unit 14 is used to adjust the parameters of the flow control aspect according to the transaction belonging platform number through the preset belonging platform aspect correspondence relationship, and generate a target flow control aspect. The target flow control aspect is the flow control logic based on aspect-oriented programming technology.

[0224] The flow control unit 15 is used to weave the target flow control aspect into the service request, and perform flow control on the service request based on the target flow control logic in the target flow control aspect.

[0225] In the embodiment of the present invention, the device further includes: a receiving unit 16 and an annotation constructing unit 17 .

[0226] The receiving unit 16 is used to receive an input annotation definition operation.

[0227] The annotation construction unit 17 is used to construct a flow control annotation according to the annotation definition operation, and the flow control annotation is used to identify the service request for flow control.

[0228] In the embodiment of the present invention, there is a receiving unit 16 and a section constructing unit 18 .

[0229] The receiving unit 16 is further used to receive an input slice definition operation.

[0230] The aspect construction unit 18 is used to construct a flow control aspect according to the aspect definition operation, and the flow control aspect includes a flow control strategy and flow restriction conditions.

[0231] In an embodiment of the present invention, the target flow control logic includes a token limit number and a token limit rate, and the service request includes a token request number and a token request rate; the flow control unit 15 is specifically used to perform flow control on the token request number and the token request rate based on the token bucket algorithm according to the token limit number and the token limit rate, and generate a flow control result.

[0232] In an embodiment of the present invention, the flow control unit 15 is specifically used to determine whether the number of token requests is less than or equal to the token limit number, and whether the token request rate is less than or equal to the token limit rate; if both are yes, a flow control result of the service request passing is generated; if at least one of them is no, the service requests exceeding the token limit number and / or exceeding the token limit rate are queried; based on the queried service requests, a flow control result of the service request failure is generated; for the service requests that do not exceed the token limit number and the token limit rate, a flow control result of the service request passing is generated.

[0233] In an embodiment of the present invention, the target flow control logic includes flow limitation conditions, the flow limitation conditions include a maximum request number threshold per second, and the service request includes a maximum request number per second; the flow control unit 15 is specifically used to determine whether the maximum request number per second in the service request is less than or equal to the maximum request number threshold per second; if so, generate a flow control result for the service request to pass; if not, query the service requests that exceed the maximum request number threshold per second; based on the queried service requests, generate a flow control result for the service request failure; for the service requests that do not exceed the maximum request number threshold per second, generate a flow control result for the service request to pass.

[0234] In an embodiment of the present invention, the target flow control logic includes flow limitation conditions, the flow limitation conditions include a concurrent connection number threshold, and the service request includes the concurrent connection number; the flow control unit 15 is specifically used to determine whether the concurrent connection number in the service request is less than or equal to the concurrent connection number threshold; if so, generate a flow control result of the service request passing; if not, generate a flow control result of the service request failing.

[0235] In an embodiment of the present invention, the target flow control logic includes a flow limitation condition, the flow limitation condition includes a total request number threshold, and the service request includes the total request number; the flow control unit 15 is specifically used to determine whether the total request number in the service request is less than or equal to the total request number threshold; if so, generate a flow control result for the service request to pass; if not, query the service requests that exceed the total request number threshold; based on the queried service requests, generate a flow control result for the service request failure; for the service requests that do not exceed the total request number threshold, generate a flow control result for the service request to pass.

[0236] In the embodiment of the present invention, the device further includes: a monitoring data acquisition unit 19 , a rule judgment unit 20 and a section updating unit 21 .

[0237] The monitoring data acquisition unit 19 is used to acquire monitoring data through a preset monitor list.

[0238] The rule determination unit 20 is used to determine whether the monitoring data conforms to the preset flow control section adjustment rule; if not, the monitoring data acquisition unit 19 is triggered to repeatedly execute the step of acquiring the monitoring data through the preset monitor list.

[0239] The section updating unit 21 is used to update the flow control section according to the monitoring data according to the flow control section adjustment rule to generate an updated flow control section.

[0240] In an embodiment of the present invention, the listener list includes a system load listener, the monitoring data includes a CPU usage rate, and the flow control aspect adjustment rules include a usage rate token coefficient correspondence relationship; the aspect update unit 21 is specifically used to determine the corresponding token coefficient according to the CPU usage rate through the usage rate token coefficient correspondence relationship; according to the determined token coefficient, the token parameters in the flow control aspect are updated to generate an updated flow control aspect.

[0241] In an embodiment of the present invention, the listener list includes configuration change listeners, and the monitoring data includes configuration token parameters; the aspect update unit 21 is specifically used to update the token parameters in the flow control aspect to the monitored configuration token parameters to generate an updated flow control aspect.

[0242] In an embodiment of the present invention, the listener list includes a time listener, the monitoring data includes the monitoring time, and the flow control section adjustment rule includes the time token parameter correspondence relationship; the section update unit 21 is specifically used to determine the corresponding token parameters according to the monitoring time through the time token parameter correspondence relationship; the token parameters in the flow control section are updated to the determined token parameters, and an updated flow control section is generated.

[0243] In the scheme of the embodiment of the present invention, a business request sent by a user is obtained, and the business request includes a request transaction code and a flow control annotation; through the preset annotation aspect correspondence relationship, according to the flow control annotation, the corresponding flow control aspect is determined; through the preset transaction belonging platform correspondence relationship, according to the request transaction code, the corresponding transaction belonging platform number is determined; through the preset belonging platform aspect correspondence relationship, according to the transaction belonging platform number, the flow control aspect is parameter adjusted to generate a target flow control aspect, and the target flow control aspect is a flow control logic based on aspect-oriented programming technology; the target flow control aspect is woven into the business request, and based on the target flow control logic in the target flow control aspect, the business request is flow controlled, and high-concurrency flow control is achieved based on the aspect, and the aspect strategy can be dynamically adjusted according to the flow change, thereby improving flexibility and dynamic adjustment capabilities; the aspect-based flow control method adopts efficient algorithms and data structures to achieve flow control with minimal performance overhead; it is decoupled from the business code, and does not need to modify the original code, so as to achieve precise control of the flow, thereby reducing delay and improving business efficiency, and has the characteristics of low intrusion, dynamics, flexibility and high performance.

[0244] It should be noted that the aspect-based flow control method provided in the embodiment of the present invention can be used in the field of financial technology, and can also be used in any technical field other than the field of financial technology. The embodiment of the present invention does not limit the application field of the virtual reality-based bank training system and its training method.

[0245] Figure 4 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention, such as Figure 4 As shown, the electronic device includes: a processor (processor) 501, a memory (memory) 502 and a bus 503.

[0246] The processor 501 and the memory 502 communicate with each other via a bus 503 .

[0247] The processor 501 is used to call the program instructions in the memory 502 to execute the methods provided by the above method embodiments.

[0248] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned slice-based flow control method is implemented.

[0249] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the above-mentioned slice-based flow control method is implemented.

[0250] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0251] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0252] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0253] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0254] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A flow control method based on a section, characterized in that: include: Obtaining a business request sent by a user, wherein the business request includes a request transaction code and a flow control annotation; By using the preset annotation section correspondence relationship, according to the flow control annotation, the corresponding flow control section is determined; By using the preset transaction attribution platform correspondence relationship, according to the requested transaction code, the corresponding transaction attribution platform number is determined; Through the preset corresponding relationship of the belonging platform aspect, according to the transaction belonging platform number, the parameters of the flow control aspect are adjusted to generate the target flow control aspect, and the target flow control aspect is the flow control logic based on aspect-oriented programming technology; The target flow control aspect is woven into the service request, and flow control is performed on the service request based on the target flow control logic in the target flow control aspect.

2. The flow control method based on section according to claim 1, characterized in that: The method further comprises: Annotation definition operation that receives input; A flow control annotation is constructed according to the annotation definition operation, and the flow control annotation is used to identify a service request for flow control.

3. The flow control method based on slices according to claim 1, characterized in that: The method further comprises: Aspect definition operations that receive input; According to the aspect definition operation, a flow control aspect is constructed, and the flow control aspect includes a flow control strategy and a flow restriction condition.

4. The flow control method based on slices according to claim 1, characterized in that: The target flow control logic includes a token limit quantity and a token limit rate, and the service request includes a token request quantity and a token request rate; The step of weaving the target flow control aspect into the service request and performing flow control on the service request based on the target flow control logic in the target flow control aspect includes: Based on the token bucket algorithm, flow control is performed on the token request quantity and the token request rate according to the token limit quantity and the token limit rate to generate a flow control result.

5. The flow control method based on section according to claim 4, characterized in that: The token bucket algorithm is based on which, according to the token limit quantity and the token limit rate, the token request quantity and the token request rate are flow controlled to generate a flow control result, including: Determine whether the token request quantity is less than or equal to the token limit quantity, and whether the token request rate is less than or equal to the token limit rate; If both are yes, a flow control result of the business request passing is generated; If at least one of them is no, querying for service requests that exceed the token limit quantity and / or exceed the token limit rate; Generate a flow control result of a failed business request based on the queried business request; For the service requests that do not exceed the token limit quantity and the token limit rate, a flow control result of the service request passing is generated.

6. The flow control method based on slices according to claim 1, characterized in that: The target flow control logic includes a flow restriction condition, the flow restriction condition includes a maximum request number threshold per second, and the service request includes a maximum request number per second; The step of weaving the target flow control aspect into the service request and performing flow control on the service request based on the target flow control logic in the target flow control aspect includes: Determine whether the maximum number of requests per second in the service request is less than or equal to the maximum number of requests per second threshold; If so, generate a flow control result for the service request to pass; If not, query the service requests that exceed the maximum number of requests per second threshold; Generate a flow control result of a failed business request based on the queried business request; For the service requests that do not exceed the maximum number of requests per second threshold, a flow control result of the service requests passing through is generated.

7. The flow control method based on slices according to claim 1, characterized in that: The target flow control logic includes a flow restriction condition, the flow restriction condition includes a concurrent connection number threshold, and the service request includes a concurrent connection number; The step of weaving the target flow control aspect into the service request and performing flow control on the service request based on the target flow control logic in the target flow control aspect includes: Determine whether the number of concurrent connections in the service request is less than or equal to the concurrent connection number threshold; If so, generate a flow control result for the service request to pass; If not, a flow control result indicating that the service request failed is generated.

8. The flow control method based on slices according to claim 1, characterized in that: The target flow control logic includes a flow restriction condition, the flow restriction condition includes a total request number threshold, and the service request includes a total request number; The step of weaving the target flow control aspect into the service request and performing flow control on the service request based on the target flow control logic in the target flow control aspect includes: Determine whether the total number of requests in the service request is less than or equal to the total number of requests threshold; If so, generate a flow control result for the service request to pass; If not, query the service requests that exceed the total request number threshold; Generate a flow control result of a failed business request based on the queried business request; For the service requests that do not exceed the total request number threshold, a flow control result of the service request passing is generated.

9. The flow control method based on slices according to claim 1, characterized in that: The method further comprises: Obtain monitoring data through the preset monitor list; Determining whether the monitored data complies with a preset flow control section adjustment rule; If yes, updating the flow control section according to the flow control section adjustment rule and the monitoring data to generate an updated flow control section; If not, repeat the step of obtaining the monitoring data through the preset monitor list.

10. The flow control method based on slices according to claim 9, characterized in that: The listener list includes system load listeners, the monitoring data includes CPU usage, and the flow control aspect adjustment rule includes usage token coefficient correspondence; The updating of the flow control section according to the monitoring data according to the flow control section adjustment rule to generate an updated flow control section includes: By using the usage rate token coefficient correspondence relationship, according to the CPU usage rate, the corresponding token coefficient is determined; According to the determined token coefficient, the token parameters in the flow control section are updated to generate an updated flow control section.

11. The flow control method based on slices according to claim 9, characterized in that: The listener list includes configuration change listeners, and the monitoring data includes configuration token parameters; The updating of the flow control section according to the monitoring data according to the flow control section adjustment rule to generate an updated flow control section includes: Update the token parameters in the flow control section to the monitored configuration token parameters and generate an updated flow control section.

12. The flow control method based on slices according to claim 9, characterized in that: The listener list includes time listeners, the monitoring data includes monitoring time, and the flow control section adjustment rule includes a time token parameter correspondence; The updating of the flow control section according to the monitoring data according to the flow control section adjustment rule to generate an updated flow control section includes: Determine the corresponding token parameter according to the monitoring time through the time token parameter correspondence relationship; The token parameters in the flow control section are updated to the determined token parameters, and an updated flow control section is generated.

13. A flow control device based on a section, characterized in that: include: A service request acquisition unit, used to acquire a service request sent by a user, wherein the service request includes a request transaction code and a flow control annotation; A section determination unit, configured to determine a corresponding flow control section according to the flow control annotation through a preset annotation section correspondence relationship; A platform number determination unit, configured to determine the corresponding transaction belonging platform number according to the requested transaction code through a preset transaction belonging platform correspondence relationship; A target aspect determination unit is used to adjust the parameters of the flow control aspect according to the transaction belonging platform number through the preset belonging platform aspect correspondence relationship, and generate a target flow control aspect, wherein the target flow control aspect is a flow control logic based on aspect-oriented programming technology; A flow control unit is used to weave the target flow control aspect into the service request, and perform flow control on the service request based on the target flow control logic in the target flow control aspect.

14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the slice-based flow control method described in any one of claims 1 to 12 is implemented.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the slice-based flow control method according to any one of claims 1 to 12 is implemented.

16. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the slice-based flow control method according to any one of claims 1 to 12 is implemented.

Citation Information

Patent Citations

  • API access control method, apparatus and device, and medium

    CN112035858A

  • System dynamic current limiting method and device, and storage medium

    CN112333111A

  • Service request processing method and device, electronic equipment and storage medium

    CN113179266A

  • Method and system for realizing current limiting based on data volume in parameter, storage medium and computer equipment

    CN115185491A

  • Flow limiting method, device and equipment of distributed system, medium and product

    CN115421922A

Cited By

  • Transaction control and processing method based on annotation

    CN122053504A