Server allocation method and device, electronic device, and computer-readable storage medium
By determining whether an exclusive server is needed in the task allocation method and selecting candidate servers according to the preset matching rules, the problem of waste of server resources is solved, and the rational allocation of server resources and normal execution of tasks is achieved.
Patent Information
- Application Number
- CN202110847576.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-26
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2041-07-26
AI Technical Summary
In the prior art, server resources are idle after executing timing tasks, resulting in waste of resources, and the server utilization rate of timing tasks is not high.
By determining whether it is necessary to assign an exclusive server to the target task, if not, select the target server from the candidate server according to the preset matching rules to ensure that the predetermined metrics of the candidate server are all smaller than the threshold, and achieve reasonable allocation of server resources.
Without affecting task execution, make full use of server resources to avoid resource waste and ensure the normal execution of tasks.
Smart Images

Figure CN113485838B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and more particularly, to a server allocation method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] In the business system, during the execution of business, it is necessary to enable business-related system applications to complete business execution. For some application processes, they need to be completed by executing scheduled tasks. Currently, each scheduled task is executed at a fixed point and is executed once a day. After the execution is completed, the server is idle, resulting in a waste of server resources. Summary of the Invention
[0003] In view of this, the present disclosure provides a server allocation method and apparatus, an electronic device, and a computer-readable storage medium.
[0004] One aspect of the present disclosure provides a server allocation method, comprising:
[0005] Determining whether to assign an exclusive server to the target task, where an exclusive server is a server that is not currently executing an assigned task, and the assigned task is an executing task; and
[0006] When it is determined that there is no need to allocate an exclusive server to the target task, determining a target server from a plurality of candidate servers according to a preset matching rule, so as to allocate the target server to the target task;
[0007] The candidate server is a server that is executing the assigned task, and the preset matching rule is: when the candidate server executes the target task and the assigned task at the same time, at least one predetermined indicator of the candidate server is less than a preset threshold.
[0008] According to an embodiment of the present disclosure, the predetermined indicator includes at least one of the following: CPU usage, memory usage, and disk usage.
[0009] According to an embodiment of the present disclosure, determining a target server from a plurality of candidate servers includes:
[0010] Determining a preselected server from a plurality of candidate servers, wherein, when the target task and the assigned task are simultaneously executed in the preselected server, at least one predetermined indicator is less than a preset threshold; and determining a target server from the plurality of preselected servers.
[0011] According to an embodiment of the present disclosure, determining a pre-selected server from a plurality of candidate servers includes:
[0012] Obtaining historical execution records of the target task within a predetermined period, wherein the historical execution records include historical records of predetermined indicator values consumed each time the target task is executed;
[0013] Determine the historical peak value of the predetermined indicator of the target task from the historical execution records;
[0014] Calculate the estimated values of each scheduled indicator for each candidate server, where the estimated value is the sum of the current consumption value of the candidate server's scheduled indicator and the historical peak value of the scheduled indicator of the target task;
[0015] The candidate servers whose estimated values of each predetermined indicator are all smaller than the preset threshold are determined as pre-selected servers.
[0016] According to an embodiment of the present disclosure, determining a target server from a plurality of pre-selected servers includes:
[0017] Determine an average indicator value of each preselected server, wherein the average indicator value is an average of respective historical highest recorded values of at least one predetermined indicator of the preselected servers within a predetermined period;
[0018] The pre-selected server with the highest average index value is determined as the target server.
[0019] According to an embodiment of the present disclosure, determining whether to allocate an exclusive server to the target task includes:
[0020] Determining whether to execute the target task in a separate server based on an attribute of the target task; and allocating an exclusive server to the target task if it is determined that the target task is to be executed in a separate server.
[0021] According to an embodiment of the present disclosure, determining whether to allocate an exclusive server to the target task includes:
[0022] Determine whether the target task has not been executed yet;
[0023] When it is determined that the target task has not been executed, an exclusive server is allocated to the target task.
[0024] According to an embodiment of the present disclosure, it further includes:
[0025] In response to the completion of executing the target task in the target server, determining whether to recycle the target server;
[0026] When it is determined that the target server will not be recycled, the target server is added to the waiting server queue;
[0027] In response to receiving an instruction to execute the target task again, a target server is allocated for the target task.
[0028] A server allocation device includes a first determination module and a second determination module.
[0029] Among them, the first determination module is used to determine whether to assign an exclusive server to the target task, wherein the exclusive server is a server that is not currently executing the assigned task, and the assigned task is a task in progress; the second determination module is used to determine the target server from multiple candidate servers according to the preset matching rules when it is determined that there is no need to assign an exclusive server to the target task, so as to assign the target server to the target task; wherein the candidate server is a server that is currently executing the assigned task, and the preset matching rule is: when the candidate server executes the target task and the assigned task at the same time, at least one predetermined indicator of the candidate server is less than the preset threshold.
[0030] According to an embodiment of the present disclosure, the predetermined indicator includes at least one of the following: CPU usage, memory usage, and disk usage.
[0031] According to an embodiment of the present disclosure, the second determining module includes: a first determining unit and a second determining unit.
[0032] Among them, the first determination unit is used to determine a pre-selected server from multiple candidate servers, wherein, when the target task and the assigned task are executed simultaneously in the pre-selected server, at least one predetermined indicator is less than a preset threshold; the second determination unit is used to determine the target server from multiple pre-selected servers.
[0033] According to an embodiment of the present disclosure, the first determining unit includes an acquiring subunit, a first determining subunit, a calculating subunit, and a second determining subunit.
[0034] An acquisition subunit is used to acquire a historical execution record of a target task within a predetermined period of time, wherein the historical execution record includes a historical record value of a predetermined indicator consumed each time the target task is executed;
[0035] A first determining subunit is configured to determine a historical peak value of a predetermined indicator of a target task from historical execution records;
[0036] A calculation subunit is used to calculate the estimated value of each predetermined indicator of each candidate server, where the estimated value of the predetermined indicator is the sum of the current consumption value of the predetermined indicator of the candidate server and the historical peak value of the predetermined indicator of the target task;
[0037] The second determining subunit is configured to determine, as pre-selected servers, candidate servers whose estimated values of respective predetermined indicators are all smaller than a preset threshold.
[0038] According to an embodiment of the present disclosure, the second determining unit includes a third determining subunit and a fourth determining subunit.
[0039] Among them, the third determination subunit is used to determine the average index value of each pre-selected server, wherein the average index value is the average of the historical highest record values of at least one predetermined index of the pre-selected server within a predetermined period; the fourth determination subunit is used to determine the pre-selected server with the highest average index value as the target server.
[0040] According to an embodiment of the present disclosure, the first determining module includes a third determining unit and a fourth determining unit.
[0041] The third determining unit is used to determine whether to execute the target task in a separate server according to the attributes of the target task; the fourth determining unit is used to allocate an exclusive server to the target task if it is determined that the target task is to be executed in a separate server.
[0042] According to an embodiment of the present disclosure, the first determining module includes a fifth determining unit and a sixth determining unit.
[0043] The fifth determining unit is used to determine whether the target task has not been executed; and the sixth determining unit is used to allocate an exclusive server to the target task if it is determined that the target task has not been executed.
[0044] According to an embodiment of the present disclosure, the above-mentioned device further includes a third determining module, an adding module and an allocating module.
[0045] Among them, the third determination module is used to determine whether to recycle the target server in response to the completion of the target task in the target server; the adding module is used to add the target server to the waiting server queue when it is determined that the target server will not be recycled; the allocation module is used to allocate the target server to the target task in response to receiving an instruction to execute the target task again.
[0046] Another aspect of the present disclosure provides an electronic device comprising: one or more processors, and a memory; wherein the memory is used to store one or more programs; wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the server allocation method as described above.
[0047] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the server allocation method described above when executed.
[0048] Another aspect of the present disclosure provides a computer program product, comprising computer-executable instructions, which are used to implement the server allocation method described above when the instructions are executed.
[0049] According to the embodiments of the present disclosure, through the above-mentioned server allocation method, it is first determined whether it is necessary to allocate an exclusive server for the target task. In the case that it is not necessary to allocate an exclusive server for the target scheduled task, shared server resources are allocated for the target scheduled task, so that the server resources are reasonably allocated and utilized. In the case that it is not necessary to allocate an exclusive server for the target scheduled task, shared server resources are allocated for the target scheduled task according to the preset matching rules, which can make full use of server resources with low resource utilization and solve the problem of server resource waste. And by establishing preset matching rules, it can be ensured that when the candidate server executes the target task and the assigned task at the same time, each predetermined indicator of the candidate server does not exceed the preset threshold, so as to avoid the target task being unable to be executed when the preset threshold is exceeded. Under the premise of making full use of server resources, the normal execution of the task is guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0051] Figure 1 Schematically illustrates an exemplary system architecture to which the server allocation method and apparatus of the present disclosure may be applied;
[0052] Figure 2 The flowchart of the server allocation method according to the embodiment of the present disclosure is schematically shown;
[0053] Figure 3 Schematically illustrates a flow chart for determining a pre-selected server from a plurality of candidate servers according to an embodiment of the present disclosure;
[0054] Figure 4 A block diagram schematically shows a server allocation device according to an embodiment of the present disclosure; and
[0055] Figure 5 A block diagram of an electronic device for implementing a server allocation method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0056] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present disclosure. In the detailed description below, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. 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 well-known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0057] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise," "include," etc. used herein indicate the presence of the features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0058] All terms used herein (including technical and scientific terms) 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.
[0059] When expressions such as “at least one of A, B, and C, etc.” are used, they should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (e.g., “a system having at least one of A, B, and C” should include but is not limited to systems having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, and C, etc.). When expressions such as “at least one of A, B, or C, etc.” are used, they should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (e.g., “a system having at least one of A, B, or C” should include but is not limited to systems having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, and C, etc.).
[0060] Before elaborating on the embodiments of the present disclosure in detail, the system structure and application scenarios involved in the methods provided in the embodiments of the present disclosure are first introduced as follows.
[0061] Figure 1 The following schematically illustrates an exemplary system architecture 100 to which the server allocation method and apparatus of the present disclosure may be applied. Figure 1 The examples shown are merely examples of system architectures to which the embodiments of the present disclosure may be applied, to help those skilled in the art understand the technical content of the present disclosure, but do not mean that the embodiments of the present disclosure may not be used in other devices, systems, environments or scenarios.
[0062] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a task allocation server 101 and a task execution service cluster 102. The task allocation server 101 and the task execution service cluster 102 may communicate with each other via a network, which may include various connection types, such as wired and / or wireless communication links.
[0063] In the application scenarios of the present disclosure, during the execution of business, some business application processes need to be completed by executing scheduled tasks. The task allocation server 101 can be used to perform scheduled task allocation, that is, to allocate each scheduled task to the corresponding execution server in the task execution service cluster 102 according to the allocation logic. The task execution service cluster 102 can include multiple execution servers for executing scheduled tasks. Each execution server can currently be in a task execution state or an idle state.
[0064] According to an embodiment of the present disclosure, before executing a business, it is necessary to establish a one-to-one association relationship between the business application and the corresponding scheduled task in advance, so as to match the corresponding scheduled task for each business application. According to an embodiment of the present disclosure, it is also necessary to register the business application information, scheduled task information and the information of each execution server in the task execution service cluster 102 to the task allocation server 101, so that the task allocation server 101 can perform scheduled task allocation and allocate each scheduled task to the corresponding execution server in the task execution service cluster 102 according to the allocation logic.
[0065] It should be noted that the server allocation method provided in the embodiments of the present disclosure can generally be executed by the task allocation server 101. Accordingly, the server allocation apparatus provided in the embodiments of the present disclosure can generally be set in the allocation server 101. The server allocation method provided in the embodiments of the present disclosure can also be executed by a terminal device, server, or server cluster that is different from the allocation server 101 and can communicate with the task execution service cluster 102.
[0066] It should be understood that Figure 1 The number of servers in FIG is only for illustration. Any number of servers may be provided according to implementation requirements.
[0067] In the process of executing business, some business application processes need to be completed by executing scheduled tasks. Currently, each scheduled task is executed at a fixed point and is executed once a day. After the execution is completed, the server is idle, or some servers do not execute many tasks and the resource utilization rate is low, resulting in a waste of server resources.
[0068] In view of this, an embodiment of the present disclosure provides a server allocation method.
[0069] Figure 2 The flowchart of the server allocation method according to the embodiment of the present disclosure is schematically shown.
[0070] like Figure 2 As shown, the method includes operations S201 to S202.
[0071] In operation S201 , it is determined whether to allocate an exclusive server to a target task, wherein an exclusive server is a server that is not currently executing an allocated task, and the allocated task is an ongoing task.
[0072] In operation S202, if it is determined that there is no need to allocate an exclusive server to the target task, a target server is determined from multiple candidate servers according to a preset matching rule, so as to allocate the target server to the target task. The candidate server is a server that is currently executing the assigned task, and the preset matching rule is: when the candidate server is simultaneously executing the target task and the assigned task, at least one predetermined metric of the candidate server is less than a preset threshold. According to an embodiment of the present disclosure, the predetermined metric may be, for example, the server's CPU usage, memory usage, disk usage, etc.
[0073] According to the embodiments of the present disclosure, in the application scenarios of the embodiments of the present disclosure, the target task may be a scheduled task to be executed corresponding to each business application process, or may be other non-scheduled computing tasks to be executed, etc.
[0074] According to an embodiment of the present disclosure, the server allocation method may be executed in a task allocation server, which may be used to execute allocated tasks alone and may not be used to execute target tasks.
[0075] According to an embodiment of the present disclosure, a target task can be executed on an execution server in a task execution service cluster. By executing the above-mentioned allocation method, each target task is allocated to a corresponding execution server in the task execution service cluster according to the allocation logic. Candidate servers are some of the execution servers in the task execution service cluster. In the task execution service cluster, each execution server can currently be in a task execution state or an idle state. A candidate server is an execution server that is currently executing an assigned task.
[0076] According to an embodiment of the present disclosure, before executing a business, it is necessary to establish a one-to-one association relationship between the business application and the corresponding target task in advance, so as to match the corresponding target task for each business application. According to an embodiment of the present disclosure, it is also necessary to register the business application information, target task information, and information about each execution server in the task execution service cluster with the task allocation server, so that the task allocation server can perform server allocation based on the above information.
[0077] According to an embodiment of the present disclosure, it is first necessary to determine in operation S201 whether to allocate an exclusive server to the target task. For example, because some target tasks consume a large amount of computing resources, sharing a server with other tasks will affect the efficiency of task execution, and it is necessary to allocate an exclusive server to them. If it is determined that an exclusive server needs to be allocated to the target task, an exclusive server is allocated to the target task, and the target task is executed on the exclusive server. The execution record is automatically saved, such as information such as the CPU, JVM (memory), and disk capacity usage during operation, and the above record information is automatically backed up in the operation log.
[0078] According to an embodiment of the present disclosure, when it is determined that there is no need to allocate an exclusive server for the target task, in operation S202, according to the preset matching rules, a target server is screened and matched from multiple candidate servers, that is, the execution servers that are executing the assigned tasks, so as to allocate the target server for the target task, execute the target task in the target server, and automatically save the execution records, such as the CPU, JVM (memory), disk capacity occupancy and other information during the operation, and automatically back up the above record information in the operation log.
[0079] According to an embodiment of the present disclosure, when there is currently no target server that meets the matching conditions in the server resource pool, wait for an idle server. If there is still no target server that meets the matching conditions after waiting for a preset time period, re-apply for a server to avoid waiting too long and affecting task execution.
[0080] According to an embodiment of the present disclosure, through the above-mentioned server allocation method, it is first determined whether it is necessary to allocate an exclusive server for the target task. In the case that it is not necessary to allocate an exclusive server for the target scheduled task, shared server resources are allocated for the target scheduled task, so that server resources are reasonably allocated and utilized. In the case that it is not necessary to allocate an exclusive server for the target scheduled task, shared server resources are allocated for the target scheduled task according to the preset matching rules, which can make full use of server resources with low resource utilization and solve the problem of server resource waste. And by establishing preset matching rules, it can be ensured that when the candidate server executes the target task and the assigned task at the same time, each predetermined indicator of the candidate server does not exceed the preset threshold, so as to avoid the target task being unable to be executed when the preset threshold is exceeded. Under the premise of making full use of server resources, the normal execution of the task is guaranteed.
[0081] According to an embodiment of the present disclosure, the predetermined indicator includes at least one of the following: CPU usage, memory usage, and disk usage. The predetermined indicator may also include other indicators that can be used to characterize server operating performance in addition to the above examples. The embodiment of the present disclosure does not limit the type of the predetermined indicator.
[0082] According to an embodiment of the present disclosure, determining whether to allocate an exclusive server to a target task includes: determining whether to execute the target task on a separate server based on the attributes of the target task; and allocating an exclusive server to the target task if it is determined that the target task is to be executed on a separate server. The attributes of the target task may be, for example, the server memory resources required to execute the target task, the required CPU execution speed, the required disk capacity, etc. For example, because some target tasks consume a large amount of computing memory resources, sharing a server with other tasks will affect the task execution efficiency, and therefore an exclusive server needs to be allocated to them.
[0083] According to an embodiment of the present disclosure, by first determining whether to allocate an exclusive server to a target task, the attributes of the target task can be taken into consideration, thereby achieving the purpose of reasonably allocating server resources.
[0084] According to an embodiment of the present disclosure, determining whether to allocate an exclusive server for a target task includes: determining whether the target task has not been executed; and in the case of determining that the target task has not been executed, allocating an exclusive server to the target task. According to an embodiment of the present disclosure, determining whether the target task has not been executed can be performed on the basis of determining whether to execute the target task in a separate server based on the attributes of the target task. For example, after analyzing the attribute information of the target task and determining that the target task does not need to be executed in a separate server, it can be further determined whether the target task has not been executed. If it has not been executed, an exclusive server can be allocated to it, and the target task can be executed in a separate server, so as to accurately record the server resource occupancy of the task, such as the CPU usage, JVM (memory) usage, disk capacity usage, etc.
[0085] According to an embodiment of the present disclosure, determining a target server from a plurality of candidate servers includes:
[0086] Determining a preselected server from the plurality of candidate servers, wherein, when the target task and the assigned task are simultaneously executed in the preselected server, at least one predetermined indicator is less than a preset threshold;
[0087] Determine the target server from among multiple pre-selected servers.
[0088] According to an embodiment of the present disclosure, determining the target server from the plurality of pre-selected servers may include: arbitrarily selecting one of the plurality of pre-selected servers to be determined as the target server.
[0089] According to an embodiment of the present disclosure, when there are multiple pre-selected servers, since each predetermined indicator is less than the preset threshold when the target task and the assigned task are executed simultaneously in the pre-selected server, there will be no situation where the target task cannot be executed when the target task is assigned to the server. Therefore, any one of the multiple pre-selected servers can be selected as the target server.
[0090] According to an embodiment of the present disclosure, in order to ensure that server resources are fully utilized in a more optimized manner, the server allocation method may also adopt the following method.
[0091] According to an embodiment of the present disclosure, determining a target server from a plurality of pre-selected servers includes:
[0092] An average index value of each preselected server is determined, wherein the average index value is an average value of at least one predetermined index of the preselected servers; and a preselected server with a highest average index value is determined as a target server.
[0093] According to an embodiment of the present disclosure, when there are multiple pre-selected servers, since each predetermined indicator is less than a preset threshold when the target task and the assigned task are executed simultaneously in the pre-selected servers, in principle, any one of the multiple pre-selected servers can be selected as the target server. Considering that there may be tasks that consume relatively more server resources in the future, the server that currently consumes the most server resources among the servers that currently meet the allocation conditions is preferentially assigned to the current target task, so that other servers that currently consume less resources can be assigned to tasks that will consume relatively more resources in the future, thereby avoiding wasting the resources of the server that currently consumes the most resources and ensuring more optimized and full utilization of server resources.
[0094] Figure 3 The flowchart of determining a pre-selected server from multiple candidate servers according to an embodiment of the present disclosure is schematically shown; Figure 3 As shown, the method includes operations S301-304.
[0095] In operation S301, a historical execution record of a target task within a predetermined period is obtained, wherein the historical execution record includes a historical record value of a predetermined indicator consumed each time the target task is executed;
[0096] In operation S302 , a predetermined indicator historical record peak value of the target task is determined from the historical execution record;
[0097] In operation S303, each predetermined indicator estimated value of each candidate server is calculated respectively, where the predetermined indicator estimated value is the sum of the current consumption value of the predetermined indicator of the candidate server and the peak value of the predetermined indicator history of the target task;
[0098] In operation S304 , candidate servers whose estimated values of respective predetermined indicators are all smaller than a preset threshold are determined as pre-selected servers.
[0099] For ease of understanding, the following describes the specific methods of the above operations:
[0100] Table 1 shows a list of candidate servers currently executing other assigned tasks. The table shows the values of the predetermined indicators (CPU usage, memory usage, disk usage) of each candidate server, as well as the average values of the three predetermined indicators.
[0101] The pre-selected server may be determined based on a rule that, when the target task and the assigned task are simultaneously executed in the pre-selected server, each predetermined indicator is less than a preset threshold.
[0102] Table 1
[0103]
[0104] Table 2 is an example of historical execution records of target tasks within a predetermined period (eg, within the last week).
[0105] Table 2
[0106]
[0107] After obtaining the above historical execution records, determine the target task's predetermined historical peak indicators from the historical execution records. For example, based on the records in Table 2, it can be determined that the target task's predetermined historical peak indicators are: CPU utilization 40% (calculated based on a CPU usage of 4 GHz), memory utilization 25% (calculated based on a JVM usage of 2 GB), and disk utilization 1% (calculated based on a disk usage of 5 GB).
[0108] After that, the estimated values of each scheduled indicator for each candidate server are calculated separately, that is, the sum of the current consumption value of the scheduled indicator of the candidate server and the historical peak value of the scheduled indicator of the target task is calculated. For example, based on the data records in Table 1 and Table 2, the following is calculated:
[0109] The estimated values of the predetermined indicators of candidate server No. 1 are: CPU utilization (78%+40%), memory utilization (40%+25%), and disk utilization (50%+1%).
[0110] The estimated values of the predetermined indicators of candidate server No. 2 are: CPU utilization (40%+40%), memory utilization (40%+25%), and disk utilization (40%+1%).
[0111] The estimated values of the predetermined indicators of candidate server No. 3 are: CPU utilization (10% + 40%), memory utilization (10% + 25%), and disk utilization (10% + 1%).
[0112] Finally, the candidate servers whose estimated values of the predetermined indicators are all smaller than the preset threshold are determined as pre-selected servers.
[0113] For example, the threshold for a predetermined indicator can be set to 80%. If the estimated CPU usage of server 1 is greater than 80%, server 1 cannot be matched. The estimated values of each predetermined indicator for servers 2 and 3 are both less than the preset threshold. These two servers can be identified as preselected servers.
[0114] Furthermore, when there are multiple pre-selected servers, since each predetermined indicator is less than the preset threshold, in principle, any one of the two pre-selected servers can be selected as the target server. Considering that there may be tasks that consume relatively more server resources in the future, the server that currently consumes the most server resources (i.e., server No. 2 with a larger average indicator value) is preferentially assigned to the current target task.
[0115] According to an embodiment of the present disclosure, it further includes:
[0116] In response to the completion of executing the target task in the target server, determining whether to recycle the target server;
[0117] When it is determined that the target server will not be recycled, the target server is added to the waiting server queue;
[0118] In response to receiving an instruction to execute the target task again, a target server is allocated for the target task.
[0119] According to an embodiment of the present disclosure, after a target task is completed on a target server, it is determined whether to recycle the server based on the attributes of the target task. If it is determined that the target server will not be recycled, the target server is added to the waiting server queue so that when the target task is executed again, the target server is directly assigned to the target task without having to match the target task with a server again, thereby improving allocation efficiency.
[0120] Figure 4 The block diagram of the server allocation device 400 according to an embodiment of the present disclosure is schematically shown.
[0121] The server allocation device 400 can be used to implement reference Figure 2 The method shown.
[0122] like Figure 4As shown, the load prediction device 400 includes: a first determination module 410 and a second determination module 420.
[0123] Among them, the first determination module 410 is used to determine whether to assign an exclusive server to the target task, wherein the exclusive server is a server that is not currently executing the assigned task, and the assigned task is an executing task; the second determination module 420 is used to determine the target server from multiple candidate servers according to the preset matching rules when it is determined that there is no need to assign an exclusive server to the target task, so as to assign the target server to the target task; wherein the candidate server is a server that is executing the assigned task, and the preset matching rule is: when the candidate server executes the target task and the assigned task at the same time, at least one predetermined indicator of the candidate server is less than the preset threshold.
[0124] According to an embodiment of the present disclosure, through the first determination module 410, it is first determined whether it is necessary to allocate an exclusive server for the target task. In the case that it is not necessary to allocate an exclusive server for the target scheduled task, shared server resources are allocated for the target scheduled task, so that the server resources are reasonably allocated and utilized. In the case that it is not necessary to allocate an exclusive server for the target scheduled task, the first determination module 410 is used to allocate shared server resources for the target scheduled task according to the preset matching rules, which can make full use of server resources with low resource utilization and solve the problem of server resource waste. And by establishing preset matching rules, it can be ensured that when the candidate server executes the target task and the assigned task at the same time, each predetermined indicator of the candidate server does not exceed the preset threshold, so as to avoid the target task being unable to be executed when the preset threshold is exceeded. Under the premise of making full use of server resources, the normal execution of the task is guaranteed.
[0125] According to an embodiment of the present disclosure, the predetermined indicator includes at least one of the following: CPU usage, memory usage, and disk usage.
[0126] According to an embodiment of the present disclosure, the second determining module 420 includes: a first determining unit and a second determining unit.
[0127] Among them, the first determination unit is used to determine a pre-selected server from multiple candidate servers, wherein, when the target task and the assigned task are executed simultaneously in the pre-selected server, at least one predetermined indicator is less than a preset threshold; the second determination unit is used to determine the target server from multiple pre-selected servers.
[0128] According to an embodiment of the present disclosure, the first determining unit includes an acquiring subunit, a first determining subunit, a calculating subunit, and a second determining subunit.
[0129] Among them, the acquisition subunit is used to obtain the historical execution records of the target task within the predetermined time period, wherein the historical execution records include the historical record values of the predetermined indicators consumed each time the target task is executed; the first determination subunit is used to determine the historical record peak value of the predetermined indicators of the target task from the historical execution records; the calculation subunit is used to calculate the estimated values of each predetermined indicator of each candidate server respectively, wherein the estimated value of the predetermined indicator is the sum of the current consumption value of the predetermined indicator of the candidate server and the historical record peak value of the predetermined indicator of the target task; the second determination subunit is used to determine the candidate server whose estimated values of each predetermined indicator are all less than the preset threshold as the pre-selected server.
[0130] According to an embodiment of the present disclosure, the second determining unit includes a third determining subunit and a fourth determining subunit.
[0131] Among them, the third determination subunit is used to determine the average index value of each pre-selected server, wherein the average index value is the average of the historical highest record values of at least one predetermined index of the pre-selected server within a predetermined period; the fourth determination subunit is used to determine the pre-selected server with the highest average index value as the target server.
[0132] According to an embodiment of the present disclosure, the first determining module 410 includes a third determining unit and a fourth determining unit.
[0133] The third determining unit is used to determine whether to execute the target task in a separate server according to the attributes of the target task; the fourth determining unit is used to allocate an exclusive server to the target task if it is determined that the target task is to be executed in a separate server.
[0134] According to an embodiment of the present disclosure, the first determining module includes a fifth determining unit and a sixth determining unit.
[0135] The fifth determining unit is used to determine whether the target task has not been executed; and the sixth determining unit is used to allocate an exclusive server to the target task if it is determined that the target task has not been executed.
[0136] According to an embodiment of the present disclosure, the above-mentioned device further includes a third determining module, an adding module and an allocating module.
[0137] Among them, the third determination module is used to determine whether to recycle the target server in response to the completion of the target task in the target server; the adding module is used to add the target server to the waiting server queue when it is determined that the target server will not be recycled; the allocation module is used to allocate the target server to the target task in response to receiving an instruction to execute the target task again.
[0138] According to the modules, submodules, units, and subunits of the embodiments of the present invention, any multiple or at least part of the functions of any multiple thereof can be implemented in one module. According to the modules, submodules, units, and subunits of the embodiments of the present invention, any one or more thereof can be split into multiple modules for implementation. According to the modules, submodules, units, and subunits of the embodiments of the present invention, any one or more thereof 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 of any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation modes of software, hardware, and firmware or in an appropriate combination of any of them. Alternatively, according to the modules, submodules, units, and subunits of the embodiments of the present invention, one or more thereof can be at least partially implemented as a computer program module, which can perform the corresponding function when the computer program module is run.
[0139] For example, any number of the first determination module 410 and the second determination module 420 can be combined into one module / unit / subunit for implementation, or any one of the modules / units / subunits can be split into multiple modules / units / subunits. Alternatively, at least part of the functions of one or more of these modules / units / subunits can be combined with at least part of the functions of other modules / units / subunits and implemented in one module / unit / subunit. According to an embodiment of the present disclosure, at least one of the first determination module 410 and the second determination module 420 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 modes of software, hardware, and firmware, or in an appropriate combination of any of them. Alternatively, at least one of the first determination module 410 and the second determination module 420 can be at least partially implemented as a computer program module, which can perform the corresponding function when the computer program module is run.
[0140] Figure 5 A block diagram of an electronic device for implementing a server allocation method according to an embodiment of the present disclosure is schematically shown.
[0141] Figure 5 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0142] like Figure 5As shown, the electronic device 500 according to an embodiment of the present disclosure includes a processor 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. The processor 501 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 (such as an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include an onboard memory for caching purposes. The processor 501 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 disclosure.
[0143] Various programs and data required for the operation of the electronic device 500 are stored in the RAM 503. The processor 501, ROM 502, and RAM 503 are connected to each other via a bus 504. The processor 501 executes the various operations of the method flow according to the embodiment of the present disclosure by executing the programs in the ROM 502 and / or RAM 503. It should be noted that the programs may also be stored in one or more memories other than the ROM 502 and the RAM 503. The processor 501 may also execute the various operations of the method flow according to the embodiment of the present disclosure by executing the programs stored in the one or more memories.
[0144] According to an embodiment of the present disclosure, electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to bus 504. System 500 may also include one or more of the following components connected to I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and speakers; a storage section 508 including a hard disk; and a communication section 509 including a network interface card such as a LAN card or a modem. Communication section 509 performs communication processing via a network such as the Internet. Drive 510 is also connected to I / O interface 505 as needed. Removable media 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed in drive 510 as needed, so that computer programs read therefrom can be installed into storage section 508 as needed.
[0145] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure 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 509, and / or installed from the removable medium 511. When the computer program is executed by the processor 501, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.
[0146] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments, or may exist independently and not be incorporated into the device / apparatus / system. The computer-readable storage medium carries one or more programs, and when executed, implements the method according to the embodiments of the present disclosure.
[0147] According to an embodiment of the present disclosure, a 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 disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0148] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 502 and / or the RAM 503 described above and / or one or more memories other than the ROM 502 and the RAM 503 .
[0149] An embodiment of the present disclosure 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 disclosure. When the computer program product is run on an electronic device, the program code is used to enable the electronic device to implement the server allocation method provided by the embodiment of the present disclosure.
[0150] When the computer program is executed by the processor 501, the above functions defined in the system / device of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0151] In one embodiment, the computer program may be stored on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal on a network medium, downloaded and installed via the communication portion 509, and / or installed from a removable medium 511. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0152] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, python, "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving 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 (for example, using an Internet service provider to connect via the Internet).
[0153] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of the systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, program segment, or portion of code, which 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 boxes may occur in an order different from that marked in the accompanying drawings. For example, two boxes shown in succession may actually be executed substantially in parallel, or they may 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, as well as the combination of boxes in the block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or may be implemented using a combination of dedicated hardware and computer instructions. It will be understood by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or coupled in various ways, even if such combinations or couplings are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or coupled in various ways, and all such combinations and / or couplings fall within the scope of the present disclosure.
[0154] The embodiments of the present disclosure are described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although each embodiment has been described separately above, this does not mean that the measures in each embodiment cannot be used in combination to advantage. The scope of the present disclosure is defined by the appended claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A server allocation method, comprising: Determining whether to allocate an exclusive server to the target task, wherein the exclusive server is a server that is not currently executing an allocated task, and the allocated task is an ongoing task; as well as When it is determined that the exclusive server does not need to be allocated to the target task, determining a target server from a plurality of candidate servers according to a preset matching rule, so as to allocate the target server to the target task; The candidate server is a server that is executing the assigned task, and the preset matching rule is: when the candidate server is executing the target task and the assigned task at the same time, at least one predetermined indicator of the candidate server is less than a preset threshold; Among them, determining the target server from multiple candidate servers includes: obtaining the historical execution records of the target task within a predetermined period of time, wherein the historical execution records include the historical record values of the predetermined indicators consumed each time the target task is executed; determining the historical record peak value of the predetermined indicators of the target task from the historical execution records; calculating the estimated values of each predetermined indicator of each candidate server respectively, wherein the estimated value of the predetermined indicator is the sum of the current consumption value of the predetermined indicator of the candidate server and the historical record peak value of the predetermined indicator of the target task, and determining the candidate servers whose estimated values of each predetermined indicator are all less than a preset threshold as pre-selected servers; and determining the target server from multiple pre-selected servers.
2. The method according to claim 1, wherein The predetermined indicator includes at least one of the following: CPU usage, memory usage, and disk usage.
3. The method according to claim 1, wherein When the target task and the assigned task are executed simultaneously in the pre-selected server, at least one of the predetermined indicators is smaller than the preset threshold.
4. The method according to claim 2, wherein Determining the target server from the plurality of pre-selected servers comprises: Determining an average indicator value of each of the preselected servers, wherein the average indicator value is an average value of at least one of the predetermined indicators of the preselected servers; The pre-selected server with the highest average index value is determined as the target server.
5. The method according to claim 1, wherein The determining whether to allocate an exclusive server to the target task includes: determining, based on the attributes of the target task, whether to execute the target task in a separate server; and In the case where it is determined that the target task is to be executed in a separate server, the exclusive server is allocated to the target task.
6. The method according to claim 1, wherein The determining whether to allocate an exclusive server to the target task includes: Determining whether the target task has not been performed; When it is determined that the target task has not been executed, the exclusive server is allocated to the target task.
7. The method according to claim 1, further comprising: In response to completion of executing the target task in the target server, determining whether to recycle the target server; If it is determined that the target server is not to be recycled, adding the target server to a waiting server queue; In response to receiving an instruction to execute the target task again, allocating the target server for the target task.
8. A server allocation device, comprising: A first determining module is configured to determine whether to allocate an exclusive server to the target task, wherein the exclusive server is a server that is not currently executing an allocated task, and the allocated task is an ongoing task; as well as a second determining module, configured to, when it is determined that the exclusive server does not need to be allocated to the target task, determine a target server from a plurality of candidate servers according to a preset matching rule, so as to allocate the target server to the target task; The candidate server is a server that is executing an assigned task, and the preset matching rule is: when the candidate server is executing the target task and the assigned task at the same time, at least one predetermined indicator of the candidate server is less than a preset threshold; The second determining module includes: a first determining unit and a second determining unit; a first determining unit configured to determine a preselected server from a plurality of candidate servers, and a second determining unit configured to determine a target server from the plurality of preselected servers; The first determination unit includes an acquisition subunit, a first determination subunit, a calculation subunit and a second determination subunit; the acquisition subunit is used to acquire the historical execution records of the target task within a predetermined time period, wherein the historical execution records include the historical record values of the predetermined indicators consumed each time the target task is executed; the first determination subunit is used to determine the historical record peak value of the predetermined indicator of the target task from the historical execution records; the calculation subunit is used to calculate the estimated values of each predetermined indicator of each candidate server respectively, wherein the estimated value of the predetermined indicator is the sum of the current consumption value of the predetermined indicator of the candidate server and the historical record peak value of the predetermined indicator of the target task; the second determination subunit is used to determine the candidate servers whose estimated values of each predetermined indicator are all less than a preset threshold as pre-selected servers.
9. An electronic device comprising: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to implement the method according to any one of claims 1 to 7.
11. A computer program product comprising computer executable instructions, wherein the instructions are used to implement the method according to any one of claims 1 to 7 when executed.
Citation Information
Patent Citations
Method and apparatus for managing capacity of cloud server
CN107231264A
Task distribution method, computer readable storage medium and terminal equipment
CN108446176A