Access control method and device, and computer-readable storage medium

By dynamically adjusting the access frequency limits of multiple interfaces of the server, the problem that the existing technology cannot adapt to changing business scenarios is solved, more efficient resource utilization and business performance improvement is achieved, and manual maintenance costs are reduced.

CN119766738APending Publication Date: 2025-04-04CHENGDU HONGHEAI CLASSROOM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411708489.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

When the prior art controls the access frequency of multiple server interfaces, it cannot adapt to changing business scenario needs, and the online configuration is costly and error-prone.

Method used

By obtaining the access frequency of multiple interfaces, and determining the ratio of the access frequency to the frequency limit of each interface within a preset interval. If the ratio is greater than the first proportional threshold, the frequency limit value is increased; if the ratio is less than the second proportional threshold, the frequency limit value is decreased. Update the access limit frequency parameter configuration of the interface using the adjusted frequency limit value.

Benefits of technology

Dynamically adjust the matching degree between the access frequency and access frequency limits of multiple interfaces, adapt to changing business scenario needs, reduce server performance consumption, improve business usage performance, and reduce manual maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119766738A_ABST
    Figure CN119766738A_ABST
Patent Text Reader

Abstract

The present application provides a method and device for access control, and a computer-readable storage medium. The access control method is applied to a server, and includes: in response to reaching a preset interval time, obtaining the access frequency of multiple interfaces; determining the ratio of the access frequency of the first interface to the first frequency limit; if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, then increasing the first frequency limit, and the increased first frequency limit is lower than the preset maximum limit frequency value; if the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold, then reducing the first frequency limit; using the adjusted first frequency limit, updating the access limit frequency parameter configuration of the first interface. The present application helps to accurately adapt to the quantitative requirements of multiple interfaces and adapt to changing business scenario requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to an access control method and device, and a computer-readable storage medium. Background Art

[0002] The server platform can provide services to multiple other platforms at the same time, and usually uses a flow control algorithm to control the access frequency of multiple interfaces of the server. For example, open source flow limiting frameworks such as Guava Rate Limiter and Resilience4j are used to implement interface access frequency restrictions. Alternatively, custom annotations or filters are used to cache interface access frequencies and configure the number of restrictions to control interface access frequencies. However, these methods are all sampled fixed interface configurations, which cannot adapt to changing business scenario requirements, or there are problems such as high manual maintenance costs and easy errors in online configuration. Summary of the invention

[0003] The present application provides an access control method and device, and a computer-readable storage medium, which are helpful to reasonably allocate access frequency limits of multiple interfaces and adapt to changing business scenario requirements. The following introduces various aspects involved in the present application.

[0004] In a first aspect, the present application provides an access control method, applied to a server, the method comprising: obtaining access frequencies of multiple interfaces; in response to reaching a preset interval time, determining the ratio of the access frequency of a first interface to a first frequency limit, the first interface being any one of the multiple interfaces, and the first frequency limit being the value of an access limit frequency parameter of the first interface; if the ratio of the access frequency of the first interface to the first frequency limit is greater than a first proportional threshold, increasing the first frequency limit, and the increased first frequency limit is lower than a preset maximum limit frequency value; if the ratio of the access frequency of the first interface to the first frequency limit is less than a second proportional threshold, reducing the first frequency limit; and using the adjusted first frequency limit, updating the access limit frequency parameter configuration of the first interface.

[0005] In the second aspect, the present application provides an access control device, comprising: an acquisition module, used to acquire the access frequencies of multiple interfaces; a determination module, used to determine the ratio of the access frequency of a first interface to a first frequency limit in response to reaching a preset interval time, the first interface being any interface among the multiple interfaces, and the first frequency limit being the value of the access limit frequency parameter of the first interface; an adjustment module, used to increase the first frequency limit if the ratio of the access frequency of the first interface to the first frequency limit is greater than a first proportional threshold, the increased first frequency limit being lower than a preset maximum limit frequency value, and if the ratio is less than a second proportional threshold, reducing the first frequency limit; a configuration module, used to update the access limit frequency parameter configuration of the first interface using the adjusted first frequency limit.

[0006] In a third aspect, the present application provides a server, comprising: a memory for storing code; and a processor connected to the memory, for executing the code stored in the memory, so that the server executes the method described in the first aspect.

[0007] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect can be implemented.

[0008] In a fifth aspect, the present application provides a computer program product, which, when executed on an electronic device, enables the electronic device to implement the method described in the first aspect.

