CN113360525B - Query request processing method, device and equipment and key value query system - Google Patents

Query request processing method, device and equipment and key value query system Download PDF

Info

Publication number
CN113360525B
CN113360525B CN202110912297.9A CN202110912297A CN113360525B CN 113360525 B CN113360525 B CN 113360525B CN 202110912297 A CN202110912297 A CN 202110912297A CN 113360525 B CN113360525 B CN 113360525B
Authority
CN
China
Prior art keywords
query
query request
thread
key
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110912297.9A
Other languages
Chinese (zh)
Other versions
CN113360525A (en
Inventor
朱炳鹏
付治钧
江进
张松清
胡瑜
周猛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alipay Hangzhou Information Technology Co Ltd
Original Assignee
Alipay Hangzhou Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alipay Hangzhou Information Technology Co Ltd filed Critical Alipay Hangzhou Information Technology Co Ltd
Priority to CN202110912297.9A priority Critical patent/CN113360525B/en
Publication of CN113360525A publication Critical patent/CN113360525A/en
Application granted granted Critical
Publication of CN113360525B publication Critical patent/CN113360525B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Embodiments of the present specification provide a query request processing method, a query request processing apparatus, a query request processing device, and a key value query system. In the query request method, a first thread-second thread pair is created in a query request processing device, an IO query request is obtained by processing a received key value query request by using the first thread and is provided for an operating system to realize IO query, and an IO query result of the operating system is processed by using the second thread and is returned to the query request initiating device. When data query request processing is carried out, the first thread and the second thread execute asynchronously and share the same query context pool and the same IO query request queue.

Description

Query request processing method, device and equipment and key value query system
Technical Field
Embodiments of the present disclosure generally relate to the field of data processing, and in particular, to a query request processing method, a query request processing apparatus, a query processing device, and a key-value query system.
Background
In some key value query systems, for example, hash-based distributed key value pair query systems, after a server device of the key value query system receives a key value query request initiated by a client device, a data storage device, such as a local data storage, needs to be queried through an IO interface of the server device, so as to obtain a key value query result and return the key value query result to the client device. This data query approach is also referred to as IO query.
In some application scenarios, for example, in a distributed Key-value pair query system, there are multiple client devices that simultaneously initiate Key-value query requests to the Key-value query system, and each Key-value query request includes a large number of keys (keys), thereby greatly increasing the load of the server device. In this case, the IO performance of the service-side IO device may severely restrict the throughput of the key value query system and increase the query processing delay.
Disclosure of Invention
In view of the above, embodiments of the present specification provide a query request processing method, a query request processing apparatus, a query request processing device, and a key value query system. By using the query request processing scheme, the first thread-second thread pair is created in the query request processing device, the first thread is used for processing the received key value query request to obtain an IO query request and providing the IO query request to the operating system to realize IO query, and the second thread is used for processing the IO query result of the operating system, so that the key value query request processing process of initiating the IO query and the IO query result processing process of returning the data query result can be decoupled, and the IO query performance is improved.
According to an aspect of embodiments of the present specification, there is provided a method for processing a key-value query request, the method being performed by a query request processing device, the query request processing device being created with a first thread-second thread pair, the method comprising: executing a first thread of the first-second thread pair to perform the following: responding to a received key value query request from a query request initiating device, and allocating a first query context for the key value query request from a query context pool of the first thread, wherein request parameters of the key value query request comprise at least one key; generating at least one IO query request according to the key value query request, wherein each key corresponds to one IO query request; setting a callback function of an IO completion event for each IO query request; storing the request parameters of the key value query requests and callback functions of all IO query requests in the first query context; and submitting each IO query request and the corresponding callback function to an IO query request queue corresponding to the second thread in an operating system of the query request processing device, where the operating system initiates an IO query for the data storage device based on the IO query request queue, and runs the second thread to execute the following processes: responding to the IO completion event returned by the operating system received by the second thread, processing the IO query data in the IO completion event through a corresponding callback function, and filling the obtained IO query data into a key value query response message; and when the IO query data corresponding to all the IO query requests are filled in the key value query response message, returning the key value query response message to the query request initiating device.
Optionally, in one example of the above aspect, the processing of the first thread is performed asynchronously to the processing of the second thread.
Optionally, in one example of the above aspect, the first thread and the second thread share a same query context pool and a same IO query request queue.
Optionally, in an example of the above aspect, the method may further include: and releasing the first query context allocated to the key value query request back to the query context pool through the second thread after receiving the IO completion event corresponding to all the IO query requests.
Optionally, in an example of the above aspect, the first thread-second thread pair includes at least two first thread-second thread pairs, and the method may further include: assigning, via the first thread, a last query context in the query context pool for the key-value query request from the query context pool of the first thread, and after submitting a corresponding IO query request to the IO query request queue, maintaining the first thread in a blocked state until a previously assigned first query context is released back to the query context pool.
Optionally, in an example of the above aspect, when the number of keys included in a key-value query request initiated by the query request initiating device exceeds a predetermined value, the key-value query request is split and then sent to the first thread.
Optionally, in one example of the above aspect, the size of the assigned first query context is determined at least in part by the number of keys comprised by the key-value query request.
Optionally, in one example of the above aspect, the pool of query contexts has a predetermined number of query contexts.
Optionally, in an example of the above aspect, the predetermined number is determined according to a computing capability, a memory capacity, and/or a read-write capability of the data storage device of the query request processing device.
Optionally, in an example of the above aspect, the data storage device includes a data storage device local to the query request processing device or a data storage device remote from the query request processing device.
Optionally, in an example of the above aspect, the method is applied to a distributed key-value query system, the query request initiating device includes at least one client device, and the query request processing device includes a server device.
According to another aspect of embodiments of the present specification, there is provided a query request processing apparatus for processing a key-value query request, the query request processing apparatus being applied to a query request processing device, the query request processing apparatus including: a thread creating unit that creates a first thread-second thread pair; the thread initialization unit is used for performing thread initialization on the created first thread and the created second thread, wherein when the first thread is initialized, a query context pool is distributed to the first thread from a memory space of query request processing equipment, and when the second thread is initialized, an API (application program interface) in an operating system is called to create an IO query request queue; and a thread running unit which runs the first thread to execute the following query request processing procedures: responding to a data query request from a query request initiating device, allocating a first query context for the key-value query request from a query context pool of the first thread, wherein request parameters of the key-value query request comprise at least one key; generating at least one IO query request according to the key value query request, wherein each key corresponds to one IO query request; setting a callback function of an IO completion event for each IO query request in each IO query request; storing the request parameters of the key value query requests and callback functions of all IO query requests in the first query context; and submitting each IO query request and the corresponding callback function to an IO query request queue corresponding to the second thread in an operating system of the query request processing device, wherein the operating system initiates IO query aiming at the data storage device based on the IO query request queue, and runs the second thread to execute the following IO query result processing processes: responding to the IO completion event returned by the operating system received by the second thread, processing the IO query data in the IO completion event through a corresponding callback function, and filling the obtained IO query data into a key value query response message; and when the IO query data corresponding to all the IO query requests are filled in the key value query response message, returning the key value query response message to the query request initiating device.
According to another aspect of embodiments of the present specification, there is provided a query request processing apparatus including the query request processing device as described above.
According to another aspect of embodiments of the present specification, there is provided a key-value query system including: at least one inquiry request initiating device sends a key value inquiry request to an inquiry request processing device; the query request processing device as described above; and a data storage device.
According to another aspect of embodiments of the present specification, there is provided an apparatus for processing a key-value query request, comprising: at least one processor, a memory coupled with the at least one processor, and a computer program stored in the memory, the at least one processor executing the computer program to implement the query request processing method as described above.
According to another aspect of embodiments of the present specification, there is provided a computer-readable storage medium storing executable instructions that, when executed, cause a processor to perform a query request processing method as described above.
According to another aspect of embodiments of the present specification, there is provided a computer program product comprising a computer program executed by a processor to implement the query request processing method as described above.
Drawings
A further understanding of the nature and advantages of the present disclosure may be realized by reference to the following drawings. In the drawings, similar components or features may have the same reference numerals.
FIG. 1 illustrates an example schematic of a key-value query system.
FIG. 2 illustrates an example flow diagram of a key-value query process of the key-value query system.
FIG. 3 illustrates an example schematic diagram of a key-value query system in accordance with an embodiment of the present specification.
FIG. 4 illustrates an example flow diagram of a process for a first thread in accordance with an embodiment of the present description.
FIG. 5 illustrates an example flow diagram of a process for a second thread in accordance with an embodiment of the present description.
FIG. 6 illustrates an example block diagram of a query request processing apparatus for processing a key-value query request in accordance with embodiments of this specification.
Fig. 7 illustrates an example schematic diagram of a query request processing apparatus implemented based on a computer system for processing key-value query requests according to an embodiment of the present specification.
Detailed Description
The subject matter described herein will now be discussed with reference to example embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and thereby implement the subject matter described herein, and are not intended to limit the scope, applicability, or examples set forth in the claims. Changes may be made in the function and arrangement of elements discussed without departing from the scope of the disclosure. Various examples may omit, substitute, or add various procedures or components as needed. For example, the described methods may be performed in an order different from that described, and various steps may be added, omitted, or combined. In addition, features described with respect to some examples may also be combined in other examples.
As used herein, the term "include" and its variants mean open-ended terms in the sense of "including, but not limited to. The term "based on" means "based at least in part on". The terms "one embodiment" and "an embodiment" mean "at least one embodiment". The term "another embodiment" means "at least one other embodiment". The terms "first," "second," and the like may refer to different or the same object. Other definitions, whether explicit or implicit, may be included below. The definition of a term is consistent throughout the specification unless the context clearly dictates otherwise.
FIG. 1 illustrates an example schematic of a key-value query system 100.
As shown in fig. 1, the key-value query system 100 includes at least one query request originating device 110 and a query request processing device 120. In one example, the key-value query system 100 may include a distributed key-value query system, the query request initiating device 110 may be a client device installed with a key-value query client, and the query request processing device 120 may be a server device installed with a key-value query server.
The query request initiating device 110 is used to initiate a key-value query request. For example, the query request initiator may initiate a key-value query request to the query request handler based on an RPC manner. In this case, the key-value query request may also be referred to as an RPC query request. The RPC query request may include one or more query keys.
In response to receiving the key value query request, the query request processing device 120 initiates an IO query on the data storage device storing the target data based on the key value query request, thereby obtaining IO query data, and returns the obtained IO query data to the query request initiating device 110.
FIG. 2 illustrates an example flow diagram of a key-value query process 200 of the key-value query system of FIG. 1. In the example shown in fig. 2, the initiated key-value query request is shown as an RPC query request, and multiple RPC threads for key-value query request processing are created in the query request processing device 120.
As shown in FIG. 2, at 210, the created RPC thread is initialized. After the RPC thread is initialized, the RPC thread monitors in a loop whether an RPC query request is received from the query request initiating device, at 220. The received RPC query request has a request parameter. The request parameters may include, for example, one or more keys, key operations, and query conditions. Here, the key operation refers to the operation content performed for the key. The query condition is a query condition in data query, for example, a data filtering condition in data query. Optionally, the request parameters may also include other parameters. Such as data query timeout, etc.
In response to receiving the RPC query request from the query request initiating device, an IO query request is generated from the RPC query request at 230. The IO query request typically includes: what the file name needs to be read, what the start offset inside the file to be read is, how long the data needs to be read. For example, if a file called file1.txt exists in a certain directory, and the total length of the file is 100 bytes, the specific information stored in an IO request may include: the file1.txt in a certain directory is read, the offset starts from the 50 th byte, and the total length is 100 bytes of data. Here, when generating the IO query request, if the RPC query request includes a plurality of keys, one IO query request is generated for each key in the RPC query request.
At 240, an IO query is initiated for the data storage device based on the generated IO query request. Specifically, the query request processing device submits the IO query request to the operating system, and the operating system initiates an IO query for the data storage device based on the IO query request. Here, the IO query refers to performing data interaction with the data storage device through an IO interface of the operating system, so that an IO query result (IO query data) is read from the data storage device into a memory of the query request processing device. In this specification, examples of the data storage device may include, but are not limited to, a data storage device suitable for IO reading, such as a floppy disk, a hard disk, and the like.
At 250, the query request processing device returns the obtained IO query result to the query request initiating device, thereby completing the data query process.
According to the data query procedure shown in fig. 2, when the RPC query request includes a plurality of keys, a plurality of IO query requests need to be generated. When multiple IO query requests are used to perform an IO query against a data storage device, a synchronous IO query is typically used. In synchronizing IO queries, the multiple IO query requests are typically processed serially. Each IO query request needs to be started after the IO query for the previous IO query request is finished, so that the data query process has a large query processing delay. In order to improve the system performance of the data query system, thread switching can be performed during RPC thread waiting to process other tasks. However, this approach may result in the RPC thread needing to switch states between the blocking/ready states multiple times, thereby increasing the overhead of the data query system.
In addition, for the key value query of the key value query system shown in fig. 1, a global thread pool technology may also be introduced to process the IO query request, so that RPC thread blocking at the query request processing device may be avoided, thereby implementing parallel processing of the IO query request. However, in this approach, a locking mutex is required both when an IO query request is added to or removed from the thread pool queue. Frequent lock operations of multiple threads may result in significant overhead and lock resource contention. In addition, all IO query requests share a thread pool, which may cause thread resource contention in processing among multiple IO query requests, and thus a query delay and tail may occur.
In view of the foregoing, embodiments of the present specification provide a query request processing scheme. In the query request processing scheme, a first thread-second thread pair is created in the query request processing equipment, the first thread is used for processing the received key value query request to obtain an IO query request, the IO query request is provided for an operating system to realize IO query, the second thread is used for processing an IO query result of the operating system and returning the IO query result to the query request initiating equipment, and the processing processes of the first thread and the second thread are not affected with each other, so that the key value query request processing process for initiating the IO query and the IO query result processing process for returning a data query result can be decoupled, and the IO query performance of the key value query system is improved.
Fig. 3 illustrates an example schematic diagram of a key-value query system 300 in accordance with an embodiment of the present specification.
As shown in fig. 3, the key-value query system 300 includes at least one query request initiating device 310, a query request processing device 320, and a data storage device 330. For simplicity of description, only 1 query request initiating device 310 is shown in the example of fig. 3, and in other embodiments, the query request initiating device 310 may include two or more query request initiating devices 310.
When performing a key-value query, the query request initiator 310 initiates a key-value query request to the query request handler 320. For example, in one example, the query request initiator may initiate a key-value query request based on an RPC manner. In this case, the key-value query request may also be referred to as an RPC query request. A Key-value query request may have request parameters that include at least one Key (Key), such as one or more keys that need to be queried. Furthermore, optionally, the request parameter may further include a key operation and/or a query condition, and the like. The Key operation may be, for example, an arithmetic operation performed on the Key, for example, summing all values of Key, or calculating an average Value of all values, or the like. The query condition may be a filter condition at the time of data query. In addition, when the query Key included in the data query request at the query request initiating device is too many, the query request initiating device may also segment the Key-value query request into a plurality of smaller Key-value query requests and send the smaller Key-value query requests to the query request processing device 320.
The query request processing apparatus 320 may have query request processing means. The query request processing apparatus may create a first thread-second thread pair, wherein the first thread is configured to process a key value query request received from a query request initiating device to generate an IO query request and initiate an IO query for the data storage device based on the generated IO query request, and the second thread is configured to process an IO query result returned from the data storage device in response to the IO query request and return the IO query result to the query request initiating device. In this specification, the first thread may be referred to as a query request processing thread, and the second thread may be referred to as an IO event processing thread.
The first thread-second thread pairs created by the query request processing device may include a plurality of first thread-second thread pairs. In this case, the plurality of first threads may process a plurality of key-value query requests from the query request initiating device in parallel, for example, a plurality of key-value query requests from a plurality of query request initiating devices.
The query request processing apparatus processes the key-value query request initiated by the query request initiator 310 using the created first-second thread pair.
FIG. 4 illustrates an example flow diagram of a process 400 for a first thread in accordance with an embodiment of the present description.
As shown in FIG. 4, at 410, a first thread is initialized at a query request processing device.
When a first thread is initialized, a query context pool is allocated to the first thread from a memory space of a query request processing device, and a corresponding second thread is created for the first thread, so that a first thread-second thread pair is created. The assigned pool of query contexts may have a predetermined number of query contexts. Here, the query context refers to a block of memory of the query request processing device, which is used for storing parameters related to the key-value query request. In one example, the number of query contexts that the query context pool has may be determined according to the computational power, memory capacity, and/or read-write capability of the query request processing device. The read-write capability of a data storage device may also be referred to as the IO capability of the data storage device. When the query request processing apparatus creates a plurality of first threads, the above initialization processing may be performed for each first thread. Each first thread performs the operations 420 through 470 described below independently of each other.
At 420, the first thread continuously monitors whether a key-value query request is received from the query request initiating device 310.
After the first thread monitors for receipt of a key-value query request from the query request initiating device 310, a first query context is assigned to the received key-value query request from the first thread's query context pool via the first thread at 430. The assigned first query context is used to store request parameters of the key-value query request. For example, the first query context may store keys to be queried in the data query, Key operations for the keys, or query conditions. In one example, the size of the assigned first query context may be determined at least in part by the number of keys contained by the Key-value query request.
At 440, an IO query request is generated from the key-value query request via the first thread. When the key-value query request includes a plurality of keys, each key generates an IO query request. In one example, the generated IO query request may include: the file name to be read, the start offset within the file to be read, and the data length of the data to be read. For example, if a file called file1.txt exists in a certain directory, and the total length of the file is 100 bytes, the specific information stored in the corresponding IO query request may include: the file1.txt in a certain directory is read, the offset starts from the 50 th byte, and the total length is 100 bytes of data.
At 450, a callback function of the IO completion event is set for each IO query request via the first thread. In this specification, the callback function is a piece of program code, and is used to indicate how to process data read from the data storage device to obtain an IO query result, backfill the obtained IO query result into a key value query response message, and return the key value query response message to the query request initiating device.
At 460, request parameters of the key-value query request and callback functions of the respective IO query requests are saved in the assigned first query context via the first thread. Each callback function may be saved in the first query context in association with a corresponding IO query request.
At 470, the generated IO query request and the corresponding callback function are submitted to an IO query request queue via the first thread. The operating system of the query request processing device provides a series of API interfaces for providing functional implementation of IO. The IO query request queue may be created via a second thread calling an API interface in the operating system upon thread initialization of the second thread. Accordingly, the first thread may, for example, call an API interface to submit the IO query request to the IO query request queue. After submitting the IO query request to an IO query request queue of the operating system, the operating system may initiate an asynchronous IO query for the data storage device based on the IO query request in the IO query request queue. After the IO instruction completes, an IO completion event may be generated. The second thread may obtain the IO completion event through a corresponding API interface of the operating system. In one example, the data storage device may be a local data store, such as a hard disk, floppy disk, etc., of the query request processing device. In another example, the data storage device may also be a remote data storage device connected to the query request processing device via a network.
Flow then returns to 420 to continue data query request monitoring via the first thread.
FIG. 5 illustrates an example flow diagram of a process 500 for a second thread in accordance with an embodiment of the present specification.
As shown in FIG. 5, at 510, thread initialization is performed on the created second thread at the query request processing device. When the second thread is initialized, the second thread calls an API (application programming interface) in the operating system to create an IO query request queue. The IO query request queue created by the second thread may be used for the corresponding first thread to submit the generated IO query request. It is noted that the query context pool created at the initialization of the first thread and the IO query request queue created at the initialization of the second thread may be common to the first thread and the second thread in the first thread-second thread pair.
At 520, it is monitored via the second thread whether an IO completion event is received for the IO query request. The term "IO completion event" refers to the end of an IO query at a data storage device and the return of IO query results. The IO completion event includes data content read from the data storage device.
At 530, in response to receiving the IO completion event, the read IO query data is processed with a corresponding callback function of the IO query request in the first query context corresponding to the IO completion event. Since the first thread and the second thread share the same query context pool, the second thread can obtain the corresponding callback function from the first query context. And when the query condition is stored for the IO query request in the first query context, the callback function indicates to filter the read IO query data according to the query condition. For example, if the query condition indicates that the Value of the returned IO query data is greater than 5, IO query data with Value less than or equal to 5 is filtered from the read IO query data. And filling the IO query result after the filtering processing into a Key value query response message, and adding 1 to the returned Key count. And if the first query context does not store the query condition, the read IO query data is directly filled in the Key value query response message without filtering, and 1 is added to the returned Key count.
At 540, it is determined whether all IO query requests for the key-value query request return IO completion events. For example, whether the count value of the Key is equal to the Key total number in the Key value query request is determined, and if the count value of the Key is equal to the Key total number, it is determined that IO completion events are returned for all IO query requests of the Key value query request. And if the count value of the Key is smaller than the Key total number, judging that all IO query requests which do not aim at the Key value query request return IO completion events. If all IO query requests that are not directed to the key-value query request return an IO completion event, return to 520.
If all the IO query requests for the key value query request return IO completion events, at 550, the key value query response message filled with the IO query result is returned to the query request initiating device.
Optionally, at 560, if all IO query requests for the key-value query request return an IO completion event, the first query context assigned to the key-value query request is released back to the query context pool created for the first thread via the second thread.
Further, it is noted that alternatively, the processing of the first thread and the processing of the second thread may be performed asynchronously.
By using the key value query scheme, a first thread-second thread pair is created in the query request processing equipment, the received key value query request is processed by using the first thread to obtain an IO query request and is provided for the operating system to realize IO query, the IO query result of the operating system is processed by using the second thread and is returned to the query request initiating equipment, the processing processes of the first thread and the second thread are not affected with each other, so that the key value query request processing process for initiating IO query and the IO query result processing process for returning data query results can be decoupled, and the IO query performance of the key value query system is improved.
In addition, by maintaining private query contexts and IO query request queues for the first thread-second thread pair, each query context (each block of memory of the query request processing device) has only one producer and consumer, thereby reducing global lock contention for threads relative to the global thread pool scheme, and improving parallel processing performance.
In addition, in the above scheme, the first thread and the second thread execute asynchronously to complete one key value query request processing together. According to the processing mode, after the IO query request of the current data query request is submitted to the IO query request queue, the first thread can immediately process the next data query request without waiting for the key value query result of the current key value query request, so that a plurality of key value query requests can form pipeline operation, and the processing efficiency of the key value query request is improved.
In addition, by using the scheme, the maximum concurrency of the key value query system can be configured by configuring the number of the query contexts in the query context pool, so that the key value query system can be conveniently optimized to the maximum concurrency processing performance.
Further, optionally, in a case that a plurality of first threads are created at the query request processing device, if the current first thread finishes allocating the last query context in the query context pool, after submitting the corresponding IO query request to the IO query request queue, the current first thread is kept in a blocking state until the previously allocated first query context is released back to the query context pool, that is, there is an allocable query context free in the query context pool.
By using the above scheme, the first thread is kept in the blocking state until the corresponding query context pool has the distributable query context when the query context pool of the first thread is empty, so that the first thread can be prevented from processing another key value query request at the moment, and the long tail caused by the fact that the key value query request blocks and waits for the query context when the first thread receives another key value query request is avoided, so that the rest key value query requests can be scheduled and processed by other idle first threads, and the possibility of the occurrence of the long tail request in the key value query system is reduced.
Fig. 6 illustrates an example block diagram of a query request processing apparatus 600 for processing a key-value query request in accordance with an embodiment of this specification. As shown in fig. 6, the query request processing apparatus 600 includes a thread creating unit 610, a thread initializing unit 620, and a thread executing unit 630.
The thread creation unit 610 is configured to create a first thread-second thread pair. The created first-second thread pair may include one or more thread pairs. The first thread may be operative to process a key-value query request received from a query request initiating device to obtain an IO query request and submit the IO query request to an operating system to initiate an IO query for the data storage device. The second thread may be run to process the IO query result returned by the operating system, and fill the processed IO query result into the key value query response message and return to the query request initiating device.
The thread initialization unit 620 is configured to perform thread initialization on the created first thread and the created second thread, wherein, when initializing the first thread, a query context pool is allocated for the first thread from a memory space of the query request processing device, and when initializing the second thread, an API interface in the operating system is called to create an IO query request queue. In one example, the allocated query context pool and the created IO query request queue may be common to the first thread and the second thread.
The thread execution unit 630 is configured to execute the first thread to perform the following query request processing procedures: in response to receiving a key value query request from a query request initiating device, allocating a first query context for the received key value query request from a query context pool of a first thread, wherein request parameters of the key value query request comprise at least one key; generating at least one IO query request according to the key value query request, wherein each key corresponds to one IO query request; setting a callback function of an IO completion event for each IO query request in each IO query request; saving request parameters of the key value query requests and callback functions of all IO query requests in a first query context; and submitting each IO query request and the corresponding callback function to an IO query request queue corresponding to a second thread in an operating system of the query request processing device, wherein the operating system initiates IO query aiming at the data storage device based on the IO query request queue.
In addition, the thread execution unit 630 may execute the following IO query result processing procedure by the second thread: responding to an IO completion event returned by the operating system received by the second thread, processing IO query data in the IO completion event through a corresponding callback function, and filling the obtained IO query data into a key value query response message; and when the IO query data corresponding to all the IO query requests are filled into the key value query response message, returning the key value query response message to the query request initiating device.
Alternatively, the running process of the first thread and the running process of the second thread may be executed asynchronously.
As described above with reference to fig. 1 to 6, a query request processing method and a query request processing apparatus and a key-value query system according to an embodiment of the present specification are described. The above query request processing means may be implemented by hardware, or may be implemented by software, or a combination of hardware and software.
Fig. 7 shows a schematic diagram of a query request processing apparatus 700 implemented based on a computer system for processing a key-value query request according to an embodiment of the present specification. As shown in fig. 7, the query request processing apparatus 700 may include at least one processor 710, a storage (e.g., a non-volatile storage) 720, a memory 730, and a communication interface 740, and the at least one processor 710, the storage 720, the memory 730, and the communication interface 740 are connected together via a bus 760. The at least one processor 710 executes at least one computer-readable instruction (i.e., the elements described above as being implemented in software) stored or encoded in memory.
In one embodiment, computer-executable instructions are stored in the memory that, when executed, cause the at least one processor 710 to: running the first thread of the first-second thread pair to perform the following process: in response to receiving a key value query request from a query request initiating device, allocating a first query context for the received key value query request from a query context pool of a first thread, wherein request parameters of the key value query request comprise at least one key; generating at least one IO query request according to the key value query request, wherein each key corresponds to one IO query request; setting a callback function of an IO completion event for each IO query request; saving request parameters of the key value query requests and callback functions of all IO query requests in a first query context; and submitting each IO query request and the corresponding callback function to an IO query request queue corresponding to a second thread in an operating system of the query request processing device, wherein the operating system initiates IO query aiming at the data storage device based on the IO query request queue, and runs the second thread to execute the following processes: responding to an IO completion event returned by the received operating system, processing IO query data in the IO completion event through a corresponding callback function, and filling the obtained IO query data into a key value query response message; and when the IO query data corresponding to all the IO query requests are filled into the key value query response message, returning the key value query response message to the query request initiating device.
It should be appreciated that the computer-executable instructions stored in the memory, when executed, cause the at least one processor 710 to perform the various operations and functions described above in connection with fig. 1-6 in the various embodiments of the present description.
According to one embodiment, a program product, such as a machine-readable medium (e.g., a non-transitory machine-readable medium), is provided. A machine-readable medium may have instructions (i.e., elements described above as being implemented in software) that, when executed by a machine, cause the machine to perform various operations and functions described above in connection with fig. 1-6 in the various embodiments of the present specification. Specifically, a system or apparatus may be provided which is provided with a readable storage medium on which software program code implementing the functions of any of the above embodiments is stored, and causes a computer or processor of the system or apparatus to read out and execute instructions stored in the readable storage medium.
In this case, the program code itself read from the readable medium can realize the functions of any of the above-described embodiments, and thus the machine-readable code and the readable storage medium storing the machine-readable code form part of the present invention.
Examples of the readable storage medium include floppy disks, hard disks, magneto-optical disks, optical disks (e.g., CD-ROMs, CD-R, CD-RWs, DVD-ROMs, DVD-RAMs, DVD-RWs), magnetic tapes, nonvolatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer or from the cloud via a communications network.
According to an embodiment, a computer program product is provided, which comprises a computer program that, when executed by a processor, causes the processor to perform the various operations and functions described above in connection with fig. 1-6 in the various embodiments of the present description.
It will be understood by those skilled in the art that various changes and modifications may be made in the above-disclosed embodiments without departing from the spirit of the invention. Accordingly, the scope of the invention should be determined from the following claims.
It should be noted that not all steps and units in the above flows and system structure diagrams are necessary, and some steps or units may be omitted according to actual needs. The execution order of the steps is not fixed, and can be determined as required. The apparatus structures described in the above embodiments may be physical structures or logical structures, that is, some units may be implemented by the same physical entity, or some units may be implemented by a plurality of physical entities, or some units may be implemented by some components in a plurality of independent devices.
In the above embodiments, the hardware units or modules may be implemented mechanically or electrically. For example, a hardware unit, module or processor may comprise permanently dedicated circuitry or logic (such as a dedicated processor, FPGA or ASIC) to perform the corresponding operations. The hardware units or processors may also include programmable logic or circuitry (e.g., a general purpose processor or other programmable processor) that may be temporarily configured by software to perform the corresponding operations. The specific implementation (mechanical, or dedicated permanent, or temporarily set) may be determined based on cost and time considerations.
The detailed description set forth above in connection with the appended drawings describes exemplary embodiments but does not represent all embodiments that may be practiced or fall within the scope of the claims. The term "exemplary" used throughout this specification means "serving as an example, instance, or illustration," and does not mean "preferred" or "advantageous" over other embodiments. The detailed description includes specific details for the purpose of providing an understanding of the described technology. However, the techniques may be practiced without these specific details. In some instances, well-known structures and devices are shown in block diagram form in order to avoid obscuring the concepts of the described embodiments.
The previous description of the disclosure is provided to enable any person skilled in the art to make or use the disclosure. Various modifications to the disclosure will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other variations without departing from the scope of the disclosure. Thus, the disclosure is not intended to be limited to the examples and designs described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (16)

1. A method for processing a key-value query request, the method performed by a query request processing device, the query request processing device created with a first thread-second thread pair, the method comprising:
executing a first thread of the first-second thread pair to perform the following:
responding to a received key value query request from a query request initiating device, and allocating a first query context for the key value query request from a query context pool of the first thread, wherein request parameters of the key value query request comprise at least one key;
generating at least one IO query request according to the key value query request, wherein each key corresponds to one IO query request;
setting a callback function of an IO completion event for each IO query request;
storing the request parameters of the key value query requests and callback functions of all IO query requests in the first query context; and
submitting each IO query request and the corresponding callback function to an IO query request queue corresponding to the second thread in an operating system of the query request processing device, wherein the operating system initiates an IO query for the data storage device based on the IO query request queue, the IO query refers to data interaction with the data storage device through an IO interface of the operating system,
running the second thread to perform the following process:
responding to the IO completion event returned by the operating system received by the second thread, processing the IO query data in the IO completion event through a corresponding callback function, and filling the obtained IO query data into a key value query response message;
and when the IO query data corresponding to all the IO query requests are filled in the key value query response message, returning the key value query response message to the query request initiating device.
2. The method of claim 1, wherein the processing of the first thread is performed asynchronously to the processing of the second thread.
3. The method of claim 1, wherein the first thread and the second thread share a same query context pool and a same IO query request queue.
4. The method of claim 1, further comprising:
and releasing the first query context allocated to the key value query request back to the query context pool through the second thread after receiving the IO completion event corresponding to all the IO query requests.
5. The method of claim 1, wherein the first thread-second thread pair comprises at least two first thread-second thread pairs, the method further comprising:
after allocating a last query context in the query context pool for the key-value query request from the query context pool of the first thread via the first thread and submitting a corresponding IO query request to the IO query request queue, maintaining the first thread in a blocked state until a previously allocated first query context is released back to the query context pool.
6. The method of claim 1, wherein when the number of keys included in the key-value query request initiated by the query request initiating device exceeds a predetermined value, the key-value query request is sent to the first thread after being split.
7. The method of claim 1, wherein the size of the assigned first query context is determined at least in part by the number of keys included in the key-value query request.
8. The method of claim 1, wherein the pool of query contexts has a predetermined number of query contexts.
9. The method of claim 8, wherein the predetermined number is determined based on computational power, memory capacity of the query request processing device, and/or read-write capability of the data storage device.
10. The method of claim 1, wherein the data storage device comprises a data storage local to the query request processing device or a data storage device remote from the query request processing device.
11. The method of any one of claims 1 to 10, wherein the method is applied to a distributed key-value query system, the query request initiating device comprises at least one client device, and the query request processing device comprises a server device.
12. A query request processing apparatus for processing a key-value query request, the query request processing apparatus being applied to a query request processing device, the query request processing apparatus comprising:
a thread creating unit that creates a first thread-second thread pair;
the thread initialization unit is used for performing thread initialization on the created first thread and the created second thread, wherein when the first thread is initialized, a query context pool is distributed to the first thread from a memory space of query request processing equipment, and when the second thread is initialized, an API (application program interface) in an operating system is called to create an IO query request queue; and
a thread running unit, running the first thread to execute the following query request processing procedures:
responding to a received key value query request from a query request initiating device, and allocating a first query context for the key value query request from a query context pool of the first thread, wherein request parameters of the key value query request comprise at least one key;
generating at least one IO query request according to the key value query request, wherein each key corresponds to one IO query request;
setting a callback function of an IO completion event for each IO query request in each IO query request;
storing the request parameters of the key value query requests and callback functions of all IO query requests in the first query context; and
submitting each IO query request and the corresponding callback function to an IO query request queue corresponding to the second thread in an operating system of the query request processing device, wherein the operating system initiates an IO query for the data storage device based on the IO query request queue, the IO query refers to data interaction with the data storage device through an IO interface of the operating system,
and operating the second thread to execute the following IO query result processing procedures:
responding to the IO completion event returned by the operating system received by the second thread, processing the IO query data in the IO completion event through a corresponding callback function, and filling the obtained IO query data into a key value query response message;
and when the IO query data corresponding to all the IO query requests are filled in the key value query response message, returning the key value query response message to the query request initiating device.
13. A query request processing apparatus comprising the query request processing device according to claim 12.
14. A key-value query system, comprising:
at least one inquiry request initiating device sends a key value inquiry request to an inquiry request processing device;
the query request processing device as claimed in claim 13; and
a data storage device.
15. An apparatus for processing a key-value query request, comprising:
at least one processor for executing a program code for the at least one processor,
a memory coupled to the at least one processor, an
A computer program stored in the memory, the computer program being executable by the at least one processor to implement the query request processing method as claimed in any one of claims 1 to 11.
16. A computer-readable storage medium storing executable instructions that, when executed, cause a processor to perform the query request processing method of any one of claims 1 to 11.
CN202110912297.9A 2021-08-10 2021-08-10 Query request processing method, device and equipment and key value query system Active CN113360525B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110912297.9A CN113360525B (en) 2021-08-10 2021-08-10 Query request processing method, device and equipment and key value query system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110912297.9A CN113360525B (en) 2021-08-10 2021-08-10 Query request processing method, device and equipment and key value query system

Publications (2)

Publication Number Publication Date
CN113360525A CN113360525A (en) 2021-09-07
CN113360525B true CN113360525B (en) 2021-12-07

Family

ID=77540796

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110912297.9A Active CN113360525B (en) 2021-08-10 2021-08-10 Query request processing method, device and equipment and key value query system

Country Status (1)

Country Link
CN (1) CN113360525B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103246659A (en) * 2012-02-06 2013-08-14 阿里巴巴集团控股有限公司 Method and device for key value data query
CN105631318A (en) * 2015-12-23 2016-06-01 北京金山安全软件有限公司 Method and device for acquiring registry key values
CN106021399A (en) * 2016-05-12 2016-10-12 网易(杭州)网络有限公司 Query request message processing method and apparatus
CN106850698A (en) * 2017-04-06 2017-06-13 广东浪潮大数据研究有限公司 A kind of User space RPC agreement multithreading optimization methods and system
CN109495303A (en) * 2018-11-19 2019-03-19 广州开信通讯***有限公司 Obtain the method, device network managing device and system, electronic device and storage medium of equipment parameter information
CN111597061A (en) * 2020-05-25 2020-08-28 瑞斯康达科技发展股份有限公司 Method and device for remote procedure call of client or server

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140214833A1 (en) * 2013-01-31 2014-07-31 Hewlett-Packard Development Company, L.P. Searching threads
CN106790022B (en) * 2016-12-14 2019-06-18 福建天泉教育科技有限公司 Communication means and its system based on more inquiry threads
CN107341056A (en) * 2017-07-05 2017-11-10 郑州云海信息技术有限公司 A kind of method and device of the thread distribution based on NFS

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103246659A (en) * 2012-02-06 2013-08-14 阿里巴巴集团控股有限公司 Method and device for key value data query
CN105631318A (en) * 2015-12-23 2016-06-01 北京金山安全软件有限公司 Method and device for acquiring registry key values
CN106021399A (en) * 2016-05-12 2016-10-12 网易(杭州)网络有限公司 Query request message processing method and apparatus
CN106850698A (en) * 2017-04-06 2017-06-13 广东浪潮大数据研究有限公司 A kind of User space RPC agreement multithreading optimization methods and system
CN109495303A (en) * 2018-11-19 2019-03-19 广州开信通讯***有限公司 Obtain the method, device network managing device and system, electronic device and storage medium of equipment parameter information
CN111597061A (en) * 2020-05-25 2020-08-28 瑞斯康达科技发展股份有限公司 Method and device for remote procedure call of client or server

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于用户级融合I/O的Key-Value存储***优化技术研究;安仲奇等;《计算机研究与发展》;20200331;第57卷(第3期);第649-659页 *

Also Published As

Publication number Publication date
CN113360525A (en) 2021-09-07

Similar Documents

Publication Publication Date Title
US7356680B2 (en) Method of loading information into a slave processor in a multi-processor system using an operating-system-friendly boot loader
US8566641B2 (en) Fault tolerant batch processing
US20130061220A1 (en) Method for on-demand inter-cloud load provisioning for transient bursts of computing needs
US9319281B2 (en) Resource management method, resource management device, and program product
US20090276781A1 (en) System and method for multi-level preemption scheduling in high performance processing
CN110188110B (en) Method and device for constructing distributed lock
CN110888893A (en) Order processing method based on micro-service e-commerce system
CN115509986B (en) Inter-core communication method, electronic device, and storage medium
CN112463290A (en) Method, system, apparatus and storage medium for dynamically adjusting the number of computing containers
WO2014202009A1 (en) Many-core system task management method and device
CN111045797A (en) Task scheduling execution method, related device and medium
CN111881476A (en) Object storage control method and device, computer equipment and storage medium
CN113360525B (en) Query request processing method, device and equipment and key value query system
CN111290842A (en) Task execution method and device
CN111835797A (en) Data processing method, device and equipment
US9342351B1 (en) Systems and methods for efficient DB2 outage operations
JP7122299B2 (en) Methods, apparatus, devices and storage media for performing processing tasks
CN110955461B (en) Processing method, device, system, server and storage medium for computing task
CN109558254B (en) Asynchronous callback method, system, device and computer readable storage medium
US11743200B2 (en) Techniques for improving resource utilization in a microservices architecture via priority queues
WO2018196459A1 (en) Download request processing method and apparatus, processing device and medium
CN112395063B (en) Dynamic multithreading scheduling method and system
CN113886082A (en) Request processing method and device, computing equipment and medium
CN114374657A (en) Data processing method and device
CN110008010B (en) System calling method, device, equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant