Method, system and storage medium for database load control
By classifying and metric calculation of database request events, high-load request events are intercepted or destroyed in real time, the problem of insufficient automation and real-time performance of database load control in the existing technology is solved, efficient load control is achieved, and database processing capabilities are ensured. stability.
Patent Information
- Application Number
- CN202011494361.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-17
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2040-12-17
AI Technical Summary
The existing technology lacks automation and real-time performance in database load control, resulting in a decrease in the processing capacity of the database under high load conditions. It requires manual intervention or indiscriminate fuse and current limiting measures, and cannot solve the system load problem in a timely manner.
By classifying request events, using the historical data and current data calculation indicators of each type of request events, we can judge in real time whether the system performance exceeds the threshold. If it exceeds, some request events will be intercepted or destroyed, and automated load control will be realized and database load control will be formed. Autonomous mechanism.
It realizes efficient real-time database load control, can promptly reflect the system load situation, ensure that the database always maintains high data processing capabilities, and avoids the delay and undifferentiated restrictions caused by manual intervention.
Smart Images

Figure CN114647632B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of database technology, and in particular to a method, system, storage medium and computer program product for database load control. Background Art
[0002] A database is a software system that stores and manages data according to data structures. It can accept data storage and search requests from other applications and respond to these requests. The ability of a database to accept and process requests is called load. It is subject to the performance ceiling of the operating system, and the processing capacity of the database cannot be increased indefinitely. Due to the existence of the performance ceiling, every time a database accepts an additional request at any time, its remaining processing capacity will be reduced until the request is processed.
[0003] Therefore, it is necessary to control the load of the database. Load control refers to controlling the ability of the database to accept and process requests, for example, to enable dynamic allocation according to actual conditions, to avoid accepting too many requests that consume relatively more resources, which in turn reduces the processing capacity for requests with low resource consumption (manifested as decreased database performance or even loss of responsiveness, etc.).
[0004] The database proxy layer is equivalent to a transit service for data processing requests. Data processing requests are sent from the client / application to the database proxy layer, which forwards the data processing requests to the underlying database, operates on the underlying database, and returns the results to the client / application. Various functions such as load control, flow control, and permission management can be added to the database proxy layer to uniformly manage data processing requests. The Universal Data Access Layer (UDAL) is a data access proxy middleware developed by China Telecom Informatization Research and Development Center. The middleware receives data processing requests from clients / applications and then forwards the data processing requests to the underlying data storage database (such as Mysql backend storage, etc.).
[0005] As the caller and the actual storage database, the database proxy layer may receive unlimited data processing requests if it lacks a database load control mechanism, resulting in problems such as poor database request processing capabilities. These problems include, for example: 1) The client of the database proxy layer submits a large number of time-consuming data processing requests, which are directly sent to the underlying data storage database without restrictions, causing the underlying database to have a reduced response capability or even lose response; 2) A client of the database proxy layer initiates a high frequency of data processing requests, causing a single client to occupy most resources, crowding out other clients, causing other clients' data processing requests to be unable to be processed or the database's processing capability to be reduced.
[0006] For such problems, in traditional technical solutions, the following methods are usually used to solve the above problems. Figure 1 For question 1), the database administrator 109 usually uses statistical monitoring tools to collect the time information 104 of the responded requests when the database proxy layer 105 is about to return a response 111 to the user 101, manually find out the relatively long requests, and then manually destroy the requests through the management connection (for example, selectively delete the longest SQL statement 107), and then notify the client / application / user 101 to optimize and adjust the statement to ensure that it will not appear again in the future. Still refer to Figure 1 For problem 2), the database cluster nodes are generally increased to ensure sufficient database processing capacity; on the other hand, the data processing request 102 can be indiscriminately fused, limited, etc. 106 according to the database load information 103 through the fuse or flow control module 110, giving priority to ensuring system stability. This solution requires manual intervention, and is either targeted at a single request or indiscriminately restricted, which is not universal and accurate enough.
[0007] In the technical solution of Alibaba Cloud Database Autonomous Service DAS, the system analyzes data processing requests based on the results of machine learning, controls the load flow of data processing requests, and continuously adds new request response results to the machine learning training data to form the load control strategy for the next stage. The effect of the load control strategy is continuously monitored for the next iterative calculation. However, machine learning will comprehensively analyze various indicator factors, and the time cycle required for training and iteration is relatively long, with poor real-time performance, and it is impossible to solve the system load problem in a timely manner. Summary of the invention
[0008] A brief overview of the disclosure is given below in order to provide a basic understanding of some aspects of the disclosure. However, it should be understood that this overview is not an exhaustive overview of the disclosure. It is not intended to identify the key or important parts of the disclosure, nor is it intended to limit the scope of the disclosure. Its purpose is simply to give some concepts of the disclosure in a simplified form as a prelude to a more detailed description given later.
[0009] According to one aspect of the present disclosure, a method for database load control is provided, including: obtaining a first request event; classifying the first request event into an event group of a corresponding type according to an execution plan represented by a statement included in the first request event; calculating one or more indicators of the event group using historical data and current data of all responded request events of the event group and current data of unresponded request events of the event group; determining whether there are indicators of the event group that satisfy a predetermined rule; determining whether system performance exceeds a first threshold in response to the existence of indicators of the event group that satisfy the predetermined rule; and intercepting the first request event in response to the system performance exceeding the first threshold.
[0010] According to one embodiment, the above method also includes, for each event group, periodically using the historical data and current data of all responded request events of the event group and the current data of the unresponded request events of the event group to calculate one or more indicators of the event group; determining whether there are indicators of the event group that satisfy predetermined rules; in response to the existence of indicators of the event group that satisfy the predetermined rules, determining whether the system performance exceeds a first threshold; and in response to the system performance exceeding the first threshold, destroying the executing request events in the event group where there are indicators that satisfy the predetermined rules.
[0011] According to one embodiment, in the above method, the historical data A of all the requested events that have been responded to in the event group includes: the sum of the number of all the requested events that have been responded to in the event group in the past T time period A.num, and the sum of the total time consumed by all the requested events that have been responded to in the event group in the past T time period A.csm. In the above method, the historical data A of all the requested events that have been responded to in the event group is divided into m sub-time periods in chronological order, and the time period length of each sub-time period is The data of each sub-time period is recorded as A i , i = 1, 2, ..., m; store data A1, A2, ..., A in stack form m , where A1, A2, …, A m is the data of each sub-time period from the closest to the current time to the earliest historical time in chronological order; where A i Includes: the number of all requested events that have been responded to in the event group in the i-th sub-time period A i .num, and the total time consumed by all the request events that have been responded to in the event group in the i-th sub-time period A i .csm; the historical data A of all responded request events of the event group is obtained according to the following formula: as well as The length of the current time period involved in the current data A0 of all the responded request events of the event group is also The current data A0 includes: the number A0.num of all the request events that have been responded to in the event group within the current time period, and the total time consumed A0.csm of all the request events that have been responded to in the event group within the current time period; wherein the current data A0 of the request events that have not been responded to in the event group un Includes: the number of request events A that have not been responded to in the event group at the current time un .num, and the total time A of the request events of the event group that have not been responded to at the current time un .csm.
[0012] According to one embodiment, in the above method, calculating one or more indicators of the event group includes: for the event group, executing To obtain the average time taken by the request event of this event group; or for this event group, execute A.num+A0.num+A un .num to obtain the total number of request events for the event group; or for the event group, obtain the concurrent processing number of request events for the event group in the current time period.
[0013] According to one embodiment, in the above method, determining whether there are indicators in the event group that meet predetermined rules includes: determining whether the average time consumed by the request events of the event group exceeds the average time consumed by the request events of all event groups; or determining whether the total number of request events of the event group accounts for more than a predetermined proportion of the total number of request events of all event groups; or determining whether the concurrent processing number of request events of the event group exceeds a second threshold.
[0014] According to one embodiment, the above method also includes, when the first request event is not intercepted: recording request information of the first request event, wherein the request information includes the request time; after the first request event has been responded to, recording response information of the first request event, wherein the response information includes the response time, and the time consumed by the first request event is equal to the difference between the response time and the request time; adding the data of the first request event to the current data of the event group of the corresponding type.
[0015] According to one embodiment, the method further includes, for each event group, using the current data of all the responded request events of the event group to update the historical data, wherein using the current data to update the historical data includes: for the data A1, A2, ..., A stored in the form of a stack m , delete the data A included in the earliest sub-time period m , insert the data A′0 of the request event that has not been intercepted in the current data to update the stack; and execute A.num-Am .num+A′0.num, and A.csm-A m .csm+A′0.csm are used as historical data for calculation operations in the next time period, wherein A′0.num and A′0.csm are the number of unintercepted request events and the total time consumed in the current data of all responded request events of the event group.
[0016] According to another aspect of the present disclosure, a system for database load control is provided, comprising: at least one processor, and a memory coupled to the at least one processor, wherein executable instructions are stored in the memory, and the instructions execute the method of the present disclosure when executed by the at least one processor.
[0017] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, on which executable instructions are stored. When the instructions are executed by a processor, the processor can execute the method of the present disclosure.
[0018] According to another aspect of the present disclosure, a computer program product for database load control is provided, including a computer program / instruction, wherein the computer program / instruction implements the operation of the method of the present disclosure when executed by a processor.
[0019] According to one or more embodiments of the present disclosure, by classifying the monitored request events and using the historical data and current data of each type of request event to calculate indicators; when the system performance is poor, some request events are intercepted and destroyed according to key indicators, the load of the database can be automatically controlled. According to one or more embodiments of the present disclosure, efficient and real-time (nanosecond level) indicator calculation and dynamic update of historical data can be achieved, so that the control results can be reflected in the indicator calculation results of the next stage and the load control mechanism of the next stage in a timely manner, forming a closed loop of the database load control autonomous mechanism, and can perform real-time adaptive adjustment of the load control mechanism according to the current database load situation, so that the database always maintains a high data processing capacity.
[0020] Other features and advantages of the present disclosure will become apparent from the following description with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure without limitation. In the various figures, like reference numerals are used to represent like items.
[0022] Figure 1 The prior art for database load control is shown.
[0023] Figure 2 FIG. 4 is a diagram showing a system environment for database load control according to an embodiment of the present disclosure.
[0024] Figure 3 is a flow chart showing a method for database load control according to an embodiment of the present disclosure.
[0025] Figure 4 is a flow chart showing a method for database load control according to another embodiment of the present disclosure.
[0026] Figure 5 The flowchart shows a method for determining whether an event group has an indicator that satisfies a predetermined rule according to an embodiment of the present disclosure.
[0027] Figure 6 FIG. 2 is a diagram showing a data structure for an event group according to an embodiment of the present disclosure.
[0028] Figure 7 FIG. 1 is a schematic diagram showing a general hardware environment in which a system according to an embodiment of the present disclosure may be implemented. DETAILED DESCRIPTION
[0029] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that unless otherwise specifically stated, the relative arrangement of the parts and steps, the numerical expressions and the numerical values set forth in these embodiments do not limit the scope of the present disclosure. The following description of at least one exemplary embodiment is actually merely illustrative and is by no means intended to limit the present disclosure and its application or use. In all examples shown and discussed herein, any specific value should be interpreted as being merely exemplary and not as a limitation. Therefore, other examples of the exemplary embodiments may have different values. The techniques, methods and devices known to those of ordinary skill in the relevant art may not be discussed in detail, but where appropriate, the techniques, methods and devices should be considered as part of the specification.
[0030] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0031] Figure 22 is a system environment 200 for database load control according to an embodiment of the present disclosure. In the system environment 200, a database proxy layer 205 receives a request event 202 from a user 201 (e.g., a client, an application, etc.), and forwards the request event to underlying data storage shards 208a, 208b, 208c (hereinafter collectively referred to as data storage shards 208 for simplicity). The database proxy layer may be, for example, a UDAL written in Java, and the request event 202 may be, for example, a data processing request expressed in a SQL statement.
[0032] According to one embodiment, whenever a user 201 sends a request event 202 to a database proxy layer 205, a database load control module 209 obtains the request event 202, and through the database load control mechanism of the present invention, intercepts 206 the request event when the request event exceeds the system performance limit; when the request event is not intercepted, the request information 203 of the request event 202 is recorded, and after the data storage shard 208 completes processing of the request, when the database proxy layer 205 is about to return a response 211 to the user 201, the response information 204 of the request event is recorded, so as to facilitate real-time updating of data used for the database load control mechanism.
[0033] According to another embodiment of the present disclosure, the database load control module 209 periodically calls the data of each request event (for example, time-consuming data), and analyzes it through the database load control mechanism of the present disclosure to destroy 207 one or more executing request events that exceed the system performance limit, so that the database always maintains a high data processing capability.
[0034] The following will be combined Figure 3-Figure 6 The database load control method disclosed in the present invention is exemplified.
[0035] Figure 3 3 is a flow chart showing a method 300 for database load control according to an embodiment of the present disclosure. The method 300 can be triggered to execute whenever a user sends a request event to the database proxy layer to control the database load. The method 300 can, for example, be a process for a data processing request newly submitted to UDAL that has not yet been executed by the database.
[0036] like Figure 3 As shown, the method 300 includes an operation M301, in which a first request event is obtained. This operation can be performed when a user sends a request event 202 to the database proxy layer 205, for example Figure 2 The database load control module 209 is used to obtain the data.
[0037] The method 300 further includes, in operation M302 , classifying the first request event into an event group of a corresponding type according to an execution plan represented by a statement included in the first request event.
[0038] Taking SQL statements as an example, when the database load control module 209 receives the request event 202, the SQL is extracted, and after lexical analysis, regularization, and parameterization, it is recorded as the identifier of the request event, so that the request event is classified into the event group of the corresponding type, that is, the request events in each event group are regarded as request events of the same type. If there is no event group of the corresponding type, create an event group of the corresponding type; if there is an event group of the corresponding type, directly obtain it. The same type of event group can be regarded as a collection of request events with roughly the same performance consumption indicators. In some examples, request events can be classified according to the amount of data involved in the SQL statement (such as the size of the table), or the operation represented by its grammatical structure. For example, select x, y, z from table_a full join table_b and selectx, y, z from table_c full join table_d belong to different types of event groups; and select 1from test_table where x=3 and select*from test_table where x=9 belong to the same type as select*from test_table where x=?. This is merely an example, and other classification methods that can classify request events with substantially the same performance consumption indicators into the same type of event group also fall within the scope of the present disclosure.
[0039] Continuing to refer to method 300, in operation M303, the historical data and current data of all the request events of the event group that have been responded to and the current data of the request events of the event group that have not yet been responded to are used to calculate one or more indicators of the event group. For example, if a first request event classified into the first event group is received, the historical data and current data of all the request events classified into the first event group can be used for the first event group to calculate one or more indicators such as the average time consumed by the request events of the first event group, the total number of request events, or the number of concurrent processing of request events. This operation can obtain the indicator status of the event group of the corresponding type at the moment the first request event arrives.
[0040] Continuing to refer to method 300, in operation M304, determine whether there is an indicator in the event group that satisfies the predetermined rules. If so, continue with operation M305; if not, continue with operation M307. Among them, the indicator satisfying the predetermined rules indicates that the request events in the event group have a certain impact on the overall performance of the system. Taking the first request event received being classified into the first event group as an example, if any one of the average time consumption, the total number of requests or the number of concurrent processing in the first event group satisfies the predetermined rules regarding the indicator, the first event group is marked to indicate that there is an indicator in the first event group that satisfies the predetermined rules.
[0041] The following will refer to Figure 5-Figure 6 Operations M303 - M304 are further described for illustration.
[0042] Continuing to refer to method 300, in operation M305, it is determined in real time whether the system performance exceeds the first threshold; if yes, then operation M306 is continued; if no, then operation M307 is continued. Among them, the system performance exceeding the first threshold indicates that the system performance is greatly affected and needs to be adjusted. For example, in the example of UDAL, it can be determined whether the thread usage rate of UDAL exceeds 80%; if it exceeds 80%, it is considered that the system load is too high and needs to be adjusted.
[0043] Continuing to refer to method 300, in operation M306, the first request event is intercepted. The intercepted request event will no longer enter the database for processing.
[0044] If the interception of the request event in operation M306 is successfully executed, the indicators of the corresponding event group will be reflected accordingly, forming an adaptive and dynamically adjusted database load control mechanism. For example, if the system performance returns to normal after operation M306, then the direct manifestation is that the number of request events that consume excessive resources has decreased. When analyzing abnormal request events later, the interception of such request events will be stopped; if the system performance has not returned to normal after operation M306, then such request events will continue to be intercepted until the system performance returns to normal.
[0045] The method 300 further includes an operation M307 of recording request information of the first request event when the first request event is not intercepted. In some embodiments, the request information includes at least the request time.
[0046] The first request event is then forwarded to the data storage shard 208 for processing. After the request event is processed, the database proxy layer returns a response to the user.
[0047] Method 300 further includes operation M308, recording response information of the first request event after the first request event has been responded to. In some embodiments, the response information at least includes a response time, and the time taken for the first request event is equal to the difference between the response time and the request time.
[0048] Relevant information such as request information and response information can be obtained by means of tracking points or network traffic detection, so as to collect and update the information of request events in real time. For example, when UDAL is used as a database proxy layer service, relevant information is sent at the code position where UDAL receives the request event 202 (such as an SQL statement) and the code position where the response is to be issued, and then the database load control module 209 receives the relevant information. For another example, the traffic data of the network card at the client / server can be monitored, and the network traffic can be sent to another server to obtain relevant information. The real-time performance of this method of obtaining information is slightly inferior to that of the tracking point method.
[0049] The time consumption and other data of the first request event can be obtained through the request information, response information, etc. of the first request event, and the data of the first request event can be added to the current data of the corresponding type of event group in the current time period. Subsequently, the current data containing the newly added request event data can be used to update the historical data. The update can be periodic (for example, every time the current time period ends), and the operation can be completed almost instantly, so that the data update is nearly real-time. Figure 6 Describe in detail.
[0050] The method can then be repeated to obtain the next request event (eg, the second request event). For the next request event, similar to operations M301 - M308 , database load control can be performed using updated historical data and current data for the next time period.
[0051] Figure 4 4 is a flow chart showing a method 400 for database load control according to another embodiment of the present disclosure. The method 400 may be executed periodically, for example, the method may be called every second to control the database load situation. The method 400 may be a process for an event group involved in an event being executed at the data storage shard 208 that has not been previously intercepted and has been submitted to the database.
[0052] like Figure 4As shown, method 400 includes operation M401, in which, for each event group, the historical data and current data of all the request events that have been responded to the event group and the current data of the request events that have not been responded to the event group are periodically used to calculate one or more indicators of the event group. For example, for each event group, the historical data and current data of all the request events classified into the event group can be used to calculate one or more indicators such as the average time consumption of the request events of the event group, the total number of request events, or the number of concurrent processing of request events. For each event group, one or more indicators of the event group can be obtained through similar operations.
[0053] Continuing to refer to method 400, in operation M402, determine whether there is an indicator in the event group that satisfies the predetermined rules. If so, continue with operation M403; if each event group does not exist, return and execute the method again in the next cycle. Among them, the indicator satisfies the predetermined rule to indicate that the request event in the event group has a certain impact on the overall performance of the system. Taking the first event group as an example, if any one of the average time consumption, the total number of requests or the number of concurrent processing in the first event group satisfies the predetermined rules regarding the indicator, the first event group is marked to indicate that there is an indicator in the first event group that satisfies the predetermined rules. By performing similar operations on each event group, each event group can be marked to determine whether there is an indicator that satisfies the predetermined rules.
[0054] The following will refer to Figure 5-Figure 6 Operations M401 - M402 are further exemplified.
[0055] Continuing to refer to method 400, in operation M403, it is determined in real time whether the system performance exceeds the first threshold; if yes, then continue to operation M404; if no, then return and execute the method again in the next cycle. Among them, the system performance exceeding the first threshold indicates that the system performance is greatly affected and needs to be adjusted. For example, in the example of UDAL, it can be determined whether the thread usage rate of UDAL exceeds 80%; if it exceeds 80%, it is considered that the system load is too high and needs to be adjusted.
[0056] Continuing to refer to method 400, in operation M404, the request events being executed in the event group whose existence index satisfies the predetermined rule are destroyed. In some embodiments, the operation includes destroying the request events in proportion.
[0057] For example, assuming that the first and second event groups have been marked as having indicators that meet predetermined rules, then for the request events that are being executed (submitted) in the first and second event groups, the request events in the first and second event groups are destroyed according to the average time consumption ratio of the first and second event groups, and the maximum number of concurrent processing allowed by the system for the first and second event groups remains.
[0058] Subsequently, for each event group, the uninterrupted current data of the event group can be used to update the historical data, and this operation can be completed almost instantly, so that the data update is nearly real-time. Then the system proceeds to the next cycle, and for the request events in the next cycle, the updated historical data and the current data of the next time period can be used to control the database load similarly to operations M401-M404.
[0059] The system intercepts and destroys some request events whose indicators exceed the preset rules in proportion to the average time consumption, effectively and in real time solving the problems caused by high-time-consuming request events and preventing the database from being under high load for a long time. The system intercepts newly added request events whose time consumption indicators are above the preset threshold, so that the proportion of such request events remains within the warning line, and can give priority to ensuring the availability of request events that occupy fewer resources, solving the problem of high-frequency request events crowding out other requests. The system can effectively solve the problems that may exist in the database proxy layer.
[0060] Moreover, the system can calculate indicators, analyze performance, adjust request events, and update request event data in real time. Therefore, it can avoid excessive restrictions caused by excessive adjustments in a short period of time, and avoid making some normal requests that may have instantaneous high concurrency unable to access stably; it can also effectively avoid insufficient adjustments in a short period of time that cause the system to remain in a high load state in the short term and squeeze out other requests.
[0061] The following will be combined Figure 5-Figure 6 An example is given for efficiently calculating the indicators of event groups in real time and making judgments on them.
[0062] Figure 5 is a flowchart showing a method 500 for determining whether an event group has an indicator that satisfies a predetermined rule according to an embodiment of the present disclosure.
[0063] like Figure 5 As shown, in operation M501a, the average time consumed by request events of the event group is calculated using the historical data and current data of all request events that have been responded to the event group and the current data of request events that have not been responded to the event group. In operation M501b, the total number of request events of the event group is calculated using the historical data and current data of all request events that have been responded to the event group and the current data of request events that have not been responded to the event group. In operation M501c, the number of concurrent processing of request events of the event group in the current time period is obtained.
[0064] Combination Figure 6 The above operation is described exemplarily by referring to the data structure for event group. Figure 6Taking the illustrated event group as an example, after lexical analysis, regularization, and parameterization, the request event belonging to the statement select*from test_table where x=? is classified into the event group, and the historical data A of all the requested events that have been responded to in the event group includes: the sum of the number of all the requested events that have been responded to in the event group in the past T time period A.num, and the sum of the total time consumed by all the requested events that have been responded to in the event group in the past T time period A.csm. In some other embodiments, the historical data also includes the concurrent processing number of the request events of the event group in the past T time period.
[0065] In the data structure of the example disclosed in the present invention, the historical data A of all the responded request events of each event group are divided into m sub-time periods in chronological order, and the time period length of each sub-time period is The data of each sub-time period is recorded as A i , i = 1, 2, ..., m; and store data A1, A2, ..., A in a stack form m , where A1, A2, …, A m is the data of each sub-time period from the closest to the current time to the earliest historical time in chronological order; where A i Includes: the number of all request events that have been responded to in the event group in the i-th sub-time period A i .num, and the total time consumed by all the request events that have been responded to in the event group in the i-th sub-time period A i In some other embodiments, the data of each sub-time period also includes the number of concurrently processed request events in the sub-time period.
[0066] The historical data A of all responded request events of this event group is obtained according to the following formula: as well as
[0067] The length of the current time period involved in the current data A0 of all the responded request events of the event group is also The current data A0 includes: the number of all the request events that have been responded to in the event group in the current time period A0.num, and the total time consumed by all the request events that have been responded to in the event group in the current time period A0.csm. In some other embodiments, the current data also includes the number of concurrent processing of the request event in the current time period.
[0068] Among them, the current data A of the request event of this event group that has not been responded to un Includes: the number of request events A that have not been responded to in the event group at the current time un.num, and the total time A of the request events of the event group that have not been responded to at the current time un .csm.
[0069] In some embodiments, the request information includes the request time, and the response information includes the response time. The time consumption of each request event can be defined as follows: when the database proxy layer responds to the request event, the time consumption of the request event is equal to the difference between the response time and the request time; when the database proxy layer has not yet responded to the request event, the time consumption of the request event is equal to the difference between the current time and the request time. If the request event is executed with a destruction command, the request event will also generate a corresponding response after the database processing is completed, and thus also has response information or response time.
[0070] Return to reference Figure 5 ,use Figure 6 The data structure shown in FIG. 5 is calculated in operation M501a by To obtain the average time taken by requesting events of the event group. In operation M501b, by executing A.num+A0.num+A un .num to get the total number of requested events for this event group.
[0071] In the embodiment of the present disclosure, the past time period T may preferably be 59 seconds (59s), m is preferably 59, then the time length of each sub-time period is 1s, and the length of the current time period involved in the current data A0 is also 1s. That is, in this preferred example, for each event group, the data of the requested events that have been responded to and the data that have not been responded to within one minute of the event group (i.e., the past 59s and the current 1s) are used to calculate the various indicators of the request events of the event group.
[0072] By taking each second as a sub-time period for statistical calculation, it is possible to clear out outdated historical data from the statistical sequence every time time advances by one second without updating the global data, and at the same time add the current data of the new second to the historical data, forming a relatively stable statistical result of recent indicators within one second.
[0073] In addition, in each sub-time period of one second, only the total time consumption and the number of request events of each event group are counted, instead of directly counting the average time consumption. The advantage of this is that when the average time consumption needs to be calculated, the total time consumption and the number can be directly divided to obtain the average time consumption index of the request events of the event group in this sub-time period. On the other hand, when adding data of new request events, the time consumption of the request events and the number of request events can be directly superimposed on the existing data in an almost lossless manner through a non-blocking thread synchronous calculation method (CompareAndSet), instead of being as complicated as updating the average time consumption in a thread-safe manner. For example, when adding data of new request events, the time consumption of the new request events is superimposed on the total time consumption A0.csm of the current data through CompareAndSet, and the number of request events A0.num of the current data is added by 1, so that the data recording of the new request events can be completed with almost no time loss through data calculations in very limited steps.
[0074] CompareAndSet is an efficient thread data synchronization method commonly used in multi-threaded programming. In traditional multi-threaded data synchronization, the target is locked first and then data synchronization is performed. Therefore, only one thread can perform data synchronization during the synchronization period, which is inefficient. The CompareAndSet method first records the value before synchronization, and then directly synchronizes the data. When updating the synchronization result, the value is compared to see if it has changed. If it has not changed, it is updated. Otherwise, the synchronization process is repeated. This method reduces the time required to lock the target to almost 0, which is more efficient.
[0075] By using the above data structure to perform request event classification and indicator calculation operations, every time you need to use indicators to analyze data, you only need to perform a comprehensive calculation of historical data and current data that changes in real time, and you can obtain key indicators such as total time consumption, average time consumption, and total number of request events with almost no performance loss. It is not difficult to see that through this data structure, all key operations can be decomposed into efficient operations with almost no time loss, which is also one of the keys to efficiently and real-time analysis of each event group.
[0076] Return to reference Figure 5 Continuing with method 500, in operation M502a, it is determined whether the average time taken for the request event of the event group exceeds the average time taken for the request events of all event groups. The average time taken for the request events of all event groups can be determined by executing To obtain, where B represents the corresponding data of another event group. Taking the preferred example as an example, the average time consumed for request events of all event groups can be obtained by dividing the total time consumed for the responded / unresponded request events of all event groups in the past minute by the total number of responded / unresponded request events of all event groups. In other embodiments, for each event group, it can be determined where the average time consumed for the request events of the event group is in the average time consumed for all event groups, for example, whether it exceeds the position of the median.
[0077] In operation M502b, it is determined whether the total number of request events of the event group exceeds a predetermined ratio to the total number of request events of all event groups. The total number of request events of all event groups can be calculated by executing ∑ I∈{A,B,..} (I.num+I0.num+I un In some embodiments, the predetermined ratio may be 80%, indicating that the request event of this type accounts for more than 80%, which is considered to affect system performance and may be a large-scale attack or other overly frequent requests.
[0078] In operation M502c, it is determined whether the number of concurrent processing of the request event of the event group exceeds the second threshold. The system has a corresponding concurrent processing limit for each event group based on indicators such as average time consumption. SQL request events limit the number of concurrent processing of any event group to less than 1000 by category, and gradually control the number of concurrent processing to less than 1 according to the increase in average time consumption. For example, a request event with an average time consumption of more than 5 seconds can only process 1 SQL statement concurrently at most, which is regarded as a SQL type that consumes a lot of resources.
[0079] If any one of operations M502a-c is determined to be yes for a certain event group, then in operation M503, the event group is marked as having an existence indicator that satisfies a predetermined rule.
[0080] Reference below Figure 6 The operation of updating the historical data with the current data in methods 300 and 400 is described. Methods 300 and 400 also include, for each event group, periodically updating the historical data of all the responded request events with the current data of all the responded request events of the event group. Figure 6 , wherein using current data to update historical data includes: for data A1, A2, ..., A stored in a stack m , delete the data A included in the earliest sub-time period m , insert the data A′0 of the request event that has not been intercepted in the current data to update the stack; and execute A.num-A m .num+A′0.num, and A.csm-A m.csm+A′0.csm are used as the historical data for the calculation operation of the next time period, where A′0.num and A′0.csm are the number of uninterrupted request events and the total time consumption of all the responded request events of the event group. The total time consumption of the request events of all event groups and the total number of the request events of all event groups are updated in the same way.
[0081] Taking m = 59 and the length of each sub-time period as 1s, a new current data at the current time point is created to replace the original current data; the original current data A′0 is pushed into the historical data and arranged before the original A1 as the new A1; the oldest A′0 is popped out. 59 Discard; subtract the old A from the total time consumed A.csm and quantity A.num in the historical data 59 The total time of A 59 .csm and quantity A 59 .num, and add the total time consumption A′0.csm and quantity A′0.num of the new A1 (i.e. the original A′0) to form a new stable indicator statistical result within 1 second; at the same time, the new A1, B1... and the old A 59 ,B 59 …are added to the total duration and total number of requests for all event groups in the same way.
[0082] According to the embodiments of the present disclosure, by classifying the monitored request events and using the historical data and current data of each type of request event to calculate the index; when the system performance is poor, some request events are intercepted and destroyed according to the key index, and the load of the database can be automatically controlled. According to the embodiments of the present disclosure, efficient and real-time (nanosecond level) index calculation and dynamic update of historical data can be achieved, so that the control results can be reflected in the index calculation results of the next stage and the load control mechanism of the next stage in a timely manner, forming a closed loop of the database load control autonomous mechanism, and can perform real-time adaptive adjustment of the load control mechanism according to the current database load, so that the database always maintains a high data processing capacity.
[0083] Figure 7 is a schematic diagram showing a general hardware environment in which a system 600 according to an embodiment of the present disclosure may be implemented.
[0084] In some embodiments, system 600 may include at least one processor 601 and memory 602 .
[0085] The processor 601 provides various functions of the system 600 for database load control. In some embodiments, the processor 601 is configured to perform the method of the present disclosure. The processor 601 can be any processor such as a microprocessor, a digital signal processor, a microcontroller, a multi-core processor, a dedicated processor, an interface for communication, etc. The processor 601 can run various program instructions stored in the memory 602 to perform corresponding operations.
[0086] In some embodiments, executable instructions are stored in the memory 602, and these executable instructions implement the functions of the present disclosure when executed by the processor 601. The memory 602 can be any of various types of memory or storage devices. For example, the memory 602 may include an installation medium (such as a CD-ROM, a floppy disk, or a tape device), a random access memory (such as a DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.), a non-volatile memory (such as a flash memory, a magnetic medium, or an optical storage device), a register or other similar types of memory elements, etc. The memory 602 may also include other types of memories or combinations thereof. In an embodiment of the present disclosure, the memory 602 may store program instructions (such as instructions for performing corresponding operations) so as to implement the method based on the embodiment of the present disclosure in a software, hardware, or a combination of software and hardware.
[0087] All features disclosed in this specification, or steps in all methods or processes disclosed, except mutually exclusive features and / or steps, can be combined in any manner.
[0088] The present disclosure may be implemented as a system, method, and / or computer program product. The computer program product may include (one or more) computer-readable storage media having computer-readable program instructions thereon for causing a processor to execute aspects of the present disclosure.
[0089] Aspects of the present disclosure may be in the form of a complete hardware embodiment, a complete software embodiment (including firmware, resident software, microcode, etc.), or a combination of software and hardware embodiments, all of which may be generally referred to herein as a "circuit," "module," or "system." Any combination of one or more computer-readable storage media may be used. A computer-readable storage medium may be a computer-readable signal medium or a computer-readable storage medium.
[0090] A computer-readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media would include the following: an electrical connection with one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer-readable storage medium may be any tangible medium that contains or stores a program used by or in conjunction with an instruction execution system, apparatus, or device.
[0091] The present disclosure includes, in various embodiments, configurations, and aspects, components, methods, processes, systems, and / or devices substantially as depicted and described herein, including various embodiments, sub-combinations, and subsets thereof. Those skilled in the art will understand how to make and use the systems and methods disclosed herein after understanding the present disclosure. In various embodiments, configurations, and aspects, the present disclosure includes providing devices and processes that do not have items not depicted and / or described herein, or in various embodiments, configurations, or aspects herein, including the absence of items that may have been used in previous devices or processes, such as for improving performance, ease of implementation, and / or reducing implementation costs.
[0092] Any feature disclosed in this specification (including any additional claims and abstract), unless otherwise stated, may be replaced by other equivalent or alternative features having similar purposes. That is, unless otherwise stated, each feature is only an example of a series of equivalent or similar features.
[0093] In addition, although the description of the present disclosure has included a description of one or more embodiments, configurations, or aspects, certain variations and modifications, other variations, combinations, and modifications are also within the scope of the present disclosure, for example, as may be within the skill and knowledge of those skilled in the art after understanding the present disclosure. The present disclosure is intended to obtain rights, which should include alternative embodiments, configurations, or aspects within the permitted scope, including alternative, interchangeable, and / or equivalent structures, functions, scopes, or steps to those claimed, regardless of whether these alternative, interchangeable, and / or equivalent structures, functions, scopes, or steps are specifically described herein. This document is not intended to publicly contribute any patentable technical solutions.
Claims
1. A method for database load control, include: Get the first request event; Classifying the first request event into an event group of a corresponding type according to an execution plan represented by a statement included in the first request event; Calculate one or more indicators of the event group using historical data and current data of all responded request events of the event group and current data of unresponded request events of the event group; Determine whether there are indicators in the event group that meet the predetermined rules; In response to the event group having an indicator satisfying a predetermined rule, determining whether system performance exceeds a first threshold; as well as In response to the system performance exceeding a first threshold, the first request event is intercepted.
2. The method according to claim 1, further comprising: include: For each event group, periodically calculate one or more indicators of the event group using historical data and current data of all requested events of the event group that have been responded to and current data of requested events of the event group that have not been responded to; Determine whether there are indicators in the event group that meet the predetermined rules; In response to the event group having an indicator satisfying a predetermined rule, determining whether system performance exceeds a first threshold; as well as In response to the system performance exceeding a first threshold, the request event being executed in the event group whose existence index satisfies a predetermined rule is destroyed.
3. The method according to claim 1, in, The historical data A of all the responded request events of the event group includes: the sum A.num of the number of all the responded request events of the event group in the past T time period, and the sum A.csm of the total time consumed by all the responded request events of the event group in the past T time period; The historical data A of all the responded request events of the event group are divided into m sub-time periods in chronological order, and the time period length of each sub-time period is The data of each sub-time period is recorded as A i , i = 1, 2, ..., m; Store data A in stack form 1 , A 2 , ..., A m , where A 1 , A 2 , ..., A m The data for each sub-time period in chronological order from the closest to the current time to the earliest historical time; Among them, A i Includes: the number of all requested events that have been responded to in the event group in the i-th sub-time period A i .num, and the total time consumed by all the request events that have been responded to in the event group in the i-th sub-time period A i .csm; The historical data A of all responded request events of the event group is obtained according to the following formula: as well as Among them, the current data A of all the requested events that have been responded to in the event group 0 The length of the current time period involved is also Current Data A 0 Includes: the number of all requested events that have been responded to in the current time period of the event group A 0 .num, and the total time consumed by all the request events that have been responded to in the event group within the current time period A 0 .csm; Among them, the current data A of the request event of the event group that has not been responded to un Includes: the number of request events A that have not been responded to in the event group at the current time un .num, and the total time A of the request events of the event group that have not been responded to at the current time un .csm.
4. The method according to claim 3, wherein one or more indicators of the event group are calculated include: For this event group, execute To obtain the average time taken for request events of this event group; or For this event group, execute A.num+A 0 .num+A un .num to get the total number of requested events for this event group; or For the event group, obtain the number of concurrently processed request events of the event group in the current time period.
5. The method according to claim 4, wherein it is determined whether the event group has an indicator that satisfies a predetermined rule include: Determine whether the average time taken for request events of the event group exceeds the average time taken for request events of all event groups; or Determine whether the total number of request events of the event group exceeds a predetermined ratio to the total number of request events of all event groups; or It is determined whether the number of concurrently processed request events of the event group exceeds a second threshold.
6. The method according to claim 3 further comprises, in the case where the first request event is not intercepted: Recording request information of the first request event, wherein the request information includes a request time; After the first request event has been responded to, recording the response information of the first request event, wherein the response information includes the response time, and the time consumption of the first request event is equal to the difference between the response time and the request time; The data of the first request event is added to the current data of the event group of the corresponding type.
7. The method according to claim 3 further comprises, for each event group, using the current data of all the requested events that have been responded to in the event group to update the historical data, wherein the historical data is updated using the current data. include: For data A stored in the form of a stack 1 , A 2 , ..., A m , delete the data A included in the earliest sub-time period m , insert the data A′ of the request event that has not been intercepted in the current data 0 , to update the stack; as well as Execute A.num-A m .num+A′ 0 .num, and A.csm-A m .csm+A′ 0 .csm are used as historical data for the calculation operation of the next time period, where A′ 0 .num and A′ 0 .csm are the number of unintercepted request events and the total time consumed in the current data of all responded request events of the event group.
8. A system for database load control, the system include: at least one processor; and A memory coupled to the at least one processor, wherein executable instructions are stored in the memory, and when the instructions are executed by the at least one processor, the method according to any one of claims 1 to 7 is implemented.
9. A non-transitory computer-readable storage medium having executable instructions stored thereon, wherein when the instructions are executed by a processor, the method according to any one of claims 1 to 7 is performed.
10. A computer program product for database load control, comprising a computer program / instructions, It is characterized in that When the computer program / instructions are executed by a processor, the operations of the method according to any one of claims 1 to 7 are implemented.
