Distributed database read request scheduling method, device and electronic device

By obtaining the historical delay data of the master copy and determining the delay threshold, the read request is dynamically scheduled to the slave copy, which solves the problem of large read request delay in distributed clusters and improves response efficiency and scheduling effect.

CN117827973BActive Publication Date: 2024-10-18云和恩墨(北京)信息技术有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311865825.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2024-10-18
Estimated Expiration
2043-12-29

AI Technical Summary

Technical Problem

The latency of read requests in distributed clusters is relatively large, which is difficult to effectively solve with existing technologies, mainly due to poor scheduling effects caused by hardware performance bottlenecks and abnormal nodes.

Method used

By obtaining the historical latency data of the primary replica, the latency threshold is determined, and when the waiting time exceeds the threshold, the read request is scheduled to the secondary replica, and the read request routing is dynamically adjusted to improve response efficiency.

Benefits of technology

It improves the response efficiency and scheduling effect of read requests, solves the problem of poor read request scheduling, adapts to changes in hardware conditions, and improves the overall performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117827973B_ABST
    Figure CN117827973B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device and electronic device for scheduling read requests of a distributed database. The method comprises: obtaining a delay data set of a master copy in a distributed database, wherein the delay data set comprises: a preset number of historical delay data intercepted from a plurality of historical delay data, each historical delay data is used to represent the delay of the master copy to the first read request that has been responded to; determining a delay threshold according to the delay data set; detecting the waiting time of the second read request that has not been responded to in the master copy; and scheduling the second read request to the slave copy of the master copy when the waiting time exceeds the delay threshold. The present invention solves the technical problem of poor scheduling effect for read requests.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a method, device and electronic equipment for scheduling read requests of a distributed database. Background Art

[0002] There may be many reasons for the long latency of read requests in distributed systems. It is possible that the CPU, memory and other equipment hardware of some nodes have reached performance bottlenecks, or the physical condition of some hard disks or frequent reading and writing have caused performance degradation. This node is the primary copy, which leads to long latency of read requests. Since distributed storage systems are often used in large-scale storage, it is common for some nodes or some hard disks of a node in a large-scale cluster to perform abnormally.

[0003] In this context, in order to solve the read request latency performance under unreliable hardware conditions in distributed clusters, there are currently several main processing methods:

[0004] Solution 1: Based on the collection system and detection system, abnormal nodes or risk disks are detected and read-only access is performed. At the same time, replicas or nodes of the data involved can be added and expanded. Subsequently, isolation or removal operations are carried out depending on the degree of status degradation.

[0005] Solution 2: Set a timeout. Once the read request times out, an error is returned or the request is retried to another replica.

[0006] However, the above solution 1 mainly adopts the method of active monitoring, identification and disposal. In this method, it takes a certain amount of time to actively monitor and identify nodes or hard disks with abnormal performance, and the entire processing flow is complicated. It takes a long time from discovering the abnormality to restoring normal latency performance. Although the above solution 2 adopts a retry mechanism, it is difficult to set the timeout time more accurately. If the timeout time is set to a long time, the retry purpose will not be achieved. If the timeout time is set to a short time, more requests will be retried, which will affect the overall performance.

[0007] Currently, no effective solution has been proposed to the above-mentioned problem of poor scheduling effect for read requests. Summary of the invention

[0008] The embodiments of the present invention provide a method, device and electronic device for scheduling read requests of a distributed database, so as to at least solve the technical problem of poor scheduling effect of read requests.

[0009] According to one aspect of an embodiment of the present invention, there is provided a method for scheduling read requests of a distributed database, comprising: obtaining a latency data set of a master replica in a distributed database, wherein the latency data set comprises: a preset number of historical latency data intercepted from a plurality of historical latency data, each of the historical latency data being used to represent the latency of the master replica to a first read request that has been responded to; determining a latency threshold based on the latency data set; detecting a waiting time of a second read request that has not been responded to in the master replica; and scheduling the second read request to a slave replica of the master replica if the waiting time exceeds the latency threshold.

[0010] Optionally, obtaining the latency data set of the master copy in the distributed database includes: collecting multiple historical latency data of the master copy in the distributed database according to a preset collection frequency; determining the request time of the first read request corresponding to each of the historical latency data; arranging the multiple historical latency data in the order of the request times to obtain a first latency sequence; and intercepting the preset number of historical latency data with the tail end of the first latency sequence as the starting point to obtain the latency data set.

[0011] Optionally, obtaining the delay data set of the master copy in the distributed database includes: collecting preset delay data generated by the master copy in response to a third read request in the distributed database, wherein the response time of the third read request is later than that of the first read request; in the historical delay data set, eliminating the historical delay data generated by the first read request with the earliest response time to obtain the delay data set to be updated; and putting the preset delay data into the delay data set to be updated to obtain an updated preset delay data set.

[0012] Optionally, according to the delay data set, determining the delay threshold includes: sorting the multiple historical delay data in the delay data set in order of delay from small to large to obtain a second delay sequence; in the second delay sequence, selecting the historical delay data at the target position as the target delay data; and determining the delay threshold according to the target delay data.

[0013] Optionally, determining the delay threshold according to the target delay data includes: detecting whether the delay of the target delay data is less than a preset minimum delay; when the delay of the target delay data is not less than the preset minimum delay, determining the delay of the target delay data as the delay threshold; when the delay of the target delay data is less than the preset minimum delay, determining the preset minimum delay as the delay threshold.

[0014] Optionally, before detecting whether the delay of the target delay data is less than a preset minimum delay, the method further includes: obtaining a plurality of the delay thresholds within a preset time period, wherein the historical delay data of the delay data set is updated multiple times within the preset time period, and multiple updates are used to generate multiple delay thresholds; determining an average value of the plurality of delay thresholds to obtain the preset minimum delay.

[0015] Optionally, when the waiting time exceeds the latency threshold, after scheduling the second read request to the slave copy of the master copy, the method further includes: monitoring the number of times the master copy schedules the second read request to the slave copy; detecting whether the number of scheduling times exceeds a preset scheduling threshold; and when the number of scheduling times exceeds the preset scheduling threshold, selecting a target copy from multiple slave copies of the master copy, and using the target copy to replace the master copy.

[0016] According to another aspect of an embodiment of the present invention, a read request scheduling device for a distributed database is also provided, including: an acquisition module, used to acquire a delay data set of a master copy in a distributed database, wherein the delay data set includes: a preset number of historical delay data intercepted from multiple historical delay data, each of the historical delay data is used to represent the delay of the master copy to a first read request that has been responded to; a determination module, used to determine a delay threshold based on the delay data set; a detection module, used to detect the waiting time of a second read request that has not been responded to in the master copy; and a scheduling module, used to schedule the second read request to a slave copy of the master copy if the waiting time exceeds the delay threshold.

[0017] According to another aspect of an embodiment of the present invention, a non-volatile storage medium is provided, wherein the non-volatile storage medium is used to store a program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the read request scheduling method of the distributed database.

[0018] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising: a memory and a processor, wherein the processor is configured to run a program stored in the processor, wherein the program executes the read request scheduling method of the distributed database when running.

[0019] In an embodiment of the present invention, a latency data set of a master copy in a distributed database is obtained, wherein the latency data set includes: a preset number of historical latency data intercepted from a plurality of historical latency data, each historical latency data being used to represent the latency of the master copy to a first read request that has been responded to; determining a latency threshold according to the latency data set; detecting the waiting time of a second read request that has not been responded to in the master copy; and scheduling the second read request to a slave copy of the master copy when the waiting time exceeds the latency threshold, so that the latency data set can be flexibly selected to update the latency threshold according to the response of the master copy to the read request, and then the second read request that has not been responded to by the master copy and whose waiting time exceeds the latency threshold is scheduled to the slave copy, so that the read request can be responded to more efficiently, thereby achieving the purpose of improving the response efficiency of the read request, realizing the technical effect of improving the scheduling effect of the read request, and thus solving the technical problem of poor scheduling effect of the read request. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0021] Figure 1 is a flow chart of a distributed database read request scheduling method according to an embodiment of the present invention;

[0022] Figure 2 is a schematic diagram of a read request scheduling device for a distributed database according to an embodiment of the present invention;

[0023] Figure 3 It is a structural block diagram of a computer terminal according to an embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings 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 interchanged where appropriate, so that the embodiments of the present invention described herein can 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.

[0026] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:

[0027] Distributed storage system: used to store data in multiple nodes of a distributed database to achieve the purpose of storing data, and generally has different degrees of data redundancy to ensure that data is not lost.

[0028] Node: Usually composed of hardware and software, it can be an instance in a server, computer, storage device, or cloud service.

[0029] Consistency protocol: A protocol used to ensure data consistency among multiple nodes in a distributed system.

[0030] Replica: A logical concept in a consistency protocol, which refers to a virtual instance of the data held in the protocol. The amount of data held can be more or less, depending on the physical concept corresponding to the virtual instance.

[0031] Request: specifically refers to the IO request in the storage system, that is, read / write request. This solution mainly targets read requests.

