Resource allocation method and device based on database

By comparing the target tenant's resources and the idle capacity of the database cluster in the multi -tenant database system, determine and interrupt the task thread to release the resources, solve the problem of resource occupation between tenants, and improve the efficiency and fairness of resource distribution.

CN118796482BActive Publication Date: 2025-01-24SUZHOU JIBEISI DATA TECHNOLOGY CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411275738.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2025-01-24
Estimated Expiration
2044-09-12

AI Technical Summary

Technical Problem

In a multi-tenant database system, the tenant who logs in first takes up too much resources, causing the tenant who logs in later to be squeezed out, resulting in too long jobs.

Method used

By comparing the target tenant's resource occupation and the idle capacity of the database cluster, if the target tenant's resources occupancy is greater than the idle capacity, it is determined to be interrupted and interrupted its execution to release the resources; Based on the updated idle capacity as the target tenant to allocate resources.

Benefits of technology

It improves the efficiency of multi-tenant resource allocation, ensures the fairness of resource allocation, and avoids resource crowding among tenants.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796482B_ABST
    Figure CN118796482B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for resource allocation based on a database, which can be applied to the field of computer technology. The method includes: in response to a task processing request from a target tenant, obtaining the resource occupation amount and the free capacity of a database cluster of the target tenant; when the resource occupation amount of the target tenant is greater than the free capacity of the database cluster, determining at least one task thread to be interrupted from multiple task threads being executed; interrupting at least one task thread to be interrupted to obtain an updated free capacity of the database cluster; when the resource occupation amount of the target tenant is less than the updated free capacity of the database cluster, allocating resources to the task processing request based on the updated free capacity of the database cluster to generate a task thread for processing the task processing request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, in particular to the field of database technology, and more specifically to a resource allocation method and device based on a database. Background Art

[0002] As cloud computing technology matures, the resource utilization and operation efficiency of multi-tenant database systems have been significantly improved. In a multi-tenant database system, the available resources of each tenant can be managed so that each tenant can share the central processing unit, memory resources, or disk input and output resources of the database system.

[0003] However, when multiple tenants execute jobs at the same time, some tenants who logged in to the database system first occupy too much resource space for their jobs, which squeezes out some resource space for other tenants who logged in later, causing other tenants who logged in later to take too long to execute their jobs. Summary of the invention

[0004] In view of this, the present invention provides a resource allocation method and device based on a database.

[0005] One aspect of the present invention provides a database-based resource allocation method, comprising: in response to a task processing request from a target tenant, obtaining the resource occupancy and database cluster free capacity of the target tenant; when the resource occupancy of the target tenant is greater than the database cluster free capacity, determining at least one task thread to be interrupted from multiple task threads being executed; interrupting the at least one task thread to be interrupted to obtain an updated database cluster free capacity; when the resource occupancy of the target tenant is less than the updated database cluster free capacity, allocating resources to the task processing request based on the updated database cluster free capacity to generate a task thread for processing the task processing request.

[0006] Another aspect of the present invention provides a database-based resource allocation device, including: an acquisition module, used to respond to a task processing request from a target tenant, and obtain the resource occupancy and database cluster free capacity of the above-mentioned target tenant; a determination module, used to determine at least one task thread to be interrupted from multiple task threads being executed when the resource occupancy of the above-mentioned target tenant is greater than the above-mentioned database cluster free capacity; an interruption module, interrupting the above-mentioned at least one task thread to be interrupted to obtain an updated database cluster free capacity; a resource allocation module, when the resource occupancy of the above-mentioned target tenant is less than the above-mentioned updated database cluster free capacity, allocates resources to the above-mentioned task processing request based on the above-mentioned updated database cluster free capacity to generate a task thread for processing the above-mentioned task processing request.

[0007] Another aspect of the present invention provides an electronic device, comprising: one or more processors; a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.

[0008] Another aspect of the present invention provides a computer-readable storage medium having a computer program or instruction stored thereon, wherein the computer program or instruction implements the steps of the above method when executed by a processor.

[0009] Another aspect of the present invention provides a computer program product, comprising a computer program or instructions, which implement the steps of the above method when executed by a processor.

[0010] According to an embodiment of the present invention, by comparing the resource occupancy of the target tenant and the current free capacity of the database cluster, it is determined whether it is necessary to determine the task thread to be interrupted from the currently executing task thread. When the resource occupancy of the other target tenants corresponding to the task thread to be interrupted is greater than the predetermined resource occupancy, the task thread to be interrupted is interrupted to release the excess resources occupied by the other target tenants, and resources are allocated to the target tenant to process the target tenant's task processing request, thereby improving the efficiency of multi-tenant resource allocation while ensuring the execution fairness of resource allocation. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings.

[0012] Figure 1 An exemplary system architecture of a method and apparatus for allocating resources based on a database according to an embodiment of the present invention is shown.

[0013] Figure 2 A flow chart of a database-based resource allocation method according to an embodiment of the present invention is shown.

[0014] Figure 3 A flow chart of a method for determining target other tenants according to an embodiment of the present invention is shown.

[0015] Figure 4 A resource allocation method based on a database according to a specific embodiment of the present invention is shown.

[0016] Figure 5 A block diagram of a resource allocation device based on a database according to an embodiment of the present invention is shown.

[0017] Figure 6A block diagram of an electronic device suitable for implementing a resource allocation method based on a database according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0018] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.

[0019] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0020] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0021] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0022] In the technical solution of the present invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0023] In the scenario of using personal information for automated decision-making, the methods, devices, and systems provided by the embodiments of the present invention provide users with corresponding operation portals for users to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered. The expression "automated decision-making" here refers to the activity of automatically analyzing and evaluating an individual's behavioral habits, interests and hobbies, or economic, health, credit status, etc. through computer programs, and making decisions. The expression "expert decision-making" here refers to the activity of making decisions by people who specialize in a certain field, have specialized experience, knowledge and skills, and have reached a certain level of professionalism.

[0024] As cloud computing technology matures, the resource utilization and operation efficiency of multi-tenant database systems have been significantly improved. Multi-tenant database systems can provide independent database services to multiple independent tenants in a database cluster. In a multi-tenant database system, the available resources of each tenant can be managed so that each tenant can share the central processing unit, memory resources, or disk input and output resources of the database system.

[0025] However, when multiple tenants execute jobs at the same time, some tenants who logged in to the database system first occupy too much resource space for their jobs, which squeezes out some resource space for other tenants who logged in later, causing other tenants who logged in later to take too long to execute their jobs.

[0026] In view of this, an embodiment of the present invention compares the resource occupancy of the target tenant and the current free capacity of the database cluster to determine whether it is necessary to determine the task thread to be interrupted from the currently executing task thread. When the resource occupancy of the other target tenants corresponding to the task thread to be interrupted is greater than the predetermined resource occupancy, the task thread to be interrupted is interrupted to release the excess resources occupied by the other target tenants, and resources are allocated to the target tenant to process the target tenant's task processing request, thereby improving the efficiency of multi-tenant resource allocation while ensuring the execution fairness of resource allocation.

