Application service current limiting method, device, equipment and storage medium
By dynamically adjusting the current limiting threshold and degradation strategy of service sub-interfaces and performing personalized current limiting based on business complexity, the problem of poor flexibility in current limiting configuration in the existing technology is solved and the stable operation of application services is ensured.
Patent Information
- Application Number
- CN202211650588.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-21
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2042-12-21
AI Technical Summary
The existing application service current limiting method limits all interfaces to the same threshold, resulting in performance degradation and poor configuration flexibility. It cannot be flexibly managed according to the business complexity of different interfaces.
By obtaining the access counter, current limiting threshold and degradation policy of each service sub-interface, the current limiting threshold and degradation policy can be dynamically adjusted according to the business complexity and access count value to achieve personalized current limiting for different interfaces.
It improves the flexibility of service current limiting, ensures the normal operation of busy interfaces, and ensures the operational stability of application services.
Smart Images

Figure CN115801685B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an application service current limiting method, device, equipment and storage medium. Background Art
[0002] Currently, in the software development process, in order to avoid the situation where the service is accessed by too many requests under high concurrency after the application service is released online, resulting in insufficient application service resources and making the application service unavailable, developers need to limit the flow of some application services. The existing flow limiting method is to configure the service access threshold in the server to limit the access to the application service. However, the existing flow limiting method is to limit the flow of all interfaces in the application service with the same threshold, resulting in the maximum flow of the application service depending on the interface with the worst performance, resulting in reduced application service performance and poor configuration flexibility. Summary of the invention
[0003] The embodiments of the present application provide an application service current limiting method, apparatus, device and storage medium, aiming to solve the technical problem that the application service current limiting configuration in the prior art is less flexible.
[0004] On the one hand, an embodiment of the present application provides an application service flow limiting method, and the application service flow limiting method includes the following steps:
[0005] In response to an application service current limiting request, obtain a target application service pointed to by the application service current limiting request and each service sub-interface in the target application service;
[0006] Obtaining access counters corresponding to each service sub-interface in the target application service, and reading access count values of each access counter;
[0007] Read the target project source code of the target application service to obtain the current limiting threshold corresponding to each service sub-interface in the target project source code;
[0008] A preset degradation strategy for each service sub-interface is obtained, and service flow limiting is performed on the service sub-interface in the target application service according to the flow limiting threshold, the access count value and the degradation strategy.
[0009] In a possible implementation of the present application, the obtaining the access counter corresponding to each service sub-interface in the target application service and reading the access count value of the access counter includes:
[0010] Accessing a project source code database to obtain the target project source code of the target application service;
[0011] Traversing the aspect method classes in the target project source code to obtain access counters corresponding to each service sub-interface in the target application service;
[0012] The time window in each access counter is read to obtain the access count value of each access counter.
[0013] In a possible implementation of the present application, the obtaining of the access counters corresponding to the service sub-interfaces in the target application service, before reading the access count value of the access counter, further includes:
[0014] For an access counter corresponding to each service sub-interface, read the current time and the counter time of the access counter, and compare the current time and the counter time;
[0015] If the time difference between the current time and the counter time is less than the time window threshold of the access counter, then counting the access count value of the access counter;
[0016] If the time difference between the current system time and the counter time is greater than or equal to the time window threshold of the access counter, the counter time of the access counter is reset.
[0017] In a possible implementation of the present application, before reading the target project source code of the target application service and obtaining the current limiting threshold corresponding to each service sub-interface in the target project source code, the method further includes:
[0018] Obtaining the service type and service complexity of each service sub-interface in the target application service;
[0019] Input the service type and the service complexity of each service sub-interface into a preset current limiting model to perform current limiting calculation, and obtain a current limiting threshold of each service sub-interface;
[0020] According to a preset annotation strategy, each of the service sub-interfaces and the current limiting threshold are associated and written into the target project source code.
[0021] In a possible implementation of the present application, the obtaining of a preset degradation strategy for each service sub-interface, and performing service flow limiting on the service sub-interface in the target application service according to the flow limiting threshold, the access count value, and the degradation strategy, includes:
[0022] Responding to a service access request, obtaining a service sub-interface corresponding to the service access request and a degradation strategy for the service sub-interface;
[0023] Comparing the current limiting threshold of the service sub-interface with the access count value of the service sub-interface;
[0024] If the access count value is less than the current limiting threshold, updating the access count value and driving the service sub-interface of the target application service to execute the service access request;
[0025] If the access count value is greater than the current limiting threshold, service current limiting is performed on the service sub-interface of the target application service according to the degradation strategy.
[0026] In a possible implementation of the present application, if the access count value is greater than the current limiting threshold, performing service current limiting on the service sub-interface of the target application service according to the degradation strategy, including:
[0027] If the access count value is greater than the current limiting threshold, obtaining the downgrade thread and downgrade feedback parameter in the downgrade strategy;
[0028] The downgrade thread is called to downgrade the service sub-interface of the target application service, and the downgrade feedback parameter is returned.
[0029] In a possible implementation of the present application, the obtaining of a preset degradation strategy for each service sub-interface, and performing service flow limiting on the service sub-interface in the target application service according to the flow limiting threshold, the access count value, and the degradation strategy, includes:
[0030] Calculate the interface load data of each service sub-interface in the target application service according to the access count value and the current limiting threshold;
[0031] Accessing a degradation strategy database, obtaining a degradation strategy corresponding to the interface load data, and extracting a load degradation strategy from the degradation strategy;
[0032] The service sub-interface in the target application service is subjected to service flow limiting according to the load degradation strategy.
[0033] On the other hand, the present application provides an application service current limiting device, the application service current limiting device comprising:
[0034] A service acquisition module is configured to respond to an application service current limiting request, acquire a target application service pointed to by the application service current limiting request, and each service sub-interface in the target application service;
[0035] A counting reading module is configured to obtain an access counter corresponding to each service sub-interface in the target application service, and read an access count value of each access counter;
[0036] A threshold acquisition module is configured to read the target project source code of the target application service and obtain the current limiting threshold corresponding to each service sub-interface in the target project source code;
[0037] The service flow limiting module is configured to obtain a preset degradation strategy for each service sub-interface, and perform service flow limiting on the service sub-interface in the target application service according to the flow limiting threshold, the access count value and the degradation strategy.
[0038] On the other hand, the present application also provides an application service current limiting device, the application service current limiting device comprising:
[0039] one or more processors;
[0040] Memory; and
[0041] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the steps of the application service current limiting method.
[0042] On the other hand, the present application also provides a computer-readable storage medium on which a computer program is stored, and the computer program is loaded by a processor to execute the steps in the application service flow limiting method.
[0043] In this application, by responding to the application service flow limiting request, the target application service pointed to by the application service flow limiting request and each service sub-interface in the target application service are obtained; the access counter corresponding to each service sub-interface in the target application service is obtained, and the access count value of each access counter is read; the target project source code of the target application service is read to obtain the flow limiting threshold corresponding to each service sub-interface in the target project source code; the preset degradation strategy of each service sub-interface is obtained, and the service flow limiting is performed on the service sub-interface in the target application service according to the flow limiting threshold, the access count value and the degradation strategy. Different degradation strategies and flow limiting thresholds are set for different service interfaces according to the complexity of the business, thereby improving the flexibility of service flow limiting, ensuring the normal operation of the interface with busy business, and thus ensuring the operation stability of the business application service. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0045] Figure 1 A schematic diagram of a scenario in which a service flow limiting method is applied in an embodiment of the present application;
[0046] Figure 2 This is a flow chart of an embodiment of the application service flow limiting method in the embodiment of the present application;
[0047] Figure 3 A flow chart of an embodiment of performing service flow limiting on a service sub-interface in the application service flow limiting method provided in an embodiment of the present application;
[0048] Figure 4 A flow chart of another embodiment of current limiting on a service sub-interface in the application service current limiting method provided in an embodiment of the present application;
[0049] Figure 5 A structural diagram of an embodiment of an application service current limiting device provided in an embodiment of the present application;
[0050] Figure 6 This is a schematic diagram of the structure of an embodiment of the application service current limiting device provided in the embodiments of the present application. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0052] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, which are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0053] In this application, the word "exemplary" is used to mean "serving as an example, illustration, or illustration." Any embodiment described in this application as "exemplary" is not necessarily to be construed as being preferred or advantageous over other embodiments. The following description is given to enable any person skilled in the art to implement and use the invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the invention can be implemented without using these specific details. In other instances, well-known structures and processes are not elaborated in detail to avoid obscuring the description of the invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in this application.
[0054] Currently, in the software development process, in order to avoid the situation where the service is accessed by too many requests under high concurrency after the application service is released online, resulting in insufficient application service resources and making the application service unavailable, developers need to limit the flow of some application services. The existing flow limiting method is to configure the service access threshold in the server to limit the access to the application service. However, the existing flow limiting method is to limit the flow of all interfaces in the application service with the same threshold, resulting in the maximum flow of the application service depending on the interface with the worst performance, resulting in reduced application service performance and poor configuration flexibility.
[0055] Based on this, the present application proposes an application service current limiting method, device, equipment and computer-readable storage medium to solve the technical problem of poor flexibility in the application service current limiting configuration in the prior art.
[0056] The application service current limiting method in the embodiment of the present invention is applied to an application service current limiting device, and the application service current limiting device is arranged in the application service current limiting device, and the application service current limiting device is provided with one or more processors, memories, and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the application service current limiting method; wherein the application service current limiting device can be an intelligent terminal, such as a mobile phone, a tablet computer, a network device, and a smart computer, etc.; optionally, the application service current limiting device can also be a server, or a service cluster composed of multiple servers.
[0057] like Figure 1 As shown, Figure 1The present invention is a schematic diagram of a scenario of the application service current limiting method in an embodiment of the present invention. The application service current limiting scenario in the embodiment of the present invention includes an application service current limiting device 100 (an application service current limiting device is integrated in the application service current limiting device 100) and a target service terminal 200. A computer-readable storage medium corresponding to the application service current limiting method is run in the application service current limiting device 100 to execute the steps of the application service current limiting method. The target service terminal 200 is a service terminal that performs service access with the application service current limiting device 100.
[0058] Understandably, Figure 1 The application service current limiting device in the application service current limiting method scenario shown, or the devices included in the application service current limiting device, does not constitute a limitation on the embodiments of the present invention, that is, the number of devices and types of devices of the application service current limiting device included in the scenario of the application service current limiting method, or the number of devices and types of devices included in each device do not affect the overall implementation of the technical solution in the embodiments of the present invention, and can all be regarded as equivalent replacements or derivatives of the technical solution claimed to be protected by the embodiments of the present invention.
[0059] The application service current limiting device 100 in the embodiment of the present invention is mainly used to: respond to an application service current limiting request, obtain a target application service pointed to by the application service current limiting request, and each service sub-interface in the target application service;
[0060] Obtaining access counters corresponding to each service sub-interface in the target application service, and reading access count values of each access counter;
[0061] Read the target project source code of the target application service to obtain the current limiting threshold corresponding to each service sub-interface in the target project source code;
[0062] A preset degradation strategy for each service sub-interface is obtained, and service flow limiting is performed on the service sub-interface in the target application service according to the flow limiting threshold, the access count value and the degradation strategy.
[0063] The application service current limiting device 100 in the embodiment of the present invention can be an independent application service current limiting device, such as a smart terminal such as a mobile phone, a tablet computer, a network device, a server, and a smart computer, or it can be an application service current limiting network or an application service current limiting cluster composed of multiple application service current limiting devices.
[0064] The embodiments of the present application provide an application service current limiting method, apparatus, device, and computer-readable storage medium, which are described in detail below.
[0065] It can be understood by those skilled in the art that Figure 1The application environment shown in is only one of the application scenarios related to the present application solution and does not constitute a limitation on the application scenario of the present application solution. Other application environments may also include Figure 1 More or fewer application service current limiting devices, or application service current limiting network connection relationships shown, such as Figure 1 Only one application service current limiting device is shown. It can be understood that the scenario of the application service current limiting method can also include one or more application service current limiting devices, which are not specifically limited here; the application service current limiting device 100 can also include a memory for storing current limiting thresholds and other data.
[0066] It should be noted that Figure 1 The scenario diagram of the application service current limiting method shown is only an example. The scenario of the application service current limiting method described in the embodiment of the present invention is to more clearly illustrate the technical solution of the embodiment of the present invention, and does not constitute a limitation on the technical solution provided by the embodiment of the present invention.
[0067] Based on the scenario of the above-mentioned application service current limiting method, various embodiments of the application service current limiting method disclosed in the present invention are proposed.
[0068] like Figure 2 As shown, Figure 2 This is a flow chart of an embodiment of the application service flow limiting method in the embodiment of the present application. The application service flow limiting method includes the following steps 201 to 204:
[0069] 201. Respond to an application service current limiting request, and obtain a target application service pointed to by the application service current limiting request, and each service sub-interface in the target application service;
[0070] The application service current limiting method in this embodiment is applied to application service current limiting devices. The type and number of application service current limiting devices are not specifically limited. That is, the application service current limiting device can be one or more smart terminals or servers. In a specific embodiment, the application service current limiting device is a smart computer.
[0071] Specifically, the application service current limiting device is configured to perform service current limiting operations on each service sub-interface in the target application service according to a preset degradation strategy and current limiting threshold through the access counter corresponding to each service sub-interface under high concurrency and insufficient service resources.
[0072] Specifically, during operation, the application service current limiting device receives an application service current limiting request, wherein the application service current limiting request is an operation instruction for driving the application service current limiting device to perform service current limiting on a specific service sub-interface in the target application service. Optionally, the triggering method of the service current limiting request is not specifically limited here, that is, the service current limiting request can be actively triggered by the user, for example, the user is an operation and maintenance personnel, and actively triggers the application service current limiting request by clicking the service current limiting button of the application service current limiting device. In addition, the application service current limiting request can also be automatically triggered by the application service current limiting device, for example, the application service current limiting request pre-sets the current limiting threshold and degradation strategy corresponding to each service interface, and automatically triggers the application service current limiting request under the preset scenario.
[0073] Specifically, after receiving the application service current limiting request, the application service current limiting device parses the application service current limiting request, obtains the application service identifier carried in the application service current limiting request, inputs the application service identifier into a preset application service database, obtains the application service associated with the application service identifier in the application service database, and sets the application service associated with the application service identifier as the target application service.
[0074] After obtaining the target application service pointed to by the application service current limiting request, the application service current limiting device also obtains each service sub-interface in the target application service.
[0075] 202. Obtain access counters corresponding to each service sub-interface in the target application service, and read access count values of each access counter;
[0076] After obtaining each service sub-interface in the target application service, the application service current limiting device also obtains the access counter corresponding to each service sub-interface in the target application service, and reads the access count value in each access counter.
[0077] Specifically, when generating each application service, the application service current limiting device sets an access counter for each service sub-interface in each application service in advance, so as to perform service current limiting on each service sub-interface according to the access counter.
[0078] Specifically, the application service current limiting device writes the access counter aspect method in the project source code of the application service, so that the access counter can take effect throughout the life cycle of the service sub-interface. Optionally, the access counter is an integer variable type counter.
[0079] Specifically, after updating the project source code of each application service, the application service current limiting device stores the updated project source code of each application service into the project source code database.
[0080] Specifically, after obtaining the target application service and each service sub-interface, the application service current limiting device accesses the source code database and obtains the target project source code of the target application service through the gitclone command.
[0081] After obtaining the target project source code of the target application service, the application service current limiting device facilitates the slicing method class in the target project source code to obtain the access counter corresponding to each service sub-interface in the target application service.
[0082] After obtaining the access counter corresponding to the service sub-interface, the application service current limiting device reads the time window of the access counter to obtain the access count value of the access counter of the service sub-interface. The access count value is the number of accesses to the service sub-interface within a preset time window. Optionally, in a specific embodiment, the time window is 1 second.
[0083] Specifically, the application service current limiting device reads the counter time of the access counter corresponding to each service sub-interface, and obtains the current time, wherein the current time is the system time of the application service current limiting device.
[0084] After obtaining the current time and the counter time, the application service current limiting device compares the current time and the counter time, and updates the access counter according to the comparison result.
[0085] Optionally, if the time difference between the current time and the counter time is less than the time window threshold of the access counter, the application service current limiting device counts the access count value of the access counter.
[0086] Optionally, if the time interpolation between the current time and the counter time is greater than or equal to the time window threshold of the access timer, the counter time of the access counter is recharged.
[0087] 203. Read the target project source code of the target application service to obtain the current limiting threshold corresponding to each service sub-interface in the target project source code;
[0088] Specifically, after obtaining the access count value of the access counter, the application service current limiting device also reads the target project source code of the target application service to obtain the current limiting threshold corresponding to each service sub-interface recorded in the target project source code.
[0089] Specifically, the application service current limiting device pre-creates a current limiting model, wherein the current limiting model is configured as an AI model for calculating the current limiting threshold of each service sub-interface. The application service current limiting device obtains the service type and service complexity of each service sub-interface in the target application service, and inputs the service type and service complexity of each service sub-interface into the current limiting model for current limiting calculation, thereby obtaining the current limiting threshold of each service sub-interface. Among them, the service complexity is the historical service access volume of the service sub-interface.
[0090] After the application service current limiting device calculates the current limiting threshold of each service sub-interface through the current limiting model, it associates each service sub-interface with the current limiting threshold and writes it into the target project source code of the target application service according to the preset annotation strategy.
[0091] Specifically, after obtaining the target project source code of the target application service, the application service current limiting device queries the current limiting threshold corresponding to each service sub-interface in the target project source code, and performs service current limiting on each service sub-interface according to the current limiting threshold.
[0092] 204. Obtain a preset degradation policy for each service sub-interface, and perform service current limiting on the service sub-interface in the target application service according to the current limiting threshold, the access count value, and the degradation policy.
[0093] Specifically, after obtaining the limiting threshold of each service sub-interface, the application service limiting device also obtains the preset degradation strategy of each service sub-interface, and performs service limiting on each service sub-interface in the target application service according to the limiting threshold, access count value and degradation strategy.
[0094] Specifically, after the application service flow limiting device obtains the target project source code, different downgrade strategies are preset in the project source code corresponding to each service sub-interface by annotating the aspect method, and after receiving the service access request, if the access count value is greater than the flow limiting threshold, the service sub-interface is service limited through the downgrade thread and downgrade feedback parameters in the downgrade strategy.
[0095] The application service current limiting device calls the downgrade thread to downgrade the service sub-interface to be current limited in the target application service, and returns the downgrade feedback parameter.
[0096] In this embodiment, the application service flow limiting device obtains the target application service pointed to by the application service flow limiting request and each service sub-interface in the target application service by responding to the application service flow limiting request; obtains the access counter corresponding to each service sub-interface in the target application service, and reads the access count value of each access counter; reads the target project source code of the target application service, and obtains the flow limiting threshold corresponding to each service sub-interface in the target project source code; obtains the preset degradation strategy of each service sub-interface, and performs service flow limiting on the service sub-interface in the target application service according to the flow limiting threshold, the access count value and the degradation strategy. It is realized that different degradation strategies and flow limiting thresholds are set for different service interfaces according to the complexity of the business, thereby improving the flexibility of service flow limiting, ensuring the normal operation of the interface with busy business, and thus ensuring the operation stability of the business application service.
[0097] like Figure 3 As shown, Figure 3 A flow chart of an embodiment of performing service flow limiting on a service sub-interface in the application service flow limiting method provided in an embodiment of the present application, specifically, including steps 301 to 304:
[0098] 301. Respond to a service access request, obtain a service sub-interface corresponding to the service access request, and a degradation strategy of the service sub-interface;
[0099] 302. Compare the current limiting threshold of the service sub-interface and the access count value of the service sub-interface;
[0100] 303. If the access count value is less than the current limiting threshold, update the access count value and drive the service sub-interface of the target application service to execute the service access request;
[0101] 303. If the access count value is greater than the current limiting threshold, perform service current limiting on the service sub-interface of the target application service according to the degradation strategy.
[0102] Based on the above embodiments, in this embodiment, the application service flow limiting device receives a service access request, determines the service sub-interface corresponding to the service request, obtains the degradation policy of the service sub-interface, and performs service flow limiting on the service sub-interface through the degradation policy.
[0103] Specifically, the application service current limiting device performs flow detection on the service sub-interface, compares the current limiting threshold of the service sub-interface and the access count value of the service sub-interface, so as to determine whether the service sub-interface needs current limiting.
[0104] Optionally, if the access count value is less than the current limiting threshold, it is determined that the access traffic of the service sub-interface is in a normal range, and the application service current limiting device updates the access count value and drives the service sub-interface of the target application service to execute the service access request.
[0105] Optionally, if the access count value is greater than or equal to the current limiting threshold, service current limiting is performed on the service sub-interface corresponding to the service access request according to the degradation strategy.
[0106] Specifically, the application service current limiting device obtains the downgrade thread and downgrade feedback parameter in the downgrade strategy, calls the downgrade thread to downgrade the service sub-interface of the target application service, and returns the downgrade feedback parameter. Optionally, in a specific embodiment, the downgrade strategy is a fallback downgrade strategy.
[0107] In this embodiment, the application service flow limiting device obtains the service sub-interface corresponding to the service access request and the degradation strategy of the service sub-interface by responding to the service access request; compares the flow limiting threshold of the service sub-interface and the access count value of the service sub-interface; if the access count value is less than the flow limiting threshold, updates the access count value and drives the service sub-interface of the target application service to execute the service access request; if the access count value is greater than the flow limiting threshold, performs service flow limiting on the service sub-interface of the target application service according to the degradation strategy. It is possible to set different degradation strategies for service flow limiting according to the different business complexities of different service sub-interfaces, thereby improving the flexibility of service flow limiting.
[0108] like Figure 4 As shown, Figure 4 A flow chart of another embodiment of limiting the flow of a service sub-interface in the application service flow limiting method provided in an embodiment of the present application, specifically, including steps 401 to 403:
[0109] 401. Calculate interface load data of each service sub-interface in the target application service according to the access count value and the current limiting threshold;
[0110] 402. Access a degradation strategy database, obtain a degradation strategy corresponding to the interface load data, and extract a load degradation strategy from the degradation strategy;
[0111] 403. Perform service flow limiting on the service sub-interface in the target application service according to the load degradation strategy.
[0112] Based on the above embodiments, in this embodiment, the application service current limiting device further determines the interface load data according to the access count value and the current limiting threshold value of each service sub-interface, and limits the current of the service sub-interface according to the interface load data.
[0113] Specifically, the application service current limiting device calculates the interface load data of each service sub-interface in the target application service based on the access count value and the current limiting threshold of each service sub-interface. Specifically, the application service current limiting device divides the access count value of the service sub-interface by the current limiting threshold of the service sub-interface to obtain the interface load data of the service sub-interface.
[0114] Specifically, after obtaining the interface load data of the service sub-interface, the application service current limiting device determines the load interval into which the interface load data falls, obtains the degradation policy of the service sub-interface, and obtains the load degradation policy in the degradation policy.
[0115] Specifically, after obtaining the load degradation policy, the application service current limiting device performs access current limiting on the service sub-interface in the target application service according to the load degradation policy. That is, the application service current limiting device obtains the load degradation thread and load interval in the load degradation policy, calls the load degradation thread to degrade the service sub-interface, and returns the load reminder parameter associated with the load interval.
[0116] In this embodiment, the application service current limiting device calculates the interface load data of each service sub-interface in the target application service according to the access count value and the current limiting threshold; accesses the degradation strategy database to obtain the degradation strategy corresponding to the interface load data, extracts the load degradation strategy in the degradation strategy; and performs service current limiting on the service sub-interface in the target application service according to the load degradation strategy. Flexible degradation of the service sub-interface is achieved according to the load condition of the service sub-interface.
[0117] In order to better implement the application service current limiting method in the embodiment of the present application, based on the application service current limiting method, an application service current limiting device is also provided in the embodiment of the present application, such as Figure 5 As shown, Figure 5 The present invention is a schematic diagram of the structure of the application service current limiting device provided in the embodiment of the present application. Specifically, the application service current limiting device 500 includes:
[0118] The service acquisition module 501 is configured to respond to an application service current limiting request, obtain a target application service pointed to by the application service current limiting request, and each service sub-interface in the target application service;
[0119] The count reading module 502 is configured to obtain the access counter corresponding to each service sub-interface in the target application service, and read the access count value of each access counter;
[0120] The threshold acquisition module 503 is configured to read the target project source code of the target application service and obtain the current limiting threshold corresponding to each service sub-interface in the target project source code;
[0121] The service flow limiting module 504 is configured to obtain a preset degradation policy for each service sub-interface, and perform service flow limiting on the service sub-interface in the target application service according to the flow limiting threshold, the access count value and the degradation policy.
[0122] In a possible implementation of the present application, the application service current limiting device obtains the access counter corresponding to each service sub-interface in the target application service, and reads the access count value of the access counter, including:
[0123] Accessing a project source code database to obtain the target project source code of the target application service;
[0124] Traversing the aspect method classes in the target project source code to obtain access counters corresponding to each service sub-interface in the target application service;
[0125] The time window in each access counter is read to obtain the access count value of each access counter.
[0126] In a possible implementation of the present application, the application service current limiting device obtains the access counter corresponding to each service sub-interface in the target application service, and before reading the access count value of the access counter, further includes:
[0127] For an access counter corresponding to each service sub-interface, read the current time and the counter time of the access counter, and compare the current time and the counter time;
[0128] If the time difference between the current time and the counter time is less than the time window threshold of the access counter, then counting the access count value of the access counter;
[0129] If the time difference between the current system time and the counter time is greater than or equal to the time window threshold of the access counter, the counter time of the access counter is reset.
[0130] In a possible implementation of the present application, the application service current limiting device reads the target project source code of the target application service and obtains the current limiting threshold value corresponding to each service sub-interface in the target project source code, and further includes:
[0131] Obtaining the service type and service complexity of each service sub-interface in the target application service;
[0132] Input the service type and the service complexity of each service sub-interface into a preset current limiting model to perform current limiting calculation, and obtain a current limiting threshold of each service sub-interface;
[0133] According to a preset annotation strategy, each of the service sub-interfaces and the current limiting threshold are associated and written into the target project source code.
[0134] In a possible implementation of the present application, the application service current limiting device obtains a preset degradation strategy for each service sub-interface, and performs service current limiting on the service sub-interface in the target application service according to the current limiting threshold, the access count value and the degradation strategy, including:
[0135] Responding to a service access request, obtaining a service sub-interface corresponding to the service access request and a degradation strategy for the service sub-interface;
[0136] Comparing the current limiting threshold of the service sub-interface with the access count value of the service sub-interface;
[0137] If the access count value is less than the current limiting threshold, updating the access count value and driving the service sub-interface of the target application service to execute the service access request;
[0138] If the access count value is greater than the current limiting threshold, service current limiting is performed on the service sub-interface of the target application service according to the degradation strategy.
[0139] In a possible implementation of the present application, if the access count value is greater than the current limiting threshold, the application service current limiting device performs service current limiting on the service sub-interface of the target application service according to the degradation strategy, including:
[0140] If the access count value is greater than the current limiting threshold, obtaining the downgrade thread and downgrade feedback parameter in the downgrade strategy;
[0141] The downgrade thread is called to downgrade the service sub-interface of the target application service, and the downgrade feedback parameter is returned.
[0142] In a possible implementation of the present application, the application service current limiting device obtains a preset degradation strategy for each service sub-interface, and performs service current limiting on the service sub-interface in the target application service according to the current limiting threshold, the access count value and the degradation strategy, including:
[0143] Calculate the interface load data of each service sub-interface in the target application service according to the access count value and the current limiting threshold;
[0144] Accessing a degradation strategy database, obtaining a degradation strategy corresponding to the interface load data, and extracting a load degradation strategy from the degradation strategy;
[0145] The service sub-interface in the target application service is subjected to service flow limiting according to the load degradation strategy.
[0146] In this embodiment, the application service current limiting device obtains the target application service pointed to by the application service current limiting request and each service sub-interface in the target application service by responding to the application service current limiting request; obtains the access counter corresponding to each service sub-interface in the target application service, and reads the access count value of each access counter; reads the target project source code of the target application service, and obtains the current limiting threshold corresponding to each service sub-interface in the target project source code; obtains the preset degradation strategy of each service sub-interface, and performs service current limiting on the service sub-interface in the target application service according to the current limiting threshold, the access count value and the degradation strategy. It is realized that different degradation strategies and current limiting thresholds are set for different service interfaces according to the complexity of the business, thereby improving the flexibility of service current limiting, ensuring the normal operation of the interface with busy business, and thus ensuring the operation stability of the business application service.
[0147] The embodiment of the present invention also provides an application service current limiting device, such as Figure 6 As shown, Figure 6 This is a schematic diagram of the structure of an embodiment of the application service current limiting device provided in the embodiments of the present application.
[0148] The application service current limiting device integrates any one of the application service current limiting devices provided in the embodiments of the present invention, and the application service current limiting device includes:
[0149] one or more processors;
[0150] Memory; and
[0151] One or more applications, wherein the one or more applications are stored in the memory and are configured so that the processor executes the steps of the application service flow limiting method described in any of the above-mentioned application service flow limiting method embodiments.
[0152] Specifically, the application service current limiting device may include one or more processing core processors 601, one or more computer-readable storage media memories 602, a power supply 603, an input unit 604 and other components. Those skilled in the art will understand that Figure 6 The application service current limiting device structure shown in the figure does not constitute a limitation on the application service current limiting device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0153] Processor 601 is the control center of the application service current limiting device. It uses various interfaces and lines to connect various parts of the entire application service current limiting device. By running or executing software programs and / or modules stored in memory 602, and calling data stored in memory 602, it executes various functions of the application service current limiting device and processes data, thereby monitoring the application service current limiting device as a whole. Optionally, processor 601 may include one or more processing cores; preferably, processor 601 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into processor 601.
[0154] The memory 602 can be used to store software programs and modules. The processor 601 executes various functional applications and data processing by running the software programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the application service current limiting device, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 602 may also include a memory controller to provide the processor 601 with access to the memory 602.
[0155] The application service current limiting device also includes a power supply 603 for supplying power to each component. Preferably, the power supply 603 can be logically connected to the processor 601 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 603 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.
[0156] The application service current limiting device may further include an input unit 604, which may be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0157] Although not shown, the application service current limiting device may also include a display unit, etc., which will not be described in detail here. Specifically in this embodiment, the processor 601 in the application service current limiting device will load the executable file corresponding to the process of one or more application programs into the memory 602 according to the following instructions, and the processor 601 will run the application program stored in the memory 602, thereby realizing various functions, as follows:
[0158] In response to an application service current limiting request, obtain a target application service pointed to by the application service current limiting request and each service sub-interface in the target application service;
[0159] Obtaining access counters corresponding to each service sub-interface in the target application service, and reading access count values of each access counter;
[0160] Read the target project source code of the target application service to obtain the current limiting threshold corresponding to each service sub-interface in the target project source code;
[0161] A preset degradation strategy for each service sub-interface is obtained, and service flow limiting is performed on the service sub-interface in the target application service according to the flow limiting threshold, the access count value and the degradation strategy.
[0162] To this end, an embodiment of the present invention provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any application service current limiting method provided in an embodiment of the present invention. For example, the computer program may be loaded by a processor to execute the following steps:
[0163] In response to an application service current limiting request, obtain a target application service pointed to by the application service current limiting request and each service sub-interface in the target application service;
[0164] Obtaining access counters corresponding to each service sub-interface in the target application service, and reading access count values of each access counter;
[0165] Read the target project source code of the target application service to obtain the current limiting threshold corresponding to each service sub-interface in the target project source code;
[0166] The target application service obtains a preset degradation strategy for each service sub-interface, and performs service flow limiting on the service provided by the service sub-interface in the target application service according to the flow limiting threshold, the access count value and the degradation strategy.
[0167] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.
[0168] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments, which will not be repeated here.
[0169] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0170] The above is a detailed introduction to an application service flow limiting method provided in an embodiment of the present application. Specific embodiments are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for limiting current of an application service, characterized in that: The application service current limiting method includes: In response to an application service current limiting request, obtain a target application service pointed to by the application service current limiting request and each service sub-interface in the target application service; Obtaining access counters corresponding to each service sub-interface in the target application service, and reading access count values of each access counter; Read the target project source code of the target application service to obtain the current limiting threshold corresponding to each service sub-interface in the target project source code, wherein the current limiting threshold corresponding to each service sub-interface is recorded in the target project source code; In response to a service access request, the service sub-interface corresponding to the service access request and the downgrade strategy of the service sub-interface are obtained, the current limiting threshold of the service sub-interface and the access count value of the service sub-interface are compared; if the access count value is less than the current limiting threshold, the access count value is updated and the service sub-interface of the target application service is driven to execute the service access request; if the access count value is greater than the current limiting threshold, the downgrade thread and downgrade feedback parameters in the downgrade strategy are obtained, the downgrade thread is called to downgrade the service sub-interface of the target application service, and the downgrade feedback parameters are returned.
2. The application service current limiting method according to claim 1, characterized in that: The obtaining of the access counters corresponding to the service sub-interfaces in the target application service and reading the access count value of the access counters includes: Accessing a project source code database to obtain the target project source code of the target application service; Traversing the aspect method classes in the target project source code to obtain access counters corresponding to each service sub-interface in the target application service; The time window in each access counter is read to obtain the access count value of each access counter.
3. The application service current limiting method according to claim 1, characterized in that: The obtaining of the access counters corresponding to the service sub-interfaces in the target application service and before reading the access count value of the access counters further includes: For an access counter corresponding to each service sub-interface, read the current time and the counter time of the access counter, and compare the current time and the counter time; If the time difference between the current time and the counter time is less than the time window threshold of the access counter, then counting the access count value of the access counter; If the time difference between the current time and the counter time is greater than or equal to the time window threshold of the access counter, the counter time of the access counter is reset.
4. The application service current limiting method according to claim 1, characterized in that: Before reading the target project source code of the target application service and obtaining the current limiting threshold corresponding to each service sub-interface in the target project source code, the method further includes: Obtaining the service type and service complexity of each service sub-interface in the target application service; Input the service type and the service complexity of each service sub-interface into a preset current limiting model to perform current limiting calculation, and obtain a current limiting threshold of each service sub-interface; According to a preset annotation strategy, each of the service sub-interfaces and the current limiting threshold are associated and written into the target project source code.
5. The application service current limiting method according to claim 1, characterized in that: After reading the target project source code of the target application service and obtaining the current limiting threshold corresponding to each service sub-interface in the target project source code, the method further includes: Dividing the access count value of the service sub-interface by the current limiting threshold of the service sub-interface, thereby obtaining the interface load data of the service sub-interface; Accessing a degradation strategy database, obtaining a degradation strategy corresponding to the interface load data, and extracting a load degradation strategy from the degradation strategy; The service sub-interface in the target application service is subjected to service flow limiting according to the load degradation strategy.
6. An application service current limiting device, characterized in that: The application service current limiting device comprises: A service acquisition module is configured to respond to an application service current limiting request, acquire a target application service pointed to by the application service current limiting request, and each service sub-interface in the target application service; A counting reading module is configured to obtain an access counter corresponding to each service sub-interface in the target application service, and read an access count value of each access counter; A threshold acquisition module is configured to read the target project source code of the target application service to obtain the current limiting threshold corresponding to each service sub-interface in the target project source code, wherein the current limiting threshold corresponding to each service sub-interface is recorded in the target project source code; The service current limiting module is configured to respond to a service access request, obtain the service sub-interface corresponding to the service access request, and the downgrade strategy of the service sub-interface, compare the current limiting threshold of the service sub-interface and the access count value of the service sub-interface, if the access count value is less than the current limiting threshold, update the access count value and drive the service sub-interface of the target application service to execute the service access request, if the access count value is greater than the current limiting threshold, obtain the downgrade thread and downgrade feedback parameters in the downgrade strategy, call the downgrade thread to downgrade the service sub-interface of the target application service, and return the downgrade feedback parameters.
7. An application service current limiting device, characterized in that: The application service current limiting device includes: one or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the steps of the application service current limiting method described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps of the application service current limiting method according to any one of claims 1 to 5.
