Gateway traffic control method and device, storage medium and computer program product

By configuring traffic control rules and weight values ​​in the gateway configuration center, and parsing and validating the rules based on the control fields, the flexibility problem of traffic gateways under multi-dimensional flow control strategies is solved, achieving efficient and flexible traffic control and reducing R&D and maintenance costs.

CN121771114APending Publication Date: 2026-03-31CHINA CONSTRUCTION BANK +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511958000.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-23
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing traffic gateways lack flexibility under complex, multi-dimensional, and nested flow control strategies. This results in the need to modify gateway code, test, and redeploy every time business requirements change or new control dimensions are added, leading to high R&D and maintenance costs and making it difficult to quickly respond to flexible and ever-changing business operation needs.

Method used

Configure traffic control rules and weight values ​​in the gateway's configuration center, parse and validate rules based on control fields, dynamically adjust them through weight value sorting and sliding time window counting, and generate traffic control instructions to determine whether to allow access requests.

Benefits of technology

It improves the flexibility of gateway traffic control, enables the execution of multi-dimensional and refined traffic control strategies, reduces R&D costs, and improves response speed and system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121771114A_ABST
    Figure CN121771114A_ABST
Patent Text Reader

Abstract

The invention discloses a gateway flow control method and device, a storage medium and a computer program product, and the method comprises the steps: configuring a flow control rule and a weight value corresponding to the flow control rule at a configuration center of a gateway, and enabling the flow control rule to carry out the flow control based on a control field; receiving an access request initiated by a requester, and analyzing the access request according to a control field corresponding to the flow control rule to obtain a control field value corresponding to the control field; and performing rule verification on the access request based on the weight value, the control field value and the flow control rule to obtain a verification result, and generating a flow control instruction according to the verification result. By adopting the technical scheme, the problem of how to improve the flexibility of flow control of the gateway is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network communication, and more specifically, to a gateway flow control method and apparatus, storage medium, and computer program product. Background Technology

[0002] Currently, in distributed systems, especially microservice architectures, technology platforms achieve the reuse and standardization of technical capabilities by aggregating and providing public services. As the unified traffic entry point for the technology platform, the traffic gateway undertakes critical service governance responsibilities. One of its core functions is to control inbound transaction traffic to prevent backend services from crashing due to overload.

[0003] Existing traffic gateways typically develop customized traffic control filters for specific traffic control dimensions, such as specific service interfaces, tenants, or IP addresses. However, when businesses require complex, multi-dimensional, nested flow control policies—for example, controlling the total traffic to a service interface while also differentiating access traffic to different tenants—existing solutions reveal significant shortcomings. Their flow control policies are hard-coded, lacking the ability to dynamically adjust at runtime, resulting in severely insufficient system flexibility. Each change in business requirements or the addition of a control dimension necessitates a lengthy process of modifying gateway code, testing, and redeploying, leading to high R&D and maintenance costs and hindering rapid response to flexible and evolving business operational needs.

[0004] Regarding the relevant technologies, there is currently no effective solution for improving the flexibility of gateways in traffic control.

[0005] Therefore, it is necessary to improve the relevant technology to overcome the aforementioned defects. Summary of the Invention

[0006] This application provides a gateway traffic control method and apparatus, storage medium and computer program product, to at least solve the problem of how to improve the flexibility of gateway traffic control.

[0007] According to one aspect of the embodiments of this application, a traffic control method for a gateway is provided, comprising: configuring traffic control rules and weight values ​​corresponding to the traffic control rules in the configuration center of the gateway, wherein the traffic control rules perform traffic control based on control fields; receiving an access request initiated by a requester, and parsing the access request according to the control fields corresponding to the traffic control rules to obtain control field values ​​corresponding to the control fields; performing rule verification on the access request based on the weight values, the control field values, and the traffic control rules to obtain verification results, and generating traffic control instructions based on the verification results.

[0008] In an exemplary embodiment, configuring traffic control rules and corresponding weight values ​​in the configuration center of the gateway includes: in response to a rule configuration request from a target object, configuring the traffic control rule, the control threshold corresponding to the traffic control rule, the control period corresponding to the traffic control rule, and the priority of the traffic control rule in the configuration center; determining the weight value of the traffic control rule according to the priority, wherein the weight value of a traffic control rule with higher priority is less than the weight value of a traffic control rule with lower priority.

[0009] In one exemplary embodiment, parsing the access request according to the control field corresponding to the traffic control rule to obtain the control field value includes: obtaining the control field corresponding to the traffic control rule, wherein the control field includes a request address, requester information, and Internet Protocol address; obtaining a predefined field parsing rule for the control field; and parsing the request message of the access request according to the field parsing rule to obtain the control field value.

[0010] In an exemplary embodiment, the access request is validated based on the weight value, the control field value, and the traffic control rule to obtain a validation result. This includes: sorting the traffic control rules in ascending order of the weight values ​​to obtain sorted traffic control rules; obtaining a target traffic control rule from the sorted traffic control rules, wherein the target traffic control rule represents the first traffic control rule among the unvalidated traffic control rules; obtaining the target field value corresponding to the target traffic control rule from the control field values; executing the target traffic control rule according to the target field value to validate the access request and obtain a sub-validation result, wherein the sub-validation result includes validation passed or validation failed; and determining the sub-validation results corresponding to all traffic control rules as the validation result.

[0011] In an exemplary embodiment, generating a flow control instruction based on the verification result includes: generating a first flow control instruction when the verification result indicates that the sub-verification result corresponding to any flow control rule fails verification, wherein the first flow control instruction is used to reject the access request and return a flow control exception response; and generating a second flow control instruction when the verification result indicates that the sub-verification results corresponding to all flow control rules pass verification, wherein the second flow control instruction is used to allow the access request.

[0012] In an exemplary embodiment, executing the target traffic control rule based on the target field value to perform rule verification on the access request and obtain a sub-verification result includes: obtaining the control period and control threshold corresponding to the target traffic control rule; obtaining the current count value corresponding to the control period, wherein the current count value is obtained by counting the access requests being processed using a sliding time window; comparing the current count value with the control threshold to obtain a comparison result; if the comparison result indicates that the current count value is greater than the control threshold, determining the sub-verification result as verification failure; if the comparison result indicates that the current count value is less than the control threshold, or the target field value does not satisfy the target traffic control rule, determining the sub-verification result as verification success.

[0013] In an exemplary embodiment, before obtaining the current count value corresponding to the control cycle, the method further includes: generating key-value pair data corresponding to the target traffic control rule, wherein the key part of the key-value pair data is the target traffic control rule, and the value part is the current count value; during the control cycle, for each access request received, the current count value is incremented by one, and for each access request processed, the current count value is decremented by one; when the control cycle ends and the next control cycle begins, the current count value is reset to a preset value.

[0014] According to another aspect of the embodiments of this application, a gateway traffic control device includes: a configuration module, configured to configure traffic control rules and weight values ​​corresponding to the traffic control rules in the configuration center of the gateway, wherein the traffic control rules perform traffic control based on control fields; a receiving module, configured to receive an access request initiated by a requester, and parse the access request according to the control field corresponding to the traffic control rules to obtain a control field value corresponding to the control field; and a verification module, configured to perform rule verification on the access request based on the weight values, the control field values, and the traffic control rules to obtain a verification result, and generate a traffic control instruction based on the verification result.

[0015] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the above-described gateway flow control method when running.

[0016] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the flow control method of the gateway through the computer program.

[0017] This application allows for the configuration of traffic control rules and corresponding weight values ​​in a gateway. Upon receiving an access request, the corresponding control field value is first extracted from the request. Then, the traffic control rules are executed sequentially according to the weight and control field value for rule verification. Finally, a traffic control instruction is generated based on the verification result to determine whether to allow the access request. This technical solution addresses the issue of improving the flexibility of traffic control in a gateway, thereby enhancing the overall flexibility of traffic control. Attached Figure Description

[0018] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments of this application and, together with the description thereof, serve to explain this application and do not constitute an undue limitation thereof. In the drawings:

[0019] Figure 1 This is a hardware structure block diagram of a computer terminal that executes the gateway flow control method according to an embodiment of this application;

[0020] Figure 2 This is a flowchart of a gateway traffic control method according to an embodiment of this application;

[0021] Figure 3 This is a schematic diagram of a gateway traffic control method according to an embodiment of this application;

[0022] Figure 4 This is a schematic flowchart (I) of a gateway traffic control method according to an embodiment of this application;

[0023] Figure 5 This is a schematic flowchart (II) of a gateway traffic control method according to an embodiment of this application;

[0024] Figure 6 This is a structural block diagram of a gateway flow control device according to an embodiment of this application. Detailed Implementation