[0032] Replica strategy: A multi-copy strategy is generally adopted in distributed systems. Generally, there will be a primary replica to provide read and write request services to the outside world, and the primary replica will synchronize data to other replicas. That is, assuming there are three replicas, there are a total of three copies of user data in the storage system. Under normal circumstances, a user's write request needs to be processed by at least 2-3 replicas before it is returned to the user. The user's read request is directly read on the primary replica.

[0033] Latency: refers to the time interval from sending a request to receiving a response. It represents the time required for data to be transmitted and processed in the storage system. The smaller the better.

[0034] According to an embodiment of the present invention, an embodiment of a read request scheduling method for a distributed database is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0035] Figure 1 is a flow chart of a distributed database read request scheduling method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0036] Step S102, obtaining a latency data set of a primary replica in a distributed database, wherein the latency data set includes: a preset number of historical latency data intercepted from a plurality of historical latency data, each historical latency data being used to represent a latency of the primary replica to a first read request that has been responded to;

[0037] Step S104, determining a delay threshold according to the delay data set;

[0038] Step S106, detecting the waiting time of the second read request that is not responded to in the primary copy;

[0039] Step S108: When the waiting time exceeds the delay threshold, the second read request is scheduled to the slave copy of the master copy.

[0040] In an embodiment of the present invention, a latency data set of a master copy in a distributed database is obtained, wherein the latency data set includes: a preset number of historical latency data intercepted from a plurality of historical latency data, each historical latency data being used to represent the latency of the master copy to a first read request that has been responded to; determining a latency threshold according to the latency data set; detecting the waiting time of a second read request that has not been responded to in the master copy; and scheduling the second read request to a slave copy of the master copy when the waiting time exceeds the latency threshold, so that the latency data set can be flexibly selected to update the latency threshold according to the response of the master copy to the read request, and then the second read request that has not been responded to by the master copy and whose waiting time exceeds the latency threshold is scheduled to the slave copy, so that the read request can be responded to more efficiently, thereby achieving the purpose of improving the response efficiency of the read request, realizing the technical effect of improving the scheduling effect of the read request, and thus solving the technical problem of poor scheduling effect of the read request.

[0041] Optionally, the read request represents a request to read data from multiple replicas of a target replica group, where the target replica group includes: a master replica and multiple slave replicas of the master replica.

[0042] As an optional embodiment, obtaining a latency data set of a master copy in a distributed database includes: collecting multiple historical latency data of the master copy in the distributed database according to a preset collection frequency; determining the request time of the first read request corresponding to each historical latency data; arranging the multiple historical latency data in order of the request time to obtain a first latency sequence; and intercepting a preset number of historical latency data with the tail end of the first latency sequence as the starting point to obtain a latency data set.

[0043] In the above-mentioned embodiment of the present invention, the historical delay data of multiple first read requests that the master copy has responded to are sorted according to the request time of the first read request to obtain a first delay sequence, and then a preset number of historical delay data are intercepted from the tail of the first delay sequence to obtain a delay data set. Furthermore, during the operation of the master copy, the delay data set can be flexibly selected according to the current operation time, so that the delay threshold determined based on the delay data set meets the requirements of the current operation time.

[0044] Optionally, the request time is the time when the primary replica receives the first read request.

[0045] As an optional embodiment, obtaining a delay data set of a master copy in a distributed database includes: collecting preset delay data generated by the master copy in response to a third read request in the distributed database, wherein the response time of the third read request is later than that of the first read request; in a historical delay data set, removing the historical delay data generated by the first read request having the earliest response time to obtain a delay data set to be updated; and putting the preset delay data into the delay data set to be updated to obtain an updated preset delay data set.

[0046] The above-mentioned embodiment of the present invention can ensure that the delay threshold determined based on the delay data set meets the requirements of the current running time by updating the delay data set for the historically determined delay data set, and then the master copy can also respond to the read request and generate new historical delay data during the period from determining the last delay data set to the current running time. In the process of updating the delay data set, the historical delay data generated by the first read request with the earliest response time can be eliminated, and the newly generated historical delay data can be added to the delay data set to realize the update of the delay data set.

[0047] Optionally, the number of historical delay data to be removed from the delay data set is determined based on the number of newly generated historical delay data. If the removal number is the same as the generation number, then for each newly generated historical delay data added to the delay data set, one historical delay data needs to be removed from the delay data set to ensure that the preset delay data in the delay data set remains at a preset number.

[0048] As an optional embodiment, determining the delay threshold based on the delay data set includes: sorting multiple historical delay data in the delay data set in order of delay from small to large to obtain a second delay sequence; in the second delay sequence, selecting the historical delay data at the target position as the target delay data; and determining the delay threshold based on the target delay data.

[0049] In the above-mentioned embodiment of the present invention, the historical delay data represents the length of time that the first read request waits in the process of the primary copy responding to the first read request. The multiple historical delay data in the delay data set are sorted in ascending order of delay, and then the target delay data at the target position is selected in the second delay sequence. This can avoid selecting the target delay data for occasional situations, thereby ensuring that the delay threshold determined based on the target delay data is sufficiently accurate.

[0050] Optionally, in the second delay sequence, the historical delay data at the position 95% of the length of the second delay sequence can be selected as the target delay data; for example, the second delay sequence includes 100 historical delay data arranged from small to large, and the historical delay data at the 95th position can be selected as the target delay data.

[0051] Optionally, the delay threshold may also be an average value of all historical experimental data in the delay data set.

[0052] As an optional embodiment, determining the delay threshold based on the target delay data includes: detecting whether the delay of the target delay data is less than a preset minimum delay; when the delay of the target delay data is not less than the preset minimum delay, determining the delay of the target delay data as the delay threshold; when the delay of the target delay data is less than the preset minimum delay, determining the preset minimum delay as the delay threshold.

[0053] In the above embodiment of the present invention, the target delay data is compared with the preset minimum delay. If the delay of the target delay data is not less than the preset minimum delay, it means that the selected target delay data can represent the response of the primary copy to the read request, and the delay of the target delay data is determined as the delay threshold; if the delay of the target delay data is less than the preset minimum delay, it means that the selected target delay data may not be accurate enough, and the preset minimum delay is determined as the delay threshold, so that by comparing the target delay data with the preset minimum delay, the accuracy of the delay threshold can be guaranteed.

[0054] As an optional embodiment, before detecting whether the delay of the target delay data is less than a preset minimum delay, the method also includes: obtaining multiple delay thresholds within a preset time period, wherein the historical delay data of the delay data set is updated multiple times within the preset time period, and multiple updates are used to generate multiple delay thresholds; determining the average value of the multiple delay thresholds to obtain the preset minimum delay.

[0055] In the above-mentioned embodiment of the present invention, the delay threshold may be updated multiple times within a preset time period, and each update will generate a delay threshold. The average value of the multiple delay thresholds generated within the preset time period is used as the preset minimum delay. The preset minimum delay can represent the response of the primary copy to the read request within the preset time period.

[0056] As an optional embodiment, when the waiting time exceeds the latency threshold, after scheduling the second read request to the slave copy of the primary copy, the method also includes: monitoring the number of times the primary copy schedules the second read request to the slave copy; detecting whether the number of scheduling times exceeds a preset scheduling threshold; when the number of scheduling times exceeds the preset scheduling threshold, selecting a target copy from multiple slave copies of the primary copy, and using the target copy to replace the primary copy.

[0057] In the above-mentioned embodiment of the present invention, when the master copy needs to schedule the second read request to the slave copy multiple times, it means that the master copy may not be able to assume the function of the master copy. In this case, a new master copy can be elected from the multiple slave copies of the master copy, and the master copy that cannot assume the function of the master copy can be adjusted to a slave copy to ensure the request efficiency of the read request.

[0058] The present invention also provides a preferred embodiment, which provides a method for optimizing read request latency in distributed storage. The method for optimizing read request latency in distributed storage is implemented based on a collection module, a statistical analysis module, and a detection and distribution module.

[0059] As an optional example, the collection module is used to collect latency data (i.e., historical latency data) of a preset number of read requests at the primary replica according to a preset sampling frequency to form an original data set (i.e., latency data set). The sampling frequency can be set according to the specific hardware memory size of the distributed database; when the node cluster where the primary and replica are located is working normally, read requests continue to be sent to the primary replica, sampling also continues, and the original data set is also updated in real time according to the latest sampling.

[0060] Optionally, each sampled data in the original data set is sorted by time. Whenever the latest latency data of a read request is collected in real time, the latency data of the oldest read request will be removed from the original data set. The overall data structure is similar to a circular queue to ensure that the original data set is the latency data of the latest read request.

[0061] As an optional example, the statistical analysis module is used to calculate a latency threshold data in real time based on the original data set at the primary copy (P95 percentile latency data is often used here, and P95 latency is commonly used in the storage industry as an indicator to judge cluster latency performance).

[0062] It should be noted that the latency threshold calculation here is performed in the background at a set frequency. The fastest frequency is the same as the original data set acquisition frequency, that is, the latency threshold calculation is updated every time the data set changes. You can also set a lower update frequency to reduce the CPU usage of latency threshold calculation.

[0063] As an optional example, the statistical analysis module is also used to calculate the average value of multiple delay thresholds within a long time span to estimate a preset minimum delay. When the delay threshold updated in real time is less than the preset minimum delay, the current real-time calculated delay threshold will not take effect, but the minimum delay will take effect. This is to avoid the delay threshold being too small due to factors such as small data volume, so that all read requests are distributed and resources are wasted for no reason.

