CN111371699A - Resource current limiting method and device, electronic equipment and storage medium - Google Patents
Resource current limiting method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN111371699A CN111371699A CN202010131366.8A CN202010131366A CN111371699A CN 111371699 A CN111371699 A CN 111371699A CN 202010131366 A CN202010131366 A CN 202010131366A CN 111371699 A CN111371699 A CN 111371699A
- Authority
- CN
- China
- Prior art keywords
- resource
- current limiting
- target resource
- configuration information
- strategy
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
- H04L47/20—Traffic policing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/903—Querying
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/08—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
- H04L43/0876—Network utilisation, e.g. volume of load or congestion level
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
- H04L47/24—Traffic characterised by specific attributes, e.g. priority or QoS
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- General Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Environmental & Geological Engineering (AREA)
- Computational Linguistics (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses a resource current limiting method, a device, electronic equipment and a storage medium, which can acquire a resource name of a target resource from a byte code by using a packet path in a reflection mode, wherein the byte code is the content obtained by compiling a code with service logic, acquire corresponding configuration information according to the resource name of the target resource, and finally execute the content corresponding to the target resource according to a current limiting strategy in the configuration information so as to realize resource current limiting, ensure that the service realized by the target resource can bear preset flow pressure, and simultaneously avoid the problem of resource omission and poor manual marking uniqueness caused by manually marking the target resource in an automatic target resource extracting mode.
Description
Technical Field
The invention relates to the technical field of software development, in particular to a resource current limiting method, a resource current limiting device, electronic equipment and a storage medium.
Background
At present, in order to ensure that some network services can bear a certain flow pressure when implemented, a current limiting tool is generally required to be accessed to a mechanism for organizing service codes, so that the service codes can be executed according to a current limiting policy preset in the current limiting tool when executed, so as to implement a current limiting operation of a specific resource in the service codes.
The server generally stores a large amount of service codes in order to implement services in various scenarios. Currently, when a server performs current limiting on a code resource, a series of configurations are performed on the code resource, which specifically includes: code resources needing to be protected, namely method business logic, need to be found out from the codes; and then labeling the resource name of each code resource, wherein the resource name can be used as a unique identifier of the code resource, and in the code compiling stage of the server, weaving a current limiting tool byte code for the code resource through an AspectJ tool to provide a current limiting strategy in execution for the code resource. After configuration is completed, when a server is started, a code resource needing to be protected needs to be found first, a current limiting strategy corresponding to the code resource is pulled, and then the code resource is executed according to the current limiting strategy, so that current limiting operation of the resource is completed.
However, the resource throttling method needs a technician to manually find the code resources to be protected from various codes and manually label each code resource, some code resources may be omitted in the process, it cannot be guaranteed that all the code resources to be protected can be labeled, and when the code resources to be protected are too many, the manual labeling manner is difficult to guarantee the uniqueness of the label.
Disclosure of Invention
The invention provides a resource current limiting method, a resource current limiting device, electronic equipment and a storage medium, and aims to solve the problems of code resource omission and non-unique labeling caused by manually labeling code resources in the conventional resource current limiting method.
In a first aspect, the present invention provides a resource current limiting method, including:
acquiring a resource name of a target resource from a byte code by using a packet path, wherein the packet path is a path appointed by the acquisition of the target resource, and the byte code is content obtained by compiling a code with service logic;
acquiring configuration information corresponding to the target resource by using the resource name, wherein the configuration information stores a current limiting strategy and a current limiting parameter related to the target resource, and the configuration information and the resource name are stored in a one-to-one correspondence manner;
and executing the content corresponding to the target resource by using the configuration information.
With reference to the first aspect, in an implementation manner of the first aspect, the step of obtaining, by using a packet path, a resource name of a target resource from a bytecode includes:
scanning all contents corresponding to the packet path in the byte code according to the packet path;
acquiring all classes in all contents under the packet path;
all classes are traversed and the method names of all methods are obtained as the resource names.
With reference to the first aspect, in an implementation manner of the first aspect, before the obtaining, by using a packet path, a resource name of a target resource from a bytecode, the method further includes:
determining each method for which a current limiting strategy needs to be customized;
a configuration message having a current limit policy and current limit parameters is generated for each method requiring a customized current limit policy.
With reference to the first aspect, in an implementation manner of the first aspect, the step of determining each method that requires customizing a current limiting policy includes:
executing all methods in the byte codes, and obtaining test traffic corresponding to each method, wherein the test traffic is used for representing the number of services processed by executing the methods;
comparing the test traffic with the real traffic in a real service scene, and if the test traffic is smaller than the real traffic, determining that the method needs to customize a current limiting policy, wherein the current limiting policy is used for indicating that the target resource needs to perform current limiting operation during execution.
With reference to the first aspect, in an implementation manner of the first aspect, the step of generating configuration information having a current limiting policy and current limiting parameters for each method requiring customization of the current limiting policy includes:
and if the method needs to customize a current limiting strategy, determining the test traffic as a current limiting parameter of the method, wherein the current limiting parameter is used for indicating the maximum traffic which can be processed by the target resource when in execution.
With reference to the first aspect, in an implementation manner of the first aspect, the step of determining each method that requires customizing a current limiting policy further includes:
and if the test traffic is zero, determining that the method needs to perform fusing operation, wherein the fusing operation is used for representing that a preset execution result is provided for the target resource.
In a second aspect, the present invention provides a resource current limiting apparatus, including:
a resource name obtaining module, configured to obtain a resource name of a target resource from a bytecode by using a package path, where the package path is a path specified by obtaining the target resource, and the bytecode is a content obtained by compiling a code having service logic;
a configuration information obtaining module, configured to obtain, by using the resource name, configuration information corresponding to the target resource, where a current limiting policy and a current limiting parameter related to the target resource are stored in the configuration information, and the configuration information and the resource name are stored in a one-to-one correspondence manner;
and the execution module is used for executing the content corresponding to the target resource by using the configuration information.
With reference to the second aspect, in an implementation manner of the second aspect, the resource name obtaining module includes:
the scanning unit is used for scanning all the contents corresponding to the packet path in the byte code according to the packet path;
a class acquisition unit, configured to acquire all classes in all contents in the packet path;
and the resource name acquisition unit is used for traversing all classes and acquiring the method names of all methods as the resource names.
With reference to the second aspect, in an implementation manner of the second aspect, the resource current limiting apparatus further includes:
the strategy determining module is used for determining each method needing to customize the current limiting strategy;
and the strategy customizing module is used for generating configuration information with the current limiting strategy and the current limiting parameter for each method needing to customize the current limiting strategy.
With reference to the second aspect, in an implementation manner of the second aspect, the policy determining module further includes:
the execution unit is used for executing all methods in the byte codes and obtaining the test traffic corresponding to each method, wherein the test traffic is used for representing the number of the services processed by executing the methods;
and the judging unit is used for comparing the test traffic with the real traffic in a real service scene, and when the test traffic is smaller than the real traffic, determining that the method needs to customize a current limiting strategy, wherein the current limiting strategy is used for indicating that the target resource needs to perform current limiting operation during execution.
With reference to the second aspect, in an implementation manner of the second aspect, the policy customization module is further configured to, when the method needs to customize a current limiting policy, determine the test traffic as a current limiting parameter of the method, where the current limiting parameter is used to indicate a maximum traffic that can be processed by the target resource when executing.
With reference to the second aspect, in an implementation manner of the second aspect, the policy determining module is further configured to determine that the method needs to perform a fusing operation when the test traffic is zero, where the fusing operation is used to indicate that a preset execution result is provided for the target resource.
In a third aspect, the present invention provides an electronic device, comprising: a memory for storing program instructions; a processor, configured to call and execute the program instructions in the memory to implement the resource throttling method according to the first aspect.
In a fourth aspect, the present invention provides a storage medium, in which a computer program is stored, and when at least one processor of a resource current limiting apparatus executes the computer program, the resource current limiting apparatus executes the resource current limiting method according to the first aspect.
According to the technical scheme, the resource current limiting method, the resource current limiting device, the electronic equipment and the storage medium provided by the invention can acquire the resource name of the target resource from the byte code by using the packet path in a reflection mode, wherein the byte code is the content obtained by compiling the code with the service logic, acquire the corresponding configuration information according to the resource name of the target resource, and finally execute the content corresponding to the target resource according to the current limiting strategy in the configuration information so as to realize the resource current limiting, ensure that the service realized by the target resource can bear the preset flow pressure, and simultaneously avoid the problem of resource omission and poor uniqueness of manual labeling caused by manually labeling the target resource in the mode of automatically extracting the target resource.
Drawings
In order to more clearly illustrate the technical solution of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious to those skilled in the art that other drawings can be obtained according to the drawings without any inventive exercise.
Fig. 1 is a flowchart of a resource current limiting method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for obtaining resource names according to an embodiment of the present invention;
fig. 3 is a flowchart of another resource throttling method according to an embodiment of the present invention;
fig. 4 is a flowchart of a method for determining that a current limiting policy needs to be customized according to an embodiment of the present invention;
fig. 5 is a block diagram of a resource current limiting apparatus according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention.
Detailed Description
Currently, when performing a current-limiting operation on a code resource of a server, a technician usually manually finds out a code to be protected from the code and labels the code; when the server is started, the marked code resources are found from the configuration file and are executed according to the corresponding current limiting strategy. At present, the current limiting mode needs technicians to label code resources manually, so that the phenomenon of resource omission can occur, and when the code resources to be protected are too much, the manual labeling is difficult to ensure the uniqueness of the labeling. Therefore, the invention provides a resource current limiting method, which can determine the resource name of the code resource only by the compiling content of the code resource without manually marking the code resource, can improve the accuracy of identifying the protected code resource and can avoid the problem of poor uniqueness of the manually marked code resource.
Fig. 1 is a flowchart of a resource current limiting method according to an embodiment of the present invention. As shown in fig. 1, a resource current limiting method provided in an embodiment of the present invention includes:
s101, acquiring a resource name of a target resource from a byte code by using a packet path, wherein the packet path is a path designated by the acquisition of the target resource, and the byte code is a content obtained by compiling a code with service logic and is a binary file containing an executive program.
In the embodiment of the invention, in order to avoid manually marking the code resource and extracting the target resource from the byte code by the marked resource name, the target resource is directly obtained by using the compiled content of the code resource. Typically, compiled bytecode includes classes, which provide a way to combine data and functionality; creating a new class means creating an object of a new type, thereby allowing a new instance of that type to be created; each class instance may have attributes that preserve its state; an instance of a class may also have a method (defined in the class) to change its state. The methods in different classes are different from each other, so that the names of the methods can be directly identified, and the content corresponding to the methods can be obtained from the byte codes. In the embodiment of the invention, the method content used in the stage of using the configuration information to perform resource flow limitation is the target resource, and the target resource is a part or all of the method resources in the byte codes.
In the embodiment of the present invention, a reflection mechanism may also be used to obtain the resource name of the target resource from the bytecode, where the reflection mechanism is a function of dynamically obtaining object information and calling an object method, and through reflection, any class in the bytecode content may be called out, and methods and attributes in this class may be obtained.
In addition, the packet path in the embodiment of the present invention is stored in a configuration file, and configuration information or an address of a remote configuration center is also stored in the configuration file, and if the configuration information is not stored in the configuration file, the configuration information may also be stored in the remote configuration center, for example, a database. The packet path in the embodiment of the present invention is used to indicate the location of the target resource, for example, a certain folder, and after the packet path is determined, the content corresponding to the packet path can be found from the bytecode, and the target resource is obtained from the content.
S102, obtaining configuration information corresponding to the target resource by using the resource name, wherein the configuration information stores a current limiting strategy and a current limiting parameter related to the target resource, and the configuration information and the resource name are stored in a one-to-one correspondence manner.
The configuration information in the embodiment of the invention is a preset current-limiting strategy obtained when a target resource is tested in advance, the test process is a process of executing the method, the result of executing the method is taken as a test result, the test result is compared with the actual service volume required to be executed on a service end, whether the execution of the method can bear the expected service pressure is judged, if the execution of the method cannot bear the expected service pressure, an executed current-limiting parameter is set for the method, and the maximum service flow which can be processed by the method cannot exceed the current-limiting parameter is represented. After testing, for a method that cannot bear expected service pressure, a corresponding current limiting policy and current limiting parameter need to be stored in a memory for the method, so that the target resource can call the current limiting policy and the current limiting parameter from the memory through a resource name during actual execution.
In the embodiment of the invention, whether the method needs to carry out current limiting processing or not is considered according to the test result of the method, and the setting of the current limiting parameter is considered in multiple aspects by combining the specifically realized function and action of the method. For example, if the result of the method execution is to display a specific picture, but the server providing the picture fails and cannot use the picture, the test result of the method may be that the picture cannot be displayed, but considering that a blank picture cannot be provided to the user, a specific display picture needs to be set for the method, and the specific display picture can be used as the current limiting parameter of the method.
S103, executing the content corresponding to the target resource by using the configuration information.
In the embodiment of the invention, the AspectJ tool can be adopted to weave the current limiting strategy into the content corresponding to the target resource, so that the target resource can execute according to the current limiting strategy.
It can be seen that the resource current limiting method provided in the embodiment of the present invention can obtain the resource name of the target resource from the bytecode through a reflection manner by using the packet path, where the bytecode is a content obtained by compiling a code having service logic, and obtain corresponding configuration information according to the resource name of the target resource, and finally execute the content corresponding to the target resource according to the current limiting policy in the configuration information, so as to implement resource current limiting of the method, ensure that the service implemented by the code can bear a predetermined flow pressure, and meanwhile, the method of automatically extracting the method also avoids the problem of resource omission and poor uniqueness of manual labeling caused by manually labeling the method.
In addition, the resource current limiting method provided in the embodiment of the present invention can perform current limiting operation on code resources in the server, and is also applicable to other web sites having the same function as the server or a service architecture having a function of implementing the code resources.
Fig. 2 is a flowchart of a method for obtaining resource names according to an embodiment of the present invention. As shown in fig. 2, the step of obtaining the resource name of the target resource from the bytecode by using the configuration file in the embodiment of the present invention specifically includes:
s201, scanning all the corresponding contents in the byte codes under the packet path according to the packet path. For example, if the packet path specified in the configuration file is folder x of windows, the content corresponding to the folder x needs to be found in the byte code.
S202, all classes in all contents in the packet path are obtained. That is, all classes in all files corresponding to folder x can be found out.
As can be seen from the foregoing description of the embodiments, the reflection mechanism may call out any class, and therefore, in the embodiments of the present invention, all classes in the bytecode resource are called out by using the reflection mechanism.
S203, traversing all classes, and obtaining method names of all methods as the resource names, wherein the method is the target resource.
After finding out all the classes in all the files corresponding to the folder x, traversing all the classes, finding out all the methods from the classes, and marking all the methods as resources, so that the method does not need to be manually determined, the position of a certain method is a certain line of a certain file in the folder x, and then manually marking the resources for the re-routing. Each class may contain methods, and the code itself distinguishes the different methods when written, so that the method name, i.e. the resource name, can be obtained by directly calling the method through a reflection mechanism.
Therefore, in the resource current limiting method provided by the embodiment of the invention, the class and the method in the byte code can be called by using the reflection mechanism, so that the resource name is obtained without depending on the manual resource marking operation of a technician, and the phenomenon of missing during resource obtaining is avoided.
Fig. 3 is a flowchart of another resource throttling method according to an embodiment of the present invention. As shown in fig. 3, in the embodiment of the present invention, before the obtaining the resource name of the target resource from the bytecode by using the packet path, the method further includes:
s301, determining each method needing to customize the current limiting strategy. Specifically, fig. 4 is a flowchart of a method for determining that a current limiting policy needs to be customized according to an embodiment of the present invention. As shown in fig. 4, in the embodiment of the present invention, the step of determining each method that requires to customize a current limiting policy includes:
s401, executing the methods in the bytecode, and obtaining the test traffic corresponding to each method, where the test traffic is used to indicate the number of services processed by executing the methods.
In the embodiment of the invention, in the test stage of the method, no current limiting measure is taken for the execution of the method, and the purpose is to obtain the test result after the execution of the method, and the test result is different from the traffic actually to be processed by the method in the actual situation, so whether the current target resource needs to be subjected to the current limiting operation or not needs to be judged according to the comparison situation of the test result and the traffic actually to be processed by the method. In addition, the test result in the embodiment of the present invention is expressed by the test traffic.
Since the resource throttling method in the embodiment of the present invention is specific to all methods in the bytecode, each method also needs to be tested in the testing stage.
S402, comparing the test traffic with the real traffic in a real service scene, and if the test traffic is smaller than the real traffic, determining that the method needs to customize a current limiting strategy, wherein the current limiting strategy is used for indicating that the target resource needs to perform current limiting operation during execution. If the test traffic is greater than or equal to the real traffic, determining that the method does not require customizing a current limiting policy.
S302, generating configuration information with the current limiting strategy and the current limiting parameters for each method needing to customize the current limiting strategy. And if the method needs to customize a current limiting strategy, determining the test traffic as a current limiting parameter of the method, wherein the current limiting parameter is used for indicating the maximum traffic which can be processed by the target resource when in execution.
In the embodiment of the invention, the test traffic and the real traffic specifically include the number, the flow and the like of the services. For example, the traffic that can be processed by a method during testing is 500 pieces/s, and the traffic that needs to be actually processed in the server that executes the method is 800 pieces/s, it can be seen that the test traffic of the method is smaller than the actual traffic, and if the method is not limited, when the server executes the method, excessive services compete for resources of the method together, which may cause the method to be unable to be executed, thereby causing a problem of failure in service processing. Therefore, the method needs to be subjected to current limiting processing, and the current limiting parameter can be set to be 500/s, so that when the method is executed in the server, the method processes at most 500 services each time, and the normal operation of the method is ensured. If the real traffic is only 300 pieces/s, the test traffic is greater than the real traffic, which indicates that the method can be normally executed and can normally process the corresponding service in the server, and at this time, the method does not need to be subjected to current limiting processing.
It should be noted that, in the embodiment of the present invention, if the method needs to customize the current limiting policy, the test traffic is determined as the current limiting parameter of the method, which is only a preferred setting manner of the current limiting parameter in this embodiment, and in general, in order to further ensure the normal operation of the method, the current limiting parameter may also be set to be smaller than the test traffic, for example, the test traffic is 500 pieces/s, and the current limiting parameter is 400 pieces/s, and the like.
In addition, in another embodiment of the present invention, if the test traffic is zero, it is determined that the method needs to perform a fusing operation, where the fusing operation is used to represent that a preset execution result is provided for the target resource. That is, the current limiting strategy may also include a fusing operation. As described in the foregoing embodiment, if the result of the execution of the method is to display a specific picture, but the server providing the picture fails and cannot use the picture, and the test result of the method may be that the picture cannot be displayed, the test traffic of the method should be represented as zero, because the method cannot be successfully executed in the end. In this case, the current limiting operation for the method cannot control the traffic volume processed by the method, but the fusing operation is performed during the execution of the method, i.e. a preset processing result is provided for the execution of the method. If the above is still taken as an example, when the picture requested by the method is not available, a specific display picture needs to be set for the method as the execution result. It can be seen that the fusing operation in the embodiment of the present invention is also to ensure the normal operation of the method.
As can be seen from the above, the resource current limiting method provided in the embodiment of the present invention can obtain, in a reflective manner, the resource name of the target resource from the bytecode by using the packet path, where the bytecode is a content obtained by compiling a code having service logic, obtain corresponding configuration information according to the resource name of the target resource, and finally execute the content corresponding to the target resource according to the current limiting policy in the configuration information, so as to implement resource current limiting and ensure that a service implemented by the target resource can bear a predetermined flow pressure, where the problem of resource omission and poor uniqueness of manual labeling caused by manual labeling of the target resource are avoided in a manner of automatically extracting the target resource, and normal operation of the target resource can also be ensured through operations such as current limiting and fusing.
Fig. 5 is a block diagram of a resource current limiting apparatus according to an embodiment of the present invention. As shown in fig. 5, a resource current limiting apparatus provided in an embodiment of the present invention includes:
a resource name obtaining module 51, configured to obtain a resource name of a target resource from a bytecode by using a package path, where the package path is a path specified by obtaining the target resource, and the bytecode is a content obtained by compiling a code having service logic; a configuration information obtaining module 52, configured to obtain, by using the resource name, configuration information corresponding to the target resource, where a current limiting policy and a current limiting parameter related to the target resource are stored in the configuration information, and the configuration information and the resource name are stored in a one-to-one correspondence manner; and the executing module 53 is configured to execute the content corresponding to the target resource by using the configuration information.
Wherein, the resource name acquisition module comprises: the scanning unit is used for scanning all the contents corresponding to the packet path in the byte code according to the packet path; a class acquisition unit, configured to acquire all classes in all contents in the packet path; and the resource name acquisition unit is used for traversing all classes and acquiring the method names of all methods as the resource names.
The resource current limiting device further comprises: the strategy determining module is used for determining each method needing to customize the current limiting strategy; and the strategy customizing module is used for generating configuration information with the current limiting strategy and the current limiting parameter for each method needing to customize the current limiting strategy.
The policy determination module further comprises: the execution unit is used for executing all methods in the byte codes and obtaining the test traffic corresponding to each method, wherein the test traffic is used for representing the number of the services processed by executing the methods; and the judging unit is used for comparing the test traffic with the real traffic in a real service scene, and when the test traffic is smaller than the real traffic, determining that the method needs to customize a current limiting strategy, wherein the current limiting strategy is used for indicating that the target resource needs to perform current limiting operation during execution.
The policy customizing module is further configured to, when the method requires customizing a current limiting policy, determine the test traffic as a current limiting parameter of the method, where the current limiting parameter is used to indicate a maximum traffic that can be processed by the target resource when executing the current limiting policy.
The policy determining module is further configured to determine that the method needs to perform a fusing operation when the test traffic is zero, where the fusing operation is used to represent that a preset execution result is provided for the target resource.
Fig. 6 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention. As shown in fig. 6, an electronic device provided in an embodiment of the present invention includes: a memory 61 for storing program instructions; and a processor 62, configured to call and execute the program instructions in the memory to implement the resource throttling method in the foregoing embodiments.
In an embodiment of the present invention, the processor 62 and the memory 61 may be connected by a bus or other means. The processor may be a general-purpose processor, such as a central processing unit, a digital signal processor, an application specific integrated circuit, or one or more integrated circuits configured to implement embodiments of the present invention. The memory may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, a hard disk, or a solid state disk.
The present invention further provides a storage medium, in which a computer program is stored, and when at least one processor of the resource current limiting apparatus executes the computer program, the resource current limiting apparatus executes the resource current limiting method described in the above embodiments.
The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a Random Access Memory (RAM).
Those skilled in the art will readily appreciate that the techniques of the embodiments of the present invention may be implemented as software plus a required general purpose hardware platform. Based on such understanding, the technical solutions in the embodiments of the present invention may be essentially or partially implemented in the form of a software product, which may be stored in a storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
The same and similar parts in the various embodiments in this specification may be referred to each other. In particular, for the embodiments of the service construction apparatus and the service loading apparatus, since they are substantially similar to the embodiments of the method, the description is simple, and the relevant points can be referred to the description in the embodiments of the method.
The above-described embodiments of the present invention should not be construed as limiting the scope of the present invention.
Claims (14)
1. A method for limiting a flow of resources, comprising:
acquiring a resource name of a target resource from a byte code by using a packet path, wherein the packet path is a path appointed by the acquisition of the target resource, and the byte code is content obtained by compiling a code with service logic;
acquiring configuration information corresponding to the target resource by using the resource name, wherein the configuration information stores a current limiting strategy and a current limiting parameter related to the target resource, and the configuration information and the resource name are stored in a one-to-one correspondence manner;
and executing the content corresponding to the target resource by using the configuration information.
2. The method of claim 1, wherein the step of obtaining the resource name of the target resource from the bytecode using the packet path comprises:
scanning all contents corresponding to the packet path in the byte code according to the packet path;
acquiring all classes in all contents under the packet path;
all classes are traversed and the method names of all methods are obtained as the resource names.
3. The method of claim 1, wherein before the obtaining the resource name of the target resource from the bytecode using the packet path, the method further comprises:
determining each method for which a current limiting strategy needs to be customized;
a configuration message having a current limit policy and current limit parameters is generated for each method requiring a customized current limit policy.
4. The method of resource throttling according to claim 3, wherein the step of determining each method that requires a customized throttling strategy comprises:
executing all methods in the byte codes, and obtaining test traffic corresponding to each method, wherein the test traffic is used for representing the number of services processed by executing the methods;
comparing the test traffic with the real traffic in a real service scene, and if the test traffic is smaller than the real traffic, determining that the method needs to customize a current limiting policy, wherein the current limiting policy is used for indicating that the target resource needs to perform current limiting operation during execution.
5. The method of claim 4, wherein the step of generating a configuration message with the current limiting policy and the current limiting parameters for each of the methods requiring customized current limiting policy comprises:
and if the method needs to customize a current limiting strategy, determining the test traffic as a current limiting parameter of the method, wherein the current limiting parameter is used for indicating the maximum traffic which can be processed by the target resource when in execution.
6. The method of resource throttling according to claim 4, wherein the step of determining each method that requires a customized throttling strategy further comprises:
and if the test traffic is zero, determining that the method needs to perform fusing operation, wherein the fusing operation is used for representing that a preset execution result is provided for the target resource.
7. A resource current limiting apparatus, comprising:
a resource name obtaining module, configured to obtain a resource name of a target resource from a bytecode by using a package path, where the package path is a path specified by obtaining the target resource, and the bytecode is a content obtained by compiling a code having service logic;
a configuration information obtaining module, configured to obtain, by using the resource name, configuration information corresponding to the target resource, where a current limiting policy and a current limiting parameter related to the target resource are stored in the configuration information, and the configuration information and the resource name are stored in a one-to-one correspondence manner;
and the execution module is used for executing the content corresponding to the target resource by using the configuration information.
8. The apparatus of claim 7, wherein the resource name obtaining module comprises:
the scanning unit is used for scanning all the contents corresponding to the packet path in the byte code according to the packet path;
a class acquisition unit, configured to acquire all classes in all contents in the packet path;
and the resource name acquisition unit is used for traversing all classes and acquiring the method names of all methods as the resource names.
9. The resource current-limiting apparatus of claim 7, further comprising:
the strategy determining module is used for determining each method needing to customize the current limiting strategy;
and the strategy customizing module is used for generating configuration information with the current limiting strategy and the current limiting parameter for each method needing to customize the current limiting strategy.
10. The resource current limiting apparatus of claim 9, wherein the policy determination module further comprises:
the execution unit is used for executing all methods in the byte codes and obtaining the test traffic corresponding to each method, wherein the test traffic is used for representing the number of the services processed by executing the methods;
and the judging unit is used for comparing the test traffic with the real traffic in a real service scene, and when the test traffic is smaller than the real traffic, determining that the method needs to customize a current limiting strategy, wherein the current limiting strategy is used for indicating that the target resource needs to perform current limiting operation during execution.
11. The apparatus of claim 10, wherein the policy customization module is further configured to determine the test traffic as a current limiting parameter of the method when the method requires customization of a current limiting policy, the current limiting parameter indicating a maximum amount of traffic that the target resource can handle when executing.
12. The apparatus according to claim 10, wherein the policy determining module is further configured to determine that the method requires a fusing operation when the test traffic is zero, where the fusing operation is used to indicate that a preset execution result is provided for the target resource.
13. An electronic device, comprising: a memory for storing program instructions;
a processor for invoking and executing program instructions in the memory to implement the resource throttling method of any of claims 1-6.
14. A storage medium having a computer program stored therein, wherein when the computer program is executed by at least one processor of a resource current limiting device, the resource current limiting device performs the resource current limiting method of any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010131366.8A CN111371699B (en) | 2020-02-28 | 2020-02-28 | Resource current limiting method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010131366.8A CN111371699B (en) | 2020-02-28 | 2020-02-28 | Resource current limiting method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111371699A true CN111371699A (en) | 2020-07-03 |
CN111371699B CN111371699B (en) | 2023-07-21 |
Family
ID=71211169
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010131366.8A Active CN111371699B (en) | 2020-02-28 | 2020-02-28 | Resource current limiting method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111371699B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113411269A (en) * | 2021-07-07 | 2021-09-17 | 杭州网易云音乐科技有限公司 | Current limiting control method, current limiting control device, storage medium and electronic equipment |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6295642B1 (en) * | 1999-04-29 | 2001-09-25 | International Business Machines Corporation | Method and apparatus for partial just in time compiling in a data processing system |
US6965574B1 (en) * | 2001-06-20 | 2005-11-15 | Arbor Networks, Inc. | Network traffic data collection and query |
CN101217494A (en) * | 2008-01-08 | 2008-07-09 | 杭州华三通信技术有限公司 | A method and network device for operation flow monitoring |
CN104951707A (en) * | 2015-05-13 | 2015-09-30 | 上海交通大学 | Sensitive resource access control policy system based on Android platform |
CN108536524A (en) * | 2018-03-13 | 2018-09-14 | Oppo广东移动通信有限公司 | Resource regeneration method, device, terminal and storage medium |
CN110838987A (en) * | 2019-10-08 | 2020-02-25 | 福建天泉教育科技有限公司 | Queue current limiting method and storage medium |
-
2020
- 2020-02-28 CN CN202010131366.8A patent/CN111371699B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6295642B1 (en) * | 1999-04-29 | 2001-09-25 | International Business Machines Corporation | Method and apparatus for partial just in time compiling in a data processing system |
US6965574B1 (en) * | 2001-06-20 | 2005-11-15 | Arbor Networks, Inc. | Network traffic data collection and query |
CN101217494A (en) * | 2008-01-08 | 2008-07-09 | 杭州华三通信技术有限公司 | A method and network device for operation flow monitoring |
CN104951707A (en) * | 2015-05-13 | 2015-09-30 | 上海交通大学 | Sensitive resource access control policy system based on Android platform |
CN108536524A (en) * | 2018-03-13 | 2018-09-14 | Oppo广东移动通信有限公司 | Resource regeneration method, device, terminal and storage medium |
CN110838987A (en) * | 2019-10-08 | 2020-02-25 | 福建天泉教育科技有限公司 | Queue current limiting method and storage medium |
Non-Patent Citations (1)
Title |
---|
王小强;顾乃杰;: "基于操作码合并的Python程序防逆转算法" * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113411269A (en) * | 2021-07-07 | 2021-09-17 | 杭州网易云音乐科技有限公司 | Current limiting control method, current limiting control device, storage medium and electronic equipment |
CN113411269B (en) * | 2021-07-07 | 2022-05-17 | 杭州网易云音乐科技有限公司 | Current limiting control method, current limiting control device, storage medium and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN111371699B (en) | 2023-07-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104820640B (en) | A kind of webpage test method and device | |
CN109800154B (en) | Test data loading method and device, computer equipment and storage medium | |
US7680668B2 (en) | Method for generating a language-independent regression test script | |
US20040194063A1 (en) | System and method for automated testing of a software module | |
US11422917B2 (en) | Deriving software application dependency trees for white-box testing | |
CN108614702B (en) | Byte code optimization method and device | |
US20080270101A1 (en) | Building Finite State Machine Model | |
CN112765023A (en) | Test case generation method and device | |
CN109558328B (en) | Method, system and device for testing code coverage rate and readable storage medium | |
CN110569194A (en) | interface testing method and device, electronic equipment and storage medium | |
CN111045941B (en) | Positioning method and device for user interface control and storage medium | |
CN111324540B (en) | Interface testing method and device | |
CN109558145B (en) | Installation package volume optimization method and device for android application | |
CN115617780A (en) | Data import method, device, equipment and storage medium | |
CN111371699B (en) | Resource current limiting method and device, electronic equipment and storage medium | |
CN114895935A (en) | Method and device for flashing vehicle ECU, electronic equipment and storage medium | |
CN114218072A (en) | Test script generation method and device, storage medium and computer equipment | |
CN112559346A (en) | Service testing method and device | |
CN116431467A (en) | Page test method, device, equipment and medium | |
CN114281427A (en) | Method and equipment for batch parameter configuration and verification | |
CN114564903A (en) | Chip simulation design verification method, device, equipment and medium | |
CN115469934A (en) | Configuration file loading method, device and equipment | |
CN112015640B (en) | Software testing method and system | |
CN110825450B (en) | APP configuration modification method and device, electronic equipment and storage medium | |
CN117435510B (en) | Automatic test method, terminal equipment and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |