Query statement processing method and device, equipment and computer medium
By obtaining and processing the traffic information of database query statements, combined with preset limit information, it identifies and limits high-pressure traffic sources, solving the aPaaS database overload problem, flexibility and low efficiency, and improving the stability of the database.
Patent Information
- Application Number
- CN202410693023.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-05-30
AI Technical Summary
In the context of aPaaS multi-tenant integrated deployment, the database overload problem makes it difficult to flexibly respond to different traffic types and sources. The current flow limiting method is inefficient, resulting in poor database stability.
By obtaining the traffic information of the database query statement, including traffic type and source, combined with the preset traffic limit information, the query statement is refined to identify and limit high-pressure traffic sources to avoid database overload.
It achieves fine-grained management and efficient prevention of database overload, improves the flexibility and efficiency of current limiting, and ensures the stable operation of the database under high load conditions.
Smart Images

Figure CN118656381A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a query statement processing method, device, equipment and computer medium. Background Art
[0002] In the context of multi-tenant converged deployment of aPaaS (Application Platform as a Service), an increasing number of tenants and application packages will share a database (database). The DB often experiences overload accidents, which last for a long time and have poor stability.
[0003] In the related art, the problem of DB overload is generally prevented and solved by limiting the QPS (Queries-per-second) of the tenant application package through the gateway layer. This method cannot flexibly respond to traffic data of different traffic types and different traffic sources. The method of preventing and solving the problem of DB overload is rough and the effect is poor. The efficiency of preventing and solving the problem of DB overload is low. Summary of the invention
[0004] The embodiment of the present disclosure provides an implementation scheme different from the related art to solve the technical problem of low efficiency in preventing and solving the DB overload problem in the related art.
[0005] In a first aspect, the present disclosure provides a query statement processing method, comprising:
[0006] Obtaining a first database query statement;
[0007] Determine first traffic information of the first database query statement, the first traffic information includes a first traffic type and a first traffic source, the first traffic type is any one of the following multiple traffic types: traffic related to a web page, traffic related to an open application program interface, traffic related to a cloud function service, traffic related to a business process corresponding to an automatic trigger mechanism, and traffic related to a calculated field;
[0008] Get preset traffic limit information;
[0009] The first database query statement is processed based on the first traffic information and the traffic limit information.
[0010] In a second aspect, the present disclosure provides a query statement processing device, comprising:
[0011] An acquisition unit, used to acquire a first database query statement;
[0012] a determining unit, configured to determine first traffic information of the first database query statement, the first traffic information comprising a first traffic type and a first traffic source, the first traffic type being any one of the following multiple traffic types: traffic associated with a web page, traffic associated with an open application program interface, traffic associated with a cloud function service, traffic associated with a business process corresponding to an automatic trigger mechanism, and traffic associated with a calculated field;
[0013] The acquisition unit is further used to acquire preset flow restriction information;
[0014] A processing unit is used to process the first database query statement based on the first traffic information and the traffic limit information.
[0015] In a third aspect, the present disclosure provides an electronic device, including:
[0016] Processor; and
[0017] A memory, configured to store executable instructions of the processor;
[0018] The processor is configured to perform the above methods by executing the executable instructions.
[0019] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the aforementioned methods when executed by a processor.
[0020] The present disclosure provides a method for obtaining a first database query statement; determining first traffic information of the first database query statement, wherein the first traffic information includes a first traffic type and a first traffic source, wherein the first traffic type is any one of the following multiple traffic types: traffic related to web pages, traffic related to open application program interfaces, traffic related to cloud function services, traffic related to business processes corresponding to automatic triggering mechanisms, and traffic related to calculation fields; obtaining preset traffic restriction information; and processing the first database query statement based on the first traffic information and the traffic restriction information. This method can effectively prevent database overload from the granularity of the traffic type and traffic source to which the database query statement belongs, and can handle the DB overload problem from a finer granularity when the DB is actually overloaded, with high flexibility, thereby improving the efficiency of preventing and resolving DB overload problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0022] Figure 1a A schematic diagram of a configuration of an aPaaS platform DB provided in an embodiment of the present disclosure;
[0023] Figure 1b A schematic diagram of a microservice call chain provided in one embodiment of the present disclosure;
[0024] Figure 2 A schematic diagram of the structure of a system provided by an embodiment of the present disclosure;
[0025] Figure 3a A flowchart of a query statement processing method provided by an embodiment of the present disclosure;
[0026] Figure 3b A scene diagram of a query statement processing method provided by an embodiment of the present disclosure;
[0027] Figure 4 A schematic diagram of the structure of a query statement processing device provided by an embodiment of the present disclosure;
[0028] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0029] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, but should not be understood as limiting the present disclosure.
[0030] The terms "first" and "second" and the like in the specification, claims, and drawings of the disclosed embodiments are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the disclosed embodiments described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0031] First, some terms in the embodiments of the present disclosure are explained below to facilitate understanding by those skilled in the art.
[0032] aPaaS, short for Application Platform as a Service, is a cloud computing service model that provides users with a complete platform for developing, running and managing software applications.
[0033] FaaS (Function as a Service) is a cloud computing service model that provides event-driven computing services. Users can write and upload function codes. When an event is triggered, the cloud service provider will automatically execute the function codes and return the results.
[0034] Metadata, also known as intermediary data or relay data, is data about data. It mainly describes the properties of data and is used to support functions such as indicating storage location, historical data, resource search, and file records.
[0035] MySQL is a relational database management system.
[0036] SQL (Structured Query Language) is a database language with multiple functions such as data manipulation and data definition. This language is interactive and can provide great convenience for users. Database management systems should make full use of SQL language to improve the work quality and efficiency of computer application systems.
[0037] The Null Value Rate of a table refers to the proportion of null values in a database table. Null values refer to the state where no data or values are stored in a field. The Null Value Rate can be used to evaluate the quality and integrity of data, because too many null values may mean that the data is missing or incomplete.
[0038] In the context of multi-tenant converged deployment of aPaaS (Application Platform as a Service), an increasing number of tenants and application packages will share a database (database). DB overload accidents often occur, and the duration is long, the stability is poor, and in related technologies, the speed of querying the cause of overload is slow and the query efficiency is low.
[0039] The inventors have found through research that in some cases, see Figure 1aAs shown in the figure, the hardware configurations of different aPaaS DBs are different, and the number of tenants and application packages on different DBs is different, so the flow limiting threshold cannot be quantified. aPaaS multi-tenant multi-application package integrated deployment, some application packages occupy less resources, and some application packages can be allowed to occupy resources exceeding the safety line to achieve the maximum benefit of the overall system.
[0040] Further, see Figure 1b As shown in the figure, in the microservice call chain, from the perspective of service C, it is easy to know that the upstream call (up_stream) is service B, but it is impossible to know the source of the traffic (origin_stream). The source of traffic is very important in aPaaS detection and overload protection or current limiting scenarios. It can specifically know which traffic and which source of traffic has caused great pressure on the DB.
[0041] The present application provides a solution, which is based on the background of aPaaS multi-tenant integrated deployment. When the DB is available, it serves as many application packages as possible, or allows the DB access volume of a few application packages to exceed the elastic limit. Appropriate measures can be taken in advance to avoid DB overload, and targeted flow control (discarding SQL requests) can be implemented to avoid overall service avalanche. High-priority requests are guaranteed without manual intervention, ensuring that the DB can work in a normal load state and can be processed quickly even in the case of overload.
[0042] In the solution of the present application, a traffic tracing protocol can be first formulated to mark the type of traffic source and transmit the entire link transparently, thereby achieving the purpose of accurately distinguishing the traffic source of the DB access data.
[0043] In this application, when it comes to measuring the pressure on the DB, the user's operation on the data is the read and write operation of the aPaaS platform object (Object) after arriving at the data server. The object is mapped to Mysql as a Table, and the object's field (Field) is mapped to Mysql as a Column of the Table. That is, the data operation of the traffic source will be translated into SQL after arriving at the data server. Quantifying the pressure caused by each SQL on the DB can compare the pressure caused by the traffic on the DB at the same order of magnitude, which is referred to as the SQL cost.
[0044] The following specific embodiments are used to describe in detail the technical solution of the present invention and how the technical solution of the present invention solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.
[0045] Figure 2 A schematic diagram of a system structure provided by an exemplary embodiment of the present disclosure, the structure comprising:
[0046] The solution of the present application relates to a system, which includes: an apaas platform and a user device, wherein the apaas platform includes: at least one business server, at least one data server, and at least one database; wherein:
[0047] The business server is used to: obtain an access request for accessing a database, where the access request may include a first database query statement; optionally, the access request may be sent by a user device, or may be generated based on an automatic trigger mechanism.
[0048] The data server is used to: obtain an access request from a business server and determine a first database query statement; determine first traffic information of the first database query statement, the first traffic information includes a first traffic type and a first traffic source, the first traffic type is any one of the following multiple traffic types: traffic related to web pages, traffic related to open application programming interfaces, traffic related to cloud function services, traffic related to business processes corresponding to automatic triggering mechanisms, and traffic related to calculation fields; obtain preset traffic limitation information; and process the first database query statement based on the first traffic information and the traffic limitation information.
[0049] The aforementioned database is used for access by the access request.
[0050] The execution principle and interaction process of each component unit in the embodiment of this system can be found in the description of the following method embodiments.
[0051] Figure 3a A flowchart of a query statement processing method provided by an exemplary embodiment of the present disclosure is provided. The method can be applied to a data server in an apaas platform. The method at least includes the following steps S201-S204:
[0052] S201, obtaining a first database query statement;
[0053] Specifically, the first database query statement is included in the database query request.
[0054] The first database query statement is a command used to retrieve information from a database. Database queries mainly include basic queries, conditional queries, deduplication queries, sorting queries, grouping queries, etc.
[0055] S202, determining first traffic information of the first database query statement, the first traffic information including a first traffic type and a first traffic source, the first traffic type being any one of the following multiple traffic types: traffic related to a web page, traffic related to an open application program interface, traffic related to a cloud function service, traffic related to a business process corresponding to an automatic trigger mechanism, and traffic related to a calculated field;
[0056] Specifically, the first traffic information of the first database query statement is: traffic information of the traffic to which the database query request to which the first database query statement belongs belongs.
[0057] Optionally, the first traffic information is also included in the database query request where the first database query statement is located.
[0058] Specifically, the aforementioned traffic related to web pages refers to the traffic generated by triggering web pages; the traffic related to open application program interfaces refers to the traffic generated by triggering Openapi; the traffic related to cloud function services refers to the traffic generated by Faas; and the traffic related to business processes corresponding to the automatic triggering mechanism refers to the traffic generated by Automation.
[0059] In other optional embodiments, the aforementioned multiple traffic types may also include other types, which are not limited in this application.
[0060] In some optional embodiments of the present application, the data server may first obtain an access request for a database, and parse the access request to obtain a first database query statement.
[0061] Optionally, the first traffic type of the first database query statement may be determined according to a traffic type identifier included in a corresponding access request.
[0062] Optionally, different first traffic sources may be distinguished by any one of the following information: an application identifier, a tenant identifier, and sending trigger information for indicating the database query request to which the first database query statement belongs.
[0063] Optionally, the aforementioned sending trigger information of the database query request may refer to operation information used to trigger the sending of the database query request.
[0064] Optionally, the aforementioned operation information may include a button logo, a web page logo, or the like.
[0065] S203, obtaining preset flow restriction information;
[0066] In some optional embodiments of the present application, regarding the determination of the flow restriction information, before obtaining the preset flow restriction information, the method further includes the following S01-S04:
[0067] S01, obtaining a first query cost of at least one second database query statement whose traffic type is the first traffic type obtained within a first time period, wherein the first time period is a time period with the current time as the end time and the time corresponding to the first time attribution unit of the current time as the start time;
[0068] Optionally, the first query cost of the at least one second database query statement is the total query cost of the query costs of the second database query statements in the at least one second database query statement.
[0069] Optionally, the aforementioned current moment is the moment of obtaining the aforementioned first query cost.
[0070] In some optional embodiments of the present application, regarding the manner of determining the first time period, the method further includes the following S41-S44:
[0071] S41, obtaining a first time measurement unit corresponding to the first traffic type;
[0072] Optionally, different first traffic types correspond to different first time measurement units.
[0073] Optionally, the first time measurement unit may refer to a value of a time length.
[0074] For example, when the first traffic type is traffic related to the cloud function service, the first time measurement unit corresponding to the first traffic type may be 2s.
[0075] For example, when the first traffic type is traffic related to an open application programming interface, the first time measurement unit corresponding to the first traffic type may be 3 seconds.
[0076] S42, obtaining a first timestamp of the current moment;
[0077] The first timestamp is data generated using digital signature technology. The object of the signature includes information such as the original file information, signature parameters, and signature time. The first timestamp system is used to generate and manage the first timestamp, and digitally sign the signature object to generate the first timestamp to prove that the original file existed before the signature time.
[0078] Optionally, in this solution, the timestamp refers to the total number of seconds from 00:00:00 Greenwich Mean Time on January 1, 1970 to the present.
[0079] S43, determining the first time attribution unit of the current moment according to the first timestamp and the first time measurement unit;
[0080] In some optional embodiments of the present application, in S43, determining the first time attribution unit of the current moment according to the first timestamp and the first time measurement unit may include: taking the quotient of the first timestamp and the first time measurement unit as the first time attribution unit of the current moment.
[0081] For example, when the first timestamp is 300 and the first time measurement unit is 3s, the first time attribution unit at the current moment is 100.
[0082] When the first timestamp is 301 and the first time measurement unit is 3s, the first time attribution unit at the current moment is 100.
[0083] When the first timestamp is 302 and the first time measurement unit is 3s, the first time attribution unit at the current moment is 100.
[0084] When the first timestamp is 303 and the first time measurement unit is 3s, the first time attribution unit at the current moment is 101.
[0085] In the present application, when it is detected that the first time period is 0, no processing is performed.
[0086] Optionally, the moment corresponding to the aforementioned first time attribution unit is the initial moment of the first time attribution unit.
[0087] S44: Determine the first time period according to the first timestamp and the first time attribution unit.
[0088] In some optional embodiments of the present application, in the aforementioned S44, determining the first time period according to the first timestamp and the first time attribution unit includes: taking the difference between the first timestamp and the first time attribution unit as the first time period.
[0089] S02, obtaining growth trend information of the first query cost within the first time period;
[0090] Specifically, the first query cost is a total query cost of at least one second database query statement.
[0091] Optionally, the quotient of the first query cost and the first time period may be used as growth trend information of the first query cost in the first time period.
[0092] S03. Obtaining a preset growth trend information threshold corresponding to the first traffic type;
[0093] In some optional embodiments of the present application, the preset growth trend information threshold corresponding to the first traffic type may be: within a first time measurement unit, the ratio of the query cost capacity value of the query statement whose traffic type is the first traffic type to the first time measurement unit.
[0094] S04. Determine the flow limit information according to the growth trend information and the preset growth trend information threshold.
[0095] In some optional embodiments of the present application, determining the traffic limitation information based on the growth trend information and the preset growth trend information threshold includes: in response to the growth trend information being greater than the preset growth trend information threshold, determining the traffic limitation information based on the first traffic type.
[0096] In some optional embodiments of the present application, determining the flow limit information based on the growth trend information and the preset growth trend information threshold also includes: in response to the growth trend information being not greater than the preset growth trend information threshold, not processing.
[0097] In some optional embodiments of the present application, determining the traffic restriction information based on the first traffic type includes the following S001-S002:
[0098] S001. Obtain priority indication information of the first traffic type;
[0099] S002. If the priority indication information indicates that the first traffic type is of low priority, then the restriction information of the first traffic type is used as the traffic restriction information; if the priority indication information indicates that the first traffic type is of high priority, then the second traffic source corresponding to the first traffic type is obtained; and the restriction information of the second traffic source is used as the traffic restriction information.
[0100] When the traffic restriction information includes restriction information of a first traffic type, the restriction information of the first traffic type is target restriction information matching the first traffic information.
[0101] When the traffic restriction information includes restriction information of the second traffic source, the restriction information of the second traffic source is target restriction information that matches the first traffic information.
[0102] In some optional embodiments of the present application, the method further includes the following S31-S32:
[0103] S31, obtaining at least one second query cost corresponding to at least one traffic source whose corresponding traffic type is the first traffic type within the first time period;
[0104] Specifically, each traffic source may correspond to a plurality of database query statements, and the sum of the query costs of the plurality of database query statements is the second query cost corresponding to the traffic source.
[0105] S32: Use the traffic source with the highest second query cost among the at least one traffic source as the second traffic source corresponding to the first traffic type.
[0106] S204: Process the first database query statement based on the first traffic information and the traffic limit information.
[0107] In some optional embodiments of the present application, in the aforementioned S204, processing the first database query statement based on the first flow information and the flow limit information includes:
[0108] Determine whether there is target restriction information in the traffic restriction information that matches the first traffic information; if so, limit the traffic of the first database query statement.
[0109] In some optional embodiments of the present application, the limiting the flow of the first database query statement includes: in response to the first database query statement being a data read statement, allowing the first database query statement to read data from a slave database, and the slave database is a slave database of the original database corresponding to the first database query statement.
[0110] In some optional embodiments of the present application, the limiting the flow of the first database query statement further includes: in response to the first database query statement being a data write statement, not processing it.
[0111] Optionally, when the traffic restriction information includes restriction information of the first traffic type or restriction information of the first traffic source, it is deemed that there is target restriction information matching the first traffic information in the traffic restriction information. When the traffic restriction information does not include restriction information of the first traffic type and does not include restriction information of the first traffic source, it is deemed that there is no target restriction information matching the first traffic information in the traffic restriction information.
[0112] In this application, each time the data server obtains a second database query statement, it will perform the following steps:
[0113] S1. Determine second traffic information of the second database query statement, where the second traffic information includes a second traffic type and a third traffic source;
[0114] S2. Calculate the query cost of the second database query statement;
[0115] S3. Obtain a second time measurement unit corresponding to the second traffic type;
[0116] S4. Obtain a second timestamp of the time when the second database query statement is obtained;
[0117] S5. Determine a second time attribution unit of the acquisition moment according to the second timestamp and the second time measurement unit;
[0118] S6. Store the second traffic type, the second time attribution unit, and the query cost of the second database query statement.
[0119] S7. Store the second traffic type, the second time attribution unit, the third traffic source, and the query cost of the second database query statement.
[0120] In some optional embodiments of the present application, in the aforementioned S6, the second traffic type, the second time attribution unit, and the query cost of the second database query statement are stored, including: splicing the second traffic type and the second time attribution unit to obtain a first splicing result, and storing the first splicing result and the query cost of the second database query statement as a first data pair.
[0121] In some optional embodiments of the present application, in the aforementioned S7, the second traffic type, the second time attribution unit, the third traffic source, and the query cost of the second database query statement are stored, including: splicing the second traffic type and the second time attribution unit to obtain a second splicing result, and storing the second splicing result, the third traffic source, and the query cost of the second database query statement as a second data pair.
[0122] Optionally, the aforementioned first data pair and second data pair may be specifically stored in a redis cache.
[0123] Optionally, the data server may determine the growth trend information of the first query cost within the first time period according to the cache content in redis.
[0124] In this application, for the database, all record IDs and -isDeleted fields can be queried in pages, and the number of record IDs and _isDeleted fields on each page can be counted respectively. Up to 2w record IDs can be counted to obtain the total number of object records and the number of undeleted records of the object in each field in the database. In addition, this application also includes determining the following database information corresponding to each field in the database: null value rate, number of different values, high-frequency word information, and histogram information corresponding to the database. The aforementioned database information can be used to determine the SQL cost corresponding to each query statement.
[0125] This solution can distinguish traffic initiation scenarios in detail by marking traffic types and traffic sources. It also has a fast response and can identify abnormal scenarios within 100ms. It can also accurately identify abnormal scenarios or traffic sources within the scenarios and issue flow limiting decisions within 100ms.
[0126] In order to more comprehensively describe the solution of this application, the following is combined with a scene diagram Figure 3b Further explanation of this plan:
[0127] In the present application, the first traffic information of the first database query statement includes a first traffic type and a first traffic source, wherein the first traffic type may be any traffic type of multiple traffic types, wherein the multiple traffic types may include: traffic related to web pages, traffic related to open application program interfaces, traffic related to cloud function services, traffic related to business processes corresponding to automatic trigger mechanisms, and traffic related to calculation fields;
[0128] Specifically, the aforementioned traffic related to web pages refers to the traffic generated by triggering web pages; the traffic related to open application program interfaces refers to the traffic generated by triggering Openapi; the traffic related to cloud function services refers to the traffic generated by Faas; and the traffic related to business processes corresponding to the automatic triggering mechanism refers to the traffic generated by Automation.
[0129] After obtaining the first database query statement, the data server can determine the first flow information of the first database query statement; obtain preset flow restriction information; and process the first database query statement based on the first flow information and the flow restriction information.
[0130] Specifically, it can be determined whether the first flow information corresponds to restriction information. If so, it is determined whether the first database query statement is a read data statement or a write data statement. If it is a read data statement, the first database query statement is allowed to read data from the database. If it is a write data statement, it is not processed. When it is determined that the first flow information does not correspond to restriction information, it is released, and the first database query statement is allowed to access the original database (that is, the database to be accessed by the first database query statement). Among them, when there is target restriction information matching the first flow information in the flow restriction information, it is regarded that the first flow information corresponds to restriction information; when there is no target restriction information matching the first flow information in the flow restriction information, it is regarded that the first flow information does not correspond to restriction information.
[0131] It should be noted that each time the data server obtains a database query statement, the scene (traffic type), window (time unit), reqSource (traffic source), and sqlCost (query cost) of the database query statement as shown in the figure can be stored in redis to determine the traffic limit information.
[0132] It should be noted that Figure 3b The following is a schematic diagram of a query statement processing method for only one database. When aPaaS includes multiple databases, the corresponding query statement processing method is different from Figure 3bThe processing method for database query statements is the same as in , so it will not be repeated here.
[0133] In the present application, the flow restriction information in the present application may be stored in a restriction information table, and the aforementioned obtaining of the preset flow restriction information may refer to obtaining the preset flow restriction information in the restriction information table.
[0134] In some optional embodiments of the present application, the above method may further include:
[0135] Obtain a third query cost of at least one third database query statement of the first traffic type obtained within a second time period, wherein the second time period is a time period with the current moment (the current moment being the moment of obtaining the third query cost obtained within the second time period) as the end moment and the moment corresponding to the second time attribution unit of the current moment as the start moment;
[0136] Obtaining growth trend information of the third query cost within the second time period;
[0137] Obtaining a preset growth trend information threshold corresponding to the first traffic type;
[0138] When the growth trend information is greater than the preset growth trend information threshold, the flow restriction information is determined based on the first flow type. When the growth trend information is not greater than the preset growth trend information threshold, no processing is performed and the target restriction information is removed from the aforementioned restriction information table.
[0139] The present disclosure provides a method for obtaining a first database query statement; determining first traffic information of the first database query statement, wherein the first traffic information includes a first traffic type and a first traffic source, wherein the first traffic type is any one of the following multiple traffic types: traffic related to web pages, traffic related to open application program interfaces, traffic related to cloud function services, traffic related to business processes corresponding to automatic triggering mechanisms, and traffic related to calculation fields; obtaining preset traffic restriction information; and processing the first database query statement based on the first traffic information and the traffic restriction information. This method can effectively prevent database overload from the granularity of the traffic type and traffic source to which the database query statement belongs, and can handle the DB overload problem from a finer granularity when the DB is actually overloaded, with high flexibility, thereby improving the efficiency of preventing and resolving DB overload problems.
[0140] Figure 4 A schematic diagram of the structure of a query statement processing device provided by an exemplary embodiment of the present disclosure;
[0141] The device comprises:
[0142] An acquisition unit 41 is used to acquire a first database query statement;
[0143] A determining unit 42 is used to determine first traffic information of the first database query statement, where the first traffic information includes a first traffic type and a first traffic source, where the first traffic type is any one of the following multiple traffic types: traffic related to a web page, traffic related to an open application program interface, traffic related to a cloud function service, traffic related to a business process corresponding to an automatic trigger mechanism, and traffic related to a calculated field;
[0144] The acquisition unit 41 is further used to acquire preset flow restriction information;
[0145] The processing unit 43 is used to process the first database query statement based on the first traffic information and the traffic limit information.
[0146] According to one or more embodiments of the present disclosure, when the device is used to process the first database query statement based on the first traffic information and the traffic limit information, it is specifically used to:
[0147] Determine whether there is target restriction information in the traffic restriction information that matches the first traffic information; if so, limit the traffic of the first database query statement.
[0148] According to one or more embodiments of the present disclosure, when the device is used to limit the flow of the first database query statement, it is specifically used to:
[0149] In response to the first database query statement being a data read statement, the first database query statement is allowed to read data from a slave database, where the slave database is a slave database of an original database corresponding to the first database query statement.
[0150] According to one or more embodiments of the present disclosure, before obtaining the preset flow restriction information, the device is further used to:
[0151] Obtaining a first query cost of at least one second database query statement whose traffic type is the first traffic type obtained within a first time period, wherein the first time period is a time period with the current time as the end time and the time corresponding to the first time attribution unit of the current time as the start time;
[0152] Obtaining growth trend information of the first query cost within the first time period;
[0153] Obtaining a preset growth trend information threshold corresponding to the first traffic type;
[0154] The flow limit information is determined according to the growth trend information and the preset growth trend information threshold.
[0155] According to one or more embodiments of the present disclosure, when the device is used to determine the flow limit information according to the growth trend information and the preset growth trend information threshold, it is specifically used to:
[0156] In response to the growth trend information being greater than the preset growth trend information threshold, the flow limit information is determined based on the first flow type.
[0157] According to one or more embodiments of the present disclosure, when the apparatus is used to determine the traffic restriction information based on the first traffic type, it is specifically used to:
[0158] Obtaining priority indication information of the first traffic type;
[0159] If the priority indication information indicates that the first traffic type is of low priority, using the restriction information of the first traffic type as the traffic restriction information;
[0160] If the priority indication information indicates that the first traffic type is a high priority, a second traffic source corresponding to the first traffic type is obtained; and restriction information of the second traffic source is used as the traffic restriction information.
[0161] According to one or more embodiments of the present disclosure, the device is further used for:
[0162] Obtain at least one second query cost corresponding to at least one traffic source whose corresponding traffic type is the first traffic type within the first time period;
[0163] The traffic source with the highest second query cost among the at least one traffic source is used as the second traffic source corresponding to the first traffic type.
[0164] According to one or more embodiments of the present disclosure, the device is further used for:
[0165] Obtaining a first time measurement unit corresponding to the first traffic type;
[0166] Obtaining a first timestamp of the current moment;
[0167] Determine the first time attribution unit of the current moment according to the first timestamp and the first time measurement unit;
[0168] The first time period is determined according to the first timestamp and the first time attribution unit.
[0169] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, no further description is given here. Specifically, the device may perform the above method embodiment, and the above and other operations and / or functions of each module in the device are the corresponding processes in each method in the above method embodiment, respectively, and no further description is given here for the sake of brevity.
[0170] The above describes the device of the embodiment of the present disclosure from the perspective of the functional module in conjunction with the accompanying drawings. It should be understood that the functional module can be implemented in hardware form, can be implemented by instructions in software form, and can also be implemented by a combination of hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present disclosure can be completed by the hardware integrated logic circuit and / or software form instructions in the processor, and the steps of the method disclosed in conjunction with the embodiment of the present disclosure can be directly embodied as a hardware decoding processor to execute, or a combination of hardware and software modules in the decoding processor to execute. Optionally, the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps in the above method embodiment in conjunction with its hardware.
[0171] Figure 5 is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure, and the electronic device may include:
[0172] The memory 501 and the processor 502, the memory 501 is used to store the computer program and transmit the program code to the processor 502. In other words, the processor 502 can call and run the computer program from the memory 501 to implement the method in the embodiment of the present disclosure.
[0173] For example, the processor 502 may be configured to execute the above method embodiments according to instructions in the computer program.
[0174] In some embodiments of the present disclosure, the processor 502 may include but is not limited to:
[0175] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
[0176] In some embodiments of the present disclosure, the memory 501 includes but is not limited to:
[0177] Volatile memory and / or non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0178] In some embodiments of the present disclosure, the computer program may be divided into one or more modules, which are stored in the memory 501 and executed by the processor 502 to complete the method provided by the present disclosure. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.
[0179] like Figure 5 As shown, the electronic device may also include:
[0180] The transceiver 503 may be connected to the processor 502 or the memory 501 .
[0181] The processor 502 may control the transceiver 503 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 503 may include a transmitter and a receiver. The transceiver 503 may further include an antenna, and the number of antennas may be one or more.
[0182] It should be understood that the various components in the electronic device are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0183] The present disclosure also provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a computer, the computer can perform the method of the above method embodiment. In other words, the present disclosure embodiment also provides a computer program product containing instructions, and when the instructions are executed by a computer, the computer can perform the method of the above method embodiment.
[0184] When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present disclosure is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (digital video disc, DVD)), or a semiconductor medium (e.g., a solid state disk (solid state disk, SSD)), etc.
[0185] According to one or more embodiments of the present disclosure, a query statement processing method is provided, including:
[0186] Obtaining a first database query statement;
[0187] Determine first traffic information of the first database query statement, the first traffic information includes a first traffic type and a first traffic source, the first traffic type is any one of the following multiple traffic types: traffic related to a web page, traffic related to an open application program interface, traffic related to a cloud function service, traffic related to a business process corresponding to an automatic trigger mechanism, and traffic related to a calculated field;
[0188] Get preset traffic limit information;
[0189] The first database query statement is processed based on the first traffic information and the traffic limit information.
[0190] According to one or more embodiments of the present disclosure, the processing of the first database query statement based on the first traffic information and the traffic limit information includes:
[0191] Determine whether there is target restriction information in the traffic restriction information that matches the first traffic information; if so, limit the traffic of the first database query statement.
[0192] According to one or more embodiments of the present disclosure, limiting the flow of the first database query statement includes:
[0193] In response to the first database query statement being a data read statement, the first database query statement is allowed to read data from a slave database, where the slave database is a slave database of an original database corresponding to the first database query statement.
[0194] According to one or more embodiments of the present disclosure, before obtaining the preset traffic restriction information, the method further includes:
[0195] Obtaining a first query cost of at least one second database query statement whose traffic type is the first traffic type obtained within a first time period, wherein the first time period is a time period with the current time as the end time and the time corresponding to the first time attribution unit of the current time as the start time;
[0196] Obtaining growth trend information of the first query cost within the first time period;
[0197] Obtaining a preset growth trend information threshold corresponding to the first traffic type;
[0198] The flow limit information is determined according to the growth trend information and the preset growth trend information threshold.
[0199] According to one or more embodiments of the present disclosure, the determining the flow restriction information according to the growth trend information and the preset growth trend information threshold includes:
[0200] In response to the growth trend information being greater than the preset growth trend information threshold, determining the flow limit information based on the first flow type.
[0201] According to one or more embodiments of the present disclosure, determining the traffic restriction information based on the first traffic type includes:
[0202] Obtaining priority indication information of the first traffic type;
[0203] If the priority indication information indicates that the first traffic type is of low priority, using the restriction information of the first traffic type as the traffic restriction information;
[0204] If the priority indication information indicates that the first traffic type is a high priority, a second traffic source corresponding to the first traffic type is obtained; and restriction information of the second traffic source is used as the traffic restriction information.
[0205] According to one or more embodiments of the present disclosure, the method further includes:
[0206] Obtain at least one second query cost corresponding to at least one traffic source whose corresponding traffic type is the first traffic type within the first time period;
[0207] The traffic source with the highest second query cost among the at least one traffic source is used as the second traffic source corresponding to the first traffic type.
[0208] According to one or more embodiments of the present disclosure, the method further includes:
[0209] Obtaining a first time measurement unit corresponding to the first traffic type;
[0210] Obtaining a first timestamp of the current moment;
[0211] Determine the first time attribution unit of the current moment according to the first timestamp and the first time measurement unit;
[0212] The first time period is determined according to the first timestamp and the first time attribution unit.
[0213] According to one or more embodiments of the present disclosure, a data processing device is provided, wherein the device includes:
[0214] An acquisition unit, used to acquire a first database query statement;
[0215] a determining unit, configured to determine first traffic information of the first database query statement, the first traffic information comprising a first traffic type and a first traffic source, the first traffic type being any one of the following multiple traffic types: traffic associated with a web page, traffic associated with an open application program interface, traffic associated with a cloud function service, traffic associated with a business process corresponding to an automatic trigger mechanism, and traffic associated with a calculated field;
[0216] The acquisition unit is further used to acquire preset flow restriction information;
[0217] A processing unit is used to process the first database query statement based on the first traffic information and the traffic limit information.
[0218] According to one or more embodiments of the present disclosure, when the device is used to process the first database query statement based on the first traffic information and the traffic limit information, it is specifically used to:
[0219] Determine whether there is target restriction information in the traffic restriction information that matches the first traffic information; if so, limit the traffic of the first database query statement.
[0220] According to one or more embodiments of the present disclosure, when the device is used to limit the flow of the first database query statement, it is specifically used to:
[0221] In response to the first database query statement being a data read statement, the first database query statement is allowed to read data from a slave database, where the slave database is a slave database of an original database corresponding to the first database query statement.
[0222] According to one or more embodiments of the present disclosure, before obtaining the preset flow restriction information, the device is further used to:
[0223] Obtaining a first query cost of at least one second database query statement whose traffic type is the first traffic type obtained within a first time period, wherein the first time period is a time period with the current time as the end time and the time corresponding to the first time attribution unit of the current time as the start time;
[0224] Obtaining growth trend information of the first query cost within the first time period;
[0225] Obtaining a preset growth trend information threshold corresponding to the first traffic type;
[0226] The flow limit information is determined according to the growth trend information and the preset growth trend information threshold.
[0227] According to one or more embodiments of the present disclosure, when the device is used to determine the flow limit information according to the growth trend information and the preset growth trend information threshold, it is specifically used to:
[0228] In response to the growth trend information being greater than the preset growth trend information threshold, the flow limit information is determined based on the first flow type.
[0229] According to one or more embodiments of the present disclosure, when the apparatus is used to determine the traffic restriction information based on the first traffic type, it is specifically used to:
[0230] Obtaining priority indication information of the first traffic type;
[0231] If the priority indication information indicates that the first traffic type is of low priority, using the restriction information of the first traffic type as the traffic restriction information;
[0232] If the priority indication information indicates that the first traffic type is a high priority, a second traffic source corresponding to the first traffic type is obtained; and restriction information of the second traffic source is used as the traffic restriction information.
[0233] According to one or more embodiments of the present disclosure, the device is further used for:
[0234] Obtain at least one second query cost corresponding to at least one traffic source whose corresponding traffic type is the first traffic type within the first time period;
[0235] The traffic source with the highest second query cost among the at least one traffic source is used as the second traffic source corresponding to the first traffic type.
[0236] According to one or more embodiments of the present disclosure, the device is further used for:
[0237] Obtaining a first time measurement unit corresponding to the first traffic type;
[0238] Obtaining a first timestamp of the current moment;
[0239] Determine the first time attribution unit of the current moment according to the first timestamp and the first time measurement unit;
[0240] The first time period is determined according to the first timestamp and the first time attribution unit.
[0241] According to one or more embodiments of the present disclosure, the present disclosure provides an electronic device, including:
[0242] Processor; and
[0243] A memory, configured to store executable instructions of the processor;
[0244] The processor is configured to perform the above methods by executing the executable instructions.
[0245] According to one or more embodiments of the present disclosure, an embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the aforementioned methods are implemented.
[0246] Those of ordinary skill in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.
[0247] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the module is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0248] The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. For example, each functional module in each embodiment of the present disclosure may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0249] The above are only specific embodiments of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A query statement processing method, It is characterized in that include: Obtaining a first database query statement; Determine first traffic information of the first database query statement, the first traffic information includes a first traffic type and a first traffic source, the first traffic type is any one of the following multiple traffic types: traffic related to a web page, traffic related to an open application program interface, traffic related to a cloud function service, traffic related to a business process corresponding to an automatic trigger mechanism, and traffic related to a calculated field; Get preset traffic limit information; The first database query statement is processed based on the first traffic information and the traffic limit information.
2. The method according to claim 1, It is characterized in that The processing of the first database query statement based on the first flow information and the flow limit information includes: Determine whether there is target restriction information in the traffic restriction information that matches the first traffic information; if so, limit the traffic of the first database query statement.
3. The method according to claim 2, It is characterized in that The limiting the flow of the first database query statement includes: In response to the first database query statement being a data read statement, the first database query statement is allowed to read data from a slave database, where the slave database is a slave database of an original database corresponding to the first database query statement.
4. The method according to claim 1, It is characterized in that Before obtaining the preset flow restriction information, the method further includes: Obtaining a first query cost of at least one second database query statement whose traffic type is the first traffic type obtained within a first time period, wherein the first time period is a time period with the current time as the end time and the time corresponding to the first time attribution unit of the current time as the start time; Obtaining growth trend information of the first query cost within the first time period; Obtaining a preset growth trend information threshold corresponding to the first traffic type; The flow limit information is determined according to the growth trend information and the preset growth trend information threshold.
5. The method according to claim 4, It is characterized in that The determining the flow limit information according to the growth trend information and the preset growth trend information threshold includes: In response to the growth trend information being greater than the preset growth trend information threshold, the flow limit information is determined based on the first flow type.
6. The method according to claim 5, It is characterized in that The determining the traffic restriction information based on the first traffic type includes: Obtaining priority indication information of the first traffic type; If the priority indication information indicates that the first traffic type is of low priority, using the restriction information of the first traffic type as the traffic restriction information; If the priority indication information indicates that the first traffic type is a high priority, a second traffic source corresponding to the first traffic type is obtained; and restriction information of the second traffic source is used as the traffic restriction information.
7. The method according to claim 6, It is characterized in that The method further comprises: Obtain at least one second query cost corresponding to at least one traffic source whose corresponding traffic type is the first traffic type within the first time period; The traffic source with the highest second query cost among the at least one traffic source is used as the second traffic source corresponding to the first traffic type.
8. The method according to claim 4, It is characterized in that The method further comprises: Obtaining a first time measurement unit corresponding to the first traffic type; Obtaining a first timestamp of the current moment; Determine the first time attribution unit of the current moment according to the first timestamp and the first time measurement unit; The first time period is determined according to the first timestamp and the first time attribution unit.
9. A query statement processing device, It is characterized in that include: An acquisition unit, used to acquire a first database query statement; a determining unit, configured to determine first traffic information of the first database query statement, the first traffic information comprising a first traffic type and a first traffic source, the first traffic type being any one of the following multiple traffic types: traffic associated with a web page, traffic associated with an open application program interface, traffic associated with a cloud function service, traffic associated with a business process corresponding to an automatic trigger mechanism, and traffic associated with a calculated field; The acquisition unit is further used to acquire preset flow restriction information; A processing unit is used to process the first database query statement based on the first traffic information and the traffic limit information.
10. An electronic device, It is characterized in that include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 8 by executing the executable instructions.
11. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
System and method of site traffic control
CN107534586A
Service traffic limiting method based on database storage process design
CN115208834A
Control of a distributed data grid layer in a federated database system
US20160154847A1
Cited By
Method, device and equipment for limiting flow of SQL (Structured Query Language) statement and distributed database
CN120492479A