[0025] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0026] It should be noted that the terms and terms such as "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0027] The collection, storage, use, processing, transmission, provision, and disclosure of financial data or user data involved in the technical solution of this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0028] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the solution.

[0029] The methods and embodiments provided in this application can be executed on a computer terminal or similar computing device. Taking running on a computer terminal as an example, Figure 1 This is a hardware structure block diagram of a computer terminal executing the gateway flow control method according to an embodiment of this application. For example... Figure 1 As shown, a computer terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor unit (MPU) or a programmable logic device (PLD)) and a memory 104 configured to store data are also included. In one exemplary embodiment, the computer terminal may further include a transmission device 106 configured for communication and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 Equivalent functions or ratios shown Figure 1 The functions shown have more different configurations.

[0030] The memory 104 may be configured to store computer programs, such as application software programs and modules, like the computer program corresponding to the gateway traffic control method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thereby implementing the aforementioned method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0031] The transmission device 106 is configured to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the computer terminal. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module configured to communicate with the Internet wirelessly.

[0032] This embodiment provides a gateway traffic control method. Figure 2 This is a flowchart of a gateway traffic control method according to an embodiment of this application, which includes the following steps:

[0033] Step S202: Configure traffic control rules and corresponding weight values ​​in the configuration center of the gateway, wherein the traffic control rules perform traffic control based on control fields;

[0034] Step S204: Receive the access request initiated by the requester, and parse the access request according to the control field corresponding to the traffic control rule to obtain the control field value corresponding to the control field.

[0035] Step S206: Based on the weight value, the control field value, and the traffic control rule, perform rule verification on the access request to obtain the verification result, and generate a traffic control instruction based on the verification result.

[0036] Optionally, in the above steps, for example, the technology platform acts as a unified traffic hub, and its traffic gateway dynamically configures traffic control rules through a configuration center, rather than using the traditional hard-coding method. Each rule is associated with a weight value, which determines the execution priority when multiple rules coexist. At runtime, the received access request should first be parsed to extract the specific values ​​of the control fields (such as interface identifiers, tenant information, etc.) on which the rules depend. Subsequently, the system performs logical verification using the extracted field values ​​and preset rules according to the weight order, and finally generates a traffic control instruction to decide whether to allow or deny the request based on the verification result.

[0037] By following the steps described above, traffic control rules and corresponding weight values ​​can be configured in the gateway. When an access request is received, the corresponding control field value is first extracted from the request. Then, the traffic control rules are executed sequentially according to the weight and control field value for rule verification. Finally, a traffic control instruction is generated based on the verification result to determine whether to allow the access request. This technical solution addresses the issue of improving the flexibility of traffic control in gateways, thereby enhancing the overall flexibility of traffic control.

[0038] In an exemplary embodiment, configuring traffic control rules and corresponding weight values ​​in the configuration center of the gateway includes: in response to a rule configuration request from a target object, configuring the traffic control rule, the control threshold corresponding to the traffic control rule, the control period corresponding to the traffic control rule, and the priority of the traffic control rule in the configuration center; determining the weight value of the traffic control rule according to the priority, wherein the weight value of a traffic control rule with higher priority is less than the weight value of a traffic control rule with lower priority.

[0039] Optionally, the configuration process is refined in the above embodiments. Administrators initiate rule configuration requests through the configuration interface. For example, a rule can be configured to "limit the total access volume of the / api / v1 / order interface," where the control field is the request URL (Uniform Resource Locator). The system parses the URL of each request, and if a match is found, the rule takes effect. A complete traffic control rule in the configuration center contains at least four elements: the rule itself (e.g., "total traffic control for interface A"), a control threshold Y (e.g., 100 requests per second), a control period Z (e.g., 1 second), and a business priority. The system then maps this business priority to an internal weight value, following the principle that higher priority results in lower weight values ​​(or, as needed, higher priority results in higher weight values). For example, the business priority of total interface traffic control is higher than that of traffic control for a specific tenant, therefore its weight value 1 is less than the weight value 2 of tenant flow control. This design ensures that more fundamental and global rules are executed first during rule validation.

[0040] In one exemplary embodiment, parsing the access request according to the control field corresponding to the traffic control rule to obtain the control field value includes: obtaining the control field corresponding to the traffic control rule, wherein the control field includes a request address, requester information, and Internet Protocol address; obtaining a predefined field parsing rule for the control field; and parsing the request message of the access request according to the field parsing rule to obtain the control field value.

[0041] Optionally, in the above embodiments, the method for obtaining control field values ​​is explicitly defined. Traffic control rules apply to different dimensions, which correspond to different control fields in the request. For example, the "request address" can be a URL path; the "requester information" can be the APP_ID field in the HTTP (Hypertext Transfer Protocol) header, used to identify the tenant; and the "Internet Protocol address" is the IP (Internet Protocol) address. To accurately extract the values ​​of these fields from the request message, predefined parsing rules are required. For example, for tenant flow control, the parsing rule could be "obtain the value from the X-APP-ID field in the HTTP request header"; for interface flow control differentiated by transaction code, the parsing rule could be "obtain the value from the txnCode field in the JSON (JavaScript Object Notation) message body". The gateway parses the request message according to these predefined rules to obtain the specific field values ​​required for rule validation.

[0042] In an exemplary embodiment, the access request is validated based on the weight value, the control field value, and the traffic control rule to obtain a validation result. This includes: sorting the traffic control rules in ascending order of the weight values ​​to obtain sorted traffic control rules; obtaining a target traffic control rule from the sorted traffic control rules, wherein the target traffic control rule represents the first traffic control rule among the unvalidated traffic control rules; obtaining the target field value corresponding to the target traffic control rule from the control field values; executing the target traffic control rule according to the target field value to validate the access request and obtain a sub-validation result, wherein the sub-validation result includes validation passed or validation failed; and determining the sub-validation results corresponding to all traffic control rules as the validation result.

[0043] Optionally, the weight-based rule verification process is described in detail in the above embodiments. When an access request triggers multiple traffic control rules simultaneously, the gateway first sorts the rules in ascending order according to their weight values. The rule with the lowest weight value (i.e., the rule with the highest priority) will be verified as the first "target traffic control rule." The gateway will use the part of the control field value previously parsed that is related to the rule (i.e., the target field value) to execute the rule logic. For example, assuming there is a total traffic control rule for interface A with a weight of 1 and a traffic control rule for tenant M with a weight of 2, the system will first verify whether the total traffic of interface A exceeds the limit. Regardless of whether this rule verification passes or fails, a "sub-verification result" will be obtained. Then, the system will continue to verify the next rule (i.e., the traffic control rule for tenant M) in sequence and obtain another sub-verification result. Finally, the sub-verification results of all rules together constitute the final verification result of this request. This sequential execution mechanism ensures that high-priority rules (such as global interface traffic control) are intercepted first, which is in line with business logic.

[0044] In an exemplary embodiment, generating a flow control instruction based on the verification result includes: generating a first flow control instruction when the verification result indicates that the sub-verification result corresponding to any flow control rule fails verification, wherein the first flow control instruction is used to reject the access request and return a flow control exception response; and generating a second flow control instruction when the verification result indicates that the sub-verification results corresponding to all flow control rules pass verification, wherein the second flow control instruction is used to allow the access request.

[0045] Optionally, in the above embodiments, a method for generating a final instruction based on the verification results is defined. The logic is a veto system. If any rule fails verification during the weighted sequential verification process (e.g., the interface's total traffic is full, or a tenant's quota has been exhausted), a first traffic control instruction is immediately generated. This instruction interrupts subsequent request processing, and the gateway directly assembles and returns a flow control exception message to the requester. Conversely, only when all rules in the sorted list pass verification will a second traffic control instruction be generated, allowing the access request to be forwarded normally to the backend service. Therefore, precise interception and passage of traffic control are achieved.

[0046] In an exemplary embodiment, executing the target traffic control rule based on the target field value to perform rule verification on the access request and obtain a sub-verification result includes: obtaining the control period and control threshold corresponding to the target traffic control rule; obtaining the current count value corresponding to the control period, wherein the current count value is obtained by counting the access requests being processed using a sliding time window; comparing the current count value with the control threshold to obtain a comparison result; if the comparison result indicates that the current count value is greater than the control threshold, determining the sub-verification result as verification failure; if the comparison result indicates that the current count value is less than the control threshold, or the target field value does not satisfy the target traffic control rule, determining the sub-verification result as verification success.

