Query statement processing method, device and equipment and computer medium

CN118656381BActive Publication Date: 2026-08-21BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410693023.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-30
Publication Date
2026-08-21
Estimated Expiration
2044-05-30

AI Technical Summary

Technical Problem

[0004]本公开实施例提供一种与相关技术不同的实现方案,以解决相关技术中预防以及解决DB过载问题的效率较低的技术问题

Benefits of technology

[0020]本公开提供的获取第一数据库查询语句;确定所述第一数据库查询语句的第一流量信息,所述第一流量信息包括第一流量类型与第一流量源,所述第一流量类型为以下多个流量类型中的任一种:与网页相关的流量、与开放应用程序接口相关的流量、与云函数服务相关的流量、与自动触发机制对应的业务流程相关的流量,以及与计算字段相关的流量;获取预设的流量限制信息;基于所述第一流量信息与所述流量限制信息处理所述第一数据库查询语句的方案,可以从数据库查询语句所属的流量类型与流量源的粒度,有效预防数据库出现超载的情况,并且,可在DB实际出现过载情况时,从更细的粒度处理DB过载的问题,灵活性较高,提高了预防以及解决DB过载问题的效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656381B_ABST
    Figure CN118656381B_ABST
Patent Text Reader

Abstract

The present disclosure discloses a query statement processing method, device and equipment and a computer medium. The method comprises: obtaining a first database query statement; determining first traffic information of the first database query statement, wherein the first traffic information comprises a first traffic type and a first traffic source, and the first traffic type is any one of the following multiple traffic types: webpage-related traffic, open application interface-related traffic, cloud function service-related traffic, business process related to an automatic triggering mechanism, and calculation field-related traffic; obtaining preset traffic limit information; and processing the first database query statement based on the first traffic information and the traffic limit information, thereby improving the efficiency of preventing and solving the DB overload problem.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure belongs to the field of database technology, and in particular relates to a query statement processing method, apparatus, device and computer medium. Background Technology

[0002] In the context of multi-tenant converged deployment of aPaaS (Application Platform as a Service), an increasing number of tenants and application packages share a single database. This database frequently experiences overload incidents that last for extended periods, resulting in poor stability.

[0003] In related technologies, the common method to prevent and resolve database overload issues is to limit the QPS (Queries-per-second) of tenant application packets at the gateway layer. However, this method cannot flexibly handle traffic data of different types and sources, and its approach to preventing and resolving database overload issues is crude, ineffective, and inefficient. Summary of the Invention

[0004] This disclosure provides an implementation scheme that differs from related technologies, in order to solve the technical problem of low efficiency in preventing and resolving DB overload issues in related technologies.

[0005] Firstly, this disclosure provides a query statement processing method, including:

[0006] Retrieve the first database query statement;

[0007] Determine the 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 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 calculated fields.

[0008] Obtain preset traffic limit information;

[0009] The first database query statement is processed based on the first traffic information and the traffic restriction information.

[0010] Secondly, this disclosure provides a query statement processing apparatus, including:

[0011] The acquisition unit is used to acquire the first database query statement;

[0012] The determining unit is used to determine the 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 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 calculated fields.

[0013] The acquisition unit is also used to acquire preset traffic restriction information;

[0014] The processing unit is used to process the first database query statement based on the first traffic information and the traffic restriction information.

[0015] Thirdly, this disclosure provides an electronic device, including:

[0016] Processor; and

[0017] Memory for storing the executable instructions of the processor;

[0018] The processor is configured to execute the methods described above by executing the executable instructions.

[0019] Fourthly, embodiments of this disclosure provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned methods.

[0020] The scheme disclosed herein provides for obtaining a first database query statement; determining the first traffic information of the first database query statement, wherein the first traffic information includes a first traffic type and a first traffic source, and the first traffic type is any one of the following 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 calculated fields; obtaining preset traffic limit information; and processing the first database query statement based on the first traffic information and the traffic limit information. This scheme can effectively prevent database overload at the granularity of the traffic type and traffic source to which the database query statement belongs. Furthermore, when the database is actually overloaded, it can handle the database overload problem at a finer granularity, providing high flexibility and improving the efficiency of preventing and resolving database overload problems. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments or related technologies of this disclosure, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings:

