Thread scheduling method and device, equipment, medium and product

By determining the number of worker threads of the target thread group based on the request processing thread when receiving the data processing request, and processing the data processing request based on the request processing thread when the resource occupancy information does not meet the preset resource constraints, the problem of the thread group being unable to process the request when it is in an overloaded state is solved, and the request processing efficiency and resource utilization of the thread pool are improved.

CN119806778APending Publication Date: 2025-04-11JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411888449.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

In the prior art, the thread scheduling method cannot effectively process data operation requests when the thread group is in an overload state, resulting in low request processing efficiency, wasted thread pool resources, and low thread scheduling efficiency and intelligence.

Method used

When receiving the data processing request, the number of worker threads of the target thread group is determined based on the request processing thread, and when the resource occupancy information does not meet the preset resource limitation conditions, the data processing request is processed based on the request processing thread.

Benefits of technology

It realizes that the thread group can still process data processing requests when it is in an overloaded state, improves the request processing efficiency and resource utilization of the thread pool, and optimizes the thread scheduling strategy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806778A_ABST
    Figure CN119806778A_ABST
Patent Text Reader

Abstract

The invention discloses a thread scheduling method and device, equipment, a medium and a product. The method comprises the steps that under the condition that a data processing request for a database is received, a request processing thread corresponding to the data processing request is determined according to the data processing request; determining the number of working threads corresponding to a target thread group to which the request processing thread belongs according to the request processing thread; under the condition that the target thread group is determined to meet a first preset overload condition based on the number of the working threads, determining corresponding resource occupation information at the current moment; and under the condition that the resource occupation information does not meet the preset resource limiting condition, processing the data processing request based on the request processing thread. According to the technical scheme, the effect that the request distributed to the thread group can still be processed based on the threads in the thread group under the condition that the thread group is in the overload state and the whole thread group is in the idle state is achieved, and the effect that the threads in the thread pool are reasonably scheduled is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of thread scheduling, and in particular to a thread scheduling method, device, equipment, medium and product. Background Art

[0002] The database can manage and store data, and the operation of the data can be realized through the operation request to the database. After connecting to the database, the data in the database can be updated, deleted, and other operations. The database can use a multi-threaded database, which includes multiple threads. Each thread can receive the operation request for the data and perform the corresponding operation, so as to realize the simultaneous execution of multiple data operations and improve the execution efficiency of the database.

[0003] In the related art, threads are usually scheduled by randomly selecting any thread group from the thread pool when a data operation request is received, and using the threads included in the thread group to process the data operation request. However, this thread scheduling method cannot process data operation requests when the thread group is in an overloaded state, and needs to wait until the thread group is not in an overloaded state before processing the data operation request, which leads to low request processing efficiency, waste of thread pool resources, and low thread scheduling efficiency and intelligence. Summary of the invention

[0004] The present invention provides a thread scheduling method, device, equipment, medium and product to achieve the effect of reasonably scheduling threads in a thread pool.

[0005] According to one aspect of the present invention, a thread scheduling method is provided, the method comprising:

[0006] In case of receiving a data processing request for a database, determining a request processing thread corresponding to the data processing request according to the data processing request;

[0007] Determining the number of working threads corresponding to the target thread group to which the request processing thread belongs according to the request processing thread; wherein the target thread group is composed of at least one thread; the target thread group is used to process at least one data operation request associated with the data processing request; the target thread group belongs to a pre-created thread pool;

[0008] In a case where it is determined based on the number of working threads that the target thread group meets a first preset overload condition, determining corresponding resource occupancy information at a current moment;

[0009] When the resource occupancy information does not satisfy a preset resource restriction condition, the data processing request is processed based on the request processing thread.

[0010] According to another aspect of the present invention, a thread scheduling device is provided, the device comprising:

[0011] A thread determination module, configured to, upon receiving a data processing request for a database, determine a request processing thread corresponding to the data processing request according to the data processing request;

[0012] A working thread quantity determination module, used to determine the number of working threads corresponding to the target thread group to which the request processing thread belongs according to the request processing thread; wherein the target thread group is composed of at least one thread; the target thread group is used to process at least one data operation request associated with the data processing request; the target thread group belongs to a pre-created thread pool;

[0013] A resource occupancy information determination module, configured to determine the corresponding resource occupancy information at the current moment when it is determined based on the number of working threads that the target thread group meets a first preset overload condition;

[0014] The request processing module is used to process the data processing request based on the request processing thread when the resource occupancy information does not meet the preset resource restriction condition.

[0015] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0016] at least one processor; and

[0017] a memory communicatively connected to the at least one processor; wherein,

[0018] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the thread scheduling method described in any embodiment of the present invention.

[0019] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the thread scheduling method described in any embodiment of the present invention when executed.

[0020] According to another aspect of the present invention, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the thread scheduling method described in any embodiment of the present invention is implemented.

