Request processing method and device, equipment and computer medium

By identifying the target query fingerprint and query cost of database query requests, the current limiting threshold is dynamically adjusted to achieve precise current limiting for slow query statements, solving the problem of low efficiency of traditional current limiting methods and improving database resource utilization and system stability.

CN118656382APending Publication Date: 2024-09-17BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410693031.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-30
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

On aPaaS platform with multi-tenants and multiple application packages, slow queries cause fatal damage to the database. The traditional current limiting method is inefficient and cannot effectively identify and limit slow queries, resulting in excessive database resource usage and affecting business stability.

Method used

By obtaining the database query request, determining its target query fingerprint and query cost, and deciding whether to limit the flow based on the number of queues and thresholds, it can achieve precise flow limiting for slow query statements and improve the accuracy and efficiency of flow limiting.

Benefits of technology

It improves the current limiting accuracy and granularity of slow query statements, reduces the occupation of database resources, improves system stability, and avoids accidental damage to SQL during repeated restrictions and recovery processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656382A
    Figure CN118656382A
Patent Text Reader

Abstract

The invention discloses a request processing method and device, equipment and a computer medium, and the method comprises the steps: obtaining a first database query request, the first database query request comprises a first database query statement, and the first database query statement is a slow query statement; determining a target query fingerprint corresponding to the first database query request, wherein the target query fingerprint is used for indicating a service category to which the first database query request belongs; obtaining a queuing request number corresponding to the target query fingerprint and a queuing number threshold value corresponding to the target query fingerprint, wherein the queuing number threshold value is determined based on the query cost of the first database query statement; and determining whether to limit the flow of the query request of the first database based on the number of the queuing requests and the queuing number threshold value, so that the effect of higher limiting efficiency can be achieved when the flow of the slow query statement is limited.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the field of database technology, and in particular, relates to a request processing method, device, equipment and computer medium. Background Art

[0002] aPaaS is an application service as a platform. Developers can build data models on the aPaaS platform without code. The objects and fields of the data model are equivalent to the tables and fields of the database. When the objects are put into use, the amount of data becomes larger and larger, and the user's queries become more and more complex, which will lead to the problem of slow queries in the database. At the database level, taking MySQL as an example, slow queries are fatal to MySQL, occupying the CPU and IO resources of the MySQL server, causing a serious decrease in MySQL's throughput. On the aPaaS platform with multiple tenants and multiple application packages, a small number of slow queries may seriously affect the DB (Database), causing abnormalities in the tenants and application packages on the DB.

[0003] For uncertain slow SQL (Structured Query Language) restriction solutions, it is generally similar to TCP (Transmission Control Protocol) congestion control solutions. When SQL queries become slow, the corresponding qps (Queries-per-second) will be reduced. In the aPaaS platform, the SQL at the application package granularity is targeted. If the SQL starts to slow down, the SQL at the application package granularity is restricted until the SQL latency is reduced, and then the restriction is stopped. This is a repeated restriction-recovery process, which causes more accidental SQL damage and has a low efficiency in restricting slow database query statements. 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 in the related art that when restricting the access of slow database query statements to a database, the restriction efficiency of slow database query statements is low.

[0005] In a first aspect, the present disclosure provides a request processing method, comprising:

[0006] Obtaining a first database query request, where the first database query request includes a first database query statement, and the first database query statement is a slow query statement;

[0007] Determine a target query fingerprint corresponding to the first database query request, where the target query fingerprint is used to indicate a business category to which the first database query request belongs;

[0008] Obtaining the number of queued requests corresponding to the target query fingerprint and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on a query cost of the first database query statement;

[0009] Determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold.

[0010] In a second aspect, the present disclosure provides a request processing device, including:

[0011] An acquiring unit, configured to acquire a first database query request, wherein the first database query request includes a first database query statement, and the first database query statement is a slow query statement;

[0012] a determining unit, configured to determine a target query fingerprint corresponding to the first database query request, wherein the target query fingerprint is used to indicate a service category to which the first database query request belongs;

[0013] The acquisition unit is further configured to acquire the number of queued requests corresponding to the target query fingerprint and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on a query cost of the first database query statement;

[0014] The determining unit is further configured to determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold.