[0022] Figure 1a This is a schematic diagram illustrating the configuration of a DB platform for an embodiment of this disclosure;

[0023] Figure 1b A schematic diagram of a microservice call chain provided in an embodiment of this disclosure;

[0024] Figure 2 This is a schematic diagram of the structure of a system provided in one embodiment of the present disclosure;

[0025] Figure 3a A flowchart illustrating a query statement processing method provided in an embodiment of this disclosure;

[0026] Figure 3b A scenario diagram illustrating a query statement processing method provided in an embodiment of this disclosure;

[0027] Figure 4 This is a schematic diagram of the structure of a query statement processing device provided in an embodiment of the present disclosure;

[0028] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0029] Embodiments of this disclosure are described in detail below, with examples of these embodiments illustrated in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this disclosure, and should not be construed as limiting it.

[0030] The terms "first" and "second," etc., used in the specification, claims, and drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the present disclosure described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0031] First, some terms used in the embodiments of this disclosure will be 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 code, and when an event is triggered, the cloud service provider will automatically execute this function code and return the result.

[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 lookup, 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 has interactive features and can provide great convenience to users. Database management systems should make full use of SQL to improve the working 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. A null value is a field that does not store any data or value. The null value rate can be used to assess the quality and integrity of data, as an excessive number of null values ​​may indicate missing or incomplete data.

[0038] In the context of multi-tenant converged deployment of aPaaS (Application Platform as a Service), an increasing number of tenants and application packages share a single database. Databases frequently experience overload incidents that last for extended periods, exhibiting poor stability. Furthermore, related technologies are slow to determine the cause of overload, resulting in low query efficiency.

[0039] The inventors discovered through research that, in some cases, [the following can be seen] Figure 1aAs shown, different databases in aPaaS have different hardware configurations, and the number of tenants and application packages on different databases varies, making it impossible to quantify the rate limiting threshold. aPaaS employs a multi-tenant, multi-application package integrated deployment approach, where some application packages consume fewer resources, allowing a portion of application packages to exceed the safety threshold to achieve the maximum overall system benefit.

[0040] Further, see Figure 1b As shown, in a microservice call chain, from the perspective of service C, it is easy to know that the upstream call (up_stream) is service B, but the source of the traffic (origin_stream) is unknown. Identifying the traffic source is crucial in aPaaS detection and overload protection or rate limiting scenarios, as it allows us to pinpoint the type of traffic and its source that is causing significant pressure on the database.

[0041] This application provides a solution that, based on the background of multi-tenant converged deployment of aPaaS, serves as many application packages as possible when the database is available, or allows the database access volume of a few application packages to elastically exceed the limit. Corresponding measures can be taken in advance to avoid database overload, and targeted rate limiting (dropping SQL requests) can be implemented to avoid overall service collapse. High-priority requests are guaranteed without manual intervention, ensuring that the database can work under normal load and can quickly handle even under overload conditions.

[0042] In the proposed solution, a traffic tracing protocol can be established first to label the type of traffic source and transmit it across the entire link, thereby achieving the goal of accurately distinguishing the traffic source of DB access data.

[0043] In this application, when it comes to measuring the pressure on the database, user operations on data, once they reach the data server, become read and write operations on aPaaS platform objects. Objects are mapped to MySQL tables, and object fields are mapped to MySQL table columns. In other words, data operations from traffic sources are translated into SQL after reaching the data server. Quantifying the pressure on the database caused by each SQL statement allows for comparison of the pressure on the database by traffic on the same order of magnitude, referred to as SQL cost or SQL cost.

[0044] The technical solutions of this disclosure and how they solve the aforementioned technical problems will be described in detail below with specific embodiments. These 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 this disclosure will now be described with reference to the accompanying drawings.

[0045] Figure 2 A schematic diagram of the structure of a system provided for an exemplary embodiment of this disclosure, the structure including:

[0046] This application relates to a system comprising: an APAAS platform and user equipment, 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 access requests for accessing the database, which may include a first database query statement; optionally, the access request may be sent by the user device or generated based on an automatic triggering mechanism.

[0048] The data server is used to: obtain access requests from the business server and determine a first database query statement; determine first traffic information for 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 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 calculated fields; obtain preset traffic restriction information; and process the first database query statement based on the first traffic information and the traffic restriction information.

[0049] The aforementioned database is used for access to the aforementioned access request.

[0050] The execution principles and interaction processes of each component unit in this system embodiment can be found in the descriptions of the following method embodiments.

[0051] Figure 3a This is a flowchart illustrating a query statement processing method provided as an exemplary embodiment of the present disclosure. The method is applicable to data servers in an APAAS platform and includes at least the following steps S201-S204:

[0052] S201. Obtain the first database query statement;

[0053] Specifically, the first database query statement is contained within 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. Determine the 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 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 calculated fields.

[0056] Specifically, the first traffic information of the first database query statement is: the traffic information of the traffic belonging to the database query request to which the first database query statement belongs.

[0057] Optionally, the first traffic information is also included in the database query request containing the first database query statement.

[0058] Specifically, the aforementioned traffic related to web pages refers to traffic generated through triggering web pages; traffic related to open application programming interfaces refers to traffic generated through triggering OpenAPI; traffic related to cloud function services refers to traffic generated through FaaS; and traffic related to business processes corresponding to automatic triggering mechanisms refers to traffic generated through Automation.

[0059] In some alternative embodiments, the aforementioned traffic types may also include other types, which are not limited in this application.

[0060] In some optional embodiments of this application, the data server may first obtain an access request for the 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 can be determined based on the traffic type identifier included in the corresponding access request.

[0062] Alternatively, different first traffic sources can be distinguished by any of the following information: application identifier, tenant identifier, or triggering information indicating the database query request to which the first database query statement belongs.

[0063] Optionally, the aforementioned database query request sending trigger information may refer to operation information used to trigger the sending of the database query request.

[0064] Optionally, the aforementioned operation information may include button icons or webpage icons, etc.

[0065] S203. Obtain preset traffic limit information;

[0066] In some optional embodiments of this application, regarding the determination of traffic restriction information, before obtaining the preset traffic restriction information, the method further includes the following S01-S04:

[0067] S01. Obtain the first query cost of at least one second database query statement with the traffic type of the first traffic type obtained within the 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 unit of the current time as the start time.

[0068] Optionally, the first query cost of at least one second database query statement is the total query cost of the query costs of each of the at least one second database query statements.

[0069] Optionally, the aforementioned current time is the time when the aforementioned first query cost is obtained.

[0070] In some optional embodiments of this application, the method further includes the following steps S41-S44 regarding the determination of the first time period:

[0071] S41. Obtain the first time metering unit corresponding to the first traffic type;

[0072] Optionally, different first flow types correspond to different first time metering units.

[0073] Optionally, the first time unit can refer to a value of time length.

[0074] For example, when the first traffic type is traffic related to cloud function services, the first time metering unit corresponding to the first traffic type can be 2 seconds.

[0075] For example, when the first traffic type is traffic related to the Open Application Programming Interface, the first time metering unit corresponding to the first traffic type can be 3 seconds.

[0076] S42. Obtain the first timestamp of the current moment;

[0077] The first timestamp is data generated using digital signature technology. The object being signed includes information such as the original file information, signature parameters, and signature time. The first timestamp system is used to generate and manage first timestamps, digitally signing the object to generate the first timestamp, proving that the original file existed before the signature time.

[0078] Optionally, in this scheme, the timestamp refers to the total number of seconds from 00:00:00 GMT on January 1, 1970 to the present.

[0079] S43. Determine the first time-attribution unit for the current moment based on the first timestamp and the first time measurement unit;

[0080] In some optional embodiments of this application, in S43, determining the first time-attribute unit of the current time based on the first timestamp and the first time measurement unit may include: using the quotient of the first timestamp and the first time measurement unit as the first time-attribute unit of the current time.

[0081] For example, when the first timestamp is 300 and the first time measurement unit is 3s, the first time 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 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 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 unit at the current moment is 101.

[0085] In this application, no processing is required when the first time period is detected to be 0.

[0086] Optionally, the time corresponding to the aforementioned first time attribution unit is the initial time of the first time attribution unit.

[0087] S44. Determine the first time period based on the first timestamp and the first time attribution unit.

[0088] In some optional embodiments of this application, in the aforementioned S44, determining the first time period based on 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. Obtain the growth trend information of the first query cost within the first time period;

[0090] Specifically, the first query cost is the 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 can be used as the growth trend information of the first query cost within the first time period.

[0092] S03. Obtain the preset growth trend information threshold corresponding to the first traffic type;

[0093] In some optional embodiments of this application, the preset growth trend information threshold corresponding to the first traffic type can be: within the first time metering unit, the traffic type is the ratio of the query cost capacity value of the query statement of the first traffic type to the first time metering unit.

[0094] S04. Determine the traffic restriction information based on the growth trend information and the preset growth trend information threshold.

[0095] In some optional embodiments of this application, determining the traffic restriction 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 restriction information based on the first traffic type.

[0096] In some optional embodiments of this application, determining the traffic restriction information based on the growth trend information and the preset growth trend information threshold further includes: in response to the growth trend information not being greater than the preset growth trend information threshold, no processing is performed.

[0097] In some optional embodiments of this application, determining the traffic restriction information based on the first traffic type includes the following S001-S002:

[0098] S001. Obtain priority indication information for 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 for a first traffic type, the restriction information for the first traffic type is the target restriction information that matches the first traffic information.

[0101] When the traffic restriction information includes the restriction information of the second traffic source, the restriction information of the second traffic source is the target restriction information that matches the first traffic information.

[0102] In some optional embodiments of this application, the method further includes the following S31-S32:

[0103] S31. Obtain at least one second query cost corresponding to at least one traffic source of the first traffic type within the first time period;

[0104] Specifically, each traffic source can correspond to multiple database query statements, and the sum of the query costs of these multiple database query statements is the second query cost corresponding to that traffic source.

[0105] S32. Among the at least one traffic source, the traffic source with the highest second query cost is taken 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 restriction information.

[0107] In some optional embodiments of this application, in the aforementioned S204, processing the first database query statement based on the first traffic information and the traffic restriction information includes:

[0108] Determine whether there is any target restriction information in the traffic restriction information that matches the first traffic information; if so, then apply traffic restriction to the first database query statement.

[0109] In some optional embodiments of this application, the flow restriction of the first database query statement includes: in response to the first database query statement being a read data statement, allowing the first database query statement to read data from a slave database, wherein the slave database is a slave database of the original database corresponding to the first database query statement.

[0110] In some optional embodiments of this application, the rate limiting of the first database query statement further includes: not processing if the first database query statement is a write data statement.

[0111] Optionally, when the traffic restriction information includes restriction information for a first traffic type or restriction information for a first traffic source, it is considered that the traffic restriction information contains target restriction information that matches the first traffic information. When the traffic restriction information does not include restriction information for a first traffic type or restriction information for a first traffic source, it is considered that the traffic restriction information does not contain target restriction information that matches the first traffic information.

[0112] In this application, the data server will perform the following steps each time it obtains a second database query statement:

[0113] S1. Determine the second traffic information of the second database query statement. The second traffic information includes the second traffic type and the third traffic source.

[0114] S2. Calculate the query cost of the second database query statement;

[0115] S3. Obtain the second time metering unit corresponding to the second traffic type;

[0116] S4. Obtain the second timestamp of the time when the second database query statement was retrieved;

[0117] S5. Determine the second time-attribution unit for the time of acquisition based on 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 this application, in the aforementioned S6, storing the second traffic type, the second time attribution unit, and the query cost of the second database query statement includes: concatenating the second traffic type and the second time attribution unit to obtain a first concatenation result, and storing the first concatenation result and the query cost of the second database query statement as a first data pair.

[0121] In some optional embodiments of this application, in the aforementioned S7, storing the second traffic type, the second time attribution unit, the third traffic source, and the query cost of the second database query statement includes: concatenating the second traffic type and the second time attribution unit to obtain a second concatenation result, and storing the second concatenation 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 can be stored in the Redis cache.

[0123] Optionally, the data server can determine the growth trend information of the aforementioned first query cost during the first time period based on the cached content in Redis.

[0124] In this application, for the database, all record IDs and the -isDeleted field can be queried page by page, and the number of record IDs and the number of -isDeleted field entries on each page can be counted. Up to 20,000 record IDs can be counted, yielding the total number of object records for each field in the database and the number of objects that have not been deleted. Additionally, this application includes determining the following database information for each field: null value rate, number of distinct 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 time, identifying abnormal scenarios within 100ms with high accuracy. It can identify abnormal scenarios or traffic sources within scenarios within 100ms and issue rate limiting decisions.

[0126] To provide a more comprehensive description of the solution in this application, a scenario diagram is provided below. Figure 3b Further explanation of this plan:

[0127] In this application, the first traffic information of the first database query statement includes a first traffic type and a first traffic source. The aforementioned first traffic type can be any of a variety of traffic types, which may include: 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 calculated fields.

[0128] Specifically, the aforementioned traffic related to web pages refers to traffic generated through triggering web pages; traffic related to open application programming interfaces refers to traffic generated through triggering OpenAPI; traffic related to cloud function services refers to traffic generated through FaaS; and traffic related to business processes corresponding to automatic triggering mechanisms refers to traffic generated through Automation.

[0129] After the data server obtains the first database query statement, it can determine the first traffic information of the first database query statement; obtain preset traffic limit information; and process the first database query statement based on the first traffic information and the traffic limit information.

[0130] Specifically, it can be determined whether the first traffic information corresponds to any 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 slave database; if it is a write data statement, no processing is performed. When it is determined that the first traffic information does not correspond to any restriction information, it is allowed to proceed, permitting the first database query statement to access the original database (i.e., the database that the first database query statement intends to access). Specifically, if the traffic restriction information contains target restriction information that matches the first traffic information, the first traffic information is considered to correspond to restriction information; if the traffic restriction information does not contain target restriction information that matches the first traffic information, the first traffic information is considered not to correspond to restriction information.

[0131] It should be noted that each time the data server obtains a database query statement, it can store the scene (traffic type), window (time unit), reqSource (traffic source), and sqlCost (query cost) of the database query statement in Redis, as shown in the figure, to determine the traffic limit information.

[0132] It should be noted that, Figure 3b This diagram illustrates a scenario where query processing is performed on a single database. When aPaaS includes multiple databases, the corresponding query processing methods will differ. Figure 3bThe processing method for database query statements is the same, so it will not be repeated here.

[0133] In this application, the traffic restriction information can be stored in a restriction information table, and the aforementioned acquisition of preset traffic restriction information can refer to acquiring preset traffic restriction information from the restriction information table.

[0134] In some optional embodiments of this application, the above method may further include:

[0135] The third query cost of at least one third database query statement with the first traffic type obtained within the second time period is obtained. The second time period is a time period with the current time (which is the time when the third query cost obtained within the second time period is obtained) as the end time and the time corresponding to the second time unit of the current time as the start time.

[0136] Obtain the growth trend information of the third query cost within the second time period;

[0137] Obtain the 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 traffic restriction information is determined based on the first traffic 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 scheme disclosed herein provides for obtaining a first database query statement; determining the first traffic information of the first database query statement, wherein the first traffic information includes a first traffic type and a first traffic source, and the first traffic type is any one of the following 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 calculated fields; obtaining preset traffic limit information; and processing the first database query statement based on the first traffic information and the traffic limit information. This scheme can effectively prevent database overload at the granularity of the traffic type and traffic source to which the database query statement belongs. Furthermore, when the database is actually overloaded, it can handle the database overload problem at a finer granularity, providing high flexibility and improving the efficiency of preventing and resolving database overload problems.

[0140] Figure 4 A schematic diagram of the structure of a query statement processing apparatus provided as an exemplary embodiment of this disclosure;

[0141] The device includes:

[0142] Acquisition unit 41 is used to acquire the first database query statement;

[0143] The determining unit 42 is used to determine the 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 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 calculated fields.

[0144] The acquisition unit 41 is also used to acquire preset traffic limit information;

[0145] Processing unit 43 is used to process the first database query statement based on the first traffic information and the traffic restriction information.

[0146] According to one or more embodiments of this disclosure, when the apparatus is used to process the first database query statement based on the first traffic information and the traffic restriction information, it is specifically used for:

[0147] Determine whether there is any target restriction information in the traffic restriction information that matches the first traffic information; if so, then apply traffic restriction to the first database query statement.

[0148] According to one or more embodiments of this disclosure, when the device is used to rate limit the first database query statement, it is specifically used for:

[0149] In response to the first database query statement being a read data statement, the first database query statement is allowed to read data from a slave database, wherein the slave database is a slave database of the original database corresponding to the first database query statement.

[0150] According to one or more embodiments of this disclosure, before obtaining the preset traffic limit information, the device is further configured to:

[0151] The first query cost of at least one second database query statement of the first traffic type obtained within the first time period is obtained. The first time period is the time period ending at the current time and starting at the time corresponding to the first time unit of the current time.

[0152] Obtain the growth trend information of the first query cost within the first time period;

[0153] Obtain the preset growth trend information threshold corresponding to the first traffic type;

[0154] The traffic restriction information is determined based on the growth trend information and the preset growth trend information threshold.

[0155] According to one or more embodiments of this disclosure, when the device is used to determine the traffic restriction information based on the growth trend information and the preset growth trend information threshold, it is specifically used for:

[0156] In response to the growth trend information being greater than the preset growth trend information threshold, the traffic restriction information is determined based on the first traffic type.

[0157] According to one or more embodiments of this disclosure, when the device is used to determine the traffic restriction information based on the first traffic type, it is specifically used to:

[0158] Obtain the priority indication information of the first traffic type;

[0159] 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;

[0160] 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.

[0161] According to one or more embodiments of this disclosure, the apparatus is further configured to:

[0162] Obtain at least one second query cost corresponding to at least one traffic source of 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 designated as the second traffic source corresponding to the first traffic type.

[0164] According to one or more embodiments of this disclosure, the apparatus is further configured to:

[0165] Obtain the first time metering unit corresponding to the first traffic type;

[0166] Obtain the first timestamp of the current moment;

[0167] The first time-attribution unit for the current moment is determined based on the first timestamp and the first time measurement unit;

[0168] The first time period is determined based on the first timestamp and the first time attribution unit.

[0169] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be referred to the method embodiments. To avoid repetition, they will not be repeated here. Specifically, the device can execute the above method embodiments, and the foregoing and other operations and / or functions of each module in the device correspond to the corresponding processes in the various methods in the above method embodiments, which will not be repeated here for the sake of brevity.

[0170] The apparatus of this disclosure embodiment has been described above from the perspective of functional modules in conjunction with the accompanying drawings. It should be understood that this functional module can be implemented in hardware, in software instructions, or in a combination of hardware and software modules. Specifically, the steps of the method embodiments in this disclosure can be completed by integrated logic circuits in the processor's hardware and / or by software instructions. The steps of the method disclosed in this disclosure embodiment can be directly embodied as being executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. Optionally, the software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps in the above method embodiments.

[0171] Figure 5 This is a schematic block diagram of an electronic device provided in an embodiment of this disclosure. The electronic device may include:

[0172] The system includes a memory 501 and a processor 502. The memory 501 stores computer programs and transfers the program code to the processor 502. In other words, the processor 502 can retrieve and run the computer programs from the memory 501 to implement the methods described in this embodiment.

[0173] For example, the processor 502 can be used to execute the above-described method embodiments according to instructions in the computer program.

[0174] In some embodiments of this disclosure, the processor 502 may include, but is not limited to:

[0175] General-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0176] In some embodiments of this disclosure, the memory 501 includes, but is not limited to:

[0177] Volatile memory and / or non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).

[0178] In some embodiments of this 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 perform the method provided in this disclosure. The one or more modules may be a series of computer program instruction segments capable of performing a specific function, which 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] Transceiver 503, which can be connected to processor 502 or memory 501.

[0181] The processor 502 can control the transceiver 503 to communicate with other devices; specifically, it can send information or data to other devices or receive information or data sent by other devices. The transceiver 503 may include a transmitter and a receiver. The transceiver 503 may further include antennas, 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 through a bus system, which includes a data bus, a power bus, a control bus, and a status signal bus.

[0183] This disclosure also provides a computer storage medium storing a computer program thereon, which, when executed by a computer, enables the computer to perform the methods of the above-described method embodiments. Alternatively, embodiments of this disclosure also provide a computer program product containing instructions that, when executed by a computer, cause the computer to perform the methods of the above-described method embodiments.

[0184] When implemented using software, it can be implemented wholly or partially as a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this disclosure are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0185] According to one or more embodiments of this disclosure, a query statement processing method is provided, including:

[0186] Retrieve the first database query statement;

[0187] Determine the 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 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 calculated fields.

[0188] Obtain preset traffic limit information;

[0189] The first database query statement is processed based on the first traffic information and the traffic restriction information.

[0190] According to one or more embodiments of this disclosure, processing the first database query statement based on the first traffic information and the traffic restriction information includes:

[0191] Determine whether there is any target restriction information in the traffic restriction information that matches the first traffic information; if so, then apply traffic restriction to the first database query statement.

[0192] According to one or more embodiments of this disclosure, the rate limiting of the first database query statement includes:

[0193] In response to the first database query statement being a read data statement, the first database query statement is allowed to read data from a slave database, where the slave database is a slave database of the original database corresponding to the first database query statement.

[0194] According to one or more embodiments of this disclosure, before obtaining the preset traffic limit information, the method further includes:

[0195] The first query cost of at least one second database query statement with the first traffic type obtained within the first time period is obtained. The first time period is a time period with the current time as the end time and the time corresponding to the first time unit of the current time as the start time.

[0196] Obtain the growth trend information of the first query cost within the first time period;

[0197] Obtain the preset growth trend information threshold corresponding to the first traffic type;

[0198] The traffic restriction information is determined based on the growth trend information and the preset growth trend information threshold.

[0199] According to one or more embodiments of this disclosure, determining the traffic restriction information based on the growth trend information and the preset growth trend information threshold includes:

[0200] If the growth trend information is greater than the preset growth trend information threshold, then the traffic restriction information is determined based on the first traffic type.

[0201] According to one or more embodiments of this disclosure, determining the traffic restriction information based on the first traffic type includes:

[0202] Obtain the priority indication information of the first traffic type;

[0203] 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;

[0204] 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.

[0205] According to one or more embodiments of this disclosure, the method further includes:

[0206] Obtain at least one second query cost corresponding to at least one traffic source of 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 designated as the second traffic source corresponding to the first traffic type.

[0208] According to one or more embodiments of this disclosure, the method further includes:

[0209] Obtain the first time metering unit corresponding to the first traffic type;

[0210] Obtain the first timestamp of the current moment;

[0211] The first time-attribution unit for the current moment is determined based on the first timestamp and the first time measurement unit;

[0212] The first time period is determined based on the first timestamp and the first time attribution unit.

[0213] According to one or more embodiments of the present disclosure, a data processing apparatus is provided, wherein the apparatus includes:

[0214] The acquisition unit is used to acquire the first database query statement;

[0215] The determining unit is used to determine the 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 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 calculated fields.

[0216] The acquisition unit is also used to acquire preset traffic restriction information;

[0217] The processing unit is used to process the first database query statement based on the first traffic information and the traffic restriction information.

[0218] According to one or more embodiments of this disclosure, when the apparatus is used to process the first database query statement based on the first traffic information and the traffic restriction information, it is specifically used for:

[0219] Determine whether there is any target restriction information in the traffic restriction information that matches the first traffic information; if so, then apply traffic restriction to the first database query statement.

[0220] According to one or more embodiments of this disclosure, when the device is used to rate limit the first database query statement, it is specifically used for:

[0221] In response to the first database query statement being a read data statement, the first database query statement is allowed to read data from a slave database, where the slave database is a slave database of the original database corresponding to the first database query statement.

[0222] According to one or more embodiments of this disclosure, before obtaining the preset traffic limit information, the device is further configured to:

[0223] The first query cost of at least one second database query statement with the first traffic type obtained within the first time period is obtained. The first time period is a time period with the current time as the end time and the time corresponding to the first time unit of the current time as the start time.

[0224] Obtain the growth trend information of the first query cost within the first time period;

[0225] Obtain the preset growth trend information threshold corresponding to the first traffic type;

[0226] The traffic restriction information is determined based on the growth trend information and the preset growth trend information threshold.

[0227] According to one or more embodiments of this disclosure, when the device is used to determine the traffic restriction information based on the growth trend information and the preset growth trend information threshold, it is specifically used for:

[0228] In response to the growth trend information being greater than the preset growth trend information threshold, the traffic restriction information is determined based on the first traffic type.

[0229] According to one or more embodiments of this disclosure, when the device is used to determine the traffic restriction information based on the first traffic type, it is specifically used to:

[0230] Obtain the priority indication information of the first traffic type;

[0231] 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;

[0232] 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.

[0233] According to one or more embodiments of this disclosure, the apparatus is further configured to:

[0234] Obtain at least one second query cost corresponding to at least one traffic source of 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 designated as the second traffic source corresponding to the first traffic type.

[0236] According to one or more embodiments of this disclosure, the apparatus is further configured to:

[0237] Obtain the first time metering unit corresponding to the first traffic type;

[0238] Obtain the first timestamp of the current moment;

[0239] The first time-attribution unit for the current moment is determined based on the first timestamp and the first time measurement unit;

[0240] The first time period is determined based on the first timestamp and the first time attribution unit.

[0241] According to one or more embodiments of this disclosure, this disclosure provides an electronic device, including:

[0242] Processor; and

[0243] Memory for storing the executable instructions of the processor;

[0244] The processor is configured to execute the methods described above by executing the executable instructions.

[0245] According to one or more embodiments of the present disclosure, the present disclosure provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the aforementioned methods.

[0246] Those skilled in the art will recognize that the modules and algorithm steps of the various examples 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 implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.

[0247] In the embodiments provided in this disclosure, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0248] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. For example, the functional modules in the various embodiments of this disclosure may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0249] The above are merely specific embodiments of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.

Claims

1. A query statement processing method, characterized in that, include: Retrieve the first database query statement; Determine the 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 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 calculated fields. Obtain preset traffic limit information; The first database query statement is processed based on the first traffic information and the traffic restriction information; Before obtaining the preset traffic limit information, the method further includes: The first query cost of at least one second database query statement with the first traffic type obtained within the first time period is obtained. The first time period is a time period with the current time as the end time and the time corresponding to the first time unit of the current time as the start time. Obtain the growth trend information of the first query cost within the first time period; Obtain the preset growth trend information threshold corresponding to the first traffic type; The traffic restriction information is determined based on the growth trend information and the preset growth trend information threshold.

2. The method according to claim 1, characterized in that, The process of processing the first database query statement based on the first traffic information and the traffic restriction information includes: Determine whether there is any target restriction information in the traffic restriction information that matches the first traffic information; if so, then apply traffic restriction to the first database query statement.

3. The method according to claim 2, characterized in that, The rate limiting of the first database query statement includes: In response to the first database query statement being a read data statement, the first database query statement is allowed to read data from a slave database, where the slave database is a slave database of the original database corresponding to the first database query statement.

4. The method according to claim 1, characterized in that, Determining the traffic restriction 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, the traffic restriction information is determined based on the first traffic type.

5. The method according to claim 4, characterized in that, Determining the traffic restriction information based on the first traffic type includes: Obtain the priority indication information of the first traffic type; 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.

6. The method according to claim 5, characterized in that, The method further includes: Obtain at least one second query cost corresponding to at least one traffic source of 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 designated as the second traffic source corresponding to the first traffic type.

7. The method according to claim 1, characterized in that, The method further includes: Obtain the first time metering unit corresponding to the first traffic type; Obtain the first timestamp of the current moment; The first time-attribution unit for the current moment is determined based on the first timestamp and the first time measurement unit; The first time period is determined based on the first timestamp and the first time attribution unit.

8. A query statement processing device, characterized in that, include: The acquisition unit is used to acquire the first database query statement; The determining unit is used to determine the 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 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 calculated fields. The acquisition unit is also used to acquire preset traffic restriction information; The processing unit is configured to process the first database query statement based on the first traffic information and the traffic restriction information; The acquisition unit is further configured to acquire the first query cost of at least one second database query statement of the first traffic type acquired within a first time period, wherein the first time period is a time period ending at the current time and starting at the time corresponding to the first time unit of the current time; acquire the growth trend information of the first query cost within the first time period; and acquire the preset growth trend information threshold corresponding to the first traffic type. The traffic restriction information is determined based on the growth trend information and the preset growth trend information threshold.

9. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the method of any one of claims 1-7 by executing the executable instructions.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-7.

Citation Information

Patent Citations

  • System and method of site traffic control

    CN107534586A

  • Service traffic limiting method based on database storage process design

    CN115208834A