[0064] As an optional example, a check distribution module is continuously run at the primary replica, and checks the current time consumed by the read requests in the read request queue being processed by the primary replica at regular time intervals, and compares it with the current latest latency threshold. If the current time consumed by the read request exceeds the latency threshold, it means that the current primary replica may not process the request in time for some reason, and the read request is immediately forwarded to other replicas for fast reading.

[0065] Optionally, in a scenario with multiple replicas, a replica with the fastest response speed will be selected to process the read request based on the heartbeat response speed of the existing master and slave replicas.

[0066] Optionally, if a large number of read requests are responded to through forwarding for a long time, the inspection module will mark the primary copy as suspected fault and hand it over to other fault handling modules in the system for master-slave switching, isolation of risk disks, and other processing.

[0067] The above-mentioned embodiment of the present invention dynamically adjusts whether to forward a read request according to the dynamic pressure level received by the cluster under the premise that the hardware conditions of the distributed database are unreliable, thereby achieving the purpose of optimizing the overall read request latency of the cluster.

[0068] According to an embodiment of the present invention, an embodiment of a read request scheduling device for a distributed database is also provided. It should be noted that the read request scheduling device for a distributed database can be used to execute the read request scheduling method for a distributed database in an embodiment of the present invention, and the read request scheduling method for a distributed database in an embodiment of the present invention can be executed in the read request scheduling device for the distributed database.

[0069] Figure 2 is a schematic diagram of a read request scheduling device for a distributed database according to an embodiment of the present invention. Figure 2As shown, the device may include: an acquisition module 22, used to obtain a delay data set of a master copy in a distributed database, wherein the delay data set includes: a preset number of historical delay data intercepted from multiple historical delay data, each historical delay data is used to represent the delay of the master copy to a first read request that has been responded to; a determination module 24, used to determine a delay threshold based on the delay data set; a detection module 26, used to detect the waiting time of a second read request that has not been responded to in the master copy; a scheduling module 28, used to schedule the second read request to a slave copy of the master copy when the waiting time exceeds the delay threshold.

[0070] It should be noted that the acquisition module 22 in this embodiment can be used to execute step S102 in the embodiment of the present application, the determination module 24 in this embodiment can be used to execute step S104 in the embodiment of the present application, the detection module 26 in this embodiment can be used to execute step S106 in the embodiment of the present application, and the scheduling module 28 in this embodiment can be used to execute step S108 in the embodiment of the present application. The examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments.

[0071] In an embodiment of the present invention, a latency data set of a master copy in a distributed database is obtained, wherein the latency data set includes: a preset number of historical latency data intercepted from a plurality of historical latency data, each historical latency data being used to represent the latency of the master copy to a first read request that has been responded to; determining a latency threshold according to the latency data set; detecting the waiting time of a second read request that has not been responded to in the master copy; and scheduling the second read request to a slave copy of the master copy when the waiting time exceeds the latency threshold, so that the latency data set can be flexibly selected to update the latency threshold according to the response of the master copy to the read request, and then the second read request that has not been responded to by the master copy and whose waiting time exceeds the latency threshold is scheduled to the slave copy, so that the read request can be responded to more efficiently, thereby achieving the purpose of improving the response efficiency of the read request, realizing the technical effect of improving the scheduling effect of the read request, and thus solving the technical problem of poor scheduling effect of the read request.

[0072] As an optional embodiment, the acquisition module includes: a first collection unit, used to collect multiple historical delay data of the master copy in the distributed database according to a preset collection frequency; a first determination unit, used to determine the request time of the first read request corresponding to each historical delay data; a first sorting unit, used to arrange the multiple historical delay data in the order of request time to obtain a first delay sequence; and an interception unit, used to intercept a preset number of historical delay data with the tail end of the first delay sequence as the starting point to obtain a delay data set.

[0073] As an optional embodiment, the acquisition module includes: a second collection unit, used to collect preset delay data generated by the master copy in response to a third read request in a distributed database, wherein the response time of the third read request is later than that of the first read request; a elimination unit, used to eliminate the historical delay data generated by the first read request with the earliest response time in the historical delay data set, to obtain the delay data set to be updated; a storage unit, used to put the preset delay data into the delay data set to be updated, to obtain an updated preset delay data set.

[0074] As an optional embodiment, the determination module includes: a second sorting unit, used to sort multiple historical delay data in the delay data set in order of delay from small to large, to obtain a second delay sequence; a selection unit, used to select the historical delay data at the target position as the target delay data in the second delay sequence; a second determination unit, used to determine the delay threshold according to the target delay data.

[0075] As an optional embodiment, the second determination unit includes: a detection subunit, used to detect whether the delay of the target delay data is less than a preset minimum delay; a first determination subunit, used to determine the delay of the target delay data as a delay threshold when the delay of the target delay data is not less than the preset minimum delay; and a second determination subunit, used to determine the preset minimum delay as the delay threshold when the delay of the target delay data is less than the preset minimum delay.

[0076] As an optional embodiment, the device also includes: an acquisition subunit, used to obtain multiple delay thresholds within a preset time period before detecting whether the delay of the target delay data is less than a preset minimum delay, wherein the historical delay data of the delay data set is updated multiple times within the preset time period, and multiple updates are used to generate multiple delay thresholds; a third determination subunit, used to determine the average value of the multiple delay thresholds to obtain the preset minimum delay.

[0077] As an optional embodiment, the device also includes: a monitoring sub-module, which is used to monitor the number of times the master copy schedules the second read request to the slave copy of the master copy after scheduling the second read request to the slave copy of the master copy when the waiting time exceeds the delay threshold; a detection sub-module, which is used to detect whether the number of scheduling times exceeds a preset scheduling threshold; and a replacement sub-module, which is used to select a target copy from multiple slave copies of the master copy and use the target copy to replace the master copy when the number of scheduling times exceeds the preset scheduling threshold.

[0078] The embodiment of the present invention can provide a computer terminal, which can be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal can also be replaced by a terminal device such as a mobile terminal.

[0079] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of the computer network.

[0080] In this embodiment, the above-mentioned computer terminal can execute the program code of the following steps in the read request scheduling method of a distributed database: obtaining a delay data set of the master copy in the distributed database, wherein the delay data set includes: a preset number of historical delay data intercepted from multiple historical delay data, each historical delay data is used to represent the delay of the master copy to the first read request that has been responded to; determining a delay threshold based on the delay data set; detecting the waiting time of the second read request that has not been responded to in the master copy; and scheduling the second read request to the slave copy of the master copy when the waiting time exceeds the delay threshold.

[0081] Optionally, Figure 3 is a structural block diagram of a computer terminal according to an embodiment of the present invention. Figure 3 As shown, the computer terminal 30 may include: one or more (only one is shown in the figure) processors 32 , and a memory 34 .

[0082] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the read request scheduling method and device of the distributed database in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, the read request scheduling method of the distributed database mentioned above is realized. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal 30 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0083] The processor can call the information and application programs stored in the memory through the transmission device to perform the following steps: obtain a delay data set of the master copy in the distributed database, wherein the delay data set includes: a preset number of historical delay data intercepted from multiple historical delay data, each historical delay data is used to represent the delay of the master copy to the first read request that has been responded to; determine the delay threshold according to the delay data set; detect the waiting time of the unresponded second read request in the master copy; and when the waiting time exceeds the delay threshold, schedule the second read request to the slave copy of the master copy.

[0084] Optionally, the processor may also execute the program code of the following steps: collecting multiple historical delay data of the master copy in the distributed database according to a preset collection frequency; determining the request time of the first read request corresponding to each historical delay data; arranging the multiple historical delay data in the order of the request time to obtain a first delay sequence; and intercepting a preset number of historical delay data with the tail end of the first delay sequence as the starting point to obtain a delay data set.

[0085] Optionally, the processor may also execute the program code of the following steps: collecting preset delay data generated by the master copy in response to the third read request in the distributed database, wherein the response time of the third read request is later than that of the first read request; in the historical delay data set, removing the historical delay data generated by the first read request with the earliest response time to obtain the delay data set to be updated; and putting the preset delay data into the delay data set to be updated to obtain an updated preset delay data set.

[0086] Optionally, the processor may also execute the following program code: sorting multiple historical delay data in the delay data set in ascending order of delay to obtain a second delay sequence; in the second delay sequence, selecting the historical delay data at the target position as the target delay data; and determining the delay threshold based on the target delay data.

[0087] Optionally, the processor may also execute the program code of the following steps: detecting whether the delay of the target delay data is less than a preset minimum delay; when the delay of the target delay data is not less than the preset minimum delay, determining the delay of the target delay data as a delay threshold; when the delay of the target delay data is less than the preset minimum delay, determining the preset minimum delay as the delay threshold.

[0088] Optionally, the processor may also execute the program code of the following steps: before detecting whether the delay of the target delay data is less than a preset minimum delay, obtaining multiple delay thresholds within a preset time period, wherein the historical delay data of the delay data set is updated multiple times within the preset time period, and multiple updates are used to generate multiple delay thresholds; determining the average value of the multiple delay thresholds to obtain the preset minimum delay.

[0089] Optionally, the processor may also execute the program code of the following steps: when the waiting time exceeds the delay threshold, after scheduling the second read request to the slave copy of the master copy, monitor the number of times the master copy schedules the second read request to the slave copy; detect whether the number of scheduling times exceeds the preset scheduling threshold; when the number of scheduling times exceeds the preset scheduling threshold, select a target copy from multiple slave copies of the master copy, and use the target copy to replace the master copy.

[0090] By adopting an embodiment of the present invention, a read request scheduling scheme for a distributed database is provided, which obtains a delay data set of a master copy in the distributed database, wherein the delay data set includes: a preset number of historical delay data intercepted from multiple historical delay data, each historical delay data is used to represent the delay of the master copy to the first read request that has been responded to; according to the delay data set, a delay threshold is determined; the waiting time of the second read request that has not been responded to in the master copy is detected; when the waiting time exceeds the delay threshold, the second read request is scheduled to the slave copy of the master copy, so that according to the response of the master copy to the read request, the delay data set can be flexibly selected to update the delay threshold, and then the second read request that has not been responded to by the master copy and the waiting time exceeds the delay threshold is scheduled to the slave copy, so that the read request can be responded to more efficiently, thereby achieving the purpose of improving the response efficiency of the read request, and realizing the technical effect of improving the scheduling effect of the read request, thereby solving the technical problem of poor scheduling effect of the read request.

[0091] It can be understood by those skilled in the art that Figure 3 The structure shown is for illustration only, and the computer terminal may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Figure 3 The structure of the electronic device is not limited. For example, the computer terminal 30 may also include Figure 3 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 3 Different configurations are shown.

[0092] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a non-volatile medium. The non-volatile storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0093] The embodiment of the present invention further provides a non-volatile storage medium. Optionally, in this embodiment, the non-volatile storage medium can be used to store the program code executed by the distributed database read request scheduling method provided in the above embodiment.

[0094] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.

[0095] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: obtaining a latency data set of a master replica in a distributed database, wherein the latency data set includes: a preset number of historical latency data intercepted from multiple historical latency data, each historical latency data being used to represent the latency of the master replica to a first read request that has been responded to; determining a latency threshold based on the latency data set; detecting the waiting time of an unresponded second read request in the master replica; and scheduling the second read request to a slave replica of the master replica when the waiting time exceeds the latency threshold.

[0096] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: collecting multiple historical delay data of the master copy in the distributed database according to a preset collection frequency; determining the request time of the first read request corresponding to each historical delay data; arranging the multiple historical delay data in order of the request time to obtain a first delay sequence; and intercepting a preset number of historical delay data with the tail end of the first delay sequence as the starting point to obtain a delay data set.

[0097] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: collecting preset delay data generated by the master copy in response to a third read request in a distributed database, wherein the response time of the third read request is later than that of the first read request; in a historical delay data set, eliminating the historical delay data generated by the first read request with the earliest response time to obtain a delay data set to be updated; and putting the preset delay data into the delay data set to be updated to obtain an updated preset delay data set.

[0098] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: sorting multiple historical delay data in the delay data set in order of delay from small to large to obtain a second delay sequence; in the second delay sequence, selecting the historical delay data at the target position as the target delay data; and determining the delay threshold based on the target delay data.

[0099] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: detecting whether the delay of the target delay data is less than a preset minimum delay; when the delay of the target delay data is not less than the preset minimum delay, determining the delay of the target delay data as a delay threshold; when the delay of the target delay data is less than the preset minimum delay, determining the preset minimum delay as the delay threshold.

[0100] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: before detecting whether the delay of the target delay data is less than a preset minimum delay, obtaining multiple delay thresholds within a preset time period, wherein the historical delay data of the delay data set is updated multiple times within the preset time period, and multiple updates are used to generate multiple delay thresholds; determining an average value of the multiple delay thresholds to obtain a preset minimum delay.

[0101] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: when the waiting time exceeds a latency threshold, after scheduling the second read request to the slave copy of the master copy, monitor the number of times the master copy schedules the second read request to the slave copy; detect whether the number of scheduling times exceeds a preset scheduling threshold; when the number of scheduling times exceeds the preset scheduling threshold, select a target copy from multiple slave copies of the master copy, and use the target copy to replace the master copy.

[0102] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0103] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0104] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units 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 units or modules, which can be electrical or other forms.