[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 request, wherein the first database query request includes a first database query statement, and the first database query statement is a slow query statement; determining a target query fingerprint corresponding to the first database query request, wherein the target query fingerprint is used to indicate a business category to which the first database query request belongs; obtaining the number of queued requests corresponding to the target query fingerprint, and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on a query cost of the first database query statement; and determining whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold, so that the slow query statements can be limited according to the business category, and the accuracy of limiting the flow of slow query statements is higher, the granularity is smaller, and the limiting efficiency is higher. 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 1 A schematic diagram of a configuration of an aPaaS platform DB provided in an embodiment of the present disclosure;

[0023] Figure 2 A schematic diagram of the structure of a system provided by an embodiment of the present disclosure;

[0024] Figure 3 A flowchart of a request processing method provided by an embodiment of the present disclosure;

[0025] Figure 4 A schematic diagram of the structure of a request processing device provided by an embodiment of the present disclosure;

[0026] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

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

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

[0029] First, some terms in the embodiments of the present disclosure are explained below to facilitate understanding by those skilled in the art.

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

[0031] Database query statements refer to statements whose response time exceeds the threshold in the slow query log, that is, SQL statements whose specific running time exceeds the long_query_time value.

[0032] The incr command is used to perform an increment operation on the specified key.

[0033] The decr command is used to perform a self-decrement operation on the specified key.

[0034] find(): find() is a command used to query data records that meet specific conditions. It can query the database for records that meet the conditions according to the specified conditions and return a result set. The result of find() is a data set that contains all records that meet the conditions. Therefore, the results of count() and find() are different. Count() returns an integer, indicating the number of records that meet the conditions; while find() returns a data set that contains all records that meet the conditions.

[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] Developers can build data models without code on the aPaaS platform. The objects and fields of the data model are equivalent to the tables and fields of the database. When the objects are put into use, the amount of data becomes larger and larger, and the user's queries become more and more complex, which will lead to the problem of slow query in the database. At the database level, taking MySQL as an example, slow query is fatal to MySQL, which will occupy the CPU and IO resources of the MySQL server and seriously reduce the throughput of MySQL. On the aPaaS platform with multiple tenants and multiple application packages, a small number of slow queries may seriously affect the DB, causing abnormal business of tenants and application packages on the DB.

[0039] Traditional backend business systems customize the query SQL, which will try to avoid slow queries. Even if there are slow queries, the qps (queries per second) will be limited to a low level. Figure 1 As shown in the figure, multi-tenant and multi-application packages are deployed on the aPaaS DB. As the number of tenants and application packages continues to increase, the qps flow limit for tenant application packages cannot solve the slow query problem. In addition, the query conditions configured by developers in aPaaS codeless or low-code are translated into a variety of SQL statements, and the pressure on the DB is uncertain, so it is impossible to identify which queries are slow.

[0040] Therefore, it is crucial to identify slow queries and use more flexible current limiting methods to limit slow queries.

[0041] The industry's solution for limiting uncertain slow SQL is generally similar to the TCP (Transmission Control Protocol) congestion control solution. When the SQL query is found to be slow, the QPS will be reduced. In the context of aPaaS, the SQL at the application package granularity is targeted. If the SQL starts to slow down, the SQL at the application package granularity is limited until the SQL latency is reduced, and then the limitation is stopped. This is a repeated limitation-recovery process, which causes more SQL to be accidentally damaged, and the limitation efficiency of the first database query statement is low.

[0042] In this application, when it comes to measuring the pressure that database query statements cause 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.

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

[0044] Figure 2 A schematic diagram of a system structure provided by an exemplary embodiment of the present disclosure, the structure comprising:

[0045] 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:

[0046] The business server is used to: obtain a first database query request for accessing a database, the first database query request may include a first database query statement, and the first database query statement is a slow query statement; optionally, the first database query request may be sent by a user device or generated based on an automatic trigger mechanism.

[0047] The data server is used to: obtain a first database query request from a business server, where the first database query request includes a first database query statement, and the first database query statement is a slow query statement;

[0048] Determine a target query fingerprint corresponding to the first database query request, where the target query fingerprint is used to indicate a business category to which the first database query request belongs;

[0049] Obtaining the number of queued requests corresponding to the target query fingerprint and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on a query cost of the first database query statement;

[0050] Determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold.

[0051] The database is used to be accessed by the first database query statement in the first database query request.

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

[0053] Figure 3 A flowchart of a request 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:

[0054] S201. Obtain a first database query request, where the first database query request includes a first database query statement, and the first database query statement is a slow query statement;

[0055] Optionally, when the query cost of the first database query statement exceeds a preset cost threshold, the first database query statement is determined to be a slow query statement. Specifically, the above method also includes: in response to the query cost exceeding the preset cost threshold, determining that the first database query statement is a slow query statement.

[0056] Optionally, the first database query request may be any database query request for accessing a target database.

[0057] In some optional embodiments of the present 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, the present 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 query cost corresponding to each query statement.

[0058] S202: Determine a target query fingerprint corresponding to the first database query request, where the target query fingerprint is used to indicate a business category to which the first database query request belongs;

[0059] In some optional embodiments of the present application, in the aforementioned S202, determining the target query fingerprint corresponding to the first database query request includes the following steps S2021-S2022:

[0060] S2021. Obtain request information of the first database query request, where the request information of the first database query request includes at least one of the following first information: an application package identifier in the first database query request, a table name of a target database accessed by the first database query request, a sorting condition of the first database query request, and partial content of the query condition corresponding to the first database query request;

[0061] In some optional embodiments of the present application, part of the aforementioned query conditions may refer to: the remaining query conditions after removing the right value from the query conditions.

[0062] S2022. Determine a target query fingerprint corresponding to the first database query request based on a hash operation result of the request information.

[0063] Specifically, the at least one first information mentioned above may be concatenated, and a hash operation may be performed on the concatenated first information to obtain a hash operation result of the request information.

[0064] Since requests with the same hash operation results can generally be classified as requests for the same business scenario, and their time consumption and other aspects will have certain commonalities, the aforementioned hash operation results can be used as target query fingerprints in this application.

[0065] In some optional embodiments of the present application, in S2022, based on the hash operation result of the request information, determining the target query fingerprint corresponding to the first database query request includes: using the hash operation result of the request information as the target query fingerprint corresponding to the first database query request.

[0066] In some other optional embodiments of the present application, in S2022, determining the target query fingerprint corresponding to the first database query request based on the hash operation result of the request information includes:

[0067] Acquire at least one of the following second information of the first database query request: a tenant identifier of a tenant to which the first database query request belongs, a request type of the first database query request, and a time when the first database query request is acquired;

[0068] The aforementioned hash operation result is concatenated with the following at least one second information to obtain a target query fingerprint corresponding to the first database query request.

[0069] Specifically, the tenant identifier refers to the Tenant ID. For ISV (Independent Software Vendors) applications, the number of records of different tenants is different, and the query performance impact is also different.

[0070] The request type of the first database query request can be Count() or Find(). Count() and find() are commonly used database operation commands, which are used to query and count data in the database. Their results are different, as follows: count() is a command used to count the number of data records that meet specific conditions. It can query the number of records that meet the conditions in the database according to the specified conditions and return the results. The result of count() is an integer, which represents the number of records that meet the conditions. find() is a command used to query data records that meet specific conditions. It can query the records that meet the conditions in the database according to the specified conditions and return a result set. The result of find() is a data set containing all records that meet the conditions.

[0071] Therefore, the results of count() and find() are different. count() returns an integer indicating the number of records that meet the criteria, while find() returns a dataset containing all records that meet the criteria.

[0072] Under the same query filtering conditions, Count() queries are usually more performance-intensive than Find() queries.

[0073] Optionally, the acquisition time of the aforementioned first database query request may refer to TimeSuffix, which may be accurate to minutes, which is equivalent to playing the role of a fixed counting time window.

[0074] S203, obtaining the number of queued requests corresponding to the target query fingerprint and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on the query cost of the first database query statement;

[0075] Specifically, for the target database accessed by the first database query request, all record IDs and -isDeleted fields can be queried in pages, and the number of record IDs on each page and the number of _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 object records for each field in the target database. In addition, the present application also includes determining the following database information corresponding to each field in the target database: null value rate, number of different values, high-frequency word information, and histogram information corresponding to the target database. The aforementioned database information can be used to determine the query cost corresponding to the first database query statement.

[0076] Optionally, the determination of the query cost corresponding to the first database query statement may also refer to related technologies, which will not be elaborated here.

[0077] The number of queued requests in the present application can be used to determine the accumulation of slow query requests. In some optional embodiments of the present application, the method further includes: determining the queue number threshold based on the query cost of the first database query statement, and determining the queue number threshold based on the query cost of the first database query statement includes the following steps S31-S33:

[0078] S31, determining a target cost interval to which the query cost belongs from a plurality of preset cost intervals;

[0079] Optionally, a plurality of preset cost intervals may be set in advance.

[0080] S32, determining a target concurrent request threshold corresponding to the target cost interval according to a preset correspondence relationship between the target cost interval, wherein the preset correspondence relationship includes a plurality of cost intervals and a concurrent request threshold corresponding to each cost interval;

[0081] Optionally, determining a target concurrent request threshold corresponding to the target cost interval based on the target cost interval and a preset correspondence includes: taking the concurrent request threshold corresponding to the cost interval that is the same as the target cost interval in the preset correspondence as the target concurrent request threshold corresponding to the target cost interval.

[0082] Optionally, the aforementioned concurrent request threshold in the present application is when the engine layer query is optimized, and the best index and the number of records matching the index will be selected based on the record statistical information. This data reflects the query cost; the specific rule is to divide the number of matching records into different levels, that is, the aforementioned multiple preset cost intervals, and the concurrent request thresholds allowed for different levels are different.

[0083] Optionally, the aforementioned preset corresponding relationship may be a table. For example, the preset corresponding relationship may be as shown in Table 1.

[0084] Table 1 Preset correspondence

[0085] Price Range Concurrent request threshold <=1000 120 <=5000 77 <=10000 45 <=30000 16 <=100000 8 >100000 3

[0086] S33: Use the target concurrent request threshold as the queue quantity threshold.

[0087] S204: Determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold.

[0088] In some optional embodiments of the present application, in the aforementioned S204, the determining whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold includes: in response to the number of queued requests being greater than the queued number threshold, limiting the flow of the first database query request; in response to the number of queued requests being not greater than the queued number threshold, allowing the first database query request to access the target database.

[0089] The limiting of the flow of the first database query request refers to not allowing the first database query request to access a target database. The target database is a database to be accessed by the first database query request.

[0090] In some optional embodiments of the present application, the method further includes: in response to detecting that the first database query request has been obtained, controlling the number of queued requests to increase by 1; in response to detecting that the first database query request has been processed, controlling the number of queued requests to decrease by 1.

[0091] It should be noted that, each time a second database query request corresponding to the target query fingerprint is obtained, the number of queued requests corresponding to the target query fingerprint is controlled to increase by 1, and each time a second database query request corresponding to the target query fingerprint is processed, the number of queued requests corresponding to the target query fingerprint is controlled to decrease by 1. The second database query request is a database query request whose fingerprint is the same as the target query fingerprint.

[0092] In some optional embodiments of the present application, the method further includes the following S1-S2:

[0093] S1. Obtaining an update instruction for the preset corresponding relationship;

[0094] S2. Update the preset corresponding relationship based on the update instruction.

[0095] This solution can dynamically adjust the concurrent request thresholds corresponding to different cost intervals, making the current limiting of slow query statements more flexible.

[0096] In addition, in some optional embodiments of the present application, when the number of queued requests is greater than the queued number threshold, the first database query request may not be directly limited, but only an alarm log may be issued and the first database query request may be processed normally. This can be used to observe whether the queued number threshold is reasonable in the initial stage of going online, and the queued number threshold may be adjusted when it is unreasonable. In some emergency situations, in the present application, the flow limiting of certain database query requests may also be turned off to avoid affecting the business.

[0097] In order to further illustrate the solution of the present application, the solution is further illustrated below in conjunction with an embodiment, and the solution includes:

[0098] The main solutions provided in this application are:

[0099] S001. Obtain a database query request, for example, the first data query request mentioned above;

[0100] S002, obtaining the application package identifier in the database query request, the table name of the target database accessed by the database query request, the sorting condition of the database query request, and part of the query condition corresponding to the database query request; concatenating the multiple pieces of information and calculating a hash value, which is the target query fingerprint corresponding to the database query request (database query statement A);

[0101] S003, calculating the query cost of the database query statement in the database query request;

[0102] When the query cost of the database query statement exceeds the preset cost threshold, the database query statement is determined to be a slow query statement, and the following steps are performed;

[0103] S004, determining a target cost interval to which the query cost belongs according to a plurality of preset cost intervals;

[0104] S005. Determine a corresponding target concurrent request threshold according to the target cost interval and a preset corresponding relationship;

[0105] S006, using the target concurrent request threshold as the queue quantity threshold corresponding to the target query fingerprint;

[0106] S007, obtaining the number of queued requests whose fingerprint is the target query fingerprint, that is, the number of queued requests;

[0107] When the number of requests in the queue is greater than the queue number threshold, the following step S008 is executed; when the number of requests in the queue is not greater than the queue number threshold, the following steps S008-S009 are executed;

[0108] S008, limiting the flow of the database query request;

[0109] S009, processing the database query request, that is, allowing the database query request to access the target database;

[0110] Among them, when the database query request is received, the INCR operation is performed on the query fingerprint in redis to control the number of requests in the queue of the target query fingerprint of the database query request to increase by 1. When it is detected that the database query request has been processed, the DECR operation is performed on the target query fingerprint in redis to control the number of requests in the queue of the target query fingerprint to decrease by 1.

[0111] The present disclosure provides a method for obtaining a first database query request, wherein the first database query request includes a first database query statement, and the first database query statement is a slow query statement; determining a target query fingerprint corresponding to the first database query request, wherein the target query fingerprint is used to indicate a business category to which the first database query request belongs; obtaining the number of queued requests corresponding to the target query fingerprint, and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on a query cost of the first database query statement; and determining whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold, so that the slow query statements can be limited according to the business category, the accuracy of limiting the flow of slow query statements is higher, the granularity is smaller, the limiting efficiency is higher, and the stability of the system is better.

[0112] Figure 4 A schematic diagram of a request processing device provided by an exemplary embodiment of the present disclosure, the device comprising:

[0113] An acquiring unit 41 is configured to acquire a first database query request, where the first database query request includes a first database query statement, and the first database query statement is a slow query statement;

[0114] A determination unit 42, configured to determine a target query fingerprint corresponding to the first database query request, wherein the target query fingerprint is used to indicate a service category to which the first database query request belongs;

[0115] The acquisition unit 41 is further configured to acquire the number of queued requests corresponding to the target query fingerprint and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on a query cost of the first database query statement;

[0116] The determining unit 42 is further configured to determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold.

[0117] According to one or more embodiments of the present disclosure, the device is further used to: determine the queue quantity threshold based on the query cost of the first database query statement, and when the device is used to determine the queue quantity threshold based on the query cost of the first database query statement, it is specifically used to:

[0118] Determining a target cost interval to which the query cost belongs from a plurality of preset cost intervals;

[0119] Determine a target concurrent request threshold corresponding to the target cost interval according to a preset correspondence relationship between the target cost interval, wherein the preset correspondence relationship includes a plurality of cost intervals and a concurrent request threshold corresponding to each cost interval;

[0120] The target concurrent request threshold is used as the queue quantity threshold.

[0121] According to one or more embodiments of the present disclosure, when the device is used to determine the target query fingerprint corresponding to the first database query request, it is specifically used to:

[0122] Obtaining request information of the first database query request, where the request information of the first database query request includes at least one of the following first information: an application package identifier in the first database query request, a table name of a target database accessed by the first database query request, a sorting condition of the first database query request, and partial content of the query condition corresponding to the first database query request;

[0123] Based on the hash operation result of the request information, a target query fingerprint corresponding to the first database query request is determined.

[0124] According to one or more embodiments of the present disclosure, the device is further used for:

[0125] In response to detecting that the first database query request has been obtained, controlling the number of queued requests to increase by 1;

[0126] In response to detecting that the first database query request has been processed, controlling the number of queued requests to decrease by 1.

[0127] According to one or more embodiments of the present disclosure, when the device is used to determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold, it is specifically used to:

[0128] In response to the number of queued requests being greater than the queued number threshold, limiting the flow of the first database query request;

[0129] In response to the number of queued requests being not greater than the queued number threshold, allowing the first database query request to access the target database.

[0130] According to one or more embodiments of the present disclosure, the device is further used for:

[0131] Obtaining an update instruction for the preset corresponding relationship;

[0132] The preset corresponding relationship is updated based on the update instruction.

[0133] According to one or more embodiments of the present disclosure, the device is further used for:

[0134] In response to the query cost exceeding a preset cost threshold, the first database query statement is determined to be a slow query statement.

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

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

[0137] 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:

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

[0139] For example, the processor 502 may be configured to execute the above method embodiments according to instructions in the computer program.

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

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

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

[0143] 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), synchlink DRAM (SLDRAM), and direct RAM bus random access memory (DRRAM).

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