[0047] Optionally, the above embodiments illustrate the verification logic for a specific traffic control rule. Rule execution relies on three key parameters: control period Z, control threshold Y, and current count value. The current count value is maintained using a sliding time window algorithm, dynamically reflecting the number of requests being processed within the most recent control period Z. During verification, the system compares the current count value with the control threshold Y. If the current count value has reached or exceeded Y, it means that the traffic has exceeded the limit, and the rule verification fails. Furthermore, there is another situation where the target field value does not meet the rule, which refers to the failure during the rule matching phase. For example, a rule is "restrict tenant M from accessing interface A," but the current requesting tenant is N, and the interface is B. In this case, the rule should not apply to this request at all; logically, it is considered "satisfied" or can be skipped. However, in a rigorous implementation, this can be attributed to "field value mismatch," causing the rule to "pass verification" for this request. The core traffic judgment is based on the comparison between the count and the threshold: if the count value is less than the threshold and the rule applies, it passes; otherwise, it fails.

[0048] In an exemplary embodiment, before obtaining the current count value corresponding to the control cycle, the method further includes: generating key-value pair data corresponding to the target traffic control rule, wherein the key part of the key-value pair data is the target traffic control rule, and the value part is the current count value; during the control cycle, for each access request received, the current count value is incremented by one, and for each access request processed, the current count value is decremented by one; when the control cycle ends and the next control cycle begins, the current count value is reset to a preset value.

[0049] Optionally, the above embodiments illustrate the implementation mechanism of the sliding time window counter. Each flow control rule corresponds to a key-value pair in the system. The key uniquely identifies the rule (e.g., "interface A_total"), and the value is the current count value. This key-value pair has a time-to-live (TTL), which is the control period Z. The counting logic is as follows: whenever the gateway receives an access request that matches the rule, it immediately increments the count value corresponding to the rule by 1 (equivalent to occupying one capacity unit); when the gateway receives the response from the backend service and returns the result to the caller, it decrements the count value by 1 (releasing one capacity unit). This "request increment, response decrement" method accurately counts the number of requests being processed concurrently within the system. When the lifetime of a key-value pair reaches the control period Z, the entry will automatically expire. The system will generate a new key-value pair for the next period and reset the count value to the initial value (such as 0), thereby realizing the periodic sliding and resetting of the count. It can flexibly support the control of different time dimensions such as TPS (Transactions Per Second) or TPM (Transactions Per Minute).

[0050] In the above embodiments, by introducing dynamic rule configuration, the traditional traffic gateway model, which requires customized code development for different flow control scenarios, is completely changed, thereby greatly improving the flexibility and R&D efficiency of traffic control. This application achieves multi-dimensional and refined management of the execution order of traffic control strategies by pre-setting weights for flow control rules at different levels, ensuring that rules such as interface-level, tenant-level, and IP-level rules take effect in an orderly manner according to business priority. Simultaneously, a sliding time window mechanism is used to maintain traffic counts, allowing the control cycle to be flexibly adjusted according to business needs, accurately supporting the control of different time granularities such as TPS and TPM. Furthermore, by pre-defining the parsing rules for control fields, this application can adapt to diverse business scenarios ranging from URLs and transaction codes to protocol headers. In summary, this application achieves a configurable, multi-level, highly efficient, and low-cost unified traffic governance capability, significantly enhancing the service governance and operational efficiency of the technology platform in complex business scenarios.

[0051] Obviously, the embodiments described above are only some embodiments of this application, and not all embodiments. To better understand the above gateway access method, the process is described below with reference to embodiments, but this is not intended to limit the technical solutions of the embodiments of this application. Specifically:

[0052] In an optional embodiment, the gateway traffic control method of this application can be implemented through, as follows: Figure 3 The illustrated traffic gateway architecture implements a system where each user initiates network requests or data transmissions using their own traffic. All user traffic is managed and controlled through a unified traffic gateway. The traffic gateway consists of inbound and outbound flow control. Inbound flow control controls traffic entering the gateway based on information such as IP address, channel, and user. Outbound flow control controls traffic leaving the gateway based on information such as business fields, interfaces, and services. The rule engine configuration center is the core of the entire system, responsible for generating and distributing traffic control rules. These rules guide the traffic gateway on how to manage and control traffic, ensuring the rational allocation and use of network resources. Traffic processed by the traffic gateway is ultimately directed to services. Services represent the final network services or applications, which users access through the traffic gateway. This architecture, through centralized management and control of traffic, effectively prevents network congestion and resource waste. The flexibility of the rule engine allows the system to dynamically adjust traffic control strategies according to actual needs, improving network stability and response speed.

[0053] In an optional embodiment, the flow control rules are mainly defined by two indicators: a control value and a control period. The control rule is set to X, the control value to Y, and the control period to Z. The rule engine then distributes the flow control rules in a configured manner. The processing methods for each part are as follows:

[0054] Control value processing method: When the traffic gateway receives an access request, the traffic value is incremented by one; when the traffic gateway receives a service response and returns the result to the caller, the traffic value is decremented by one; within the control period Z, when the traffic value exceeds the control value Y, the traffic gateway will no longer send service requests to the backend, but will directly assemble a flow control exception message and return it to the requester.

[0055] Control cycle processing method: Control rules and control values ​​exist in the form of key-value pairs. The expiration time of each key-value pair is Z. When the lifespan of a key-value pair exceeds the control cycle Z, the control rule becomes invalid and a new key-value pair is generated to start counting again.

[0056] Control rule processing method: Control rules can be layered according to the actual business scenario. The rule hierarchy is illustrated as follows: {Rule 5 {Rule 4: {Rule 3: {Rule 2: {Rule 1: Value}}}}. Each rule needs to be pre-set with weights in the rule engine according to the different rule granularities. Taking interface-level flow control and tenant-level flow control as examples, when the business requirement is to control the total traffic accessing interface A while controlling the traffic accessing interface A by tenants M and N, in the actual business processing flow, triggering interface traffic control rules will take precedence over tenant control rules. This is because tenant control rules are only effective when interface A can make requests and responses normally. When the total traffic control of interface A has been triggered, tenant-level control is ineffective. The interface flow control weight can be set to 1, and the tenant flow control weight can be set to 2. Furthermore, if it is also necessary to set flow control policies for each IP address under the tenant cluster, the IP flow control weight can be set to 3.

[0057] The rule engine actually designs three rules based on business requirements. The overall interface traffic control rule is designed as {interface A: value}, with a weight of 1. Since tenant M and tenant N have the same flow control weight, the tenant traffic control rules are designed as {tenant M:{interface A: value}} and {tenant N:{interface A: value}}, with a weight of 2. The rule engine synchronizes each rule and its weight to the traffic gateway. The traffic gateway controls the execution order of traffic control according to the weight. In this scenario, interface-level flow control is executed first, followed by tenant-level flow control for tenant M and tenant N simultaneously.

[0058] General traffic weight design, such as Figure 4 As shown, the labels represent the control rule weights: Gateway overall flow control 1, Service overall flow control 2, Interface flow control 3, Interface-level tenant flow control 4, IP flow control 5. If it is also necessary to control the flow of tenants to services, new weight branches can be created based on the weight design, such as... Figure 5 As shown: Gateway overall flow control 1, Service overall flow control 2, Service-level tenant flow control 3, Interface flow control 3, Interface-level tenant flow control 4, IP flow control 5.

[0059] Methods for obtaining control fields: When designing flow control rules, it is also necessary to define how to obtain the control fields for each rule. For example, for interface flow control, the definition of the interface needs to be clearly defined. If the interface is distinguished by URL address, the URL exposed by the traffic gateway is used as the interface flow control field. If the interface is distinguished by transaction code, the transaction code field in the received message is used as the interface flow control field. Similarly, for tenant flow control, if tenant information is distinguished by APP_ID information in the HTTP header, the value of APP_ID is obtained from the header as the control field. If tenant information is distinguished by message fields, the tenant information value is obtained from the message as the control field.

[0060] In the above embodiments, the configuration of the rule engine in the configuration center enables flexible combination and configuration of traffic control rules, reducing the customization development process of traffic control strategies. By setting traffic control weights, the execution order of traffic control methods can be controlled, thus refining the traffic control strategy. Configuring the traffic control cycle in a sliding window manner allows for customized adjustment of the time dimension of traffic control, facilitating control cycle adjustments for different business scenarios. Configuration information can control the acquisition rules of key traffic control fields in different ways, satisfying specific control requirements for different business scenarios.

[0061] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.

[0062] This embodiment also provides a gateway flow control device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.

[0063] Figure 6 This is a structural block diagram of a gateway traffic control device according to an embodiment of this application. The device includes:

[0064] Configuration module 62 is used to configure traffic control rules and corresponding weight values ​​in the configuration center of the gateway, wherein the traffic control rules perform traffic control based on control fields;

[0065] The receiving module 64 is used to receive the access request initiated by the requester, and parse the access request according to the control field corresponding to the flow control rule to obtain the control field value corresponding to the control field.

[0066] The verification module 66 is used to perform rule verification on the access request based on the weight value, the control field value and the traffic control rule, obtain the verification result, and generate a traffic control instruction based on the verification result.

[0067] The gateway traffic control device according to the embodiments of this application can configure traffic control rules and corresponding weight values ​​in the gateway. When an access request is received, the corresponding control field value is first extracted from the request. Then, the traffic control rules are executed sequentially according to the weight and control field value for rule verification. Finally, a traffic control instruction is generated based on the verification result to determine whether to allow the access request. By adopting the above technical solution, the problem of how to improve the flexibility of gateway traffic control is solved, thereby achieving the effect of improving the flexibility of gateway traffic control.

[0068] In an exemplary embodiment, the configuration module 62 is configured, in response to a rule configuration request from a target object, to configure the traffic control rule, the control threshold corresponding to the traffic control rule, the control period corresponding to the traffic control rule, and the priority of the traffic control rule in the configuration center; and to determine the weight value of the traffic control rule according to the priority, wherein the weight value of a traffic control rule with a higher priority is less than the weight value of a traffic control rule with a lower priority.

[0069] In an exemplary embodiment, the receiving module 64 is configured to obtain a control field corresponding to the traffic control rule, wherein the control field includes a request address, requester information, and Internet Protocol address; obtain a predefined field parsing rule for the control field; and parse the request message of the access request according to the field parsing rule to obtain the control field value.

[0070] In an exemplary embodiment, the verification module 66 is configured to: sort the traffic control rules according to the weight values ​​in ascending order to obtain sorted traffic control rules; obtain a target traffic control rule from the sorted traffic control rules, wherein the target traffic control rule represents the first traffic control rule among the unverified traffic control rules; obtain the target field value corresponding to the target traffic control rule from the control field values; execute the target traffic control rule according to the target field value to perform rule verification on the access request, and obtain a sub-verification result, wherein the sub-verification result includes verification passed or verification failed; and determine the sub-verification results corresponding to all traffic control rules as the verification result.

[0071] In an exemplary embodiment, the verification module 66 is configured to generate a first flow control instruction when the verification result indicates that the sub-verification result corresponding to any flow control rule fails, wherein the first flow control instruction is used to reject the access request and return a flow control exception response; and to generate a second flow control instruction when the verification result indicates that the sub-verification results corresponding to all flow control rules pass, wherein the second flow control instruction is used to allow the access request.

[0072] In an exemplary embodiment, the verification module 66 is configured to: obtain the control period and control threshold corresponding to the target traffic control rule; obtain the current count value corresponding to the control period, wherein the current count value is obtained by counting access requests in the process using a sliding time window; compare the current count value with the control threshold to obtain a comparison result; if the comparison result indicates that the current count value is greater than the control threshold, determine the sub-verification result as verification failure; if the comparison result indicates that the current count value is less than the control threshold, or the target field value does not meet the target traffic control rule, determine the sub-verification result as verification success.

[0073] In an exemplary embodiment, the verification module 66 is configured to generate key-value pair data corresponding to the target traffic control rule, wherein the key part of the key-value pair data is the target traffic control rule, and the value part is the current count value; during the control cycle, the current count value is incremented by one for each access request received, and decremented by one for each access request processed; when the control cycle ends and the next control cycle begins, the current count value is reset to a preset value.

[0074] Embodiments of this application also provide a storage medium including a stored program, wherein the program executes any of the above embodiments when it is run.

[0075] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:

[0076] S1, Configure traffic control rules and corresponding weight values ​​in the configuration center of the gateway, wherein the traffic control rules perform traffic control based on control fields;

[0077] S2, receive the access request initiated by the requester, and parse the access request according to the control field corresponding to the traffic control rule to obtain the control field value corresponding to the control field;

[0078] S3. Based on the weight value, the control field value, and the traffic control rule, the access request is validated to obtain the validation result, and a traffic control instruction is generated according to the validation result.

[0079] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0080] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.