[0009] In an embodiment of the present application, if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, the first frequency limit is increased, and more resources are configured for the first interface, which helps to alleviate the congestion pressure of the first interface and improve processing efficiency. If the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold, the first frequency limit is reduced to reduce resource waste, and more resources are reserved for other interfaces, which helps to improve the matching degree between the access frequency of the first interface and the first frequency limit. In an embodiment of the present application, in order to meet the basic access requirements of multiple external platforms, through statistics and calculations, the matching degree between the access frequency of multiple interfaces and the access frequency limit can be dynamically adjusted, and the quantitative requirements of multiple interfaces can be more accurately adapted, the performance consumption of the server can be reduced, and the business performance can be improved. It can adapt to the changing business scenario requirements and avoid the problems of high manual maintenance costs and easy errors caused by online configuration. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.

[0011] Figure 1 It is a flowchart of the access control method provided in an embodiment of the present application.

[0012] Figure 2 yes Figure 1 A flowchart of a possible implementation of step S110 of the method.

[0013] Figure 3 yes Figure 1 A flowchart of another possible implementation of the method.

[0014] Figure 4 It is a schematic diagram of an access control device provided in an embodiment of the present application.

[0015] Figure 5 It is a schematic diagram of a component unit / partial component unit of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0016] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The same or similar reference numerals are used in the drawings to represent the same or similar modules. It should be understood that the drawings are only schematic, and the protection scope of the present application is not limited thereto.

[0017] First, the application scenarios involved in the embodiments of the present application are introduced.

[0018] Multi-platform service means that one platform provides services to multiple other platforms at the same time. For example, a platform product can connect to multiple external platform services at the same time. With the continuous development of network technology, the number of network access users continues to increase. When a large number of users (or clients) access the server platform, under the condition of high concurrency and high traffic, problems such as access blocking and access errors will occur. To address the above problems, a flow control algorithm can be used to control the access frequency of multiple interfaces of the server.

[0019] (I) You can use open source rate limiting frameworks, such as Guava RateLimiter, Resilience4j, etc. to implement the access frequency limit of the interface. These frameworks provide convenient application programming interfaces (APIs) to configure and manage rate limiting strategies, and can perform customized rate limiting control as needed.

[0020] Among them, Guava is Google's open source Java tool library, which includes the implementation of interface access frequency limiting. Guava's current limiting principle is based on the token bucket algorithm. The token bucket algorithm is a time-based algorithm that can control the number of access requests to an interface within a given time. In the token bucket algorithm, it is assumed that there is a bucket of fixed size, which places tokens at a fixed rate, and the number of tokens changes over time. Whenever an access request arrives, it must take a token before it can be processed. If no token is available when the access request arrives, the access request will be discarded, which can help limit the number of access requests to the interface and protect the stability and availability of the interface. However, Guava's limiting strategy is relatively simple, and lacks support for the implementation of current limiting for multiple strategies. Resilience4j is a lightweight fault-tolerant component that is mainly designed for Java 8 and functional programming.

[0021] (ii) You can use custom annotations or filters to cache the interface access frequency and configure the limit number to control the interface access frequency. Annotations are a kind of metadata. Adding annotations to the code can provide additional information to help compilers, tools, and frameworks better understand the code.

[0022] However, in actual use, it is found that the current interface traffic control algorithm has shortcomings to varying degrees: fixed interface configuration may be suitable for certain business scenarios, but it cannot fully cover changing business scenarios and different docking platforms. If you modify the configuration to continuously adapt to changing business scenarios and platforms, it will cause a lot of labor costs and easily lead to online failures due to misoperation; human judgment is not necessarily accurate, which may lead to limited business performance or excessive overhead of server performance due to high access frequency.

[0023] It can be seen that the current interface traffic control algorithm for connecting to different platforms has problems such as unreasonable configuration of interface access restriction frequency, inability to adapt to changing business scenario requirements, and high manual maintenance cost and easy errors in online configuration.

[0024] Therefore, it is necessary to design a technical solution for multi-interface traffic control that can adapt to changing business scenarios.

[0025] Based on this, the embodiment of the present application proposes a method for access control. The method of the embodiment of the present application is applied to a server, which may be a distributed server, and the distributed server may receive access requests from multiple users or multiple clients. Figure 1 The access control method of the embodiment of the present application is described in detail. Figure 1 As shown, the access control method of the embodiment of the present application may mainly include steps S110 to S140, and these steps are described in detail below.

[0026] It should be pointed out that the size of the serial numbers of the steps in the embodiments of the present application does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0027] In step S110, access frequencies of multiple interfaces are obtained.