[0145] like Figure 5 As shown, the electronic device may also include:

[0146] The transceiver 503 may be connected to the processor 502 or the memory 501 .

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

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

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

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

[0151] According to one or more embodiments of the present disclosure, a request processing method is provided, including:

[0152] Obtaining a first database query request, where the first database query request includes a first database query statement, and the first database query statement is a slow query statement;

[0153] Determine a target query fingerprint corresponding to the first database query request, where the target query fingerprint is used to indicate a business category to which the first database query request belongs;

[0154] Obtaining the number of queued requests corresponding to the target query fingerprint and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on a query cost of the first database query statement;

[0155] Determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold.

[0156] According to one or more embodiments of the present disclosure, the method further includes: determining the queue quantity threshold based on the query cost of the first database query statement, wherein the determining the queue quantity threshold based on the query cost of the first database query statement includes:

[0157] Determining a target cost interval to which the query cost belongs from a plurality of preset cost intervals;

[0158] Determine a target concurrent request threshold corresponding to the target cost interval according to a preset correspondence relationship between the target cost interval, wherein the preset correspondence relationship includes a plurality of cost intervals and a concurrent request threshold corresponding to each cost interval;

[0159] The target concurrent request threshold is used as the queue quantity threshold.

[0160] According to one or more embodiments of the present disclosure, determining the target query fingerprint corresponding to the first database query request includes:

[0161] Obtaining request information of the first database query request, where the request information of the first database query request includes at least one of the following first information: an application package identifier in the first database query request, a table name of a target database accessed by the first database query request, a sorting condition of the first database query request, and partial content of the query condition corresponding to the first database query request;

[0162] Based on the hash operation result of the request information, a target query fingerprint corresponding to the first database query request is determined.

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

[0164] In response to detecting that the first database query request has been obtained, controlling the number of queued requests to increase by 1;

[0165] In response to detecting that the first database query request has been processed, controlling the number of queued requests to decrease by 1.

[0166] According to one or more embodiments of the present disclosure, the determining whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold includes:

[0167] In response to the number of queued requests being greater than the queued number threshold, limiting the flow of the first database query request;

[0168] In response to the number of queued requests being not greater than the queued number threshold, allowing the first database query request to access the target database.

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

[0170] Obtaining an update instruction for the preset corresponding relationship;

[0171] The preset corresponding relationship is updated based on the update instruction.

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

[0173] In response to the query cost exceeding a preset cost threshold, the first database query statement is determined to be a slow query statement.

[0174] According to one or more embodiments of the present disclosure, a request processing device is provided, including:

[0175] An acquiring unit, configured to acquire a first database query request, wherein the first database query request includes a first database query statement, and the first database query statement is a slow query statement;