[0105] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0106] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0107] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a non-volatile storage medium, including several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned non-volatile storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0108] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for scheduling read requests of a distributed database, characterized in that: include: Obtaining a latency data set of a primary replica in a distributed database, wherein the latency data set includes: a preset number of historical latency data intercepted from a plurality of historical latency data, each of the historical latency data being used to represent the latency of the primary replica to a first read request that has been responded to; Determining a delay threshold according to the delay data set; Detecting a waiting time of a second read request that is not responded to in the primary copy; When the waiting time exceeds the delay threshold, scheduling the second read request to a slave copy of the master copy; Wherein, determining the delay threshold according to the delay data set includes: Sorting the plurality of historical delay data in the delay data set in ascending order of delay to obtain a second delay sequence; In the second delay sequence, selecting historical delay data at a target position as target delay data; Determine the delay threshold according to the target delay data; Wherein, determining the delay threshold according to the target delay data includes: Detecting whether the delay of the target delay data is less than a preset minimum delay; When the delay of the target delay data is not less than the preset minimum delay, determining the delay of the target delay data as the delay threshold; When the delay of the target delay data is less than the preset minimum delay, determining the preset minimum delay as the delay threshold; Before detecting whether the delay of the target delay data is less than a preset minimum delay, the method further includes: Acquire a plurality of delay thresholds within a preset time period, wherein the historical delay data of the delay data set is updated multiple times within the preset time period, and the multiple updates generate multiple delay thresholds; An average value of the plurality of delay thresholds is determined to obtain the preset minimum delay.

2. The method according to claim 1, characterized in that: Obtaining the time-delayed data set of the primary replica in a distributed database includes: Collecting multiple historical delay data of the master copy in the distributed database according to a preset collection frequency; Determine a request time of a first read request corresponding to each of the historical delay data; Arrange the plurality of historical delay data in the order of the request times to obtain a first delay sequence; The preset amount of historical delay data is intercepted with the tail end of the first delay sequence as a starting point to obtain the delay data set.

3. The method according to claim 1, characterized in that Obtaining the time-delayed data set of the primary replica in a distributed database includes: Collecting preset delay data generated by the primary replica in response to a third read request in the distributed database, wherein a response time of the third read request is later than a response time of the first read request; In the historical delay data set, the historical delay data generated by the first read request with the earliest response time is removed to obtain the delay data set to be updated; The preset time delay data is put into the delay data set to be updated to obtain an updated preset time delay data set.

4. The method according to claim 1, characterized in that: In the case where the waiting time exceeds the latency threshold, after scheduling the second read request to the slave copy of the master copy, the method further includes: Monitoring the number of times the primary replica schedules the second read request to the secondary replica; Detecting whether the scheduling number exceeds a preset scheduling threshold; In a case where the scheduling number exceeds the preset scheduling threshold, a target copy is selected from multiple slave copies of the master copy, and the master copy is replaced by the target copy.

5. A read request scheduling device for a distributed database, characterized in that: include: An acquisition module is used to acquire a latency data set of a master replica in a distributed database, wherein the latency data set includes: a preset number of historical latency data intercepted from a plurality of historical latency data, each of the historical latency data is used to represent the latency of the master replica to a first read request that has been responded to; A determination module, configured to determine a delay threshold according to the delay data set; A detection module, used for detecting a waiting time of a second read request that is not responded to in the primary copy; A scheduling module, configured to schedule the second read request to a slave copy of the master copy when the waiting time exceeds the delay threshold; Wherein, the determination module includes: A second sorting unit, configured to sort the plurality of historical delay data in the delay data set in ascending order of delay to obtain a second delay sequence; A selection unit, configured to select, in the second delay sequence, historical delay data at a target position as target delay data; A second determining unit, configured to determine the delay threshold according to the target delay data; Wherein, the second determining unit includes: A detection subunit, used to detect whether the delay of the target delay data is less than a preset minimum delay; A first determining subunit, configured to determine the delay of the target delay data as the delay threshold if the delay of the target delay data is not less than the preset minimum delay; A second determining subunit, configured to determine the preset minimum delay as the delay threshold when the delay of the target delay data is less than the preset minimum delay; an acquisition subunit, configured to acquire a plurality of delay thresholds within a preset time period before detecting whether the delay of the target delay data is less than a preset minimum delay, wherein the historical delay data of the delay data set is updated multiple times within the preset time period, and multiple updates are performed to generate multiple delay thresholds; The third determining subunit is used to determine an average value of the multiple delay thresholds to obtain the preset minimum delay.

6. A non-volatile storage medium, characterized in that: The non-volatile storage medium is used to store a program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the read request scheduling method for a distributed database as described in any one of claims 1 to 4.

7. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the processor, wherein the program, when running, executes the read request scheduling method for a distributed database as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Distributed data reading method and device

    CN106598488A

  • Detection of slow node in distributed storage system

    CN106878388A

  • Tail delay adjusting method and device

    CN117097646A