[0028] Multiple interfaces may correspond to multiple clients, different interfaces may correspond to different clients, and access requests from clients may be received through the interfaces. Alternatively, multiple interfaces may correspond to multiple different business scenarios.

[0029] It is understandable that the access frequency of the interface is the number of access requests per unit time, for example, the number of access requests within 1 minute. The access frequency of the interface can be calculated by counting the number of access requests within a predetermined time.

[0030] The calculated access frequencies of multiple interfaces may be stored in a cache area, for example, the access frequencies of multiple interfaces may be cached in a Redis database according to the interface dimension.

[0031] In some implementations, within a predetermined time, the number of access requests to multiple interfaces can be counted based on the aspect mechanism of aspect oriented programming (AOP), and the access frequencies of multiple interfaces obtained by statistics are cached in a memory database according to the interface dimension. The memory database can be, for example, a Memcached database or a Redis database. AOP is a technology that implements unified maintenance of program functions through precompilation and dynamic proxy during runtime. The predetermined time can be, for example, 0.5 minutes, 1 minute, or 3 minutes.

[0032] In step S120, in response to reaching a preset interval time, a ratio of an access frequency of a first interface to a first frequency limit is determined. The first interface is any interface among a plurality of interfaces, and the first frequency limit is a value of an access limit frequency parameter of the first interface.

[0033] The access restriction frequencies of different interfaces can be the same or different. To cope with changing business scenarios, the access restriction frequency parameters of multiple interfaces are usually set differently.

[0034] The server is usually provided with a configuration module responsible for configuring the access restriction frequency parameters of multiple interfaces. In some implementations, the current access restriction frequencies of multiple interfaces can be obtained through the configuration module. In other implementations, the access restriction frequencies of multiple interfaces can also be read from a cache area that caches the access restriction frequency parameter values ​​of multiple interfaces.

[0035] The preset interval time can be, for example, 0.5 minutes, 1 minute, or 3 minutes. The specific value of the preset interval time can be flexibly adjusted according to the access restriction time range required by the interface. If the time interval is too short, the access restriction frequency of the interface is adjusted too frequently, which is not conducive to server stability; if the time interval is too long, the access restriction frequency adjustment setting of the interface is prone to lag behind, which cannot meet the access control requirements of rapidly changing business scenarios.

[0036] According to the preset interval time, the access frequency of the first interface is compared with the first frequency limit to determine the specific ratio of the access frequency of the first interface to the first frequency limit, so as to understand the matching degree between the access frequency of the first interface and the first frequency limit, and then determine specific adjustment measures.

[0037] In step S130, if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, the first frequency limit is increased, and the increased first frequency limit is lower than the preset maximum frequency limit value. If the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold, the first frequency limit is reduced. It can be understood that the first ratio threshold is greater than the second ratio threshold, and the first ratio threshold and the second ratio threshold are both greater than 0 and not greater than 1. Specifically, the first ratio threshold is greater than 1 / 2, for example, it can be 2 / 3, 3 / 4, and the second ratio threshold is less than 1 / 2, for example, it can be 1 / 3, 1 / 4.

[0038] If the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, it means that the first interface has many access requests and a large business volume. Increasing the first frequency limit can configure more resources for the first interface, which helps to alleviate the congestion pressure of the first interface and improve processing efficiency. If the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold, it means that the first interface has few access requests and a small business volume, and the currently set frequency limit wastes resources. Therefore, its access frequency limit can be reduced to improve the matching degree between the access frequency of the first interface and the first frequency limit, thereby reserving more resources for other interfaces, which helps to improve the overall processing capacity of multiple interfaces.

[0039] In some implementations, if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, then the first frequency limit is increased; if the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold, then the first frequency limit is reduced, which may include: if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, then the first frequency limit is increased to a first preset multiple of the original frequency limit; if the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold, then the first frequency limit is reduced to a second preset multiple of the original frequency limit. Wherein, the first preset multiple is greater than 1 and less than or equal to 2, and the second preset multiple is greater than 0 and less than 1. The first preset multiple may be, for example, 1.4, 1.5, 1.6 or 2, and the second preset multiple may be, for example, 0.4, 0.5, 0.6. The first preset multiple and the second preset multiple may be manually set according to actual conditions, or the values ​​of the first preset multiple and the second preset multiple may be automatically adjusted by an automated system. By reasonably setting the first frequency limit, it is helpful to reduce the number of times / frequency of adjusting the first frequency limit configuration, quickly improve the matching degree between the access frequency of the first interface and the first frequency limit, and improve the overall processing capacity of multiple interfaces.