[0176] a determining unit, configured to determine a target query fingerprint corresponding to the first database query request, wherein the target query fingerprint is used to indicate a service category to which the first database query request belongs;

[0177] The acquisition unit is further configured to acquire the number of queued requests corresponding to the target query fingerprint and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on a query cost of the first database query statement;

[0178] The determining unit is further configured to determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold.

[0179] According to one or more embodiments of the present disclosure, the device is further used to: determine the queue quantity threshold based on the query cost of the first database query statement, and when the device is used to determine the queue quantity threshold based on the query cost of the first database query statement, it is specifically used to:

[0180] Determining a target cost interval to which the query cost belongs from a plurality of preset cost intervals;

[0181] Determine a target concurrent request threshold corresponding to the target cost interval according to a preset correspondence relationship between the target cost interval, wherein the preset correspondence relationship includes a plurality of cost intervals and a concurrent request threshold corresponding to each cost interval;

[0182] The target concurrent request threshold is used as the queue quantity threshold.

[0183] According to one or more embodiments of the present disclosure, when the device is used to determine the target query fingerprint corresponding to the first database query request, it is specifically used to:

[0184] Obtaining request information of the first database query request, where the request information of the first database query request includes at least one of the following first information: an application package identifier in the first database query request, a table name of a target database accessed by the first database query request, a sorting condition of the first database query request, and partial content of the query condition corresponding to the first database query request;

[0185] Based on the hash operation result of the request information, a target query fingerprint corresponding to the first database query request is determined.

[0186] According to one or more embodiments of the present disclosure, the device is further used for:

[0187] In response to detecting that the first database query request has been obtained, controlling the number of queued requests to increase by 1;

[0188] In response to detecting that the first database query request has been processed, controlling the number of queued requests to decrease by 1.

[0189] According to one or more embodiments of the present disclosure, when the device is used to determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold, it is specifically used to:

[0190] In response to the number of queued requests being greater than the queued number threshold, limiting the flow of the first database query request;

[0191] In response to the number of queued requests being not greater than the queued number threshold, allowing the first database query request to access the target database.

[0192] According to one or more embodiments of the present disclosure, the device is further used for:

[0193] Obtaining an update instruction for the preset corresponding relationship;

[0194] The preset corresponding relationship is updated based on the update instruction.

[0195] According to one or more embodiments of the present disclosure, the device is further used for:

[0196] In response to the query cost exceeding a preset cost threshold, the first database query statement is determined to be a slow query statement.

[0197] According to one or more embodiments of the present disclosure, the present disclosure provides an electronic device, including:

[0198] Processor; and

[0199] A memory, configured to store executable instructions of the processor;

[0200] The processor is configured to perform the above methods by executing the executable instructions.

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

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

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

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