[0021] The technical solution of the embodiment of the present invention achieves the effect of determining the request processing thread corresponding to the data processing request according to the data processing request, and realizes the correspondence between the data processing request and the request processing thread used to process the data processing request; further, the number of working threads corresponding to the target thread group to which the request processing thread belongs is determined according to the request processing thread, thereby providing a data basis for subsequent scheduling of threads, and the target thread group is used to process at least one data operation request associated with the data processing request, thereby realizing a one-to-one correspondence between the data processing request and the target thread group; when it is determined based on the number of working threads that the target thread group satisfies the first preset overload condition, it is determined that the corresponding The resource occupancy information of the thread group is realized, and the effect of scheduling the threads in the thread group according to the resource occupancy information is achieved when the thread group is in an overloaded state; when the resource occupancy information does not meet the preset resource restriction conditions, the data processing request is processed based on the request processing thread, which solves the problems of low request processing efficiency, thread pool resource waste, low thread scheduling efficiency and intelligence in the related technology, and realizes that when the thread group is in an overloaded state but the whole is in an idle state, the request allocated to the thread group can still be processed based on the threads in the thread group, and the effect of reasonably scheduling the threads in the thread pool is achieved, the request processing efficiency is improved, and the thread utilization rate in the thread pool is improved. By scheduling threads according to resource occupancy information when the thread group is in an overloaded state, the thread scheduling strategy in the thread pool is prioritized.

[0022] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0024] Figure 1 is a flowchart of a thread scheduling method provided according to Embodiment 1 of the present invention;

[0025] Figure 2 is a flowchart of a thread scheduling method provided according to Embodiment 2 of the present invention;

[0026] Figure 3is a structural diagram of a thread scheduling device provided according to Embodiment 3 of the present invention;

[0027] Figure 4 It is a structural schematic diagram of an electronic device for implementing the thread scheduling method according to an embodiment of the present invention. DETAILED DESCRIPTION

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

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

[0030] Embodiment 1

[0031] Figure 1 This is a flowchart of a thread scheduling method provided by the first embodiment of the present invention. This embodiment is applicable to the case where, when a data processing request is received, threads in a thread pool are scheduled to process the data processing request. The method can be executed by a thread scheduling device, which can be implemented in the form of hardware and / or software, and can be configured in a terminal and / or a server. Figure 1 As shown, the method includes:

[0032] S110 . When a data processing request for a database is received, a request processing thread corresponding to the data processing request is determined according to the data processing request.

[0033] Among them, the database can be a data management system used in the server to store and manage a large amount of data. The data processing request can be understood as an instruction requesting the execution of the data processing operation. The data processing request can be a pre-written program code, which is used to implement the data processing function. The data processing request can be a statement written in any programming language, optionally, a SQL statement. In this embodiment, the data processing request can be an instruction for requesting the execution of relevant data processing operations on the database. Optionally, the data processing request includes but is not limited to a data query request, a data addition request, a data deletion request, and a data modification request. The generation triggering method of the data processing request can include multiple methods. Optionally, when a trigger operation for a preset data processing control is received, a data processing request can be generated; or, when it is detected that the audio information received by the user end includes a trigger word associated with the data processing request, a data processing request can be generated; or, when it is detected that the received instruction includes a data processing request trigger instruction, a data processing request can be generated. The request processing thread can be a thread for processing requests sent by the client. Generally, when the client sends a request to the server, the request detection module on the server receives these requests. Furthermore, the server will allocate one or more threads from the thread pool to process these requests. The allocated threads will be responsible for receiving requests, parsing requests, executing corresponding business logic, and generating responses. After processing, the thread will return the generated response to the client. The thread that has processed the request will be released and returned to the thread pool, waiting to process other requests. The thread pool can be understood as a pre-built space for threads to store certain data. The thread pool is usually a multi-threaded concurrent processing mode that creates and maintains a certain number of threads in advance and puts these threads into a "pool".

[0034] In this embodiment, when a user requests to perform a data processing operation on data in a database, a data processing request can be generated based on the client, and the data processing request can be sent to the server. Further, when the server receives the data processing request, a data processing thread corresponding to the data processing request can be determined from a thread pool according to the data processing request.

[0035] As an optional implementation of this embodiment, the thread pool includes at least one thread group; when a data processing request is received, a thread group corresponding to the data processing request can be determined from the at least one thread group according to a request identifier carried in the data processing request. Further, a request processing thread corresponding to the data processing request can be determined according to the working status information of the threads included in the thread group.

[0036] S120 , determining the number of working threads of the target thread group to which the request processing thread belongs according to the request processing thread.

[0037] Among them, the target thread group may be composed of at least one thread. The target thread group is used to process at least one data operation request associated with the data processing request. The data processing request and at least one data operation request associated with it may be operation requests input for the same operation object. Exemplarily, the data processing request and at least one data operation request associated with it may be operation requests input for the same data table. The target thread group belongs to a pre-created thread pool. That is, the pre-created thread pool may include at least one thread group; and the thread group may include at least one thread. The number of working threads may be used to characterize the total number of working threads included in the target thread group. The working thread may generally be a thread whose thread state is a working state.

[0038] In this embodiment, when the request processing thread is determined, the request processing thread may be used as a working thread in the target thread group to which it belongs, and the number of working threads in the target thread group is determined.

[0039] Optionally, determining the number of working threads corresponding to the target thread group to which the request processing thread belongs based on the request processing thread includes: taking the request processing thread as the working thread in the target thread group to which it belongs, and determining the number of working threads corresponding to the target thread group based on the working threads included in the target thread.

[0040] The working thread may be a thread in a working state, that is, a thread that is processing a corresponding request.

[0041] As an optional implementation of this embodiment, when determining the request processing thread, the request processing thread can be used as a working thread in the target thread group to which it belongs. Further, the number of working threads corresponding to the target thread group can be determined according to all working threads included in the target thread group.

[0042] S130. When it is determined based on the number of working threads that the target thread group meets a first preset overload condition, determine corresponding resource occupation information at the current moment.

[0043] The first preset overload condition may be a predetermined standard for defining whether a thread group is overloaded. In this embodiment, whether the target thread group is in an overload state may be determined according to the first preset overload condition. When the target thread group satisfies the first preset overload condition, it may be determined that the target thread group is in an overload state; when the target thread group does not meet the first preset overload condition, it may be determined that the target thread group is not in an overload state. Optionally, the first preset overload condition may be that the number of working threads is greater than a first preset number threshold and less than or equal to a second preset number threshold. The first preset number threshold may be any value. The second preset number threshold may also be any value. The first preset number threshold is less than the second preset number threshold. The current moment may be the moment corresponding to when it is determined that the target thread group satisfies the first preset overload condition. The resource occupancy information may be information for characterizing resource occupancy. The resource occupancy information includes first resource occupancy information corresponding to the system to which the database belongs and / or second resource occupancy information corresponding to the thread pool. The first resource occupancy information may be information characterizing resource occupancy in the system. The system to which the database belongs may be a server; or, the system to which the database belongs may also be any data processing unit in the server. In addition to processing data processing requests for a database, the system can also be used to process other requests and / or to calculate other data volumes. The second resource occupancy information can be used to characterize the number of working threads of all thread groups included in the thread pool.

[0044] In actual applications, when it is determined that the target thread group for processing data processing requests is in an overloaded state, the data processing request is usually placed in a waiting queue, and after a preset period of time, it is re-judged whether the target thread group is in an overloaded state, until it is determined that the target thread group is not in an overloaded state, and the data processing request is processed based on the target thread group. In this case, when the target thread group is in an overloaded state, other thread groups are not in an overloaded state, or the system is currently in a resource-free state, it is still necessary to wait until the target thread group is not in an overloaded state before processing the data processing request, which leads to low request processing efficiency and low intelligence of the thread scheduling strategy.

[0045] In view of the above situation, in this embodiment, after determining the number of working threads of the target thread group, the working status information can be compared with the preset overload condition. Further, when it is determined that the number of working threads is greater than the first preset number threshold and less than or equal to the second preset number threshold, it can be determined that the target thread group meets the first preset overload condition, that is, it is determined that the target thread group is in an overload state. Further, the corresponding resource occupancy information at the current moment can be determined. Then, the thread scheduling strategy corresponding to the target thread group is determined based on the resource occupancy information.

[0046] It should be noted that the resource occupancy information includes the first resource occupancy information corresponding to the system to which the database belongs and / or the second resource occupancy information corresponding to the thread pool. That is to say, when determining the corresponding resource occupancy information at the current moment, the first resource occupancy information corresponding to the system to which the database belongs at the current moment can be determined, or the second resource occupancy information corresponding to the thread pool at the current moment can be determined. Further, the first resource occupancy information or the second resource occupancy information can be used as the corresponding resource occupancy information at the current moment. Or, when determining the corresponding resource occupancy information at the current moment, the first resource occupancy information corresponding to the system to which the database belongs at the current moment can be determined, and the second resource occupancy information corresponding to the thread pool at the current moment can be determined. Further, the first resource occupancy information and the second resource occupancy information can be used as the corresponding resource occupancy information at the current moment.

[0047] Optionally, the resource occupancy information includes system resource occupancy information; determining the corresponding resource occupancy information at the current moment includes: determining the resource occupancy rates corresponding to multiple resource evaluation indicators of the system to which the database belongs at the current moment; processing multiple resource occupancy rates by weighted summation or averaging to obtain the system resource occupancy information corresponding to the system at the current moment.

[0048] The resource evaluation index may be an index for evaluating resource occupancy. The resource evaluation index may include a variety of indicators for evaluating resource occupancy, including, optionally, CPU space occupancy, memory space occupancy, disk space occupancy, and input / output (I / O) device utilization.

[0049] As an optional implementation of this embodiment, when it is determined that the target thread group meets the first preset overload condition, multiple resource evaluation indicators corresponding to the system to which the database belongs at the current moment can be obtained. Further, the weight value corresponding to each resource evaluation indicator is determined respectively, and a weighted sum operation is performed on the multiple resource evaluation indicators and their corresponding weight values, and the value obtained by the operation is used as the system resource occupancy information corresponding to the system to which the database belongs at the current moment.

[0050] As another optional implementation of this embodiment, when it is determined that the target thread group meets the first preset overload condition, multiple resource evaluation indicators corresponding to the system to which the database belongs at the current moment can be obtained. Further, an average operation can be performed on the multiple resource evaluation indicators, and the average value obtained by the operation is used as the system resource occupancy information corresponding to the system to which the database belongs at the current moment.

[0051] Optionally, the resource occupancy information includes second resource occupancy information corresponding to the thread pool; determining the corresponding resource occupancy information at the current moment includes: determining the number of working threads corresponding to each thread group included in the thread pool; adding the number of each working thread to obtain the second resource occupancy information corresponding to the thread pool at the current moment.

[0052] As an optional implementation of this embodiment, when it is determined that the target thread group meets the first preset overload condition, the number of working threads corresponding to each thread group included in the thread group can be determined. Further, the number of working threads can be added together, and the number of threads obtained after the addition is used as the second resource occupancy information corresponding to the thread pool at the current moment.

[0053] S140: When the resource occupancy information does not satisfy a preset resource restriction condition, process the data processing request based on a request processing thread.

[0054] Among them, the preset resource restriction condition may be a predetermined standard for determining whether resource restriction is required. The preset resource restriction condition may also be used to determine whether it is in a resource-constrained state. Optionally, the preset resource restriction condition may include at least one of the following: the first resource occupancy information is not less than the first resource occupancy threshold; the second resource occupancy information is not less than the second resource occupancy threshold. The first resource occupancy threshold may be a pre-set standard for determining whether the system to which the database belongs is in a resource-constrained state. The first resource occupancy threshold may be any value, optionally, 0.5, 0.6 or 0.7, etc. The second resource occupancy threshold may be a pre-set standard for determining whether the thread pool is in a resource-constrained state. The second resource occupancy threshold is determined based on the first preset ratio threshold and the number of thread groups included in the thread pool. Exemplarily, the product between the first preset ratio threshold and the number of thread groups included in the thread pool may be determined, and the product may be used as the second resource occupancy threshold.

[0055] As an optional implementation of this embodiment, when the resource occupancy information is the first resource occupancy information, the first resource occupancy information may be compared with the first resource occupancy threshold. Further, when it is determined that the first resource occupancy information is less than the first resource occupancy threshold, it may be determined that the resource occupancy information does not meet the preset resource restriction condition. Further, the data processing request may be processed based on the request processing thread.

[0056] As another optional implementation of this embodiment, when the resource occupancy information is the second resource occupancy information, the second resource occupancy information may be compared with the second resource occupancy threshold. Further, when it is determined that the second resource occupancy information is less than the second resource occupancy threshold, it may be determined that the resource occupancy information does not meet the preset resource restriction condition. Further, the data processing request may be processed based on the request processing thread.

[0057] As another optional implementation of this embodiment, when the resource occupancy information includes the first resource occupancy information and the second resource occupancy information, the first resource occupancy information may be compared with the first resource occupancy threshold, and the second resource occupancy information may be compared with the second resource occupancy threshold. Further, when the first resource occupancy information is less than the first resource occupancy threshold, or the second resource occupancy information is less than the second resource occupancy threshold, it may be determined that the resource occupancy information does not meet the preset resource restriction condition. Further, the data processing request may be processed based on the request processing thread.

[0058] In this embodiment, it also includes: when it is determined based on the number of working threads that the target thread group meets the third preset overload condition, or when the resource occupancy information meets the preset resource limitation condition, after a preset period of time, the steps of determining the number of working threads of the target thread group to which the request processing thread belongs and determining whether the thread group meets the preset overload condition based on the number of working threads are re-executed.

[0059] Among them, the third preset overload condition may be a predetermined standard for defining whether the thread group is in a severe overload state. In this embodiment, whether the target thread group is in a severe overload state may be determined based on the third preset overload condition. When the target thread group meets the third preset overload condition, it may be determined that the target thread group is in a severe overload state; when the target thread group does not meet the third preset overload condition, it may be determined that the target thread group is not in a severe overload state. Optionally, the third preset overload condition may be that the number of working threads is greater than the second preset number threshold.

[0060] As an optional implementation of this embodiment, after obtaining the number of working threads corresponding to the target thread, the number of working threads can be compared with a first preset number threshold and a second preset number threshold. Further, when it is determined that the number of working threads is greater than the second preset number threshold, it can be determined that the target thread group meets a third preset overload condition. Furthermore, it can be determined that the target thread group is in a serious overload state. Further, the data processing request can be placed in a waiting queue, and after a preset period of time, the steps of determining the number of working threads of the target thread group to which the request processing thread belongs and determining whether the thread group meets the preset overload condition based on the number of working threads are re-executed until the data processing request can be executed based on the request processing thread.

[0061] As another optional implementation of this embodiment, after determining the corresponding resource occupancy information at the current moment, when the resource occupancy information includes the first resource occupancy information, the first resource occupancy information can be compared with the first resource occupancy threshold. Further, when it is determined that the first resource occupancy information is not less than the first resource occupancy threshold, it can be determined that the resource occupancy information meets the preset resource restriction condition, that is, it is determined that the system to which the database belongs is in a resource-constrained state. Further, the data processing request can be put into a waiting queue, and after a preset period of time, the steps of determining the number of working threads of the target thread group to which the request processing thread belongs and determining whether the thread group meets the preset overload condition based on the number of working threads are re-executed until the data processing request can be processed based on the request processing thread.

[0062] As another optional implementation of this embodiment, after determining the corresponding resource occupancy information at the current moment, when the resource occupancy information includes the second resource occupancy information, the second resource occupancy information can be compared with the second resource occupancy threshold. Further, when it is determined that the second resource occupancy information is not less than the second resource occupancy threshold, it can be determined that the resource occupancy information meets the preset resource restriction condition, that is, it is determined that the thread pool is in a resource-constrained state. Further, the data processing request can be put into a waiting queue, and after a preset period of time, the steps of determining the number of working threads of the target thread group to which the request processing thread belongs and determining whether the thread group meets the preset overload condition based on the number of working threads are re-executed until the data processing request can be processed based on the request processing thread.

[0063] In this embodiment, in order to more clearly and intuitively understand the status of each thread group included in the thread pool and the status of each thread included in the thread group, it also includes: for at least one thread group included in the thread pool, obtaining the thread status corresponding to each thread in the thread group and the number of working threads and the number of idle threads corresponding to the thread group, and displaying each thread status, the number of working threads and the number of idle threads in association with the thread group.

[0064] As an optional implementation manner of this embodiment, after the request processing thread completes processing the data processing request, the number of working threads corresponding to the target thread group is determined; when it is determined based on the number of working threads that the target thread group meets the second preset overload condition, the length of time from the time the request processing thread completes processing the data processing request to the current moment is determined; when the time duration is greater than the preset idle duration threshold, the request processing thread is deleted from the target thread group.

[0065] As another optional implementation of this embodiment, after the request processing thread completes processing the data processing request, the number of working threads corresponding to the target thread group is determined; when it is determined based on the number of working threads that the target thread group does not meet the second preset overload condition, the total number of threads of the target thread group is determined; when the total number of threads is greater than the preset number of reserved threads, the request processing thread is deleted from the target thread group; when the total number of threads is not greater than the preset number of reserved threads, the request processing thread is retained in the target thread group, and the thread state of the request processing thread is adjusted to an idle state.

[0066] The technical solution of the embodiment of the present invention achieves the effect of determining the request processing thread corresponding to the data processing request according to the data processing request, and realizes the correspondence between the data processing request and the request processing thread used to process the data processing request; further, the number of working threads corresponding to the target thread group to which the request processing thread belongs is determined according to the request processing thread, thereby providing a data basis for subsequent scheduling of threads, and the target thread group is used to process at least one data operation request associated with the data processing request, thereby realizing a one-to-one correspondence between the data processing request and the target thread group; when it is determined based on the number of working threads that the target thread group satisfies the first preset overload condition, it is determined that the corresponding The resource occupancy information of the thread group is realized, and the effect of scheduling the threads in the thread group according to the resource occupancy information is achieved when the thread group is in an overloaded state; when the resource occupancy information does not meet the preset resource restriction conditions, the data processing request is processed based on the request processing thread, which solves the problems of low request processing efficiency, thread pool resource waste, low thread scheduling efficiency and intelligence in the related technology, and realizes that when the thread group is in an overloaded state but the whole is in an idle state, the request allocated to the thread group can still be processed based on the threads in the thread group, and the effect of reasonably scheduling the threads in the thread pool is achieved, the request processing efficiency is improved, and the thread utilization rate in the thread pool is improved. By scheduling threads according to resource occupancy information when the thread group is in an overloaded state, the thread scheduling strategy in the thread pool is prioritized.

[0067] Embodiment 2

[0068] Figure 2It is a flowchart of a thread scheduling method provided in the second embodiment of the present invention. On the basis of the above embodiment, the method for determining the request processing thread is further refined. Optionally, the thread pool includes at least one thread group; determining the request processing thread corresponding to the data processing request includes: determining the thread group corresponding to the data processing request from at least one thread group according to the request identifier carried in the data processing request and the number of thread groups included in the thread pool; determining the request processing thread corresponding to the data processing request according to the thread group corresponding to the data processing request. The specific implementation method can refer to the technical solution of this embodiment. Among them, the technical terms that are the same or similar to those in the above embodiment are not repeated here.

[0069] like Figure 2 As shown, the method includes:

[0070] S210. When a data processing request for a database is received, a target thread group corresponding to the data processing request is determined from at least one thread group according to a request identifier carried in the data processing request and the number of thread groups included in the thread pool.

[0071] The request identifier may be information used to distinguish a data processing request. The request identifier may be any type of information, and may optionally be a request identification code. It should be noted that the request identifier carried in at least one data operation request associated with the data processing request is consistent with the request identifier carried in the data processing request. The number of thread groups is the number of all thread groups included in the thread pool.

[0072] In this embodiment, when a data processing request for a database is received, a request identifier carried in the data processing request and the number of thread groups included in the thread pool can be obtained. Further, the request identifier and the number of thread groups are processed according to a preset data processing algorithm, and a target thread group corresponding to the data processing request is determined from at least one thread group based on the values ​​obtained after the processing.

[0073] Optionally, based on the request identifier carried in the data processing request and the number of thread groups included in the thread pool, a target thread group corresponding to the data processing request is determined from at least one thread group, including: processing the request identifier and the number of thread groups included in the thread pool according to a hash algorithm to obtain a target parameter corresponding to the data processing request; determining a thread group whose thread group identifier is a target parameter based on the thread group identifier corresponding to at least one thread group, and using the determined thread group as the target thread group corresponding to the data processing request.

[0074] The thread group identifier may be information used to distinguish threads. The thread group identifier may be any type of information, and may optionally be a thread group identification code.

[0075] As an optional implementation of this embodiment, when a data processing request for a database is received, the request identifier carried in the data processing request can be obtained, and the number of thread groups included in the thread pool can be obtained. Further, the request identifier and the number of thread groups can be calculated by a hash algorithm, and a target parameter corresponding to the data processing request can be obtained. Further, the thread group identifiers corresponding to each thread group included in the thread pool can be obtained, and the thread group whose thread group identifier is the target parameter can be determined according to the thread group identifier corresponding to at least one thread group, and the determined thread group is used as the target thread group corresponding to the data processing request.

[0076] S220: Determine a request processing thread corresponding to the data processing request according to the target thread group corresponding to the data processing request.

[0077] In this embodiment, when determining the target thread group corresponding to the data processing request, a request processing thread corresponding to the data processing request may be determined from at least one thread included in the target thread group.

[0078] It should be noted that when determining the request processing thread corresponding to the data processing request, there may be two situations in the target thread group, namely, there are idle threads and there are no idle threads. For these two situations, there may be two corresponding thread determination methods.

[0079] Optionally, determining a request processing thread corresponding to the data processing request based on a target thread group corresponding to the data processing request includes: determining thread states corresponding to respective threads included in the target thread group corresponding to the data processing request; and determining a request processing thread corresponding to the data processing request based on the idle threads when it is determined that there are idle threads in the target thread group based on the respective thread states.

[0080] The thread state generally refers to different stages or conditions in its life cycle. Optionally, the thread state includes at least an idle state and a working state.

[0081] As an optional implementation of this embodiment, when determining the target thread group corresponding to the data processing request, the thread state corresponding to each thread can be determined according to the thread association information corresponding to each thread included in the target thread group. Further, each thread state is analyzed, and when it is determined that each thread state includes an idle state, it can be determined that there are idle threads in the target thread group. Further, a request processing thread can be selected from at least one idle thread according to a thread scheduling policy, and the request processing thread can be assigned to the data processing request. Among them, the thread scheduling policy can include any scheduling policy, optionally including a random scheduling policy and / or determining according to the idle time of the thread (e.g., threads with relatively long idle time are assigned first), etc.

[0082] Optionally, a request processing thread corresponding to the data processing request is determined based on a target thread group corresponding to the data processing request, including: when it is determined based on the states of each thread that there are no idle threads in the target thread group, determining the number of working threads corresponding to the target thread group; when it is determined based on the number of working threads that the target thread group does not meet a second preset overload condition, creating a working thread in the target thread group, and using the created working thread as the request processing thread corresponding to the data processing request.

[0083] The second preset overload condition may be a predetermined standard for determining whether the thread group is overloaded. Optionally, the second preset overload condition may include that the number of working threads is greater than a first preset number threshold; or the number of working threads is greater than a second preset number threshold.

[0084] As an optional implementation of this embodiment, each thread state is analyzed, and when it is determined that the idle state is not included in the thread states, it can be determined that there are no idle threads in the target thread group. Further, the number of working threads corresponding to the target thread group can be determined based on the acquired thread states. Further, the number of working threads can be compared with a first preset number threshold or a second preset number threshold. When the number of working threads is less than the first preset number threshold, or the number of working threads is less than the second preset number threshold, it can be determined that the target thread group does not meet the second preset overload condition. Further, a working thread can be created in the target thread group, and the created working thread can be used as a request processing thread corresponding to the data processing request.

[0085] S230: Determine the number of working threads of the target thread group to which the request processing thread belongs according to the request processing thread.

[0086] S240: When it is determined based on the number of working threads that the target thread group meets the first preset overload condition, determine the corresponding resource occupation information at the current moment.

[0087] S250: When the resource occupancy information does not satisfy a preset resource restriction condition, process the data processing request based on a request processing thread.

[0088] The technical solution of the embodiment of the present invention achieves the effect of determining the request processing thread corresponding to the data processing request according to the data processing request when receiving a data processing request for a database, and realizes the correspondence between the data processing request and the request processing thread used to process the data processing request; further, the number of working threads corresponding to the target thread group to which the request processing thread belongs is determined according to the request processing thread, which provides a data basis for subsequent scheduling of threads, and the target thread group is used to process at least one data operation request associated with the data processing request, thereby realizing a one-to-one correspondence between the data processing request and the target thread group; when the target thread group is determined based on the number of working threads to meet the first Under the preset overload condition, the corresponding resource occupancy information at the current moment is determined, so that when the thread group is in an overloaded state, the threads in the thread group are scheduled according to the resource occupancy information; when the resource occupancy information does not meet the preset resource restriction condition, the data processing request is processed based on the request processing thread, so that when the thread group is in an overloaded state but the whole is in an idle state, the request allocated to the thread group can still be processed based on the threads in the thread group, and the effect of reasonable scheduling of threads in the thread pool is achieved, the request processing efficiency is improved, and the thread utilization rate in the thread pool is improved. By scheduling threads according to resource occupancy information when the thread group is in an overloaded state, the thread scheduling strategy in the thread pool is prioritized.

[0089] Embodiment 3

[0090] Figure 3 Schematic diagram of the structure of a thread scheduling device provided by Embodiment 3 of the present invention. Figure 3 As shown, the device includes: a thread determination module 310, a work thread quantity determination module 320, a resource occupancy information determination module 330 and a request processing module 340.

[0091] Among them, the thread determination module 310 is used to determine the request processing thread corresponding to the data processing request according to the data processing request when a data processing request for a database is received; the working thread number determination module 320 is used to determine the number of working threads corresponding to the target thread group to which the request processing thread belongs according to the request processing thread; wherein the target thread group is composed of at least one thread; the target thread group is used to process at least one data operation request associated with the data processing request; the target thread group belongs to a pre-created thread pool; the resource occupancy information determination module 330 is used to determine the corresponding resource occupancy information at the current moment when it is determined based on the number of working threads that the target thread group meets the first preset overload condition; the request processing module 340 is used to process the data processing request based on the request processing thread when the resource occupancy information does not meet the preset resource restriction condition.

[0092] The technical solution of the embodiment of the present invention achieves the effect of determining the request processing thread corresponding to the data processing request according to the data processing request, and realizes the correspondence between the data processing request and the request processing thread used to process the data processing request; further, the number of working threads corresponding to the target thread group to which the request processing thread belongs is determined according to the request processing thread, thereby providing a data basis for subsequent scheduling of threads, and the target thread group is used to process at least one data operation request associated with the data processing request, thereby realizing a one-to-one correspondence between the data processing request and the target thread group; when it is determined based on the number of working threads that the target thread group satisfies the first preset overload condition, it is determined that the corresponding The resource occupancy information of the thread group is realized, and the effect of scheduling the threads in the thread group according to the resource occupancy information is achieved when the thread group is in an overloaded state; when the resource occupancy information does not meet the preset resource restriction conditions, the data processing request is processed based on the request processing thread, which solves the problems of low request processing efficiency, thread pool resource waste, low thread scheduling efficiency and intelligence in the related technology, and realizes that when the thread group is in an overloaded state but the whole is in an idle state, the request allocated to the thread group can still be processed based on the threads in the thread group, and the effect of reasonably scheduling the threads in the thread pool is achieved, the request processing efficiency is improved, and the thread utilization rate in the thread pool is improved. By scheduling threads according to resource occupancy information when the thread group is in an overloaded state, the thread scheduling strategy in the thread pool is prioritized.

[0093] Optionally, the working thread quantity determination module 320 is specifically configured to use the request processing thread as a working thread in the target thread group to which it belongs, and determine the number of working threads corresponding to the target thread group according to the working threads included in the target thread group.

[0094] Optionally, the first preset overload condition is that the number of working threads is greater than a first preset number threshold and less than or equal to a second preset number threshold.

[0095] Optionally, the thread pool includes at least one thread group; the thread determination module 310 includes: a target thread group determination unit and a thread determination unit.

[0096] a target thread group determining unit, configured to determine a target thread group corresponding to the data processing request from at least one of the thread groups according to a request identifier carried in the data processing request and the number of thread groups included in the thread pool;

[0097] The thread determination unit is used to determine a request processing thread corresponding to the data processing request according to a target thread group corresponding to the data processing request.

[0098] Optionally, the thread determination unit includes: a thread state determination subunit, a first thread determination unit, a working thread quantity determination unit and a second thread determination unit.

[0099] A thread state determination subunit, used to determine the thread state corresponding to each thread included in the target thread group corresponding to the data processing request;

[0100] a first thread determination unit, configured to determine a request processing thread corresponding to the data processing request according to the idle threads when it is determined based on the states of each of the threads that there are idle threads in the target thread group;

[0101] a working thread quantity determining unit, configured to determine the number of working threads corresponding to the target thread group when it is determined based on the states of each of the threads that no idle threads exist in the target thread group;

[0102] The second thread determination unit is used to create a working thread in the target thread group when it is determined based on the number of working threads that the target thread group does not meet the second preset overload condition, and use the created working thread as a request processing thread corresponding to the data processing request.

[0103] Optionally, the resource occupancy information includes first resource occupancy information corresponding to the system to which the database belongs; the resource occupancy information determination module 330 includes: an evaluation index determination unit and a first resource occupancy information determination unit.

[0104] An evaluation index determination unit, used to determine a plurality of resource evaluation indexes corresponding to the system to which the database belongs at the current moment;

[0105] A first resource occupancy information determining unit, configured to process a plurality of resource evaluation indicators by weighted sum operation or average operation to obtain first resource occupancy information corresponding to the system at the current moment;

[0106] The preset resource restriction condition is that the first resource occupancy information is not less than a first resource occupancy threshold.

[0107] Optionally, the resource occupancy information includes second resource occupancy information corresponding to the thread pool; the resource occupancy information determination module 330 also includes: a working thread quantity determination unit and a second resource occupancy information determination unit.

[0108] A working thread quantity determination unit, used to determine the number of working threads corresponding to each thread group included in the thread pool;

[0109] A second resource occupancy information determining unit, configured to add the number of each worker thread to obtain the second resource occupancy information corresponding to the thread pool at the current moment;

[0110] The preset resource restriction condition is that the second resource occupation information is not less than a second resource occupation threshold; wherein the second resource occupation threshold is determined based on a first preset quantity threshold and the number of thread groups included in the thread pool.

[0111] Optionally, the device further includes: a thread group information display module.

[0112] A thread group information display module is used to obtain, for at least one thread group included in the thread pool, the thread status corresponding to each thread in the thread group and the number of working threads and the number of idle threads corresponding to the thread group, and associate the thread status, the number of working threads and the number of idle threads with the thread group for display.

[0113] The thread scheduling device provided in the embodiment of the present invention can execute the thread scheduling method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0114] Embodiment 4

[0115] Figure 4A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0116] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0117] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0118] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a thread scheduling method.

[0119] In some embodiments, the thread scheduling method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the thread scheduling method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the thread scheduling method in any other appropriate manner (e.g., by means of firmware).

[0120] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0121] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0122] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0123] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0124] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a target blockchain network, and the Internet.

[0125] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0126] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0127] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A thread scheduling method, characterized in that: include: In case of receiving a data processing request for a database, determining a request processing thread corresponding to the data processing request according to the data processing request; Determining the number of working threads corresponding to the target thread group to which the request processing thread belongs according to the request processing thread; wherein the target thread group is composed of at least one thread; the target thread group is used to process at least one data operation request associated with the data processing request; the target thread group belongs to a pre-created thread pool; In a case where it is determined based on the number of working threads that the target thread group meets a first preset overload condition, determining corresponding resource occupancy information at a current moment; When the resource occupancy information does not satisfy a preset resource restriction condition, the data processing request is processed based on the request processing thread.

2. The thread scheduling method according to claim 1, characterized in that: The determining, according to the request processing thread, the number of working threads corresponding to the target thread group to which the request processing thread belongs includes: The request processing thread is used as a working thread in the target thread group to which it belongs, and the number of working threads corresponding to the target thread group is determined according to the working threads included in the target thread.

3. The thread scheduling method according to claim 1, characterized in that: The first preset overload condition is that the number of working threads is greater than a first preset number threshold and is less than or equal to a second preset number threshold.

4. The thread scheduling method according to claim 1, characterized in that: The thread pool includes at least one thread group; the determining a request processing thread corresponding to the data processing request according to the data processing request includes: Determining a target thread group corresponding to the data processing request from at least one of the thread groups according to the request identifier carried in the data processing request and the number of thread groups included in the thread pool; A request processing thread corresponding to the data processing request is determined according to a target thread group corresponding to the data processing request.

5. The thread scheduling method according to claim 4, characterized in that: The determining the request processing thread corresponding to the data processing request according to the target thread group corresponding to the data processing request includes: Determine a thread state corresponding to each thread included in a target thread group corresponding to the data processing request; In a case where it is determined based on each of the thread states that there is an idle thread in the target thread group, determining a request processing thread corresponding to the data processing request according to the idle thread; or, In a case where it is determined based on each of the thread states that no idle threads exist in the target thread group, determining the number of working threads corresponding to the target thread group; When it is determined based on the number of working threads that the target thread group does not meet the second preset overload condition, a working thread is created in the target thread group, and the created working thread is used as a request processing thread corresponding to the data processing request.

6. The thread scheduling method according to claim 1, characterized in that: The resource occupation information includes first resource occupation information corresponding to the system to which the database belongs; The determining of the resource occupancy information corresponding to the current moment includes: Determine a plurality of resource evaluation indicators corresponding to the system to which the database belongs at the current moment; Processing the plurality of resource evaluation indicators by weighted sum operation or average operation to obtain first resource occupancy information corresponding to the system at the current moment; The preset resource restriction condition is that the first resource occupancy information is not less than a first resource occupancy threshold.

7. The thread scheduling method according to claim 1, characterized in that: The resource occupancy information includes the second resource occupancy information corresponding to the thread pool; the resource occupancy information corresponding to the current moment is determined, including: Determine the number of working threads corresponding to each thread group included in the thread pool; Adding the numbers of each worker thread to obtain the second resource occupancy information corresponding to the thread pool at the current moment; The preset resource restriction condition is that the second resource occupation information is not less than a second resource occupation threshold; wherein the second resource occupation threshold is determined based on a first preset quantity threshold and the number of thread groups included in the thread pool.

8. The thread scheduling method according to claim 1, characterized in that: Also includes: For at least one thread group included in the thread pool, the thread state corresponding to each thread in the thread group and the number of working threads and the number of idle threads corresponding to the thread group are obtained, and each of the thread states, the number of working threads and the number of idle threads are associated with the thread group and displayed.

9. A thread scheduling device, characterized in that: include: A thread determination module, configured to, upon receiving a data processing request for a database, determine a request processing thread corresponding to the data processing request according to the data processing request; A working thread quantity determination module, used to determine the number of working threads corresponding to the target thread group to which the request processing thread belongs according to the request processing thread; wherein the target thread group is composed of at least one thread; the target thread group is used to process at least one data operation request associated with the data processing request; the target thread group belongs to a pre-created thread pool; A resource occupancy information determination module, configured to determine the corresponding resource occupancy information at the current moment when it is determined based on the number of working threads that the target thread group meets a first preset overload condition; The request processing module is used to process the data processing request based on the request processing thread when the resource occupancy information does not meet the preset resource restriction condition.

10. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the thread scheduling method according to any one of claims 1 to 8.