[0040] In some implementations, the first ratio threshold may be 3 / 4, and the second ratio threshold may be 1 / 4, which helps to widen the gap between the first ratio threshold and the second ratio threshold. If the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, the first frequency limit is increased to the first preset multiple of the original frequency limit; if the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold, the first frequency limit is reduced to the second preset multiple of the original frequency limit, which may include: if the ratio of the access frequency of the first interface to the first frequency limit is greater than 3 / 4, the first frequency limit is increased to 1.5 times the original frequency limit; if the ratio of the access frequency of the first interface to the first frequency limit is less than 1 / 4, the first frequency limit is reduced to 0.5 times the original frequency limit. By reasonably setting the first frequency limit, it is helpful to reduce the number / frequency of adjusting the configuration of the first frequency limit, quickly improve the matching degree between the access frequency of the first interface and the first frequency limit, improve efficiency and save resources.

[0041] However, the increased first frequency limit value must be lower than the preset maximum frequency limit value. The preset maximum frequency limit value is the maximum access frequency limit value of any interface.

[0042] In some implementations, the preset maximum frequency limit value is determined based on the access frequency quota of the server and the number of multiple interfaces. The access frequency quota of the server is also called the maximum access frequency limit of the system. For example, if the access frequency quota of the server is 10,000 and the number of multiple interfaces is 10, the preset maximum frequency limit value may be 10,000 / 10*3=3,000, or the preset maximum frequency limit value may be 10,000 / 10*4=4,000. Reasonable determination of the preset maximum frequency limit value helps to improve overall efficiency.

[0043] In some implementations, the sum of the access restriction frequencies of multiple interfaces may be equal to the access frequency quota of the server. Considering that the probability that access requests from multiple interfaces reach the access restriction frequency at the same time is low, in other implementations, the sum of the access restriction frequencies of multiple interfaces may be greater than the access frequency quota of the server, for example, the sum of the access restriction frequencies of multiple interfaces is 1.1 times, 1.2 times, or 1.5 times the access frequency quota of the server, which helps to improve the overall access capability and efficiency of the system.

[0044] In step S140, the access restriction frequency parameter configuration of the first interface is updated using the adjusted first frequency limit value.

[0045] In some implementations, a distributed configuration module may be called to update the access frequency limit parameter configuration of the first interface to the adjusted first frequency limit. The distributed configuration module or distributed configuration center may be, for example, Apollo, Spring Cloud Config, Nacos, etc.

[0046] Before acquiring the access frequencies of the multiple interfaces, the method of the embodiment of the present application may further include: configuring access limit frequency parameters of the multiple interfaces according to preset frequency limits of the multiple interfaces.

[0047] During initial settings, the access frequency limits of multiple interfaces can be set to preset frequency limits, which are also called system default values. For example, if the access frequency limit of the server is 10,000 and the number of multiple interfaces is 10, the system default value can be 10,000 / 10=1,000.

[0048] In an embodiment of the present application, if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, the first frequency limit is increased, and more resources are configured for the first interface, which helps to alleviate the congestion pressure of the first interface and improve processing efficiency. If the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold, the first frequency limit is reduced to reduce resource waste, and more resources are reserved for other interfaces, which helps to improve the matching degree between the access frequency of the first interface and the first frequency limit. In an embodiment of the present application, in order to meet the access requirements of multiple external platforms, through statistics and calculations, the matching degree between the access frequency of multiple interfaces and the access frequency limit can be dynamically adjusted, and the quantitative requirements of multiple interfaces can be more accurately adapted, the performance consumption of the server can be reduced, and the service usage performance can be improved. It can adapt to the changing business scenario requirements and avoid the problems of high manual maintenance costs and easy errors in online configuration.

[0049] The method of the embodiment of the present application can be modified dynamically, take effect in real time, and is not perceived by the user, which helps to reduce manual maintenance costs and improve the stability of online operations. It helps to improve the overall processing capacity of multiple interfaces, that is, to make full use of service resources and avoid service jams and unavailability caused by fluctuations in access frequency. When docking multiple platforms, it can adapt to the needs of changes in interface access frequency caused by changes in business scenarios and time periods.

[0050] The method of the embodiment of the present application is further explained below in combination with some possible implementation methods of the present application.

[0051] For example, the application development framework uses Spring, which can annotate the interface access configuration. The cache framework uses the Redis database to count the access frequencies of multiple interfaces. The scheduled task uses XXL-Job to summarize the access frequencies of each interface at a scheduled time. The distributed configuration module uses Apollo to connect to multiple open interfaces for dynamic configuration modification and monitor configuration changes to take effect in real time.