[0205] 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 request processing method, It is characterized in that include: Obtaining a first database query request, where the first database query request includes a first database query statement, and the first database query statement is a slow query statement; Determine a target query fingerprint corresponding to the first database query request, where the target query fingerprint is used to indicate a business category to which the first database query request belongs; Obtaining the number of queued requests corresponding to the target query fingerprint and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on a query cost of the first database query statement; Determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold.

2. The method according to claim 1, It is characterized in that The method further includes: determining the queue quantity threshold based on the query cost of the first database query statement, wherein determining the queue quantity threshold based on the query cost of the first database query statement includes: Determining a target cost interval to which the query cost belongs from a plurality of preset cost intervals; Determine a target concurrent request threshold corresponding to the target cost interval according to a preset correspondence relationship between the target cost interval, wherein the preset correspondence relationship includes a plurality of cost intervals and a concurrent request threshold corresponding to each cost interval; The target concurrent request threshold is used as the queue quantity threshold.

3. The method according to claim 1, It is characterized in that The determining the target query fingerprint corresponding to the first database query request includes: Obtaining request information of the first database query request, where the request information of the first database query request includes at least one of the following first information: an application package identifier in the first database query request, a table name of a target database accessed by the first database query request, a sorting condition of the first database query request, and partial content of the query condition corresponding to the first database query request; Based on the hash operation result of the request information, a target query fingerprint corresponding to the first database query request is determined.

4. The method according to claim 1, It is characterized in that The method further comprises: In response to detecting that the first database query request has been obtained, controlling the number of queued requests to increase by 1; In response to detecting that the first database query request has been processed, controlling the number of queued requests to decrease by 1.

5. The method according to claim 1, It is characterized in that The determining whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold includes: In response to the number of queued requests being greater than the queued number threshold, limiting the flow of the first database query request; In response to the number of queued requests being not greater than the queued number threshold, allowing the first database query request to access the target database.

6. The method according to claim 2, It is characterized in that The method further comprises: Obtaining an update instruction for the preset corresponding relationship; The preset corresponding relationship is updated based on the update instruction.

7. The method according to claim 2, It is characterized in that The method further comprises: In response to the query cost exceeding a preset cost threshold, the first database query statement is determined to be a slow query statement.

8. A request processing device, It is characterized in that include: An acquiring unit, configured to acquire a first database query request, wherein the first database query request includes a first database query statement, and the first database query statement is a slow query statement; a determining unit, configured to determine a target query fingerprint corresponding to the first database query request, wherein the target query fingerprint is used to indicate a service category to which the first database query request belongs; The acquisition unit is further configured to acquire the number of queued requests corresponding to the target query fingerprint and a queued number threshold corresponding to the target query fingerprint, wherein the queued number threshold is determined based on a query cost of the first database query statement; The determining unit is further configured to determine whether to limit the flow of the first database query request based on the number of queued requests and the queued number threshold.

9. 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 7 by executing the executable instructions.

10. 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 7 is implemented.