[0027] Specifically, an embodiment of the present invention provides a database-based resource allocation method, including: in response to a task processing request from a target tenant, obtaining the resource occupancy of the target tenant and the free capacity of the database cluster; when the resource occupancy of the target tenant is greater than the free capacity of the database cluster, determining at least one task thread to be interrupted from multiple task threads being executed; interrupting at least one task thread to be interrupted to obtain an updated free capacity of the database cluster; when the resource occupancy of the target tenant is less than the updated free capacity of the database cluster, allocating resources to the task processing request based on the updated free capacity of the database cluster to generate a task thread for processing the task processing request.

[0028] It should be noted that the database-based resource allocation method and device determined in the embodiment of the present invention can be used in the field of computer technology, such as the field of database technology. The database-based resource allocation method and device determined in the embodiment of the present invention can also be used in any field other than the field of computer technology, such as the field of computer science and information technology, the field of cloud computing technology, etc. The application field of the database-based resource allocation method and device determined in the embodiment of the present invention is not limited.

[0029] Figure 1 The following is an exemplary system architecture of a method and device for allocating resources based on a database that can be applied according to an embodiment of the present invention. It should be noted that: Figure 1 The examples shown are merely examples of system architectures to which the embodiments of the present invention may be applied, to help those skilled in the art understand the technical content of the present invention, but do not mean that the embodiments of the present invention may not be used in other devices, systems, environments or scenarios.

[0030] like Figure 1 As shown, the system architecture according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0031] The user may use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (only for example).

[0032] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0033] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0034] It should be noted that the resource allocation method based on the database provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the resource allocation device based on the database provided in the embodiment of the present invention can generally be set in the server 105. The resource allocation method based on the database provided in the embodiment of the present invention can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Correspondingly, the resource allocation device based on the database provided in the embodiment of the present invention can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Alternatively, the resource allocation method based on the database provided in the embodiment of the present invention can also be executed by the first terminal device 101, the second terminal device 102 or the third terminal device 103, or can also be executed by other terminal devices different from the first terminal device 101, the second terminal device 102 or the third terminal device 103. Correspondingly, the database-based resource allocation device provided in the embodiment of the present invention can also be set in the first terminal device 101, the second terminal device 102, or the third terminal device 103, or in other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103.

[0035] For example, the task processing request of the target tenant may come from any one of the first terminal device 101, the second terminal device 102, or the third terminal device 103 (for example, the first terminal device 101, but not limited thereto), or may be stored on an external storage device and may be imported into the first terminal device 101. Then, the first terminal device 101 may locally execute the resource allocation method based on the database provided in the embodiment of the present invention, or send the task processing request of the target tenant to other terminal devices, servers, or server clusters, and the resource allocation method based on the database provided in the embodiment of the present invention may be executed by the other terminal devices, servers, or server clusters that receive the task processing request of the target tenant.

[0036] It should be understood that Figure 1The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0037] Figure 2 A flow chart of a database-based resource allocation method according to an embodiment of the present invention is shown.

[0038] like Figure 2 As shown, the method includes operations S201 to S204.

[0039] In operation S201 , in response to a task processing request from a target tenant, the resource usage and database cluster idle capacity of the target tenant are obtained.

[0040] According to an embodiment of the present invention, a task processing request may be used to request processing of a data processing task associated with a target tenant, wherein the data processing task may include operations such as environment deployment, application development, data storage, and data access.

[0041] According to an embodiment of the present invention, the target tenant may be used to represent the tenant that sends a task processing request to the database at the current moment. The tenant may include a person, enterprise or group that rents the database.

[0042] According to an embodiment of the present invention, the resource usage of the target tenant can be used to characterize the amount of resources required for the data processing task requested by the target tenant to be processed at the current moment. The resource usage may include memory resource usage, CPU resource usage, etc.

[0043] According to an embodiment of the present invention, a database cluster may be used to represent a resource pool cluster that a database system may provide to a user, wherein the resource pool cluster may include multiple sub-resource pools.

[0044] According to an embodiment of the present invention, the free capacity of the database cluster may be used to characterize the remaining resource capacity in the resource pool cluster.

[0045] According to an embodiment of the present invention, when the server receives a task processing request from a target tenant, the resource occupancy required for the data processing task is obtained based on the data processing task requested to be processed by the target tenant. At the same time, the remaining resource capacity of the database cluster resource pool cluster at the current moment is also obtained.

[0046] In operation S202, when the resource usage of the target tenant is greater than the idle capacity of the database cluster, at least one task thread to be interrupted is determined from a plurality of task threads being executed.

[0047] According to an embodiment of the present invention, the data processing task sent by the target tenant may be executed by one or more concurrent threads in the database system.

[0048] According to an embodiment of the present invention, the resource usage of the target tenant is greater than the free capacity of the database cluster, which can be used to indicate that the remaining capacity of the database cluster at the current moment is insufficient to provide the target tenant with the required resources. Therefore, when the resource usage of the target tenant is greater than the free capacity of the database cluster, it is necessary to determine one or more task threads to be interrupted from the multiple task threads being executed. The multiple task threads being executed are generated for task processing requests of other tenants. The free capacity of the database cluster can be determined based on the resource usage of the multiple task threads being executed at the current moment.

[0049] According to an embodiment of the present invention, the resource occupancy of the target other tenants corresponding to at least one task thread to be interrupted is greater than the predetermined resource occupancy. The predetermined resource occupancy can be configured based on actual demand. In this embodiment, the predetermined resource occupancy can be determined based on the resource requirements of different tenants. For example, the resource requirement requested by tenant A is 10 bits, and the resource requirement requested by tenant B is 5 bits, then the predetermined resource occupancy of tenant A and tenant B can be configured as different values. Specifically, the predetermined resource occupancy of tenant A can be configured as 10 bits, and the predetermined resource occupancy of tenant B can be configured as 5 bits.

[0050] According to an embodiment of the present invention, the target other tenant is determined based on the resource occupation of the other tenants and the respective predetermined resource occupation. Specifically, if the resource occupation of the other tenant corresponding to the multiple task threads being executed is greater than the predetermined resource occupation, the tenant can be determined as the target other tenant.

[0051] According to an embodiment of the present invention, at least one task thread to be interrupted is determined based on a plurality of task threads being executed by target other tenants.

[0052] In operation S203, at least one task thread to be interrupted is interrupted to obtain updated free capacity of the database cluster.

[0053] According to an embodiment of the present invention, at least one task thread to be interrupted is interrupted, and based on the resource usage per unit time of multiple task threads remaining to be executed at the current moment, the free capacity of the database cluster is updated to obtain an updated free capacity of the database cluster.

[0054] For example, the free capacity of the database cluster is 1000 bits, and the resource occupancy of the task thread to be interrupted of the target other tenant C is 500 bits. The task thread to be interrupted is interrupted to release 500 bits of resources. At this time, the free capacity of the database cluster is updated based on the resources used per unit time by the remaining multiple task threads being executed, and the updated free capacity of the database cluster can be obtained as 1500 bits.

[0055] In operation S204, when the resource occupation amount of the target tenant is less than the updated free capacity of the database cluster, resources are allocated to the task processing request based on the updated free capacity of the database cluster to generate a task thread for processing the task processing request.

[0056] According to an embodiment of the present invention, when the updated free capacity of the database cluster is obtained, the resource occupancy of the target tenant can be compared with the updated database cluster space capacity. If the resource occupancy of the target tenant is less than the updated database cluster space capacity, it can be indicated that the database cluster space capacity at the current moment can allocate sufficient resources to the target tenant to process the task processing request. If the resource occupancy of the target tenant is greater than the updated database cluster space capacity, it means that the database cluster space capacity at the current moment is still insufficient to allocate sufficient resources to the target tenant to process the task processing request, and therefore, operation S203 needs to be performed again.

[0057] According to an embodiment of the present invention, when the resource occupation of the target tenant is less than the updated database cluster space capacity, resources are allocated to the task processing request based on the updated database cluster free capacity to generate a task thread for processing the task processing request.

[0058] The embodiment of the present invention compares the resource occupancy of the target tenant and the current free capacity of the database cluster to determine whether it is necessary to determine the task thread to be interrupted from the currently executing task threads. When the resource occupancy of the target other tenants corresponding to the task thread to be interrupted is greater than the predetermined resource occupancy, the task thread to be interrupted is interrupted to release the excess resources occupied by the target other tenants, and resources are allocated to the target tenant to process the target tenant's task processing request, thereby improving the efficiency of multi-tenant resource allocation while ensuring the execution fairness of resource allocation.

[0059] According to an embodiment of the present invention, when the resource occupancy of the target tenant is greater than the free capacity of the database cluster, determining at least one task thread to be interrupted from multiple task threads being executed includes: when the resource occupancy of the target tenant is greater than the free capacity of the database cluster, obtaining the resource occupancy and the predetermined resource occupancy of other target tenants corresponding to each of the multiple task threads being executed; when the resource occupancy of other target tenants is greater than the predetermined resource occupancy of other target tenants, determining at least one task thread among the multiple task threads being executed by other target tenants as a task thread to be interrupted.

[0060] According to an embodiment of the present invention, when the resource usage of the target tenant is greater than the idle capacity of the database cluster, the resource usage and the predetermined resource usage of other tenants corresponding to each of the multiple task threads being executed are obtained. Specifically, for other tenants corresponding to each of the multiple task threads currently being executed, the resource usage of each other tenant can be obtained based on the task processing requests of each of the other tenants. At the same time, the predetermined resource usage configured for each other tenant in the database cluster can also be obtained.

[0061] According to an embodiment of the present invention, the resource occupation amount of each other tenant is compared with the predetermined resource occupation amount to obtain a plurality of comparison results.

[0062] According to an embodiment of the present invention, if the comparison result indicates that the resource occupation of another tenant is greater than the predetermined resource occupation of the other tenant, the other tenant can be determined as the target other tenant, and one or more task threads among the multiple task threads being executed by the target other tenant can be determined as task threads to be interrupted.

[0063] According to an embodiment of the present invention, if the comparison result indicates that the resource occupation of another tenant is less than or equal to the predetermined resource occupation of the other tenant, the resource occupation of the next other tenant may be compared with the predetermined resource occupation.

[0064] An embodiment of the present invention compares the resource occupancy of target other tenants corresponding to each of the multiple task threads being executed with the predetermined resource occupancy to determine the target other tenants whose task threads need to be interrupted and the task threads to be interrupted, so that all tenants will not occupy resources from each other and can use resources in a balanced manner, thereby achieving fairness in the use of multi-tenant resources.

[0065] According to an embodiment of the present invention, when the resource occupation of the target other tenant is greater than the predetermined resource occupation of the target other tenant, at least one task thread among the multiple task threads being executed by the target other tenant is determined as a task thread to be interrupted, including: when the resource occupation of the target other tenant is greater than the predetermined resource occupation of the target other tenant, based on the resource occupation for executing each task thread included in the task processing request of the target other tenant, at least one task thread among the multiple task threads being executed by the target other tenant is determined as a task thread to be interrupted.

[0066] According to an embodiment of the present invention, when the resource occupation of the target other tenant exceeds its predetermined resource occupation, the task thread to be interrupted that needs to be interrupted can be determined among the multiple task threads being executed by the target other tenant at the current moment based on the resource occupation of the target other tenant at the current moment and the predetermined resource occupation of the target other tenant.

[0067] Specifically, the amount of resources to be released of the target other tenant can be determined based on the difference between the resource occupancy of the target other tenant at the current moment and the predetermined resource occupancy of the target other tenant. Based on the amount of resources to be released, one or more task threads to be interrupted that match the amount of resources to be released are determined among the multiple task threads currently being executed by the target other tenant.

[0068] For example, when the resource usage of the target tenant A is greater than the updated free capacity of the database cluster, the current resource usage and the scheduled resource usage of other tenants are obtained. If the current resource usage of the target other tenant B exceeds the scheduled resource usage of the target other tenant B, based on the amount of resources by which the current resource usage of the target other tenant B exceeds the scheduled resource usage of the target other tenant B, one or more task threads among the multiple task threads being executed by the target other tenant B that match the amount of resources that exceeds the scheduled resource usage can be interrupted to release the amount of resources that exceeds the scheduled resource usage and provide resources for the target tenant A.

[0069] In an embodiment of the present invention, when the idle capacity of a database cluster is insufficient to provide a predetermined resource occupancy for a target tenant, a target other user whose resource occupancy is greater than a predetermined resource occupancy is determined through the resource occupancy of other tenants and the predetermined resource occupancy of other tenants, and based on the resource occupancy of the target other tenant and the predetermined resource occupancy of the target other tenant, a task thread to be interrupted that needs to be interrupted is determined among multiple task threads currently being executed by the target other tenant, so as to release the resource amount of the target other tenant that exceeds the predetermined resource occupancy, and provide resources for the target tenant, so as to ensure fairness in the use of resources by all tenants.

[0070] According to an embodiment of the present invention, the database-based resource allocation method also includes: when the resource occupation of the target other tenants is greater than the predetermined resource occupation of the target other tenants, determining the excess resource amount of the target other tenants according to the resource occupation of the target other tenants and the predetermined resource occupation of the target other tenants; when the excess resource amount of the target other tenants is less than the updated free capacity of the database cluster, allocating resources for the task processing requests of the target other tenants based on the updated free capacity of the database cluster to generate a task thread for processing the task processing requests.

[0071] According to an embodiment of the present invention, when the resource occupation of the target other tenant is greater than the predetermined resource occupation of the target other tenant, the excess resource amount of the target other tenant can be determined according to the difference between the resource occupation of the target other tenant and the predetermined resource occupation of the target other tenant. The excess resource amount can be used to characterize the amount of resources whose resource occupation exceeds the predetermined resource occupation amount.

[0072] According to an embodiment of the present invention, the excess resource amount of the target other tenant is less than the updated database cluster idle capacity, which can be represented by the updated database cluster at the current moment being able to allocate the excess resource amount required by the target other tenant to the target other tenant. In this case, based on the updated database cluster idle capacity, the excess resources can be allocated to the task processing request of the target other tenant to generate a task thread for processing the task processing request of the target other tenant.

[0073] For example, when the free capacity of the updated database cluster is relatively abundant, if the resource usage required by all work threads of target other user B has exceeded the predetermined resource usage allocated to target other user B, and the excess resource amount is less than the free capacity of the database cluster updated at the current moment, in order to ensure the task execution efficiency of target other user B, excess resources can be allocated to target other user B to generate a task thread for processing the task processing request of target other user B, so that target other user B can use the free resources of the database cluster in excess.

[0074] In an embodiment of the present invention, when the excess resource amount of the target other tenant is less than the updated free capacity of the database cluster, the updated free capacity of the database cluster is used to allocate excess resources to the target other user, so that the target other user can use the free resources of the database cluster in excess, thereby improving the task execution efficiency of the target other tenant without affecting the execution of task threads of other tenants.

[0075] According to an embodiment of the present invention, the database-based resource allocation method further includes: acquiring historical resource occupancy information corresponding to the tenant identifier according to the tenant identifier of the target tenant; and determining a predetermined resource occupancy amount based on the historical resource occupancy information.

[0076] According to an embodiment of the present invention, the tenant identifier can be used to represent the tenant's identity information. The tenant identifier can include an account name, an account code, or other third-party account identifier information used by the tenant when registering an account. Among them, other third-party account identifier information can be used to represent the tenant's account alias information, such as a mobile phone number, an email address, and other information.

[0077] According to an embodiment of the present invention, the historical resource occupancy information corresponding to the tenant identifier can be obtained based on the tenant identifier of the target tenant. The historical resource occupancy information corresponding to the tenant identifier can include a historical resource occupancy amount sequence of the target tenant in a historical period.

[0078] According to an embodiment of the present invention, the historical resource occupancy sequence may be obtained based on the historical resource occupancy at multiple moments in a historical period.

[0079] For example, based on the tenant identifier a of the target tenant A, the historical resource occupancy of the target tenant A every 24 hours associated with the tenant identifier a in the past month is obtained from the server, and based on the historical resource occupancy of the target tenant A associated with the tenant identifier a in one month, the historical resource occupancy sequence of the target tenant A is obtained.

[0080] According to an embodiment of the present invention, historical resource occupancy information may also include account registration time information, and the historical time may be determined based on the account registration time information. The registration time information may be used to characterize the registration time acquired by the system when the tenant performs a registration operation. For example, after filling in the registration information, when the tenant clicks the registration button, the current registration time will be displayed as xx / ...

[0081] According to an embodiment of the present invention, a predetermined resource occupancy amount may be configured for the target tenant based on the historical resource occupancy information of the target tenant. For example, if the historical resource occupancy amount of the target tenant in the historical period is large, a large predetermined resource occupancy amount may be allocated to the target tenant.

[0082] According to an embodiment of the present invention, when allocating a predetermined resource occupancy amount to a plurality of tenants, a different predetermined resource occupancy amount may be allocated to each tenant in proportion based on the historical resource occupancy amount of the plurality of tenants in the same historical period.

[0083] An embodiment of the present invention configures a predetermined resource occupancy amount for a target tenant based on historical resource occupancy information corresponding to the target tenant, so that when the target tenant logs into the database later, resources will not be occupied by tenants who logged in earlier, thereby ensuring fairness in the use of resources by multiple tenants who log in to the database at the same time.

[0084] According to an embodiment of the present invention, determining a predetermined resource occupancy based on historical resource occupancy information includes: determining a relationship curve between historical resource occupancy and historical moments based on a historical resource occupancy sequence; determining a target historical resource occupancy in a historical period based on a curve type of the relationship curve; and determining a predetermined resource occupancy based on the target historical resource occupancy.

[0085] According to an embodiment of the present invention, a relationship curve between historical resource occupancy and historical moments can be obtained based on the historical resource occupancy of each of multiple historical moments, and the curve type of the relationship curve may include a straight line curve, a sawtooth waveform curve, a normal distribution curve, etc. Among them, the straight line curve may include a linear function curve, a constant function curve, etc.

[0086] According to an embodiment of the present invention, based on the curve type to which the relationship curve between the historical resource occupancy and the historical time belongs, the target historical resource occupancy in the historical period can be determined.

[0087] According to a specific embodiment of the present invention, in a rectangular coordinate system in which the x-axis represents multiple historical moments in a historical period and the y-axis represents the historical resource occupancy, if the relationship curve between the historical resource occupancy of the target tenant A and the historical moments is a straight line parallel to the x-axis, it can represent that the historical resource occupancy of the target tenant A has not changed at multiple historical moments. Therefore, it can be determined that the curve type of the relationship curve is a constant function curve.

[0088] According to a specific embodiment of the present invention, in a rectangular coordinate system in which the x-axis represents multiple historical moments in a historical period and the y-axis represents the historical resource occupancy, if a relationship curve between the historical resource occupancy of the target tenant A and the historical moments is a straight line that shows the change of the historical resource occupancy over time within the historical period, then it can be represented that the historical resource occupancy of the target tenant A at multiple historical moments gradually increases over time. Therefore, it can be determined that the curve type of the relationship curve is a linear function curve.

[0089] According to an embodiment of the present invention, for a constant function curve and a linear function curve, the target historical resource occupancy of a target tenant in a historical period may be determined by calculating a mean value or a weighted average value.

[0090] According to another specific embodiment of the present invention, in a rectangular coordinate system in which the x-axis represents multiple historical moments in a historical time period and the y-axis represents the historical resource occupancy, if the relationship curve between the historical resource occupancy of the target tenant A and the historical moments presents a periodic sawtooth waveform, it can be characterized that the historical resource occupancy of the target tenant A at multiple historical moments changes periodically within the same historical time period sub-interval, and therefore, it can be determined that the curve type of the relationship curve is a sawtooth waveform curve.

[0091] According to an embodiment of the present invention, for the sawtooth waveform curve, the target historical resource occupancy of the target tenant in the historical period can be determined by calculating the mean value or the weighted average value.

[0092] According to a specific embodiment of the present invention, in a rectangular coordinate system in which the x-axis represents multiple historical moments in a historical period and the y-axis represents the historical resource occupancy, if the relationship curve between the historical resource occupancy of the target tenant A and the historical moments presents a Gaussian distribution, it can be determined that the curve type of the relationship curve is a normal distribution curve.

[0093] According to an embodiment of the present invention, for a normal distribution curve, the probability density of the normal distribution curve can be determined by calculating curve indicators such as the mean, variance, and standard deviation, thereby determining the target historical resource occupancy of the target tenant in the historical period and some historical periods with larger target historical resource occupancy based on the probability density.

[0094] According to an embodiment of the present invention, when determining the target historical resource occupancy of the target tenant in the historical period, the target tenant can be allocated a predetermined resource occupancy based on the target historical resource occupancy and the database cluster capacity. For example, the database cluster capacity is 100GB, and the average historical resource occupancy of the target tenant A within 24 hours before the current moment is 19GB. Therefore, the database cluster can allocate 20GB of resources to the target tenant A as the predetermined resource occupancy, so that the target tenant A can use the predetermined resource occupancy of resources at any time when logging into the database to generate a task thread for processing task processing requests.

[0095] According to an embodiment of the present invention, when multiple tenants join the database cluster, historical resource occupancy information corresponding to each tenant identifier can be obtained based on the tenant identifiers of the multiple tenants, and the predetermined resource occupancy corresponding to each tenant identifier can be determined based on the historical resource occupancy information corresponding to each tenant identifier.

[0096] Specifically, when multiple tenants join the database cluster, the predetermined resource occupancy ratio of each tenant is determined based on the target historical resource occupancy of each tenant in the historical period. Based on the predetermined resource occupancy ratio of each tenant, a predetermined resource occupancy is allocated to each tenant. By using this method, different predetermined resource occupancy can be configured for each tenant. When a tenant logs into the database system, the tenant can use the resources allocated to him in real time, and will not be squeezed out by the tenant who logged in earlier because of logging in later, so as to avoid waiting for a certain time to execute the task thread.

[0097] For example, when tenant C, tenant D, and tenant E join the database cluster, the target historical resource occupancy of tenant C is 20GB, the target historical resource occupancy of tenant D is 30GB, and the target historical resource occupancy of tenant E is 50GB. The scheduled resource occupancy can be allocated to tenant C, tenant D, and tenant E in a ratio of 2:3:5. If the database cluster capacity is 100GB, the scheduled resource occupancy allocated to tenant C is 20GB, the scheduled resource occupancy allocated to tenant D is 30GB, and the scheduled resource occupancy allocated to tenant E is 50GB. If the database cluster capacity is 200GB, the scheduled resource occupancy allocated to tenant C is 40GB, the scheduled resource occupancy allocated to tenant D is 60GB, and the scheduled resource occupancy allocated to tenant E is 100GB.

[0098] According to an embodiment of the present invention, since some background threads included in the database system also need to consume resources, when allocating a predetermined resource occupancy amount to one or more tenants, a portion of the system predetermined resource occupancy amount can also be reserved for the background threads included in the database system itself, so as to execute the background threads included in the database system itself.

[0099] Specifically, based on the multiple background task threads included in the database system, the resource occupation of each of the multiple background task threads is determined, and based on the resource occupation of each of the multiple background task threads, the system predetermined resource occupation is determined.

[0100] According to an embodiment of the present invention, when allocating the predetermined resource occupancy for multiple tenants, the system predetermined resource occupancy also needs to be considered. Therefore, the available capacity of the database cluster can be obtained based on the database cluster capacity and the system predetermined resource occupancy, and the predetermined resource occupancy can be allocated to multiple tenants based on the available capacity of the database cluster.

[0101] For example, based on the resources required for executing multiple background task threads included in the database system, the system's scheduled resource usage is 20GB. If the database cluster capacity is 200GB, the available capacity of the database cluster is 180GB. In this case, the available capacity of the database cluster can be used as the maximum value of the resources that can be used by the task threads included in all tenants at the current moment. If the scheduled resource usage is allocated to tenants C, D, and E in a ratio of 2:3:5, the scheduled resource usage allocated to tenant C is 36GB, the scheduled resource usage allocated to tenant D is 54GB, and the scheduled resource usage allocated to tenant E is 90GB. The cumulative resource usage of all tenants under the database cluster does not exceed the available capacity of the database cluster.

[0102] According to an embodiment of the present invention, when allocating a predetermined resource occupancy amount for multiple tenants, the predetermined resource occupancy amount of each of the multiple tenants can be configured into multiple sub-resource pools. For example, when a tenant logs in to the database system for the first time, a sub-resource pool can be allocated to the tenant, and the resource value of the predetermined resource occupancy amount allocated to the tenant and the tenant identifier of the tenant can be configured into the object of the sub-resource pool, so that the tenant is bound to the corresponding sub-resource pool. After the binding is completed, the database system can obtain the predetermined resource occupancy amount of the tenant from the sub-resource pool object bound to the tenant, thereby providing a basis for the database system to manage resources.

[0103] According to a specific embodiment of the present invention, in a distributed database, a resource pool creation instruction can be used to create a sub-resource pool for each tenant who logs in for the first time. For example, when the number of tenants applying to use the database disk input and output resources is determined, the "CREATE RESOURCE POOL user_pool WITH(io_limits=user_io_limit)" instruction can be used to allocate the predetermined resource occupancy to different tenants according to different proportions, and the resource value of the predetermined resource occupancy allocated to the tenant and the tenant identifier of the tenant are configured in the object of the sub-resource pool, so that the tenant is bound to the corresponding sub-resource pool. Among them, "CREATE RESOURCE POOL" can be represented as a sub-resource pool creation instruction, "user_pool" can be represented as the tenant's sub-resource pool, and "io_limits=user_io_limit" can be represented as the resource amount that each thread of the sub-resource pool can concurrently process is the predetermined resource occupancy allocated to the tenant. Among them, the distributed database can include a multi-mode and multi-state distributed database, etc.

[0104] According to a specific embodiment of the present invention, when each tenant logs into the database for the first time, a login account creation instruction can be used to create a sub-resource pool and set a password for each tenant who logs into the database for the first time. For example, a "CREATE USER tennant RESOURCE POOL 'user_pool' PASSWORD 'user_pwd'" instruction can be used to create a sub-resource pool for a tenant and set a login password. Among them, CREATE USER tennant RESOURCE POOL 'user_pool' can be represented as creating a sub-resource pool for a tenant, and PASSWORD 'user_pwd' can be represented as the login password configured when the tenant logs into the sub-resource pool bound to it.

[0105] An embodiment of the present invention determines the target historical resource occupancy of a target tenant in a historical period based on the curve type of the relationship curve between historical resource occupancy and historical moments, and adaptively allocates predetermined resource occupancy to multiple tenants based on different relationship curve types of different target tenants in historical periods, thereby improving resource space utilization and avoiding multiple tenants from squeezing out resources from each other to achieve fairness in multi-tenant resource use.

[0106] Figure 3 A flow chart of a method for determining target other tenants according to an embodiment of the present invention is shown.

[0107] like Figure 3 As shown, the method includes operations S301 to S303.

[0108] In operation S301 , a plurality of candidate other tenants are determined from a plurality of other tenants based on the resource occupation of each other tenant and the predetermined resource occupation of each other tenant.

[0109] According to an embodiment of the present invention, the candidate other tenants may be used to represent one or more tenants whose resource occupation exceeds their predetermined resource occupation among multiple other tenants.

[0110] According to an embodiment of the present invention, the resource occupancy of each other tenant and the predetermined resource occupancy allocated to each other tenant are obtained, and the resource occupancy of each other tenant and the predetermined resource occupancy allocated to each other tenant are compared. If the resource occupancy of any tenant exceeds the predetermined resource occupancy allocated to each other tenant, the tenant can be determined as a candidate other tenant.

[0111] In operation S302 , based on the task threads being executed by each of the plurality of candidate other tenants, the responsiveness of each task thread being executed is determined.

[0112] According to an embodiment of the present invention, the responsiveness can be used to characterize the difficulty of executing a task, wherein the difficulty of the task is determined based on the task threads being executed by each of the candidate other tenants. Specifically, the difficulty of the task can be determined based on conditions such as the resource usage of each task thread being executed by each of the candidate other tenants, the execution time of each task thread, etc.

[0113] According to a specific embodiment of the present invention, the responsiveness of each task thread being executed can be represented by the percentage value of the resource occupation of each task thread being executed by each of the candidate other tenants in the available resource capacity of the database. The larger the proportion of the resource occupation of each task thread in the available resource capacity of the database, the more difficult it is to complete the task. Conversely, the smaller the proportion of the resource occupation of each task thread in the available resource capacity of the database, the easier it is to complete the task.

[0114] According to a specific embodiment of the present invention, the responsiveness of each task thread being executed can also be represented by the execution time of each task thread being executed by each of the candidate other tenants. The longer the execution time of each task thread from the execution start time to the current time, the more difficult it is to complete the task. Conversely, the shorter the execution time of each task thread from the execution start time to the current time, the easier it is to complete the task.

[0115] In operation S303 , a target other tenant is determined from a plurality of candidate other tenants based on the responsiveness of each task thread being executed.

[0116] According to an embodiment of the present invention, based on the responsiveness of each task thread being executed, a target other tenant for which one or more task threads need to be interrupted is selected from a plurality of candidate other tenants.

[0117] According to a specific embodiment of the present invention, based on the responsiveness of each task thread being executed, determining the target other tenant from multiple candidate other tenants may include: obtaining the responsiveness of each task thread being executed based on the resource occupancy of each task thread being executed by each of the multiple candidate other tenants, and sorting the responsiveness of each task thread being executed in a preset order, determining the task thread with the smallest responsiveness, that is, the task thread with the largest resource occupancy at the current moment, as the task thread to be interrupted, and determining the candidate other tenant to which the task thread to be interrupted belongs as the target other tenant. The preset order may be from large to small, or from small to large, which is not limited in this embodiment.

[0118] According to a specific embodiment of the present invention, based on the responsiveness of each task thread being executed, determining the target other tenant from multiple candidate other tenants may also include: obtaining the responsiveness of each task thread being executed based on the thread execution time of each task thread being executed by each of the multiple candidate other tenants within a preset time period, and sorting the responsiveness of each task thread being executed in a preset order, determining the task thread with the smallest responsiveness, that is, the task thread with the longest thread execution time within the preset time period, as the task thread to be interrupted, and determining the candidate other tenant to which the task thread to be interrupted belongs as the target other tenant.

[0119] According to a specific embodiment of the present invention, the target other tenant can also be determined from the multiple candidate other tenants based on the number of task threads being executed by each of the multiple candidate other tenants. Specifically, the multiple candidate other tenants can be sorted in a preset order based on the number of task threads being executed by each of the multiple candidate other tenants at the current moment, and the candidate other tenant with the largest number of task threads being executed at the current moment can be determined as the target other tenant.

[0120] The embodiment of the present invention determines other tenants whose resource occupation exceeds the predetermined resource occupation as candidate other tenants, and based on the responsiveness of the task thread currently being executed, that is, the difficulty of executing the task, determines the task thread with too long resource occupation time or too large resource occupation as the task thread to be interrupted, and determines the candidate other tenants corresponding to the task thread to be interrupted as the target other tenant, so that when the resource occupation of the target tenant is greater than the idle capacity of the database cluster, the task thread to be interrupted of the target other tenant that exceeds the resource occupation limit is interrupted to ensure fairness in the use of resources by the target tenant.

[0121] According to an embodiment of the present invention, interrupting at least one task thread to be interrupted to obtain an updated database cluster free capacity includes: adding a pending task corresponding to the at least one task thread to be interrupted to a pending task queue to interrupt the at least one task thread to be interrupted; and determining the updated database cluster free capacity based on the resource occupancy required for executing the at least one task thread to be interrupted and the database cluster free capacity.

[0122] According to an embodiment of the present invention, the pending task queue may be used to temporarily store one or more pending tasks in a task processing process.

[0123] According to an embodiment of the present invention, when at least one task thread to be interrupted is determined, the pending task corresponding to the at least one task thread to be interrupted is added to the pending task queue to interrupt the at least one task thread to be interrupted, so that the at least one task thread to be interrupted waits for the next scheduling of the database system.

[0124] According to an embodiment of the present invention, after interrupting at least one task thread to be interrupted, the resource occupancy required for executing the at least one task thread to be interrupted can be obtained, and the resource occupancy is used as the spare capacity of the at least one task thread to be interrupted obtained by interrupting the at least one task thread to be interrupted. The spare capacity of the at least one task thread to be interrupted and the free capacity of the database cluster are accumulated to obtain the updated free capacity of the database cluster.

[0125] According to an embodiment of the present invention, after obtaining the updated database cluster free capacity, if the target tenant's resource usage is still greater than the updated database cluster free capacity, operations S202 and S203 may be repeated until the target tenant's resource usage is less than the updated database cluster free capacity.

[0126] According to an embodiment of the present invention, after adding the pending tasks corresponding to at least one task thread to be interrupted to the pending tasks queue to interrupt at least one task thread to be interrupted, it also includes: if the total resource occupancy of all tenants at the current moment is less than the available resource capacity of the database, and the idle capacity of the database cluster is sufficient to provide available resources for the pending tasks corresponding to at least one task thread to be interrupted, then the pending tasks corresponding to at least one task thread to be interrupted stored in the pending tasks queue can be scheduled, and the task thread for processing the pending tasks can be regenerated.

[0127] The embodiment of the present invention interrupts the task thread to be interrupted by adding the pending task corresponding to the task thread to be interrupted to the pending task queue, and updates the free capacity of the database cluster by the remaining resource occupancy of the task thread to be interrupted, thereby providing sufficient resource occupancy for the target tenant, so that the resource occupancy of the target tenant and other target tenants is balanced to avoid crowding out resource space from each other, thereby ensuring fairness in resource use for all tenants.

[0128] According to an embodiment of the present invention, in response to a task processing request from a target tenant, obtaining the resource occupancy of the target tenant and the free capacity of the database cluster includes: in response to the task processing request from the target tenant, obtaining the free capacity of the database cluster and the pending task information corresponding to the task identifier according to the task identifier indicated in the task processing request; determining a plurality of task threads to be executed for executing the pending task request according to the pending task information; and determining the resource occupancy of the target tenant based on the resource occupancy of each task thread to be executed.

[0129] According to an embodiment of the present invention, each task processing request carries a task identifier, which can be used to indicate the pending task information corresponding to the task processing request. The pending task information may include task categories such as environment deployment, application development, data storage, and data access.

[0130] According to an embodiment of the present invention, when a task processing request is received from a target tenant, the task category indicated by the task identifier is acquired according to the task identifier indicated by the task processing request.

[0131] According to an embodiment of the present invention, after the target tenant accesses the database system, the number of task threads to be executed for executing the pending task request and the resource occupancy of each of the multiple task threads to be executed are determined based on the task category indicated by the task identifier. The database system allocates multiple task threads to the target tenant for processing its task processing request. Since a tenant can execute multiple jobs, a tenant can have multiple task threads.

[0132] According to an embodiment of the present invention, the database system can determine the resource usage of the target tenant based on the resource usage of each task thread to be executed. For example, the resource value of each task thread to be executed can be accumulated to obtain the resource usage of the target tenant.

[0133] According to an embodiment of the present invention, in response to receiving task processing requests sent by multiple target tenants, based on the task identifiers indicated by each of the multiple task processing requests, a task thread to be executed for executing each task request to be processed is obtained, and based on the affiliation of the multiple task threads to be executed, the resource values ​​of the multiple task threads to be executed belonging to the same target tenant are accumulated to obtain the resource occupancy of each target tenant.

[0134] According to an embodiment of the present invention, the resource allocation method based on the database also includes: if the total resource usage of all tenants at the current moment is less than the available resource capacity of the database, in the case where the target tenant needs intensive operations, even if the resource usage of the target tenant exceeds the predetermined resource usage, the target tenant can be allowed to use resources in excess, without affecting the operations of other tenants, so as to improve the resource utilization of the database and enable the target tenant to efficiently execute its task thread. If other tenants log in to the database to start executing operations at this time, and the total resource usage of all tenants at the current moment is greater than the available resource capacity of the database, the database system will interrupt at least one task thread of the tenant that has exceeded the predetermined resource usage allocated to the tenant, and let it wait for the next operating system scheduling.

[0135] Reference below Figure 4, the resource allocation method based on the database is further explained in combination with a specific embodiment.

[0136] Figure 4 A resource allocation method based on a database according to a specific embodiment of the present invention is shown.

[0137] like Figure 4 As shown, the database-based resource allocation method of this specific embodiment includes operations S401 to S408.

[0138] In operation S401, the resource occupancy of the target tenant and the free capacity of the database cluster are obtained. And operation S402 is performed to determine whether the resource occupancy of the target tenant is greater than the predetermined resource occupancy. If not, operation S403 is performed to allocate predetermined resources for the task processing request of the target tenant. If yes, operation S404 is performed to determine whether the total resource occupancy of all tenants at the current moment is greater than the available resource capacity of the database. If not, operation S405 is performed to allocate excess resources for the task processing request of the target tenant. If yes, operation S406 is performed to interrupt at least one task thread to be interrupted of other target tenants to obtain the updated free capacity of the database cluster. In operation S407, it is determined whether the resource occupancy of the target tenant is less than the updated free capacity of the database cluster. If yes, operation S408 is performed to allocate resources for the task processing request of the target tenant. If not, operation S406 is repeated.

[0139] In an embodiment of the present invention, when other tenants in the database system use resources in excess, if the target tenant's job also needs to use resources, it is possible to switch from a mode that ensures the execution efficiency of other tenants to a mode that ensures execution fairness for all tenants, so that both execution efficiency and execution fairness can be guaranteed, and the two modes can be switched in real time, thereby improving the flexibility of resource allocation.

[0140] It should be noted that, unless it is explicitly stated that there is a sequence of execution between different operations shown in the flowchart in the embodiments of the present invention, or different operations have a sequence of execution in technical implementation, otherwise, the execution order of multiple operations may not be particular, and multiple operations may also be executed simultaneously.

[0141] Figure 5 A block diagram of a resource allocation device based on a database according to an embodiment of the present invention is shown.

[0142] like Figure 5 As shown, the resource allocation device based on the database includes an acquisition module 510 , a determination module 520 , an interruption module 530 and a resource allocation module 540 .

[0143] The acquisition module 510 is used to obtain the resource usage and database cluster idle capacity of the target tenant in response to a task processing request from the target tenant.

[0144] The determination module 520 is used to determine at least one task thread to be interrupted from multiple task threads being executed when the resource usage of the target tenant is greater than the idle capacity of the database cluster.

[0145] The interruption module 530 interrupts at least one task thread to be interrupted to obtain updated free capacity of the database cluster.

[0146] The resource allocation module 540 allocates resources to the task processing request based on the updated free capacity of the database cluster when the resource usage of the target tenant is less than the updated free capacity of the database cluster, so as to generate a task thread for processing the task processing request.

[0147] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware, and firmware, or by a proper combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be executed.

[0148] For example, any multiple of the acquisition module 510, the determination module 520, the interruption module 530, and the resource allocation module 540 can be combined in one module / unit / sub-unit for implementation, or any one of the modules / units / sub-units can be split into multiple modules / units / sub-units. Alternatively, at least part of the functions of one or more of these modules / units / sub-units can be combined with at least part of the functions of other modules / units / sub-units and implemented in one module / unit / sub-unit. According to an embodiment of the present invention, at least one of the acquisition module 510, the determination module 520, the interruption module 530, and the resource allocation module 540 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware or in a suitable combination of any of them. Alternatively, at least one of the acquisition module 510, the determination module 520, the interruption module 530, and the resource allocation module 540 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be performed.

[0149] It should be noted that the database-based resource allocation device part in the embodiment of the present invention corresponds to the database-based resource allocation method part in the embodiment of the present invention. The description of the database-based resource allocation device part specifically refers to the database-based resource allocation method part, which will not be repeated here.

[0150] Figure 6 A block diagram of an electronic device suitable for implementing a resource allocation method based on a database according to an embodiment of the present invention is shown. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0151] like Figure 6 As shown, the computer electronic device according to an embodiment of the present invention includes a processor 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory ROM 602 or the program loaded from the storage part 608 to the random access memory RAM 603. The processor 601 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an on-board memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0152] In RAM 603, various programs and data required for the operation of the electronic device are stored. The processor 601, ROM 602 and RAM 603 are connected to each other via a bus 604. The processor 601 performs various operations of the method flow according to the embodiment of the present invention by executing the programs in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. The processor 601 can also perform various operations of the method flow according to the embodiment of the present invention by executing the programs stored in the one or more memories.

[0153] According to an embodiment of the present invention, the electronic device may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The electronic device may further include one or more of the following components connected to the input / output (I / O) interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 609 including a network interface card such as a LAN card, a modem, etc. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.

[0154] According to an embodiment of the present invention, the method flow according to an embodiment of the present invention can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above-mentioned functions defined in the system of the embodiment of the present invention are executed. According to an embodiment of the present invention, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0155] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.

[0156] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include but is not limited to: 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), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device.

[0157] For example, according to an embodiment of the present invention, the computer-readable storage medium may include the ROM 602 and / or the RAM 603 described above and / or one or more memories other than the ROM 602 and the RAM 603 .

[0158] An embodiment of the present invention also includes a computer program product, which includes a computer program, which contains program code for executing the method provided by the embodiment of the present invention. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the database-based resource allocation method provided by the embodiment of the present invention.

[0159] When the computer program is executed by the processor 601, the above functions defined in the system / device of the embodiment of the present invention are executed. According to the embodiment of the present invention, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0160] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 609, and / or installed from a removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0161] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

[0162] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments of the present invention can be combined and / or combined in various ways, even if such a combination or combination is not explicitly recorded in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features recorded in the various embodiments of the present invention can be combined and / or combined in various ways. All these combinations and / or combinations fall within the scope of the present invention.

[0163] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination advantageously. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.

Claims

1. A resource allocation method based on a database, characterized in that: The method comprises: In response to a task processing request from a target tenant, obtaining resource usage and database cluster idle capacity of the target tenant; In a case where the resource occupation of the target tenant is greater than the idle capacity of the database cluster, determining at least one task thread to be interrupted from the multiple task threads being executed, wherein the multiple task threads being executed are generated for task processing requests of other tenants, and the resource occupation of the target other tenant corresponding to the at least one task thread to be interrupted is greater than a predetermined resource occupation; Interrupting the at least one task thread to be interrupted to obtain updated free capacity of the database cluster; In a case where the resource usage of the target tenant is less than the updated free capacity of the database cluster, allocating resources to the task processing request based on the updated free capacity of the database cluster to generate a task thread for processing the task processing request; The method further comprises: According to the tenant identifier of the target tenant, acquiring historical resource occupancy information corresponding to the tenant identifier, wherein the historical resource occupancy information includes a sequence of historical resource occupancy amounts of the target tenant in a historical period; Determining the predetermined resource occupancy amount based on the historical resource occupancy information; Wherein, determining the predetermined resource occupancy amount based on the historical resource occupancy information includes: Based on the historical resource occupancy sequence, determining a relationship curve between the historical resource occupancy and the historical time; Determining a target historical resource occupancy amount in the historical period based on a curve type of the relationship curve; Determining the predetermined resource occupancy based on the target historical resource occupancy; The method further comprises: Determine a plurality of candidate other tenants from the plurality of other tenants based on the resource occupation of each of the other tenants and the predetermined resource occupation of each of the other tenants; Based on the task threads being executed by each of the multiple candidate other tenants, determine the responsiveness of each task thread being executed, wherein the responsiveness represents the difficulty of executing the task, wherein the difficulty of executing the task is determined based on the resource occupation of each task thread being executed; The target other tenant is determined from the multiple candidate other tenants based on the responsiveness of each of the task threads being executed.

2. The method according to claim 1, characterized in that When the resource occupation of the target tenant is greater than the idle capacity of the database cluster, determining at least one task thread to be interrupted from the multiple task threads being executed includes: When the resource occupation of the target tenant is greater than the idle capacity of the database cluster, obtaining the resource occupation and the predetermined resource occupation of the other tenants corresponding to each of the multiple task threads being executed; When the resource occupation amount of the target other tenant is greater than the predetermined resource occupation amount of the target other tenant, at least one task thread among the multiple task threads being executed by the target other tenant is determined as the task thread to be interrupted.

3. The method according to claim 2, characterized in that When the resource occupation amount of the target other tenant is greater than the predetermined resource occupation amount of the target other tenant, determining at least one task thread among the multiple task threads being executed by the target other tenant as the task thread to be interrupted includes: When the resource occupation of the target other tenant is greater than the predetermined resource occupation of the target other tenant, at least one task thread among the multiple task threads being executed by the target other tenant is determined as the task thread to be interrupted based on the resource occupation of the target other tenant and the predetermined resource occupation of the target other tenant.

4. The method according to claim 1, characterized in that: The method further comprises: In a case where the resource occupation of the target other tenant is greater than the predetermined resource occupation of the target other tenant, determining the excess resource amount of the target other tenant according to the resource occupation of the target other tenant and the predetermined resource occupation of the target other tenant; When the excess resource amount of the target other tenant is less than the updated free capacity of the database cluster, resources are allocated to the task processing request of the target other tenant based on the updated free capacity of the database cluster to generate a task thread for processing the task processing request.

5. The method according to claim 1, characterized in that Interrupting the at least one task thread to be interrupted to obtain updated free capacity of the database cluster includes: Adding a to-be-processed task corresponding to the at least one to-be-interrupted task thread to a to-be-interrupted task queue to interrupt the at least one to-be-interrupted task thread; The updated database cluster free capacity is determined based on the resource occupation amount required for executing the at least one task thread to be interrupted and the database cluster free capacity.

6. The method according to claim 1, characterized in that The step of obtaining the resource usage and database cluster idle capacity of the target tenant in response to the task processing request from the target tenant includes: In response to a task processing request from the target tenant, obtaining, according to a task identifier indicated by the task processing request, free capacity of the database cluster and information of tasks to be processed corresponding to the task identifier; Determining, according to the pending task information, a plurality of task threads to be executed for executing the pending task request; The resource occupation of the target tenant is determined based on the resource occupation of each of the task threads to be executed.

7. A resource allocation device based on a database, characterized in that: The device comprises: An acquisition module, configured to obtain the resource usage and database cluster idle capacity of the target tenant in response to a task processing request from the target tenant; a determination module, configured to determine, when the resource occupation of the target tenant is greater than the idle capacity of the database cluster, at least one task thread to be interrupted from the multiple task threads being executed, wherein the multiple task threads being executed are generated for task processing requests of other tenants, and the resource occupation of the target other tenant corresponding to the at least one task thread to be interrupted is greater than a predetermined resource occupation; An interruption module, interrupting the at least one task thread to be interrupted, and obtaining an updated free capacity of the database cluster; A resource allocation module, when the resource occupation of the target tenant is less than the updated free capacity of the database cluster, allocates resources to the task processing request based on the updated free capacity of the database cluster to generate a task thread for processing the task processing request; Wherein, the device is also used for: According to the tenant identifier of the target tenant, acquiring historical resource occupancy information corresponding to the tenant identifier, wherein the historical resource occupancy information includes a sequence of historical resource occupancy amounts of the target tenant in a historical period; and determining the predetermined resource occupancy amount based on the historical resource occupancy information; Wherein, determining the predetermined resource occupancy amount based on the historical resource occupancy information includes: Based on the historical resource occupancy sequence, determining a relationship curve between the historical resource occupancy and the historical time; Determining a target historical resource occupancy amount in the historical period based on a curve type of the relationship curve; Determining the predetermined resource occupancy based on the target historical resource occupancy; Wherein, the device is also used for: Determine a plurality of candidate other tenants from the plurality of other tenants based on the resource occupation of each of the other tenants and the predetermined resource occupation of each of the other tenants; Based on the task threads being executed by each of the multiple candidate other tenants, determine the responsiveness of each task thread being executed, wherein the responsiveness represents the difficulty of executing the task, wherein the difficulty of executing the task is determined based on the resource occupation of each task thread being executed; The target other tenant is determined from the multiple candidate other tenants based on the responsiveness of each of the task threads being executed.

Citation Information

Patent Citations

  • Resource allocation method and device and electronic equipment

    CN114398173A