Service control method, device, computer equipment and storage medium under microservice
Through dynamic detection and current limiting processing, the server pressure problem caused by excessive resource usage in microservices is solved, and efficient linkage control and stability of the system are achieved, which is suitable for multi-service concurrent processing scenarios.
Patent Information
- Application Number
- CN202010163908.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-10
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-03-10
AI Technical Summary
In microservices, excessive resource usage leads to a reduction in server processing efficiency. Existing technologies are difficult to detect and control resource conflicts in a timely manner, resulting in poor system performance.
By receiving concurrent service requests, it dynamically detects the resource usage status of microservices, obtains resource usage, and performs current limiting processing and control based on preset thresholds and changes to ensure that resource usage is within a safe range.
It effectively avoids resource overload, improves the stability and processing performance of the microservice system, and is suitable for multi-service concurrent processing scenarios.
Smart Images

Figure CN111475373B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a service control method, device, computer equipment and storage medium under microservices. Background Art
[0002] With the rapid development of the Internet, the degree of resource sharing in microservices has greatly increased, which will bring new opportunities and challenges to the concurrency control of microservices. At present, when resource conflicts do not occur frequently, microservice requests can only rely on mature health checks and dynamic load balancing to solve the concurrency control of microservices, which can meet basic needs. The inventors realized that when multiple services are processing tasks, if the services with excessive resource utilization cannot be found and controlled in time, it is easy to cause high pressure on the server and poor processing performance of the entire program. Summary of the invention
[0003] The purpose of the embodiments of the present application is to propose a service control method, device, computer equipment and storage medium under microservices, aiming to solve the technical problem that the processing efficiency of the server is reduced due to the excessive resource utilization of microservices.
[0004] In order to solve the above technical problems, the present application embodiment provides a service control method under microservices, which adopts the following technical solutions:
[0005] A service control method under microservices includes the following steps:
[0006] Receive several concurrent service requests, and call corresponding microservices to perform processing tasks according to the service requests;
[0007] When executing the processing task, dynamically detect the resource usage status of the current microservice, and obtain a first resource usage rate corresponding to the resource usage status;
[0008] Determine whether the first resource usage rate is greater than a preset resource usage threshold, and when it is determined that the first resource usage rate is greater than the resource usage threshold, store the first resource usage rate and the service information of the current microservice in a database;
[0009] querying the database periodically, and dynamically reacquiring the resource usage rate of the microservice as the second resource usage rate according to the service information stored in the database, and if the second resource usage rate is greater than the first resource usage rate, using the second dynamic resource usage rate as the real-time resource usage rate of the microservice;
[0010] Obtaining the real-time resource usage rates at multiple query time points, calculating the change in the real-time resource usage rates at two adjacent query time points, and determining the dynamic increment of the microservice according to the change;
[0011] The current microservice is controlled based on the change amount, the dynamic increment situation and the real-time resource usage rate.
[0012] Furthermore, the step of calling the corresponding microservice to execute the processing task according to the service request includes:
[0013] Obtain initial configuration information and initialize the configuration of the microservice system;
[0014] It is determined whether the number of tasks being executed by the microservice corresponding to the service request is greater than a preset number threshold. If so, the processing task corresponding to the service request is first subjected to flow limiting processing, otherwise the processing task is executed normally.
[0015] Furthermore, the step of determining whether the number of tasks being executed by the microservice corresponding to the service request is greater than a preset number threshold includes:
[0016] Obtain the number of current task threads of the microservice corresponding to the service request, use the number of task threads as the number of tasks being executed by the microservice corresponding to the service request, and determine whether the number of task threads is greater than a preset number threshold;
[0017] The first performing flow limiting processing on the processing task corresponding to the service request includes:
[0018] The processing task corresponding to the service request is cached, and when it is determined that an old task thread in the microservice has finished executing, the old task thread is interrupted, and a new task thread is started from a thread pool to execute the processing task.
[0019] Further, the resource usage status includes at least one of response time, average time delay, concurrency, http error response code percentage, cpu usage rate and memory usage rate, and the step of obtaining the first resource usage rate corresponding to the resource usage status includes:
[0020] Obtain the priority policies corresponding to the response time, the average time delay, the concurrency, the http error response code percentage, the cpu usage rate and the memory usage rate;
[0021] According to the priority strategy, a first resource usage rate corresponding to the resource usage status is calculated.
[0022] Furthermore, the step of determining the dynamic increment of the microservice according to the change amount includes:
[0023] Calculate the time difference between adjacent query time points as the incremental time, and calculate the incremental slope corresponding to the instantaneous resource usage rate of adjacent query time points according to the incremental time and the change amount;
[0024] The dynamic increment situation of the microservice is determined according to the increment slope.
[0025] Furthermore, the step of controlling the current microservice based on the change amount, the dynamic increment situation and the real-time resource usage rate includes:
[0026] Determine the restriction condition of the microservice based on the change amount, the dynamic increment situation and the real-time resource usage rate;
[0027] According to the restriction condition, determine whether to restrict the current microservice, wherein when the restriction condition is a necessary restriction condition, the microservice is restricted, and when the restriction condition is a non-necessary restriction condition, the microservice is not restricted.
[0028] Further, after the step of determining whether to restrict the current microservice according to the restriction condition, the service control method under the microservice also includes:
[0029] The service status of the microservice is detected periodically, and when it is determined that the service status is a restricted state, the microservice is restricted.
[0030] In order to solve the above technical problems, the embodiment of the present application also provides a service control device under microservices, which adopts the following technical solution:
[0031] A receiving module is used to receive several concurrent service requests and call corresponding microservices to execute processing tasks according to the service requests;
[0032] A first acquisition module is used to dynamically detect the resource usage status of the current microservice when executing the processing task, and obtain a first resource usage rate corresponding to the resource usage status;
[0033] a determination module, configured to determine whether the first resource usage rate is greater than a preset resource usage threshold, and when it is determined that the first resource usage rate is greater than the resource usage threshold, store the first resource usage rate and service information of the current microservice in a database;
[0034] a timing query module, configured to query the database at a regular interval, and dynamically obtain the resource usage rate of the microservice as the second resource usage rate according to the service information stored in the database, and if the second resource usage rate is greater than the first resource usage rate, use the second dynamic resource usage rate as the real-time resource usage rate of the microservice;
[0035] The second acquisition module is used to obtain the real-time resource usage rates of multiple query time points, calculate the change in the real-time resource usage rates of two adjacent query time points, and determine the dynamic increment of the microservice according to the change;
[0036] A control module is used to control the current microservice based on the change amount, the dynamic increment situation and the real-time resource usage rate.
[0037] In order to solve the above technical problems, an embodiment of the present application also provides a computer device, including a memory and a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the service control method under the above microservices when executing the computer-readable instructions.
[0038] In order to solve the above technical problems, an embodiment of the present application further provides a computer-readable storage medium, which stores computer-readable instructions. When the computer-readable instructions are executed by a processor, the steps of the service control method under the above microservices are implemented.
[0039] The service control method, device, computer equipment and storage medium under the above-mentioned microservice receive several concurrent service requests, call the corresponding microservice to execute the processing task according to the service request, and then dynamically detect the resource usage status of the current microservice when executing the processing task, and obtain the first resource usage rate corresponding to the resource usage status, wherein the resource usage status includes the response time, average time delay and other values of the current microservice. Therefore, according to the resource usage status, the first resource usage rate reflected by various values in the current microservice can be obtained. Then, it is determined whether the first resource usage rate is greater than a preset resource usage threshold. When it is determined that the first resource usage rate is greater than the resource usage threshold, the first resource usage rate and the service information of the current microservice are stored in the database, so as to query the resource usage rate of the current microservice according to the service information; thereafter, the database is queried regularly, and the resource usage rate of the microservice is dynamically acquired again as the second resource usage rate according to the service information stored in the database. If the second resource usage rate is greater than the first resource usage rate, the second dynamic resource usage rate is used as the instant resource usage rate of the microservice, and the instant resource usage rate is the resource usage rate of the microservice at this moment; then the instant resource usage rates of multiple query time points are acquired, the change amount of the instant resource usage rates of two adjacent query time points is calculated, and the dynamic increment of the microservice is determined according to the change amount; the change amount and the dynamic increment reflect the resource change trend of the current microservice, and finally the current microservice is controlled based on the change amount, the dynamic increment and the instant resource usage rate, so as to realize an efficient linkage control method for microservices and effectively ensure the stability of the system when multiple services process tasks at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0042] Figure 2 This is a flowchart of the service control method under microservices;
[0043] Figure 3 for Figure 2 A detailed flow chart of step 200;
[0044] Figure 4 for Figure 2 A detailed flow chart of step 300;
[0045] Figure 5 for Figure 2 A detailed flow chart of step 600;
[0046] Figure 6 for Figure 2 A detailed flow chart of step 700;
[0047] Figure 7 is a structural diagram of an embodiment of a service control device under a microservice according to the present application;
[0048] Figure 8 It is a structural diagram of an embodiment of a computer device according to the present application.
[0049] Reference numerals: 1100 receiving module; 1200 first acquisition module; 1300 determination module; 1400 timing query module; 1500 second acquisition module; 1600 control module. DETAILED DESCRIPTION
[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0051] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0052] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0053] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0054] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0055] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.
[0056] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0057] It should be noted that the service control method under the microservice provided in the embodiment of the present application is generally executed by the server / terminal, and accordingly, the service control device under the microservice is generally set in the server / terminal device.
[0058] It should be understood that Figure 1 The number of terminals, networks and servers in the embodiment is only for illustration. Any number of terminals, networks and servers may be provided according to the implementation requirements.
[0059] Continue to refer Figure 2 , shows a flow chart of an embodiment of a service control method under microservices according to the present application. The service control method under microservices comprises the following steps:
[0060] Step S200, receiving several concurrent service requests, and calling corresponding microservices to execute processing tasks according to the service requests;
[0061] The service request is initiated by multiple request senders. When a service request is received, the service request is parsed to obtain the parsed content corresponding to the service request. According to the parsed content, the microservice and processing task corresponding to the service request can be obtained. The service corresponding to the service request is called to execute the processing task corresponding to the service request, and a response is sent to the request sender indicating that the service request has been successfully received.
[0062] Step S300, when executing the processing task, dynamically detect the resource usage status of the current microservice, and obtain a first resource usage rate corresponding to the resource usage status;
[0063] Resource usage status includes: service response time, average time delay, concurrency, http error response code percentage, cpu usage and memory usage. When the service executes the processing task, the current resource usage status of the service is dynamically detected based on polling.
[0064] Specifically, one possible implementation method is to collect information on CPU usage and memory usage based on a collection algorithm, such as using the Process Explorer tool, executing top, jstack and other commands to view system resource usage such as response time, average time delay, concurrency, http error response code percentage, etc., and then obtain the CPU and memory usage through analysis and algorithm calculation. Another possible implementation method is to directly read the system files of the current operating system to obtain response time, average time delay, concurrency, http error response code percentage, call the resource collection interface implementation class of the relevant operating system, and obtain the CPU usage and memory usage.
[0065] When the current resource usage status of the service is obtained, the first resource usage rate of the current service can be calculated based on the resource usage status, wherein the first resource usage rate can be an indicator value corresponding to any item in the current resource usage status, such as a specific value corresponding to the CPU usage rate in the resource usage status. In addition, the first resource usage rate can also be a value calculated based on the comprehensive resource usage status, that is, the indicator values corresponding to the service response time, average time delay, concurrency, http error response code percentage, CPU usage rate and memory usage rate included in the resource usage status are comprehensively calculated according to the preset calculation rules. For example, a preset calculation method such as summing up the same weights corresponding to each item in the resource usage status.
[0066] Step S400, determining whether the first resource usage rate is greater than a preset resource usage threshold, and when it is determined that the first resource usage rate is greater than the resource usage threshold, storing the first resource usage rate and the service information of the current microservice in a database;
[0067] Calculate the first resource usage rate corresponding to the resource usage status in the current microservice, obtain the preset resource usage threshold corresponding to the microservice, and compare the first resource usage rate with the resource usage threshold. Specifically, one implementation is that if the response time of microservice A = 500s, the average time delay = 400s, the concurrency = 1000, the http error response code percentage = 40%, the cpu usage = 60% and the memory usage = 70%, the first resource usage rate of microservice A is:
[0068]
[0069] The configuration center sets the preset response time = 300s, the preset average time delay = 200s, the preset concurrency = 1500, the preset http error response code percentage = 20%, the preset cpu usage = 70% and the preset memory usage = 80%. The resource usage threshold set by the configuration center is σ (pc) =1*100+1*100+1*10+1*10+1*10+1+1; By comparison, it can be seen that the first resource usage rate of service A is greater than the resource usage threshold set by the configuration center, and the first resource usage rate corresponding to the microservice A and the current service information of the service are stored in the database. Among them, the resource usage threshold is set by the configuration center. When it is determined that the first resource usage rate is greater than the resource usage threshold, the early warning instruction is sent to the monitoring center. The early warning instruction is that if the resource usage rate of the current service exceeds the preset resource usage threshold, the early warning instruction is automatically triggered to the monitoring center, and it can be displayed on the monitoring interface at the same time, which is convenient for operation and maintenance personnel to view.
[0070] Step S500, regularly querying the database, and dynamically re-obtaining the resource usage rate of the microservice as the second resource usage rate according to the service information stored in the database, and if the second resource usage rate is greater than the first resource usage rate, using the second dynamic resource usage rate as the real-time resource usage rate of the microservice;
[0071] Among them, the scheduled query is initiated by the gateway. The scheduled query is to use the quartz scheduled task. The scheduleJob() method of quartz stores the query task and trigger in the Jobstore database, starts the scheduling thread, and continuously executes the triggered task from the database. The trigger sets the automatic trigger time, such as 5 seconds, 3 seconds, etc. The first resource utilization rate and service information stored in the database are obtained, and the resource utilization rate of the microservice is dynamically obtained again according to the service information. The resource utilization rate obtained again is the second resource utilization rate; the second resource utilization rate is compared with the first resource utilization rate. If the second resource utilization rate is greater than the first resource utilization rate, the second resource utilization rate is used as the instant resource utilization rate of the current service.
[0072] Specifically, one implementation method is to obtain the various indicator values in the resource usage status corresponding to the second resource usage rate, perform algorithmic operations based on the priority strategy corresponding to each item, sum the operation results of each item, and obtain the first resource usage rate A; compare the first resource usage rate A with the resource usage rate threshold B in the configuration file of the configuration center, and the B is also obtained by performing algorithmic operations based on the priority strategy of each item and summing the operation results of each item. If A>B, send an early warning instruction to the monitoring center, and cache the resource usage status and service information corresponding to A to the database as a static indicator; obtain the dynamic second resource usage rate regularly through the service information, and the second resource usage rate is C; if C is less than A, it is determined that the resource usage rate of the service has begun to decline; if C is greater than A, it is determined that the resource usage rate of the service is still continuing to rise and C1 is used as the instantaneous resource usage rate of the current service.
[0073] Another implementation method is to set the resource usage rate of the first acquisition to P 1 , the resource usage rate of the Nth acquisition is P n , judge P1>P, if false, do not do anything; if true, change P 1 Write to the database. Get P 2 , judge P 2 >P 1 , recursively compare, and after each comparison, save the largest p value in the database until the comparison reaches P n , then the current limiting judgment ends; if during the comparison process, it is judged that P m >P m-1 If true, the resource utilization rate is on the rise. Determine whether the current resource utilization rate of the service is greater than p. If it is greater than p, limit the service. Otherwise, do not limit the service. If the service has been limited in the comparison, determine P m <P m-1 If true, the resource utilization rate is on a downward trend. Determine whether the resource utilization rate is less than p. If it is less than p, lift the flow limit on the service. Otherwise, no flow limit is performed.
[0074] Step S600, obtaining the real-time resource usage rates of multiple query time points, calculating the change in the real-time resource usage rates of two adjacent query time points, and determining the dynamic increment of the microservice according to the change;
[0075] The real-time resource usage rates of the adjacent query time points of the current microservice are obtained respectively, wherein the real-time resource usage rate of the previous moment in the adjacent query time point is the first moment resource usage rate, and the real-time resource usage rate of the next moment is the second moment resource usage rate. The difference between the first moment resource usage rate and the second moment resource usage rate is calculated, and the difference is the change amount.
[0076] When the change in the instantaneous resource utilization rate between adjacent query time points is calculated, the dynamic incremental situation of the service can be determined based on the change. Specifically, the time difference between the resource utilization rate at the first moment and the resource utilization rate at the second moment is calculated as the incremental time. The instantaneous resource utilization rate is cached in the custom model corresponding to the current service. The custom model is performed under monitoring. The custom model can calculate the incremental slope corresponding to the resource utilization rate at the first moment and the resource utilization rate at the second moment based on the incremental time and the change. The dynamic incremental situation of the current service can be further determined based on the incremental slope.
[0077] Step S700: Control the current microservice based on the change amount, the dynamic increment situation and the real-time resource usage rate.
[0078] When the change amount, dynamic increment and real-time resource utilization rate of the microservice are obtained, the restriction conditions corresponding to the service are determined according to the change amount, dynamic increment and real-time resource utilization rate. For example, the real-time resource utilization rate is compared with the preset standard threshold to obtain the comparison result, which is condition one (A), and the value is large or small relative to the preset standard threshold, A (large / small); the change amount of the service obtained at two adjacent time nodes is used as condition two (B); the dynamic increment of the current service is used as condition three (C). Among them, the result of condition one A determines whether the current microservice exceeds the set threshold, the result of condition two B determines whether the resource utilization rate of the current microservice is rising or falling, and condition three C represents the speed of rising or falling. According to the different results of condition one, condition two and condition three, it is determined whether the microservice needs to be controlled. When it is determined that the microservice needs to be controlled, the microservice is controlled.
[0079] In this embodiment, an efficient linkage control method for microservices is implemented, which is more suitable for the decentralized characteristics of microservices and effectively ensures the stability of the system when multiple services are processing tasks at the same time.
[0080] In some embodiments of the present application, Figure 3 As shown, step S200, calling the corresponding microservice to perform the processing task according to the service request includes:
[0081] Step S210, obtaining initial configuration information and initializing the configuration of the microservice system;
[0082] Step S220, determine whether the number of tasks being executed by the microservice corresponding to the service request is greater than a preset number threshold, if so, perform flow limiting on the processing task corresponding to the service request, otherwise execute the processing task normally.
[0083] The initial configuration information is obtained by the gateway; when the initial configuration message is obtained, the microservice system is initialized and configured. When the initial configuration is completed, the number of tasks being executed by the microservice corresponding to the current service request is obtained to determine whether the number of tasks is greater than the preset number threshold. If it is determined that the number of tasks is greater than the preset number threshold, the processing task corresponding to the service request is current-limited; if it is determined that the number of tasks is not less than the preset number threshold, the processing task corresponding to the service request is executed normally.
[0084] In this embodiment, the number of threads executing tasks is determined. When the number of tasks is greater than a preset threshold, current limiting is performed to avoid high concurrency and ensure system stability.
[0085] In some embodiments of the present application, determining whether the number of tasks being executed by the microservice corresponding to the service request is greater than a preset number threshold includes:
[0086] Obtain the number of current task threads of the microservice corresponding to the service request, use the number of task threads as the number of tasks being executed by the microservice corresponding to the service request, and determine whether the number of task threads is greater than a preset number threshold;
[0087] The first performing flow limiting processing on the processing task corresponding to the service request includes:
[0088] The processing task corresponding to the service request is cached, and when it is determined that an old task thread in the microservice has finished executing, the old task thread is interrupted, and a new task thread is started from a thread pool to execute the processing task.
[0089] The actuator component based on springcloud monitors thread resources. The metrics monitoring endpoint of the actuator can count HTTP requests. The Scheduledtasks() method in the actuator is used to monitor the task status in the program. If the task is monitored to be in the running state, the number of current task threads is counted and the number of task threads is used as the number of tasks being executed by the microservice corresponding to the service request. When it is determined that the number of tasks is greater than the preset number threshold, the processing task corresponding to the service request is cached.
[0090] When it is determined that the old task thread in the service has finished executing, the interrupt() method is called to interrupt the old task thread. At this time, the thread pool is idle, and a new task thread is called from the thread pool to execute the processing task corresponding to the service request. Among them, the thread pool creates several threads in advance. If there is a task to be processed, the thread in the thread pool processes the task. After processing, the thread will not be destroyed, but wait for the next task.
[0091] In this embodiment, thread resources are monitored, thus avoiding the consumption of resources when repeatedly creating and destroying threads.
[0092] In some embodiments of the present application, Figure 4 As shown, the resource usage status includes at least one of response time, average time delay, concurrency, http error response code percentage, CPU usage rate and memory usage rate. In step S300, the step of obtaining the first resource usage rate corresponding to the resource usage status includes:
[0093] Step S310, obtaining the priority policies corresponding to the response time, the average time delay, the concurrency, the http error response code percentage, the cpu usage rate and the memory usage rate;
[0094] Step S320: Calculate a first resource usage rate corresponding to the resource usage status according to the priority strategy.
[0095] Resource usage status includes indicators such as response time, average time delay, concurrency, http error response code percentage, CPU usage, and memory usage. Assume that the detected response time is a, and the set response time is A; use the percentage to obtain the percentage corresponding to each indicator: The percentages corresponding to the indicators are cached. Each indicator included in the resource usage status is detected respectively, and when the percentages corresponding to each indicator are obtained, the first resource usage rate corresponding to the resource usage status can be calculated according to the percentages of each indicator.
[0096] In one embodiment, the response time and average time delay are set to level A; the concurrency and http error response code percentage are set to level B; other basic resource indicators such as cpu usage and memory usage are set to level C; the value corresponding to level A is set to 10 2 , the value corresponding to level B is 10 1 , the value corresponding to level C is 10 0 ; The level setting is the priority strategy of each indicator in the resource usage status. The specific calculation formula is as follows: σ (p) That is the calculated first resource usage rate.
[0097] In this embodiment, dynamic detection of various indicators in the resource usage status is implemented, which effectively avoids the situation of excessive resource utilization to a certain extent. By detecting the CPU utilization and memory utilization, services with excessively high concurrency can be accurately found, and high-concurrency services can be processed accurately and quickly, which ensures the stability of the system to a certain extent.
[0098] In some embodiments of the present application, Figure 5 As shown, step S600, determining the dynamic increment of the microservice according to the change amount includes:
[0099] Step S610, calculating the time difference between adjacent query time points as the incremental time, and calculating the incremental slope corresponding to the instantaneous resource usage rate between adjacent query time points according to the incremental time and the change amount;
[0100] Step S620: determining the dynamic increment of the microservice according to the increment slope.
[0101] When calculating the change in the instantaneous resource utilization rate of adjacent query time points, calculate the time difference between the adjacent query time points, and the time difference is the incremental time. Calculate the incremental slope corresponding to the incremental time and the change based on the custom model. Set the time change function to, then the incremental time is ΔX, and the change in the instantaneous resource utilization rate of adjacent query time points on the incremental time is ΔY; then ΔY = f(x+ΔX)-f(x); the derivative is The actual meaning of this derivative is the incremental slope.
[0102] When the incremental slope of each two adjacent query time nodes is obtained by calculation, each group of incremental slopes is compared (two adjacent query time points are a group) to obtain a comparison result, and the dynamic incremental situation of the current service can be determined based on the comparison result. For example, the incremental slope of group A on incremental time is obtained The previous incremental slope of the incremental time of group A By comparing the two groups of incremental slopes, it can be found that the incremental slopes corresponding to group A and group B are decreasing, thereby obtaining the dynamic incremental situation of the current service that the instantaneous growth of instant resource utilization is gradually decreasing.
[0103] In this embodiment, the calculation of the incremental slope of adjacent query time points is implemented, so that the dynamic incremental situation of the current service is further determined through the incremental slope, so that the resource usage status of the current service can be judged more accurately.
[0104] In some embodiments of the present application, Figure 6 As shown, step S700, the step of controlling the current microservice based on the change amount, the dynamic increment situation and the real-time resource usage rate includes:
[0105] Step S710, determining the restriction condition of the microservice based on the change amount, the dynamic increment situation and the real-time resource usage rate;
[0106] Step S720: Determine whether to restrict the current microservice according to the restriction condition, wherein when the restriction condition is a necessary restriction condition, the microservice is restricted, and when the restriction condition is a non-necessary restriction condition, the microservice is not restricted.
[0107] In one embodiment, the instantaneous resource usage rate is compared with the preset standard threshold to obtain a comparison result, which is condition one (A), and the value is whether it is larger or smaller than the preset standard threshold, A (large / 4); the change amount of the service obtained at two adjacent time nodes is used as condition two (B), B (20% / -20%); the dynamic increment of the current service is used as condition three (C), C (60° / 20°). The result of condition one A determines whether the current microservice exceeds the set threshold, the result of condition two B determines whether the resource usage rate of the current microservice is rising or falling, and condition three C represents the speed of rising or falling.
[0108] If A is large, B is a positive value, and C exceeds 45°, it means that the resource usage of the current microservice is growing explosively and needs to be restricted in time. The current restriction condition is type I, that is, a necessary restriction condition.
[0109] If A is large, B is a positive value, and C does not exceed 45 degrees, it means that the resource usage rate of the current microservice is growing slowly and needs to be restricted in time. The current restriction condition is type I, that is, a necessary restriction condition;
[0110] If A is small, B is positive, and C exceeds 45°, it means that the resource usage of the current microservice is growing explosively and needs to be restricted in time. The current restriction condition is type I, that is, a necessary restriction condition.
[0111] If A is small, B is a positive value, and C does not exceed 45°, it means that the resource usage of the current microservice is growing explosively and does not need to be restricted. The current restriction condition is type II, that is, a non-essential restriction condition;
[0112] If A is large, B is negative, and C exceeds 45°, it means that the resource usage of the current microservice is decreasing explosively and no restriction is needed for the time being. The current restriction condition is type II, that is, a non-essential restriction condition.
[0113] If A is large, B is negative, and C does not exceed 45 degrees, it means that the resource utilization rate of the current microservice is slowly decreasing and needs to be restricted in time. The current restriction condition is type I, that is, a necessary restriction condition;
[0114] If A is small, B is negative, and C exceeds 45°, it means that the resource usage of the current microservice is decreasing explosively and no restriction is needed. The current restriction condition is type II, that is, a non-essential restriction condition.
[0115] If A is small, B is a negative value, and C does not exceed 45°, it means that the resource utilization rate of the current microservice is slowly decreasing and no restriction is needed. The current restriction condition is type II, that is, a non-essential restriction condition.
[0116] As shown in Table 1:
[0117] Condition 1A Condition 2B Condition 3C Restrictions big Positive >45° Type I big Positive ≤45° Type I big Negative Values >45° Type II big Negative Values ≤45° Type I Small Positive >45° Type I Small Positive ≤45° Type II Small Negative Values >45° Type II Small Negative Values ≤45° Type II
[0118] Table 1
[0119] In some embodiments of the present application, after the step of determining whether to restrict the current microservice according to the restriction condition, the service control method under the microservice further includes:
[0120] The service status of the microservice is detected periodically, and when it is determined that the service status is a restricted state, the microservice is restricted.
[0121] The service status of the service includes start, pause, end, uninstall, limit and other states, which can be represented by the preset status codes staus=0, staus=1, staus=2, staus=3, and staus=4 respectively. The specific implementation method of the status code is to add new states in the status bar of the service, such as start, pause, end, uninstall, limit and other states, and bind the five service states with the preset status codes respectively. Among them, when the service needs to be restricted, that is, when the service status is restricted, the restriction state only closes the interface for receiving new tasks, and other processing interfaces and other business interfaces process the original tasks normally.
[0122] Specifically, when it is determined that the service needs to be restricted according to the resource usage status of the current service, that is, when the restriction condition of the service is the first restriction condition, the status code of the service is changed to the corresponding restriction status code, such as staus=4; the service status of the current service is regularly detected, and when it is detected that the current status code of the service is staus=4, the service is restricted. When the restriction condition of the service is the second restriction condition, the status code of the service is changed to the corresponding start status code, such as staus=0; the service status of the current service is regularly detected, and when it is detected that the current status code of the service is staus=0, there is no need to restrict the service.
[0123] In this embodiment, the service status of the current service is judged according to the status code, so that it is possible to quickly and clearly determine whether to restrict the current service through the status code.
[0124] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0125] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0126] Further references Figure 7 , as a response to the above Figure 2 The present application provides an embodiment of a service control device under microservices, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0127] like Figure 7 As shown, the service control device 1000 under the microservice described in this embodiment includes:
[0128] A receiving module 1100 is used for receiving a plurality of concurrent service requests and calling corresponding microservices to perform processing tasks according to the service requests;
[0129] Wherein, the receiving module comprises:
[0130] The configuration unit is used to obtain initial configuration information and initialize the configuration of the microservice system;
[0131] The judgment unit is used to judge whether the number of tasks being executed by the microservice corresponding to the service request is greater than a preset number threshold. If so, the processing task corresponding to the service request is first subjected to flow limiting processing; otherwise, the processing task is executed normally.
[0132] The judging unit further includes:
[0133] A first acquisition unit is used to acquire the number of current task threads of the microservice corresponding to the service request, use the number of task threads as the number of tasks being executed by the microservice corresponding to the service request, and determine whether the number of task threads is greater than a preset number threshold;
[0134] The cache unit caches the processing task corresponding to the service request, and when it is determined that the execution of an old task thread in the microservice has ended, interrupts the old task thread and starts a new task thread from a thread pool to execute the processing task.
[0135] The service request is initiated by multiple request senders. When a service request is received, the service request is parsed to obtain the parsed content corresponding to the service request. According to the parsed content, the microservice and processing task corresponding to the service request can be obtained. The service corresponding to the service request is called to execute the processing task corresponding to the service request, and a response is sent to the request sender indicating that the service request has been successfully received.
[0136] The first acquisition module 1200 is used to dynamically detect the resource usage status of the current microservice when executing the processing task, and obtain a first resource usage rate corresponding to the resource usage status;
[0137] The resource usage status includes at least one of service response time, average time delay, concurrency, http error response code percentage, cpu usage rate and memory usage rate. When the service executes the processing task, the resource usage status of the current service is dynamically detected based on polling.
[0138] Wherein, the first acquisition module includes:
[0139] A second acquisition unit is used to acquire the priority strategy corresponding to the response time, the average time delay, the concurrency, the http error response code percentage, the cpu usage rate and the memory usage rate;
[0140] The first calculation unit is used to calculate a first resource usage rate corresponding to the resource usage state according to the priority strategy.
[0141] Resource usage status includes: service response time, average time delay, concurrency, http error response code percentage, cpu usage and memory usage. When the service executes the processing task, the current resource usage status of the service is dynamically detected based on polling.
[0142] Specifically, one possible implementation method is to collect information on CPU usage and memory usage based on a collection algorithm, such as using the Process Explorer tool, executing top, jstack and other commands to view system resource usage such as response time, average time delay, concurrency, http error response code percentage, etc., and then obtain the CPU and memory usage through analysis and algorithm calculation. Another possible implementation method is to directly read the system files of the current operating system to obtain response time, average time delay, concurrency, http error response code percentage, call the resource collection interface implementation class of the relevant operating system, and obtain the CPU usage and memory usage.
[0143] When the current resource usage status of the service is obtained, the first resource usage rate of the current service can be calculated based on the resource usage status, wherein the first resource usage rate can be an indicator value corresponding to any item in the current resource usage status, such as a specific value corresponding to the CPU usage rate in the resource usage status. In addition, the first resource usage rate can also be a value calculated based on the comprehensive resource usage status, that is, the indicator values corresponding to the service response time, average time delay, concurrency, http error response code percentage, CPU usage rate and memory usage rate included in the resource usage status are comprehensively calculated according to the preset calculation rules. For example, a preset calculation method such as summing up the same weights corresponding to each item in the resource usage status.
[0144] The determination module 1300 is used to determine whether the first resource usage rate is greater than a preset resource usage threshold, and when it is determined that the first resource usage rate is greater than the resource usage threshold, store the first resource usage rate and the service information of the current microservice in a database;
[0145] Calculate the first resource usage rate corresponding to the resource usage status in the current microservice, obtain the preset resource usage threshold corresponding to the microservice, and compare the first resource usage rate with the resource usage threshold. Specifically, one implementation is that if the response time of microservice A = 500s, the average time delay = 400s, the concurrency = 1000, the http error response code percentage = 40%, the cpu usage = 60% and the memory usage = 70%, the first resource usage rate of microservice A is:
[0146]
[0147] The configuration center sets the preset response time = 300s, the preset average time delay = 200s, the preset concurrency = 1500, the preset http error response code percentage = 20%, the preset cpu usage = 70% and the preset memory usage = 80%. The resource usage threshold set by the configuration center is σ(pc) =1*100+1*100+1*10+1*10+1*10+1+1; By comparison, it can be seen that the first resource usage rate of service A is greater than the resource usage threshold set by the configuration center, and the first resource usage rate corresponding to the microservice A and the current service information of the service are stored in the database. Among them, the resource usage threshold is set by the configuration center. When it is determined that the first resource usage rate is greater than the resource usage threshold, the early warning instruction is sent to the monitoring center. The early warning instruction is that if the resource usage rate of the current service exceeds the preset resource usage threshold, the early warning instruction is automatically triggered to the monitoring center, and it can be displayed on the monitoring interface at the same time, which is convenient for operation and maintenance personnel to view.
[0148] The timing query module 1400 is used to query the database at a regular time, and dynamically obtain the resource usage rate of the microservice as the second resource usage rate according to the service information stored in the database, and if the second resource usage rate is greater than the first resource usage rate, use the second dynamic resource usage rate as the real-time resource usage rate of the microservice;
[0149] Among them, the scheduled query is initiated by the gateway. The scheduled query is to use the quartz scheduled task. The scheduleJob() method of quartz stores the query task and trigger in the Jobstore database, starts the scheduling thread, and continuously executes the triggered task from the database. The trigger sets the automatic trigger time, such as 5 seconds, 3 seconds, etc. The first resource utilization rate and service information stored in the database are obtained, and the resource utilization rate of the microservice is dynamically obtained again according to the service information. The resource utilization rate obtained again is the second resource utilization rate; the second resource utilization rate is compared with the first resource utilization rate. If the second resource utilization rate is greater than the first resource utilization rate, the second resource utilization rate is used as the instant resource utilization rate of the current service.
[0150] Specifically, one implementation method is to obtain the various indicator values in the resource usage status corresponding to the second resource usage rate, perform algorithmic operations based on the priority strategy corresponding to each item, sum the operation results of each item, and obtain the first resource usage rate A; compare the first resource usage rate A with the resource usage rate threshold B in the configuration file of the configuration center, and the B is also obtained by performing algorithmic operations based on the priority strategy of each item and summing the operation results of each item. If A>B, send an early warning instruction to the monitoring center, and cache the resource usage status and service information corresponding to A to the database as a static indicator; obtain the dynamic second resource usage rate regularly through the service information, and the second resource usage rate is C; if C is less than A, it is determined that the resource usage rate of the service has begun to decline; if C is greater than A, it is determined that the resource usage rate of the service is still continuing to rise and C1 is used as the instantaneous resource usage rate of the current service.
[0151] Another implementation method is to set the resource usage rate of the first acquisition to P 1 , the resource usage rate of the Nth acquisition is P n , judge P 1 >P, if false, no operation is performed; if true, P 1 Write to the database. Get P 2 , judge P 2 >P 1 , recursively compare, and after each comparison, save the largest p value in the database until the comparison reaches P n , then the current limiting judgment ends; if during the comparison process, it is judged that P m >P m-1 If true, the resource utilization rate is on the rise. Determine whether the current resource utilization rate of the service is greater than p. If it is greater than p, limit the service. Otherwise, do not limit the service. If the service has been limited in the comparison, determine P m <P m-1 If true, the resource utilization rate is on a downward trend. Determine whether the resource utilization rate is less than p. If it is less than p, lift the flow limit on the service. Otherwise, no flow limit is performed.
[0152] The second acquisition module 1500 is used to acquire the real-time resource usage rates at multiple query time points, calculate the change in the real-time resource usage rates at two adjacent query time points, and determine the dynamic increment of the microservice according to the change;
[0153] Wherein, the second acquisition module includes:
[0154] A second calculation unit is used to calculate the time difference between adjacent query time points as the incremental time, and calculate the incremental slope corresponding to the instantaneous resource usage rate of the adjacent query time points according to the incremental time and the change amount;
[0155] The first determining unit is used to determine the dynamic increment situation of the microservice according to the increment slope.
[0156] The real-time resource usage rates of the adjacent query time points of the current microservice are obtained respectively, wherein the real-time resource usage rate of the previous moment in the adjacent query time point is the first moment resource usage rate, and the real-time resource usage rate of the next moment is the second moment resource usage rate. The difference between the first moment resource usage rate and the second moment resource usage rate is calculated, and the difference is the change amount.
[0157] When the change in the instantaneous resource utilization rate between adjacent query time points is calculated, the dynamic incremental situation of the service can be determined based on the change. Specifically, the time difference between the resource utilization rate at the first moment and the resource utilization rate at the second moment is calculated as the incremental time. The instantaneous resource utilization rate is cached in the custom model corresponding to the current service. The custom model is performed under monitoring. The custom model can calculate the incremental slope corresponding to the resource utilization rate at the first moment and the resource utilization rate at the second moment based on the incremental time and the change. The dynamic incremental situation of the current service can be further determined based on the incremental slope.
[0158] A control module 1600 is used to control the current microservice based on the change amount, the dynamic increment situation and the real-time resource usage rate;
[0159] Wherein, the control module comprises:
[0160] A second determining unit is used to determine the restriction condition of the microservice based on the change amount, the dynamic increment situation and the real-time resource usage rate;
[0161] The processing unit is used to determine whether to restrict the current microservice according to the restriction condition, wherein when the restriction condition is a necessary restriction condition, the microservice is restricted, and when the restriction condition is a non-necessary restriction condition, the microservice is not restricted.
[0162] When the change amount, dynamic increment and real-time resource utilization rate of the microservice are obtained, the restriction conditions corresponding to the service are determined according to the change amount, dynamic increment and real-time resource utilization rate. For example, the real-time resource utilization rate is compared with the preset standard threshold to obtain the comparison result, which is condition one (A), and the value is large or small relative to the preset standard threshold, A (large / small); the change amount of the service obtained at two adjacent time nodes is used as condition two (B); the dynamic increment of the current service is used as condition three (C). Among them, the result of condition one A determines whether the current microservice exceeds the set threshold, the result of condition two B determines whether the resource utilization rate of the current microservice is rising or falling, and condition three C represents the speed of rising or falling. According to the different results of condition one, condition two and condition three, it is determined whether the microservice needs to be controlled. When it is determined that the microservice needs to be controlled, the microservice is controlled.
[0163] The detection unit is used to periodically detect the service status of the microservice, and when it is determined that the service status is a restricted state, restrict the microservice.
[0164] The service status of the service includes start, pause, end, uninstall, limit and other states, which can be represented by the preset status codes staus=0, staus=1, staus=2, staus=3, and staus=4 respectively. The specific implementation method of the status code is to add new states in the status bar of the service, such as start, pause, end, uninstall, limit and other states, and bind the five service states with the preset status codes respectively. Among them, when the service needs to be restricted, that is, when the service status is restricted, the restriction state only closes the interface for receiving new tasks, and other processing interfaces and other business interfaces process the original tasks normally.
[0165] Specifically, when it is determined that the service needs to be restricted according to the resource usage status of the current service, that is, when the restriction condition of the service is the first restriction condition, the status code of the service is changed to the corresponding restriction status code, such as staus=4; the service status of the current service is regularly detected, and when it is detected that the current status code of the service is staus=4, the service is restricted. When the restriction condition of the service is the second restriction condition, the status code of the service is changed to the corresponding start status code, such as staus=0; the service status of the current service is regularly detected, and when it is detected that the current status code of the service is staus=0, there is no need to restrict the service.
[0166] In this embodiment, an efficient linkage control method for services is implemented, which is more suitable for the decentralized characteristics of microservices and effectively ensures the stability of the system when multiple services are processing tasks at the same time.
[0167] To solve the above technical problems, the present application also provides a computer device. Figure 8 , Figure 8 This is a basic structural block diagram of the computer device in this embodiment.
[0168] The computer device 2000 includes a memory 2001, a processor 2002, and a network interface 2003 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 2000 having components 2001-2003, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital processor (DSP), an embedded device, etc.
[0169] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0170] The memory 2001 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 2001 can be an internal storage unit of the computer device 2000, such as a hard disk or memory of the computer device 2000. In other embodiments, the memory 2001 can also be an external storage device of the computer device 2000, such as a plug-in hard disk equipped on the computer device 2000, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 2001 can also include both the internal storage unit of the computer device 2000 and its external storage device. In this embodiment, the memory 2001 is generally used to store the operating system and various application software installed on the computer device 2000, such as the program code of the service control method under the microservice, etc. In addition, the memory 2001 can also be used to temporarily store various data that have been output or are to be output.
[0171] The processor 2002 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 2002 is generally used to control the overall operation of the computer device 2000. In this embodiment, the processor 2002 is used to run the program code stored in the memory 2001 or process data, such as running the program code of the service control method under the microservice.
[0172] The network interface 2003 may include a wireless network interface or a wired network interface. The network interface 2003 is generally used to establish a communication connection between the computer device 2000 and other electronic devices.
[0173] In this embodiment, the computer device implements an efficient linkage control method for microservices, which is more suitable for the decentralized service characteristics of microservices and effectively ensures the stability of the system when multiple services are processing tasks at the same time.
[0174] The present application also provides another implementation mode, namely, providing a computer-readable storage medium, which may be a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores a service control program under a microservice, and the service control program under the microservice may be executed by at least one processor so that the at least one processor performs the steps of the service control method under the microservice as described above.
[0175] In this embodiment, the computer-readable storage medium implements an efficient linkage control method for microservices, which is more suitable for the decentralized service characteristics of microservices and effectively ensures the stability of the system when multiple services process tasks at the same time.
[0176] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0177] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A service control method under microservices, characterized in that: The steps include: Receive several concurrent service requests, and call corresponding microservices to perform processing tasks according to the service requests; When executing the processing task, dynamically detect the resource usage status of the current microservice, and obtain a first resource usage rate corresponding to the resource usage status; Determine whether the first resource usage rate is greater than a preset resource usage threshold, and when it is determined that the first resource usage rate is greater than the resource usage threshold, store the first resource usage rate and the service information of the current microservice in a database; querying the database periodically, and dynamically reacquiring the resource usage rate of the microservice as the second resource usage rate according to the service information stored in the database, and if the second resource usage rate is greater than the first resource usage rate, using the second resource usage rate as the real-time resource usage rate of the microservice; Obtaining the real-time resource usage rates at multiple query time points, calculating the change in the real-time resource usage rates at two adjacent query time points, and determining the dynamic increment of the microservice according to the change; The current microservice is controlled based on the change amount, the dynamic increment situation and the real-time resource usage rate.
2. The service control method under microservice according to claim 1, characterized in that: The step of calling the corresponding microservice to execute the processing task according to the service request includes: Obtain initial configuration information and initialize the configuration of the microservice system; It is determined whether the number of tasks being executed by the microservice corresponding to the service request is greater than a preset number threshold. If so, the processing task corresponding to the service request is first subjected to flow limiting processing, otherwise the processing task is executed normally.
3. The service control method under microservice according to claim 2 is characterized in that: The step of determining whether the number of tasks being executed by the microservice corresponding to the service request is greater than a preset number threshold comprises: Obtain the number of current task threads of the microservice corresponding to the service request, use the number of task threads as the number of tasks being executed by the microservice corresponding to the service request, and determine whether the number of task threads is greater than a preset number threshold; The first performing flow limiting processing on the processing task corresponding to the service request includes: The processing task corresponding to the service request is cached, and when it is determined that an old task thread in the microservice has finished executing, the old task thread is interrupted, and a new task thread is started from a thread pool to execute the processing task.
4. The service control method under microservice according to claim 1, characterized in that: The resource usage status includes at least one of response time, average time delay, concurrency, http error response code percentage, cpu usage rate and memory usage rate, and the step of obtaining the first resource usage rate corresponding to the resource usage status includes: Obtain the priority policies corresponding to the response time, the average time delay, the concurrency, the http error response code percentage, the cpu usage rate and the memory usage rate; According to the priority strategy, a first resource usage rate corresponding to the resource usage status is calculated.
5. The service control method under microservice according to claim 1, characterized in that: The step of determining the dynamic increment of the microservice according to the change amount includes: Calculate the time difference between adjacent query time points as the incremental time, and calculate the incremental slope corresponding to the instantaneous resource usage rate of adjacent query time points according to the incremental time and the change amount; The dynamic increment situation of the microservice is determined according to the increment slope.
6. The service control method under microservice according to claim 1, characterized in that: The step of controlling the current microservice based on the change amount, the dynamic increment situation and the instant resource usage rate includes: Determine the restriction condition of the microservice based on the change amount, the dynamic increment situation and the real-time resource usage rate; According to the restriction condition, determine whether to restrict the current microservice, wherein when the restriction condition is a necessary restriction condition, the microservice is restricted, and when the restriction condition is a non-necessary restriction condition, the microservice is not restricted.
7. The service control method under microservice according to claim 6 is characterized in that: After the step of determining whether to restrict the current microservice according to the restriction condition, the service control method under the microservice further includes: The service status of the microservice is detected periodically, and when it is determined that the service status is a restricted state, the microservice is restricted.
8. A service control device under microservice, characterized in that: include: A receiving module is used to receive several concurrent service requests and call corresponding microservices to perform processing tasks according to the service requests; A first acquisition module is used to dynamically detect the resource usage status of the current microservice when executing the processing task, and obtain a first resource usage rate corresponding to the resource usage status; a determination module, configured to determine whether the first resource usage rate is greater than a preset resource usage threshold, and when it is determined that the first resource usage rate is greater than the resource usage threshold, store the first resource usage rate and service information of the current microservice in a database; a timing query module, used for timing querying the database, and dynamically re-acquiring the resource usage rate of the microservice as the second resource usage rate according to the service information stored in the database, and if the second resource usage rate is greater than the first resource usage rate, using the second resource usage rate as the instantaneous resource usage rate of the microservice; The second acquisition module is used to obtain the real-time resource usage rates of multiple query time points, calculate the change in the real-time resource usage rates of two adjacent query time points, and determine the dynamic increment of the microservice according to the change; A control module is used to control the current microservice based on the change amount, the dynamic increment situation and the real-time resource usage rate.
9. A computer device, comprising a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the service control method under the microservice according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the service control method under the microservice according to any one of claims 1 to 7 are implemented.