[0052] Among them, the Spring framework is created for the complexity of software development and is not limited to server-side development. Redis is an open source in-memory data structure storage system that can be used as a database, cache, and message middleware. XXL-Job is a distributed task scheduling platform whose core design goals are rapid development, simple learning, lightweight, and easy to expand. The Apollo Open Platform is an API interface service provided to developers for managing and controlling data in the Apollo autonomous driving platform.

[0053] Create a new Spring project in the software development tool, write multiple interfaces that need to be connected, use custom annotations and AOP to intercept requests to limit the access frequency of multiple interfaces, and introduce the access frequency limit parameters of multiple interfaces into Apollo configuration. Custom annotations refer to some tags that developers can define according to their own needs to identify certain classes, methods, variables, etc. During the process of code writing and execution, these annotation information can be read to achieve some specific functions. The interface access frequency can be counted according to the interface dimension in the cache framework Redis through the AOP aspect mechanism.

[0054] You can set a scheduled task based on a predetermined time period, such as a preset interval, to compare the access frequency of the current interface (for example, the first interface) in the Redis cache with the corresponding access frequency limit (such as the first frequency limit). If it reaches 3 / 4 of the access frequency limit, the access frequency limit will be increased, for example, it can be set to 3 / 2 times the current access frequency limit, but not more than the preset maximum limit frequency set by the current server. Conversely, if it is lower than 1 / 4 of the currently configured access frequency limit, the access frequency limit will be lowered, for example, it can be 1 / 2 times the current access frequency limit. It helps to improve the matching degree between the access frequency of any interface and its frequency limit, and improve the overall processing power of multiple interfaces.

[0055] By calling the Apollo open platform interface, using the adjusted access frequency limit, modify the parameter configuration of the current interface, and set the access frequency limit parameter of the current interface to the adjusted access frequency limit. And by monitoring Apollo, the configuration is updated in real time, and the change log is persisted to the database.

[0056] Operation and maintenance personnel can refer to the configuration change records of the current interface to understand the usage of the current service interface and allocate service resources, which helps to make rational and full use of resources.

[0057] Through the above process, for different interfaces that provide multiple business scenarios, as multiple platforms are added and removed, and business changes occur, the current service interface of the server can be called and counted in real time to achieve the effect of dynamic configuration modification of the system, which helps to make full use of the server's access service resources and maintain a good service status in a complex business environment. The following is an explanation of some possible implementation codes and processes.

[0058] It is understandable that the access frequency of the interface is the number of access requests per unit time, for example, the number of access requests per minute. The access frequency limit of the interface is the maximum number of access requests allowed per unit time, for example, the maximum number of access requests allowed per minute. The access frequency limit can be achieved by setting the maximum number of access requests allowed per unit time (or the maximum number of requests), for example, by setting the maximum number of access requests allowed per minute to set the access frequency limit of the interface.

[0059] The client sends an access request to the server, enters the AOP aspect processing class, and obtains the maximum number of requests corresponding to the current interface from the interface and maximum number of requests Map (i.e., mapping table) configured by Apollo according to the current interface name. If the corresponding maximum number of requests is not obtained, it means that it is a new interface, and its maximum number of requests can take the system default value, that is, the maximum number of requests corresponding to the preset frequency limit. Then read the cumulative number of requests for the cached interface in Redis. The cumulative number of requests is the cumulative number of access requests, which corresponds to the access frequency. If the cache exists and does not exceed the maximum number of requests, the cumulative number of requests is increased by 1; otherwise, if the cache does not exist, the cache value of the interface is added, and the initial number of requests can be set to 1.

[0060] Figure 2 yes Figure 1 A flow chart of a possible implementation of step S110 of the method. Specifically, Figure 2 As shown, step S110 may mainly include steps S111 to S119, which are described in detail below.

[0061] In step S111, AOP interception is performed.

[0062] AOP interception refers to inserting additional logic through a proxy mechanism before or after a method is executed or when an exception occurs, in order to enhance or modify the behavior of a method. This interception mechanism enables developers to add cross-cutting concerns such as logging, transaction management, and security checks without changing the original business logic code.

[0063] In step S112, the access request of the client enters through the corresponding interface.

[0064] In step S113, the access frequency limits of multiple interfaces configured by Apollo are obtained.

[0065] In step S114, it is determined whether the number of access requests of the interface exists in the cache. If yes, the process proceeds to step S115; if no, the process proceeds to step S118.

[0066] In step S115, the cumulative number of accesses to the cached interface is retrieved. The cumulative number of accesses to the interface within a unit time (eg, 1 minute) is the access frequency.

[0067] In step S116, it is determined whether the cumulative number of accesses to the interface is less than the configured maximum number of requests. The maximum number of requests to the interface within a unit of time (such as 1 minute) is the access frequency limit. If it is less than, the process proceeds to step S118; if it is not less than, the process proceeds to step S117.

[0068] In step S117, since the accumulated access number is not less than the maximum request number, that is, the access frequency of the interface is greater than or equal to the access frequency limit, the access request is intercepted.

[0069] In step S118, the cumulative number of accesses to the cache is increased by 1, or a new cache is created.

[0070] Since the cumulative access count is less than the maximum request count, that is, the access frequency of the interface is less than the access frequency limit, the interface allows the access request to enter, and the cumulative access count of the cache is increased by 1. If the interface has no cumulative access count, or it is a new interface, a new cumulative access count cache is created, and the initial access request count is set to 1.

[0071] In step S119, the cache value is updated, that is, the cumulative number of accesses to the interface is updated.

[0072] The above is the processing flow of Redis cache.

[0073] Add custom annotations to the interfaces that need to limit access frequency, and perform unified processing through the custom annotated aspect class.

[0074] Figure 3 yes Figure 1 A flow chart of a possible implementation of the method. Figure 3 As shown, the method of the embodiment of the present application may mainly include steps S310 to S380, and these steps are described in detail below.

[0075] In step S310, a predetermined time interval is set, and XXL-Job is responsible for executing the scheduled task.

[0076] In step S320, the access frequency limit of multiple interfaces configured by Apollo is obtained, that is, the maximum number of accesses to the multiple interfaces per unit time.

[0077] In step S330, the cache count of all interfaces is read, that is, the cumulative access count of all cached interfaces.

[0078] In step S340, traversal processing is performed according to the interface dimension.

[0079] All interfaces are processed in sequence, either according to the interface numbers or according to the order of access frequency limits.

[0080] In step S350, it is determined whether the configuration parameters of the interface exist.

[0081] If the access frequency limit configuration of the interface exists, then go to step S360; if not, it indicates that the interface may be a new interface and cannot be compared with the access frequency of the interface, then go to step S370.

[0082] In step S360, a judgment is made according to a predetermined rule to calculate a new configuration value.

[0083] The predetermined rule may be: if the ratio of the access frequency of the first interface to the first frequency limit is greater than 3 / 4, the first frequency limit is increased to 1.5 times; if the ratio of the access frequency of the first interface to the first frequency limit is less than 1 / 4, the first frequency limit is reduced to 0.5 times. That is, if the ratio of the cumulative number of accesses to the first interface to the maximum number of accesses is greater than 3 / 4, the first frequency limit is increased to 1.5 times; if the ratio of the cumulative number of accesses to the first interface to the maximum number of accesses is less than 1 / 4, the first frequency limit is reduced to 0.5 times.

[0084] In step S370, the default value of the interface is set, that is, the access frequency limit of the interface is set to the system default value (ie, the preset frequency limit).

[0085] In step S380, the access frequency limit parameters of each interface configured by Apollo are updated.

[0086] The above is the processing flow of the Apollo configuration module.

[0087] The embodiments of the present application can perform call statistics on the interfaces in the service in real time, and perform periodic calculations and adjustments according to the rules designed by the system, so as to achieve the effect of dynamically adjusting the configuration of the system within the access frequency adjustment range under a complex business environment, which helps to make full use of service resources and maintain a good service status.

[0088] The XXL-Job scheduled calculation task is set to execute once every 1 minute. That is, the preset interval time is 1 minute, and the preset interval time can be flexibly adjusted according to the access restriction time range required by the interface. If the time interval is too short, for example, you can use a cache key-value pair for one time interval, and then batch process the 1-minute scheduled task. The scheduled task pulls the number of access requests accumulated in the cache for the interface, and traverses and processes according to the interface name. Set the adjustment rules in advance, then check which interval the number of access requests meets, adjust the configuration value of the maximum number of accesses (corresponding to the number of access frequency limits) according to the rules, and update it to the Apollo configuration table.

[0089] According to the Apollo official open interface document, you can write an Apollo configuration update method to update the adjusted interface access frequency limit configuration table to Apollo. By monitoring parameter configuration changes in Apollo, you can synchronize them to all services that reference the configuration in real time.

[0090] After the new configuration takes effect, a new round of caching, timing calculation, and configuration update operations for the number of access requests for multiple interfaces will be performed, so that the configuration of each interface of the server can be automatically and flexibly adjusted within the control range.

[0091] In an embodiment of the present application, if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, the first frequency limit is increased, and more resources are configured for the first interface, which helps to alleviate the congestion pressure of the first interface and improve processing efficiency. If the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold, the first frequency limit is reduced to reduce resource waste, and more resources are reserved for other interfaces, which helps to improve the matching degree between the access frequency of the first interface and the first frequency limit. In an embodiment of the present application, in order to meet the basic access requirements of multiple external platforms, through statistics and calculations, the matching degree between the access frequency of multiple interfaces and the access frequency limit can be dynamically adjusted, and the quantitative requirements of multiple interfaces can be more accurately adapted, reducing the performance consumption of the server and improving the performance of business use. It can adapt to the changing business scenario requirements and avoid the problems of high manual maintenance costs and easy errors caused by online configuration.

[0092] The method of the embodiment of the present application can be modified dynamically, take effect in real time, and is not perceived by the user, which helps to reduce manual maintenance costs and improve the stability of online operations. It helps to improve the overall processing capacity of multiple interfaces, that is, to make full use of service resources and avoid service jams and unavailability caused by fluctuations in access frequency. When docking multiple platforms, it can adapt to the needs of changes in interface access frequency caused by changes in business scenarios and time periods.

[0093] Combination of the above Figure 1-Figure 3 The method embodiment of the present application is described in detail. Figures 4 to 5 The device embodiment of the present application is described in detail. It should be understood that the description of the device embodiment corresponds to the description of the method embodiment, so the parts not described in detail can refer to the previous method embodiment.

[0094] Figure 4 It is a schematic diagram of the composition of the access control device provided in an embodiment of the present application. Figure 4 The access control device is applied to the server. Figure 4 As shown, the access control apparatus 400 may include: an acquisition module 410 , a determination module 420 , an adjustment module 430 and a configuration module 440 .

[0095] The acquisition module 410 is used to acquire access frequencies of multiple interfaces, and the multiple interfaces may correspond to multiple user terminals.

[0096] The determination module 420 is used to determine the ratio of the access frequency of the first interface to the first frequency limit in response to reaching the preset interval time. The first interface is any interface among the multiple interfaces, and the first frequency limit is the value of the access limit frequency parameter of the first interface.

[0097] The adjustment module 430 is used to increase the first frequency limit if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, and the increased first frequency limit is lower than the preset maximum limit frequency value. If the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold, then reduce the first frequency limit.

[0098] The configuration module 440 is used to update the access restriction frequency parameter configuration of the first interface by using the adjusted first frequency limit value.

[0099] Optionally, the first ratio threshold is greater than 1 / 2 and less than 1, and the second ratio threshold is greater than 0 and less than 1 / 2. The adjustment module 430 is configured to increase the first frequency limit to a first preset multiple of the original frequency limit if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, and to reduce the first frequency limit to a second preset multiple of the original frequency limit if the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold.

[0100] Optionally, the first preset multiple is greater than 1 and less than or equal to 2, and the second preset multiple is greater than 0 and less than 1.

[0101] Optionally, the first ratio threshold is 3 / 4, and the second ratio threshold is 1 / 4. The adjustment module 430 is used to increase the first frequency limit to 1.5 times the original frequency limit if the ratio of the access frequency of the first interface to the first frequency limit is greater than 3 / 4, and to reduce the first frequency limit to 0.5 times the original frequency limit if the ratio of the access frequency of the first interface to the first frequency limit is less than 1 / 4.

[0102] Optionally, the acquisition module 410 is used to count the number of access requests of multiple interfaces respectively based on the aspect mechanism of aspect-oriented programming, and cache the access frequencies of the multiple interfaces obtained by counting in an in-memory database according to the interface dimension.

[0103] Optionally, the preset maximum limit frequency value is determined based on the access frequency quota of the server and the number of multiple interfaces.

[0104] Optionally, the configuration module 440 is further configured to configure the access limit frequency parameters of the multiple interfaces according to the preset frequency limits of the multiple interfaces. The configuration module 440 is configured to call the distributed configuration module to update the access frequency limit parameter configuration of the first interface to the adjusted first frequency limit.

[0105] Figure 5 Schematic diagram of a component unit / partial component unit of a server provided in an embodiment of the present application. Figure 5 As shown, the server 500 may include: a memory 510 and at least one processor 520 .

[0106] The memory 510 is used to store codes or computer programs.

[0107] The processor 520 is connected to the memory 510 and is used to execute the code or computer program stored in the memory 510 to control the server 500 to execute any of the methods described above.

[0108] Exemplarily, the computer program may be divided into one or more modules / units, one or more modules / units are stored in the memory 510 and executed by the processor 520 to complete the present application.

[0109] Those skilled in the art will understand that Figure 5 This is merely an example of the server 500 and does not constitute a limitation on the server. The server 500 may include more or fewer components than shown in the figure, or some components may be combined, or different components may be included.

[0110] The processor 520 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor, etc.

[0111] The server 500 provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0112] An embodiment of the present application further provides a non-volatile computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0113] An embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0114] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above method embodiments, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above method embodiments can be implemented. Among them, the computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / electronic device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), read-only compact disc (CD-ROM), magnetic tape, floppy disk and optical data storage device. The computer-readable storage medium mentioned in the present application can be a non-volatile storage medium, in other words, it can be a non-transient storage medium.

[0115] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0116] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0117] In the embodiments provided in the present application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0118] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0119] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0120] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0121] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0122] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method of access control, characterized in that: Applied to a server, the method comprises: Get the access frequency of multiple interfaces; In response to reaching a preset interval time, determining a ratio of an access frequency of a first interface to a first frequency limit value, the first interface being any interface among the multiple interfaces, the first frequency limit value being a value of an access limit frequency parameter of the first interface; If the ratio of the access frequency of the first interface to the first frequency limit is greater than a first ratio threshold, the first frequency limit is increased, and the increased first frequency limit is lower than a preset maximum limit frequency value; if the ratio of the access frequency of the first interface to the first frequency limit is less than a second ratio threshold, the first frequency limit is reduced; The access restriction frequency parameter configuration of the first interface is updated using the adjusted first frequency limit value.

2. The method according to claim 1, characterized in that The first ratio threshold is greater than 1 / 2 and less than 1, the second ratio threshold is greater than 0 and less than 1 / 2, and if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, the first frequency limit is increased, and if the ratio is less than the second ratio threshold, the first frequency limit is decreased, including: If the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, the first frequency limit is increased to a first preset multiple of the original frequency limit; if the ratio is less than the second ratio threshold, the first frequency limit is reduced to a second preset multiple of the original frequency limit.

3. The method according to claim 2, characterized in that The first preset multiple is greater than 1 and less than or equal to 2, and the second preset multiple is greater than 0 and less than 1.

4. The method according to claim 1, characterized in that The obtaining of access frequencies of multiple interfaces includes: Within a preset time, based on the aspect mechanism of aspect-oriented programming, the number of access requests of the multiple interfaces is counted respectively, and the access frequencies of the multiple interfaces obtained by counting are cached in an in-memory database according to the interface dimension.

5. The method according to claim 1, characterized in that Before obtaining the access frequencies of the multiple interfaces, the method further includes: According to the preset frequency limits of the multiple interfaces, configuring the access limit frequency parameters of the multiple interfaces; The updating of the access frequency limit parameter configuration of the first interface by using the adjusted first frequency limit includes: The distributed configuration module is called to update the access frequency limit parameter of the first interface to the adjusted first frequency limit.

6. The method according to claim 1, characterized in that The preset maximum limit frequency value is determined based on the access frequency quota of the server and the number of the multiple interfaces.

7. An access control device, characterized in that: Applied to a server, the device comprises: An acquisition module, used to acquire access frequencies of multiple interfaces; a determination module, configured to determine, in response to reaching a preset interval time, a ratio of an access frequency of a first interface to a first frequency limit value, wherein the first interface is any interface among the multiple interfaces, and the first frequency limit value is a value of an access limit frequency parameter of the first interface; an adjustment module, configured to increase the first frequency limit if a ratio of the access frequency of the first interface to the first frequency limit is greater than a first ratio threshold, and the increased first frequency limit is lower than a preset maximum frequency limit value, and to decrease the first frequency limit if the ratio is less than a second ratio threshold; A configuration module is used to update the access restriction frequency parameter configuration of the first interface by using the adjusted first frequency limit value.

8. The device according to claim 7, characterized in that The first ratio threshold is greater than 1 / 2 and less than 1, and the second ratio threshold is greater than 0 and less than 1 / 2. The adjustment module is used to increase the first frequency limit to a first preset multiple of the original frequency limit if the ratio of the access frequency of the first interface to the first frequency limit is greater than the first ratio threshold, and to reduce the first frequency limit to a second preset multiple of the original frequency limit if the ratio of the access frequency of the first interface to the first frequency limit is less than the second ratio threshold.

9. The device according to claim 8, characterized in that The first preset multiple is greater than 1 and less than or equal to 2, and the second preset multiple is greater than 0 and less than 1.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed, the computer program is used to implement the method according to any one of claims 1 to 6.