[0081] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0082] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:

[0083] S1, Configure traffic control rules and corresponding weight values ​​in the configuration center of the gateway, wherein the traffic control rules perform traffic control based on control fields;

[0084] S2, receive the access request initiated by the requester, and parse the access request according to the control field corresponding to the traffic control rule to obtain the control field value corresponding to the control field;

[0085] S3. Based on the weight value, the control field value, and the traffic control rule, the access request is validated to obtain the validation result, and a traffic control instruction is generated according to the validation result.

[0086] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0087] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.

[0088] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.

[0089] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.

Claims

1. A traffic control method of a gateway, characterized by, The method comprises the following steps: configuring a traffic control rule and a weight value corresponding to the traffic control rule in a configuration center of a gateway, wherein the traffic control rule controls traffic based on a control field; receiving an access request initiated by a requestor, and parsing the access request according to a control field corresponding to the traffic control rule to obtain a control field value corresponding to the control field; based on the weight value, the control field value and the traffic control rule, performing rule verification on the access request to obtain a verification result, and generating a traffic control instruction according to the verification result.

2. The traffic control method of a gateway according to claim 1, wherein, Configuring a traffic control rule and a weight value corresponding to the traffic control rule in a configuration center of a gateway comprises: in response to a rule configuration request of a target object, configuring the traffic control rule, a control threshold value corresponding to the traffic control rule, a control period corresponding to the traffic control rule and a priority of the traffic control rule in the configuration center; determining the weight value of the traffic control rule according to the priority, wherein the weight value of a traffic control rule with a high priority is smaller than the weight value of a traffic control rule with a low priority.

3. The traffic control method of the gateway according to claim 2, wherein, Parsing the access request according to a control field corresponding to the traffic control rule to obtain a control field value comprises: obtaining a control field corresponding to the traffic control rule, wherein the control field comprises a request address, requestor information and an Internet Protocol address; obtaining a field parsing rule predefined for the control field; parsing a request message of the access request according to the field parsing rule to obtain the control field value.

4. The traffic control method of a gateway according to claim 1, wherein, Based on the weight value, the control field value and the traffic control rule, performing rule verification on the access request to obtain a verification result comprises: sorting the traffic control rules in ascending order of the weight values to obtain sorted traffic control rules; obtaining a target traffic control rule in the sorted traffic control rules, wherein the target traffic control rule represents a first traffic control rule in unverified traffic control rules; obtaining a target field value corresponding to the target traffic control rule from the control field value; executing the target traffic control rule according to the target field value to perform rule verification on the access request to obtain a sub-verification result, wherein the sub-verification result comprises verification pass or verification fail; determining the sub-verification result corresponding to all traffic control rules as the verification result.

5. The traffic control method of a gateway according to claim 4, wherein, Generating a traffic control instruction according to the verification result comprises: in a case where it is determined that the verification result indicates that any sub-verification result corresponding to a traffic control rule is verification fail, generating a first traffic control instruction, wherein the first traffic control instruction is used to reject the access request and return response information of flow control exception; in a case where it is determined that the verification result indicates that the sub-verification results corresponding to all traffic control rules are verification pass, generating a second traffic control instruction, wherein the second traffic control instruction is used to release the access request.

6. The traffic control method of a gateway according to claim 4, wherein, The target traffic control rule is executed according to the target field value to perform rule checking on the access request, and a sub-checking result is obtained, including: obtaining a control period and a control threshold corresponding to the target traffic control rule; obtaining a current count value corresponding to the control period, wherein the current count value is obtained by counting the access requests in processing by using a sliding time window; comparing the current count value with the control threshold to obtain a comparison result; in a case where it is determined that the comparison result indicates that the current count value is greater than the control threshold, determining that the sub-checking result is failed; in a case where it is determined that the comparison result indicates that the current count value is less than the control threshold, or the target field value does not satisfy the target traffic control rule, determining that the sub-checking result is passed.

7. The traffic control method of a gateway according to claim 6, wherein, Before obtaining the current count value corresponding to the control period, the method further includes: generating a key-value pair data corresponding to the target traffic control rule, wherein the key part of the key-value pair data is the target traffic control rule, and the value part is the current count value; in the control period, adding one to the current count value for each received access request, and subtracting one from the current count value for each processed access request; when the control period ends and enters the next control period, resetting the current count value to a preset value.

8. A traffic control apparatus of a gateway, characterized by, including: a configuration module configured to configure a traffic control rule and a weight value corresponding to the traffic control rule in a configuration center of a gateway, wherein the traffic control rule is based on a control field to control traffic; a receiving module configured to receive an access request initiated by a request party, and parse the access request according to a control field corresponding to the traffic control rule to obtain a control field value corresponding to the control field; a checking module configured to perform rule checking on the access request based on the weight value, the control field value and the traffic control rule, obtain a checking result, and generate a traffic control instruction according to the checking result.

9. A computer readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program performs the method described in any one of claims 1 to 7 when running.

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