[go: up one dir, main page]

CN116339992A - Resource allocation method, device, electronic device and storage medium - Google Patents

Resource allocation method, device, electronic device and storage medium Download PDF

Info

Publication number
CN116339992A
CN116339992A CN202310315705.1A CN202310315705A CN116339992A CN 116339992 A CN116339992 A CN 116339992A CN 202310315705 A CN202310315705 A CN 202310315705A CN 116339992 A CN116339992 A CN 116339992A
Authority
CN
China
Prior art keywords
target
resource
calculation
computing
partition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310315705.1A
Other languages
Chinese (zh)
Inventor
吴降龙
姜建卫
祁长福
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Glodon Co Ltd
Original Assignee
Glodon Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Glodon Co Ltd filed Critical Glodon Co Ltd
Priority to CN202310315705.1A priority Critical patent/CN116339992A/en
Publication of CN116339992A publication Critical patent/CN116339992A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

本发明公开了一种资源分配方法、装置、电子设备和存储介质,其中,资源分配方法包括接收待进行资源分配的目标计算类型,其中,不同的计算类型用于区分不同计算方式的计算;为目标计算类型分配目标资源分区,其中,目标资源分区表征执行目标计算类型的计算时允许使用的资源集合,不同的计算类型具有各自对应的资源分区;获取目标资源分区的资源分配策略,其中,不同的资源分区具有各自对应的资源分配策略;及按照目标资源分区的资源分配策略,给目标资源分区分配资源。可以提升服务器性能。

Figure 202310315705

The present invention discloses a resource allocation method, device, electronic equipment and storage medium, wherein the resource allocation method includes receiving target calculation types to be resource allocated, wherein different calculation types are used to distinguish calculations in different calculation modes; The target computing type allocates the target resource partition, where the target resource partition represents the set of resources allowed to be used when performing the calculation of the target computing type, and different computing types have their corresponding resource partitions; obtain the resource allocation strategy of the target resource partition, where different The resource partitions have their corresponding resource allocation policies; and allocate resources to the target resource partition according to the resource allocation policy of the target resource partition. Can improve server performance.

Figure 202310315705

Description

资源分配方法、装置、电子设备和存储介质Resource allocation method, device, electronic device and storage medium

技术领域technical field

本发明涉及建筑工程设计技术领域,具体涉及一种资源分配方法、装置、电子设备和存储介质。The invention relates to the technical field of architectural engineering design, in particular to a resource allocation method, device, electronic equipment and storage medium.

背景技术Background technique

随着计算机信息技术的快速发展和各类信息化单位数据量急速增加,现在的软件应用系统正在向在线化、服务化和智能化方向飞速演进,这就衍生出大量的服务器计算需求。而发挥服务器计算的作用,需要有两个先决条件:服务器能高并发的计算以及足够的计算资源。因此,在进行服务器计算时,如何高效地对服务器的资源进行调度就成为一个重要的研究课题。With the rapid development of computer information technology and the rapid increase in the amount of data in various information units, the current software application system is rapidly evolving in the direction of online, service and intelligence, which leads to a large number of server computing needs. To play the role of server computing, there are two prerequisites: the server can perform high-concurrency computing and sufficient computing resources. Therefore, when performing server computing, how to efficiently schedule server resources has become an important research topic.

目前,在服务器,针对不同类型的计算,均是按照CPU、内存等资源的使用率来进行资源分配。对于数据密集性计算来说,这种类型的计算单次计算时间较短且占用计算资源较少,按照CPU、内存等资源的使用率来进行资源分配是比较适用的。但对于计算密集型计算来说,这种类型的计算单次计算时间较长、占用计算资源较多、经常占满CPU和内存,按照CPU、内存等资源的使用率来进行资源分配就不是特别适用。简单来说,是因为计算密集型计算经常占满CPU和内存,若按照CPU、内存等资源的使用率来进行资源分配,那么会不断地给相应的计算分配资源,这很容易造成资源池颠簸以及资源浪费,进而降低服务器性能。At present, in servers, for different types of calculations, resource allocation is performed according to the utilization rate of resources such as CPU and memory. For data-intensive calculations, this type of calculation takes less time for a single calculation and occupies less computing resources. It is more suitable to allocate resources according to the utilization rate of resources such as CPU and memory. But for computing-intensive computing, this type of computing takes a long time, takes up more computing resources, and often fills up the CPU and memory. It is not special to allocate resources according to the utilization rate of CPU, memory and other resources. Be applicable. Simply put, it is because computing-intensive computing often occupies the CPU and memory. If resources are allocated according to the utilization rate of resources such as CPU and memory, resources will be continuously allocated to the corresponding computing resources, which will easily cause resource pool thrashing. And resource waste, thereby reducing server performance.

发明内容Contents of the invention

有鉴于此,本发明实施方法提供了一种资源分配方法、资源分配装置、电子设备和计算机可读存储介质,可以提升服务器性能。In view of this, the implementation method of the present invention provides a resource allocation method, a resource allocation device, an electronic device, and a computer-readable storage medium, which can improve server performance.

本发明一方面提供了一种资源分配方法,所述方法包括:One aspect of the present invention provides a resource allocation method, the method comprising:

接收待进行资源分配的目标计算类型,其中,不同的计算类型用于区分不同计算方式的计算;Receive the target computing type for resource allocation, where different computing types are used to distinguish the computing of different computing methods;

为所述目标计算类型分配目标资源分区,其中,所述目标资源分区表征执行所述目标计算类型的计算时允许使用的资源集合,不同的计算类型具有各自对应的资源分区;Allocating a target resource partition for the target computing type, wherein the target resource partition represents a set of resources allowed to be used when performing the calculation of the target computing type, and different computing types have respective corresponding resource partitions;

获取所述目标资源分区的资源分配策略,其中,不同的资源分区具有各自对应的资源分配策略;及Obtaining resource allocation strategies of the target resource partition, wherein different resource partitions have respective corresponding resource allocation strategies; and

按照所述目标资源分区的资源分配策略,给所述目标资源分区分配资源。Allocate resources to the target resource partition according to the resource allocation policy of the target resource partition.

在本申请一些实施例的技术方案中,通过为不同的计算类型分配各自对应的资源分区,并基于各个资源分区的资源分配策略,给相应的资源分区分配资源。如此,在执行不同计算类型的计算时,可以根据各自对应的资源分配策略进行资源分配,避免了不同计算类型的计算共用同一个资源分配策略时出现的资源浪费等问题,进而可以提升服务器性能。In the technical solutions of some embodiments of the present application, resources are allocated to corresponding resource partitions by assigning corresponding resource partitions to different computing types, and based on resource allocation policies of each resource partition. In this way, when performing calculations of different calculation types, resource allocation can be performed according to their corresponding resource allocation strategies, which avoids resource waste when calculations of different calculation types share the same resource allocation strategy, thereby improving server performance.

在一些实施例中,所述资源分配策略包括基于当前时间所在的时间段,动态给所述目标资源分区分配第一动态资源;In some embodiments, the resource allocation strategy includes dynamically allocating the first dynamic resource to the target resource partition based on the time period of the current time;

所述给所述目标资源分区分配资源,包括:The allocating resources to the target resource partition includes:

若当前时间在第一时间段内,给所述目标资源分区分配所述第一动态资源;If the current time is within the first time period, allocate the first dynamic resource to the target resource partition;

若当前时间在所述第一时间段之外的第二时间段内,从所述目标资源分区释放所述第一动态资源。If the current time is within a second time period other than the first time period, releasing the first dynamic resource from the target resource partition.

基于当前时间所在的时间段,动态给目标资源分区分配第一动态资源,可以在满足业务需求的同时,减少资源浪费。Based on the time period of the current time, the first dynamic resource is dynamically allocated to the target resource partition, which can reduce waste of resources while meeting business requirements.

在一些实施例中,所述第一时间段和所述第二时间段是基于如下方法确定的:In some embodiments, the first time period and the second time period are determined based on the following method:

基于历史已执行的所述目标计算类型的计算,得到所述目标计算类型的计算对应的历史时间分布;Obtaining a historical time distribution corresponding to the calculation of the target calculation type based on historically executed calculations of the target calculation type;

基于所述历史时间分布,确定所述目标计算类型的计算执行时的波峰时间段和波谷时间段,并将所述波峰时间段作为所述第一时间段,以及将所述波谷时间段作为所述第二时间段。Based on the historical time distribution, determine the peak time period and the valley time period when the calculation of the target calculation type is executed, and use the peak time period as the first time period, and use the valley time period as the first time period. the second time period.

按照波峰时间段和波谷时间段动态给目标资源分区分配第一动态资源,可以在目标计算类型的计算请求较多的情况下,保证基本的计算需求;而在目标计算类型的计算请求较少时,释放第一动态资源,以达到节省资源的目的。Dynamically allocate the first dynamic resource to the target resource partition according to the peak time period and valley time period, which can guarantee the basic computing requirements when the target computing type has many computing requests; and when the target computing type has fewer computing requests , to release the first dynamic resource, so as to achieve the purpose of saving resources.

在一些实施例中,所述资源分配策略包括基于所述目标资源分区的作业队列,动态给所述目标资源分区分配第二动态资源,其中,所述作业队列包括作业请求,每个作业请求表征一个待执行的所述目标计算类型的计算;In some embodiments, the resource allocation strategy includes dynamically allocating the second dynamic resource to the target resource partition based on the job queue of the target resource partition, wherein the job queue includes job requests, and each job request represents a computation to be performed of said target computation type;

所述给所述目标资源分区分配资源,包括:The allocating resources to the target resource partition includes:

预测所述作业队列中的作业请求全部执行完成时所需的总时长;predicting the total time required when all the job requests in the job queue are executed;

在所述总时长超过时长阈值的情况下,为所述目标资源分区划分所述第二动态资源。If the total duration exceeds a duration threshold, allocate the second dynamic resource for the target resource partition.

如此,可以防止目标资源分区中的资源被占满时,不合理地给目标资源分区分配资源所造成的资源浪费。In this way, resource waste caused by irrationally allocating resources to the target resource partition when resources in the target resource partition are fully occupied can be prevented.

在一些实施例中,所述目标计算类型的计算通过计算模型来执行,所述作业请求包括执行所述目标计算类型的计算时所需的参数文件,以及调用所述计算模型时所需的模型调用参数;In some embodiments, the calculation of the target calculation type is performed by a calculation model, and the job request includes the parameter file required for performing the calculation of the target calculation type, and the model required for calling the calculation model call parameters;

所述预测所述作业队列中的作业请求全部执行完成时所需的总时长,包括:The prediction of the total time required for all job requests in the job queue to be executed includes:

将所述作业队列中各个作业请求对应的参数文件大小以及模型调用参数输入已完成训练的预测模型,由所述预测模型输出所述总时长。The size of the parameter file corresponding to each job request in the job queue and the model calling parameters are input into the predicted model that has been trained, and the predicted model outputs the total duration.

基于各个作业请求对应的参数文件大小以及模型调用参数预测总时长,可以使预测得到的总时长与实际更相符,提高预测准确度。Based on the size of the parameter file corresponding to each job request and the total duration of the model call parameter prediction, the predicted total duration can be more consistent with the actual time, and the prediction accuracy can be improved.

在一些实施例中,在由所述预测模型输出所述总时长之前,基于如下方法训练得到所述预测模型:In some embodiments, before the total duration is output by the prediction model, the prediction model is trained based on the following method:

获取已执行完成的历史作业请求对应的历史参数文件、历史模型调用参数以及历史执行时长;Obtain the historical parameter files, historical model call parameters, and historical execution time corresponding to the executed historical job requests;

将所述历史参数文件、所述历史模型调用参数以及所述历史执行时长作为训练数据,训练得到所述预测模型。The prediction model is obtained through training using the historical parameter file, the calling parameters of the historical model, and the historical execution time as training data.

将历史数据作为训练数据,训练数据的获取方式较为简单。Using historical data as training data, the way to obtain training data is relatively simple.

在一些实施例中,在训练所述预测模型之前,所述方法还包括:In some embodiments, before training the predictive model, the method further includes:

对至少部分所述训练数据进行归一化处理。Perform normalization processing on at least part of the training data.

如此,可以避免训练数据中存在量纲差异的数据,提高训练精度。In this way, data with dimensional differences in the training data can be avoided and the training accuracy can be improved.

在一些实施例中,所述资源分配策略包括给所述目标资源分区分配在预设时长内均有效的资源;In some embodiments, the resource allocation strategy includes allocating resources valid within a preset time period to the target resource partition;

所述给所述目标资源分区分配资源,包括:The allocating resources to the target resource partition includes:

分配预设数量大小的目标资源给所述目标资源分区,并将所述目标资源设置为所述预设时长后释放。Allocating a preset number of target resources to the target resource partition, and setting the target resources to be released after the preset duration.

如此,在预设时长内,基于目标资源,可以执行基本的目标计算类型的计算,防止其他计算类型的计算请求爆发时,将资源全部占完,导致无法执行目标计算类型的计算。In this way, within a preset period of time, based on the target resources, basic calculations of the target computing type can be performed to prevent calculation requests of other computing types from taking up all the resources and making it impossible to perform the calculation of the target computing type.

本发明另一方面还提供了一种资源分配装置,装置包括:Another aspect of the present invention also provides a resource allocation device, which includes:

接收模块,用于接收待进行资源分配的目标计算类型,其中,不同的计算类型用于区分不同计算方式的计算;A receiving module, configured to receive target computing types to be allocated for resources, wherein different computing types are used to distinguish computing in different computing modes;

分区分配模块,用于为所述目标计算类型分配目标资源分区,其中,所述目标资源分区表征执行所述目标计算类型的计算时允许使用的资源集合,不同的计算类型具有各自对应的资源分区;A partition allocation module, configured to allocate a target resource partition for the target computing type, wherein the target resource partition represents a set of resources allowed to be used when performing the calculation of the target computing type, and different computing types have respective corresponding resource partitions ;

策略获取模块,用于获取所述目标资源分区的资源分配策略,其中,不同的资源分区具有各自对应的资源分配策略;及a policy acquisition module, configured to acquire the resource allocation policy of the target resource partition, wherein different resource partitions have their own corresponding resource allocation policies; and

资源分配模块,用于按照所述目标资源分区的资源分配策略,给所述目标资源分区分配资源。A resource allocation module, configured to allocate resources to the target resource partition according to the resource allocation policy of the target resource partition.

本发明另一方面还提供了一种电子设备,所述电子设备包括处理器和存储器,所述存储器用于存储计算机程序,所述计算机程序被所述处理器执行时,实现如上所述的方法。Another aspect of the present invention also provides an electronic device, the electronic device includes a processor and a memory, the memory is used to store a computer program, and when the computer program is executed by the processor, the above-mentioned method is realized .

本发明另一方面还提供了一种计算机可读存储介质,所述计算机可读存储介质用于存储计算机程序,所述计算机程序被处理器执行时,实现如上所述的方法。Another aspect of the present invention also provides a computer-readable storage medium, the computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the above-mentioned method is realized.

附图说明Description of drawings

通过参考附图会更加清楚的理解本发明的特征和优点,附图是示意性的而不应理解为对本发明进行任何限制,在附图中:The features and advantages of the present invention will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the invention in any way. In the accompanying drawings:

图1示出了本申请的一个实施例提供的资源分配方法的流程示意图;FIG. 1 shows a schematic flowchart of a resource allocation method provided by an embodiment of the present application;

图2示出了本申请的一个实施例提供的资源分配装置的模块示意图;FIG. 2 shows a schematic module diagram of a resource allocation device provided by an embodiment of the present application;

图3示出了本申请的一个实施例提供的电子设备的示意图。Fig. 3 shows a schematic diagram of an electronic device provided by an embodiment of the present application.

具体实施方式Detailed ways

为使本发明实施方法的目的、技术方案和优点更加清楚,下面将结合本发明实施方法中的附图,对本发明实施方法中的技术方案进行清楚、完整地描述,显然,所描述的实施方法是本发明一部分实施方法,而不是全部的实施方法。基于本发明中的实施方法,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施方法,都属于本发明保护的范围。In order to make the purpose, technical solution and advantages of the implementation method of the present invention clearer, the technical solutions in the implementation method of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the implementation method of the present invention. Obviously, the described implementation method It is a part of the implementation method of the present invention, but not all of the implementation methods. Based on the implementation method in the present invention, all other implementation methods obtained by those skilled in the art without creative work belong to the protection scope of the present invention.

本申请提供的资源分配方法可应用于具备计算能力的服务器。在本实施例中,服务器包括云服务器。云服务器可以用于执行建筑工程领域相关的计算,比如计算钢筋量、工程量等。具体的,针对不同类型的计算,云服务器可以开放不同的接口。用户可以通过接口调用的方式,使云服务器执行不同类型的计算。The resource allocation method provided in this application can be applied to servers with computing capabilities. In this embodiment, the server includes a cloud server. The cloud server can be used to perform calculations related to the field of construction engineering, such as calculating the amount of steel bars and engineering quantities. Specifically, for different types of computing, the cloud server may open different interfaces. Users can make the cloud server perform different types of calculations by calling the interface.

举例来说,云服务器可以开放接口A和接口B。其中,接口A用于实现与钢筋量相关的逻辑计算,接口B用于实现与工程量相关的逻辑计算。在建筑工程项目中需要进行钢筋量计算时,用户可以通过本地电脑调用接口A,并将建筑工程项目中与钢筋量计算相关的参数(比如楼高)发送给云服务器,由云服务器进行钢筋量的计算,并返回计算得到的结果。同理,在建筑工程项目中需要进行工程量计算时,用户可以通过本地电脑调用接口B,并将建筑工程项目中与工程量计算相关的参数发送给云服务器,由云服务器进行工程量的计算,并返回计算得到的结果。如此,建筑工程领域的相关计算逻辑便可以放置到云服务器中,由云服务器提供计算所需的资源(比如CPU、内存等),进而在用户本地电脑的资源配置较低的情况下,也能完成算力要求较高的计算。For example, the cloud server may open interface A and interface B. Among them, interface A is used to realize the logical calculation related to the amount of reinforcement, and interface B is used to realize the logical calculation related to the engineering quantity. When it is necessary to calculate the amount of reinforcement in a construction project, the user can call the interface A through the local computer, and send the parameters related to the calculation of the amount of reinforcement in the construction project (such as building height) to the cloud server, and the cloud server will calculate the amount of reinforcement. calculation, and returns the result of the calculation. Similarly, when the engineering quantity calculation is required in the construction project, the user can call the interface B through the local computer, and send the parameters related to the engineering quantity calculation in the construction project to the cloud server, and the cloud server will calculate the engineering quantity , and returns the result of the calculation. In this way, the relevant calculation logic in the field of construction engineering can be placed in the cloud server, and the cloud server provides the resources required for calculation (such as CPU, memory, etc.), and then it can also be used when the resource configuration of the user's local computer is low. Completion of calculations with high computing power requirements.

其中,调用云服务器执行计算的过程,又可称为云计算。在上述关于云计算的相关描述中,是以建筑工程领域相关的计算为例来进行说明的。可以理解的是,云服务器可以执行的计算包括但不限于建筑工程领域。Wherein, the process of invoking a cloud server to perform calculation may also be referred to as cloud computing. In the above related description about cloud computing, computing related to the field of construction engineering is taken as an example for illustration. It can be understood that the computing that the cloud server can perform includes but is not limited to the field of construction engineering.

通常,云服务器可以并行执行多个计算,每个计算可以称为一个计算任务。云服务器可以为每个计算任务分配相应的资源,用以保证计算的正常执行。其中,资源包括但不限于CPU、内存、硬盘等。正常情况下,对于计算量较大,或对计算速度要求较高的计算任务,可以分配较多的资源,以保证该些计算任务可以及时完成;对于计算量较小,或对计算速度要求较低的计算任务,可以适当减少资源分配,以减少资源浪费。在一些技术中,是监控各个计算任务的资源使用情况,来给计算任务进行资源分配。比如在执行计算任务A时,若计算任务A的资源均处于高负荷状态,那么可以给计算任务A新增资源,以保证计算任务A正常执行。但在一些场景中,这种资源分配方式不是特别合适。比如,对于计算密集型计算来说,这种类型的计算单次计算时间较长、占用计算资源较多、经常占满CPU和内存,若按照CPU、内存等资源的使用率来进行资源分配,会不断给这些计算任务分配新的资源,这显然是不合理的,并且还可能造成资源池颠簸以及资源浪费,进而降低服务器性能。Generally, cloud servers can perform multiple calculations in parallel, and each calculation can be called a computing task. The cloud server can allocate corresponding resources for each computing task to ensure the normal execution of the computing. Wherein, the resource includes but not limited to CPU, memory, hard disk and so on. Under normal circumstances, more resources can be allocated for computing tasks that require a large amount of calculation or higher computing speed to ensure that these computing tasks can be completed in time; For low computing tasks, resource allocation can be appropriately reduced to reduce resource waste. In some technologies, the resource usage of each computing task is monitored to allocate resources to the computing tasks. For example, when computing task A is executed, if the resources of computing task A are in a high-load state, then resources can be added to computing task A to ensure the normal execution of computing task A. But in some scenarios, this resource allocation method is not particularly suitable. For example, for computing-intensive computing, this type of computing takes a long time, takes up more computing resources, and often fills up the CPU and memory. If resources are allocated according to the utilization rate of resources such as CPU and memory, It is obviously unreasonable to continuously allocate new resources to these computing tasks, and it may also cause resource pool thrashing and resource waste, thereby reducing server performance.

鉴于此,请参阅图1,为本申请的一个实施例提供的资源分配方法的流程示意图。图1中,资源分配方法包括如下步骤:In view of this, please refer to FIG. 1 , which is a schematic flowchart of a resource allocation method provided by an embodiment of the present application. In Fig. 1, the resource allocation method includes the following steps:

步骤S11,接收待进行资源分配的目标计算类型,其中,不同的计算类型用于区分不同计算方式的计算。Step S11, receiving target computing types to be allocated resources, where different computing types are used to distinguish computing in different computing modes.

计算方式可以表征计算逻辑。不同计算类型的计算,可以具有不同的计算逻辑。比如,以建筑工程领域为例。钢筋量和工程量的计算具有不同的计算逻辑。那么钢筋量的计算可以作为一个计算类型。工程量的计算可以作为另一个计算类型。Computational methods may represent computational logic. Calculations of different calculation types can have different calculation logics. For example, take the field of construction engineering as an example. The calculation of reinforcement quantity and engineering quantity has different calculation logic. Then the calculation of the amount of reinforcement can be used as a calculation type. Calculations of quantities can be considered as another calculation type.

在本实施例中,每个计算类型可以有分别对应的计算模型。每个计算模型用于实现所对应计算类型的计算逻辑。比如,计算模型A包括钢筋量的计算逻辑,用于实现钢筋量的计算,计算模型B包括工程量的计算逻辑,用于实现工程量的计算。在需要进行钢筋量计算时,可以运行计算模型A来进行计算;在需要进行工程量计算时,可以运行计算模型B来进行计算。In this embodiment, each calculation type may have a corresponding calculation model. Each calculation model is used to realize the calculation logic of the corresponding calculation type. For example, the calculation model A includes the calculation logic of the steel bar quantity, and is used to realize the calculation of the steel bar quantity, and the calculation model B includes the calculation logic of the engineering quantity, and is used to realize the calculation of the engineering quantity. When it is necessary to calculate the amount of reinforcement, you can run the calculation model A to perform the calculation; when you need to perform the calculation of the engineering quantity, you can run the calculation model B to perform the calculation.

具体的,在调用云服务器执行一个计算类型的计算之前,可以首先创建该计算类型对应的计算模型。如此,以便于云服务器在接收到该计算类型的计算请求时,可以运行对应的计算模型进行计算。计算模型可以具有输入参数和输出参数。输入参数可以是计算过程中所需的参数,输出参数可以是计算结果。输入参数的取值不同,得到的计算结果不同。比如,以建筑工程领域为例,假设在进行工程量计算时,楼层数F和建筑面积S是输入参数。在计算项目工程A的工程量时,楼层数F的取值为20,建筑面积S的取值为400,那么运行计算模型后得到的结果可能是30;在计算项目工程B的工程量时,楼层数F的取值为10,建筑面积S的取值为100,那么运行计算模型后得到的结果可能是10。在需要调用云服务器执行一个计算类型的计算时,可以在计算请求中携带需要调用的计算模型、输入参数等信息,以便于云服务器基于这些信息,运行对应的计算模型进行计算。Specifically, before invoking the cloud server to perform a calculation of a calculation type, a calculation model corresponding to the calculation type may be created first. In this way, when the cloud server receives a calculation request of this calculation type, it can run the corresponding calculation model for calculation. A computational model can have input parameters and output parameters. The input parameter may be a parameter required in the calculation process, and the output parameter may be the calculation result. The values of the input parameters are different, and the calculation results obtained are different. For example, taking the field of construction engineering as an example, it is assumed that the number of floors F and the building area S are input parameters when calculating the engineering quantity. When calculating the quantity of project A, the value of the number of floors F is 20, and the value of building area S is 400, then the result obtained after running the calculation model may be 30; when calculating the quantity of project B, The value of the number of floors F is 10, and the value of the building area S is 100, then the result obtained after running the calculation model may be 10. When it is necessary to call the cloud server to perform a calculation of a calculation type, information such as the calculation model to be called and input parameters can be carried in the calculation request, so that the cloud server can run the corresponding calculation model for calculation based on these information.

步骤S12,为目标计算类型分配目标资源分区,其中,目标资源分区表征执行目标计算类型的计算时允许使用的资源集合,不同的计算类型具有各自对应的资源分区。Step S12, assigning target resource partitions to the target computing type, where the target resource partition represents a set of resources allowed to be used when performing the calculation of the target computing type, and different computing types have respective corresponding resource partitions.

在本实施例中,为目标计算类型初始分配的目标资源分区可以为空。目标资源分区中的资源按照资源分配策略进行分配,具体可参见步骤S13和步骤S14的相关描述,此处不赘述。In this embodiment, the target resource partition initially allocated for the target computing type may be empty. The resources in the target resource partition are allocated according to the resource allocation strategy. For details, please refer to the relevant descriptions of step S13 and step S14, which will not be repeated here.

不同计算类型对应的资源分区可以是相互独立的。对于任一计算类型来说,执行该计算类型的计算时,只允许使用该计算类型所对应的资源分区中的资源。如此,不同计算类型的计算之间不会相互影响。比如假设计算类型A对应资源分区A,计算类型B对应资源分区B。在计算类型A的计算请求大量增加的情况下,由于计算类型A的计算只能使用资源分区A中的资源,不会占用资源分区B中的资源,故可以保证计算类型B的计算不受影响,提高系统稳定性。Resource partitions corresponding to different computing types can be independent of each other. For any calculation type, only the resources in the resource partition corresponding to the calculation type are allowed to be used when performing the calculation of this calculation type. In this way, calculations of different calculation types will not affect each other. For example, suppose computing type A corresponds to resource partition A, and computing type B corresponds to resource partition B. In the case of a large increase in computing requests of computing type A, since computing of computing type A can only use resources in resource partition A and will not occupy resources in resource partition B, it can be guaranteed that computing of computing type B will not be affected , improve system stability.

步骤S13,获取目标资源分区的资源分配策略,其中,不同的资源分区具有各自对应的资源分配策略。Step S13 , acquiring the resource allocation policy of the target resource partition, wherein different resource partitions have respective corresponding resource allocation policies.

具体的,可以根据目标计算类型的计算特征,指定目标资源分区的资源分配策略。计算特征包括但不限于计算速度、计算过程中对算力的要求大小等。比如,假设在执行目标计算类型的计算时,要求具有较快的计算速度,那么可以给目标资源分区分配较多资源,以保证计算速度。Specifically, the resource allocation strategy of the target resource partition can be specified according to the computing characteristics of the target computing type. Calculation features include but are not limited to calculation speed, computing power requirements during the calculation process, etc. For example, assuming that a faster calculation speed is required when performing the calculation of the target calculation type, more resources can be allocated to the target resource partition to ensure the calculation speed.

可以理解的是,基于不同计算类型的计算特征,不同的资源分区可以具有各自对应的资源分配策略。比如,假设计算类型A对应资源分区A,计算类型B对应资源分区B。对于计算类型A的计算来说,要求能够快速计算出结果,那么可以给资源分区A分配较多的资源,以保证执行计算类型A的计算时,可以具有较快的计算速度;而对于计算类型B的计算来说,对计算速度的要求不高,那么可以适当减少资源分区B的资源分配。又比如,假设执行计算类型A的计算时,数据处理量大,对算力的要求较高,那么可以给资源分区A分配较多的资源,以保证计算类型A的计算可以顺利执行;而执行计算类型A的计算时,数据处理量较小,对算力的要求较低,那么可以减少资源分区B的资源分配。再比如,在执行计算类型A的计算时,若资源分区A中的资源使用率超过阈值,可以给资源分区A分配新的资源;在执行计算类型B的计算时,在资源分区B中的资源使用率超过阈值一定时长后,再给资源分区B分配新的资源。关于资源分配策略的详细说明,可参数后续相关描述,此处不赘述。It can be understood that, based on computing characteristics of different computing types, different resource partitions may have corresponding resource allocation policies. For example, suppose computing type A corresponds to resource partition A, and computing type B corresponds to resource partition B. For the calculation of calculation type A, it is required to be able to quickly calculate the result, then more resources can be allocated to resource partition A to ensure that the calculation of calculation type A can have a faster calculation speed; and for the calculation type For the calculation of B, the requirement for calculation speed is not high, so the resource allocation of resource partition B can be appropriately reduced. For another example, assuming that when the calculation of calculation type A is performed, the amount of data processing is large and the requirements for computing power are high, then more resources can be allocated to resource partition A to ensure that the calculation of calculation type A can be executed smoothly; When calculating type A, the amount of data processing is small and the requirements for computing power are low, so the resource allocation of resource partition B can be reduced. For another example, when performing calculation of type A, if the resource usage rate in resource partition A exceeds the threshold, new resources can be allocated to resource partition A; when performing calculation of type B, resources in resource partition B After the usage rate exceeds the threshold for a certain period of time, new resources are allocated to resource partition B. For a detailed description of the resource allocation strategy, you can refer to the subsequent description of the parameters, which will not be repeated here.

步骤S14,按照目标资源分区的资源分配策略,给目标资源分区分配资源,以便于基于目标资源分区中的资源,执行目标计算类型的计算。Step S14, according to the resource allocation policy of the target resource partition, allocate resources to the target resource partition, so as to execute the calculation of the target computing type based on the resources in the target resource partition.

具体的,基于资源分配策略,可以在执行目标计算类型的计算之前,预先给目标资源分区分配资源,也可以在执行目标计算类型的计算过程中,实时给目标资源分区分配资源。具体的资源分配过程可参见后续相关描述,此处不赘述。Specifically, based on the resource allocation strategy, resources can be allocated to the target resource partition in advance before the calculation of the target computing type is executed, or resources can be allocated to the target resource partition in real time during the execution of the calculation of the target computing type. For the specific resource allocation process, refer to subsequent related descriptions, and details are not repeated here.

在本申请一些实施例的技术方案中,通过为不同的计算类型分配各自对应的资源分区,并基于各个资源分区的资源分配策略,给相应的资源分区分配资源。如此,在执行不同计算类型的计算时,可以根据各自对应的资源分配策略进行资源分配,避免了不同计算类型的计算共用同一个资源分配策略时出现的资源浪费等问题,进而可以提升服务器性能。In the technical solutions of some embodiments of the present application, resources are allocated to corresponding resource partitions by assigning corresponding resource partitions to different computing types, and based on resource allocation policies of each resource partition. In this way, when performing calculations of different calculation types, resource allocation can be performed according to their corresponding resource allocation strategies, which avoids resource waste when calculations of different calculation types share the same resource allocation strategy, thereby improving server performance.

以下结合一些具体的实施例,对本申请的资源分配策略以及资源分配方法作进一步的详细说明。The resource allocation strategy and resource allocation method of the present application will be further described in detail below in conjunction with some specific embodiments.

在一些实施例中,资源分配策略包括给目标资源分区分配在预设时长内均有效的资源。上述给目标资源分区分配资源,包括:In some embodiments, the resource allocation strategy includes allocating resources valid within a preset time period to the target resource partition. The above allocation of resources to the target resource partition includes:

分配预设数量大小的目标资源给目标资源分区,并将目标资源设置为预设时长后释放。Allocate a preset number of target resources to the target resource partition, and set the target resource to be released after a preset period of time.

具体的,目标资源又可称为目标资源分区的常驻型资源。目标资源分配给目标资源分区后,在预设时长内,不管是否接收到目标计算类型的计算请求,该资源均不会从目标资源分区中释放。如此,在预设时长内,基于目标资源,可以执行基本的目标计算类型的计算,防止其他计算类型的计算请求爆发时,将资源全部占完,导致无法执行目标计算类型的计算。Specifically, the target resource may also be called a resident resource of the target resource partition. After the target resource is allocated to the target resource partition, the resource will not be released from the target resource partition within a preset period of time, no matter whether a computing request of the target computing type is received or not. In this way, within a preset period of time, based on the target resources, basic calculations of the target computing type can be performed to prevent calculation requests of other computing types from taking up all the resources and making it impossible to perform the calculation of the target computing type.

在一些实施例中,资源分配策略包括基于当前时间所在的时间段,动态给目标资源分区分配第一动态资源。上述给目标资源分区分配资源,包括:In some embodiments, the resource allocation strategy includes dynamically allocating the first dynamic resource to the target resource partition based on the time period of the current time. The above allocation of resources to the target resource partition includes:

若当前时间在第一时间段内,给目标资源分区分配第一动态资源;If the current time is within the first time period, allocate the first dynamic resource to the target resource partition;

若当前时间在第一时间段之外的第二时间段内,从目标资源分区释放第一动态资源。If the current time is within a second time period other than the first time period, release the first dynamic resource from the target resource partition.

具体的,第一时间段和第二时间段可以在资源分配策略中根据实际情况进行配置。比如,第一时间段可以一天当中的0点至12点;第二时间段可以是一天当中的12点至24点。又比如,第一时间段可以是一周中的周一至周五,第二时间段可以是一周中的周六和周日。基于当前时间所在的时间段,动态给目标资源分区分配第一动态资源,可以在满足业务需求的同时,减少资源浪费。比如,基于业务需求,在第一时间段内对计算速度的要求较高,那么可以在第一时间段内给目标资源分区分配第一动态资源,以提高计算速度;在第二时间段内对计算速度的要求较低,那么可以从目标资源分区中释放第一动态资源,以避免资源浪费。Specifically, the first time period and the second time period may be configured in the resource allocation policy according to actual conditions. For example, the first time period may be from 0:00 to 12:00 in a day; the second time period may be from 12:00 to 24:00 in a day. For another example, the first time period may be Monday to Friday in a week, and the second time period may be Saturday and Sunday in a week. Based on the time period of the current time, the first dynamic resource is dynamically allocated to the target resource partition, which can reduce waste of resources while meeting business requirements. For example, based on business needs, there is a high requirement for computing speed in the first time period, so the first dynamic resource can be allocated to the target resource partition in the first time period to improve the computing speed; If the requirement for computing speed is low, then the first dynamic resource may be released from the target resource partition to avoid resource waste.

在本实施例中,第一时间段和第二时间段是基于如下方法确定的:In this embodiment, the first time period and the second time period are determined based on the following method:

基于历史已执行的目标计算类型的计算,得到目标计算类型的计算对应的历史时间分布;Based on the calculation of the target calculation type that has been executed in history, the historical time distribution corresponding to the calculation of the target calculation type is obtained;

基于历史时间分布,确定目标计算类型的计算执行时的波峰时间段和波谷时间段,并将波峰时间段作为第一时间段,以及将波谷时间段作为第二时间段。Based on the historical time distribution, determine the peak time period and the valley time period when the calculation of the target calculation type is executed, and use the peak time period as the first time period and the valley time period as the second time period.

其中,波峰时间段是执行目标计算类型的计算较为频繁的时间段,波谷时间段是执行目标计算类型的计算较为稀少的时间段。具体的,可以设置次数阈值,若在一个时间段内,目标计算类型的计算次数超过次数阈值,则该时间段为波峰时间段。相应的,若在一个时间段内,目标计算类型的计算次数未超过次数阈值,则该时间段为波谷时间段。Wherein, the peak time period is a time period in which calculations of the target calculation type are frequently performed, and the valley time period is a time period in which calculations of the target calculation type are relatively seldom performed. Specifically, a times threshold may be set, and if within a time period, the calculation times of the target calculation type exceeds the times threshold, then this time period is a peak time period. Correspondingly, if within a time period, the number of calculations of the target calculation type does not exceed the number threshold, then this time period is a trough time period.

在一些实施例中,第一时间段和第二时间段的初始值可以是根据经验人为设置的。基于初始设置的第一时间段和第二时间段,在云服务器执行目标计算类型的计算时,采集各个计算执行时的实际时间,得到目标计算类型的计算对应的历史时间分布,基于历史时间分布,可以对第一时间段和第二时间段进行调整修改。比如,以一天为例。假设将第一时间段初始设置为0点到10点,第二时间段初始设置为10点到24点。在云服务器的实际计算过程中,发现目标计算类型的计算所对应的波峰时间段通常在0点到8点,那么可以将第一时间段修改为0点到8点,以及将第二时间段修改为8点到24点。In some embodiments, the initial values of the first time period and the second time period may be artificially set according to experience. Based on the first time period and the second time period initially set, when the cloud server executes the calculation of the target calculation type, the actual time when each calculation is executed is collected to obtain the historical time distribution corresponding to the calculation of the target calculation type, based on the historical time distribution , you can adjust and modify the first time period and the second time period. For example, take one day as an example. Assume that the first time period is initially set from 0:00 to 10:00, and the second time period is initially set from 10:00 to 24:00. In the actual calculation process of the cloud server, it is found that the peak time period corresponding to the calculation of the target calculation type is usually from 0:00 to 8:00, then the first time period can be modified to 0:00 to 8:00, and the second time period Revised to 8:00 to 24:00.

按照波峰时间段和波谷时间段动态给目标资源分区分配第一动态资源,可以在目标计算类型的计算请求较多的情况下,保证基本的计算需求;而在目标计算类型的计算请求较少时,释放第一动态资源,以达到节省资源的目的。Dynamically allocate the first dynamic resource to the target resource partition according to the peak time period and valley time period, which can guarantee the basic computing requirements when the target computing type has many computing requests; and when the target computing type has fewer computing requests , to release the first dynamic resource, so as to achieve the purpose of saving resources.

另外,通过上述相关描述可知,在执行一些计算类型的计算时(比如计算密集型计算),往往会将资源分区的资源占满,但这个属于正常情况,若单纯以资源分区中的资源使用情况来进行资源分配,这是不合理的。鉴于此,在一些实施例中,本申请的资源分配策略包括基于目标资源分区的作业队列,动态给目标资源分区分配第二动态资源,其中,作业队列包括作业请求,每个作业请求表征一个待执行的目标计算类型的计算。上述给目标资源分区分配资源,包括:In addition, from the above related descriptions, it can be known that when performing some types of calculations (such as calculation-intensive calculations), the resources of the resource partition will often be fully occupied, but this is a normal situation. If we simply use the resource usage in the resource partition It is unreasonable to allocate resources. In view of this, in some embodiments, the resource allocation strategy of the present application includes a job queue based on the target resource partition, and dynamically allocates the second dynamic resource to the target resource partition, wherein the job queue includes job requests, and each job request represents a pending Computation of the target calculation type performed. The above allocation of resources to the target resource partition includes:

预测作业队列中的作业请求全部执行完成时所需的总时长;Predict the total time required for all job requests in the job queue to be executed;

在总时长超过时长阈值的情况下,为目标资源分区划分第二动态资源。When the total duration exceeds the duration threshold, allocate the second dynamic resource for the target resource partition.

具体的,时长阈值可以根据实际情况来设置。比如,若对目标计算类型的计算速度要求较高,那么时长阈值可以设置为较小的值。这样,在目标资源分区的作业队列中出现较少的作业请求时,便会及时给目标资源分区划分第二动态资源,从而保证作业队列中的作业请求可以及时被处理。Specifically, the duration threshold may be set according to actual conditions. For example, if the calculation speed of the target calculation type is high, the duration threshold can be set to a smaller value. In this way, when there are fewer job requests in the job queue of the target resource partition, the second dynamic resource will be assigned to the target resource partition in time, so as to ensure that the job requests in the job queue can be processed in time.

基于作业队列中的作业请求全部执行完成时所需的总时长,来判断是否给目标资源分区划分第二动态资源,这种资源分配方法未考虑目标资源分区中的资源使用情况,可以防止目标资源分区中的资源被占满时,不合理地给目标资源分区分配资源所造成的资源浪费。Based on the total time required to complete the execution of all job requests in the job queue, it is judged whether to assign the second dynamic resource to the target resource partition. This resource allocation method does not consider the resource usage in the target resource partition, which can prevent the target resource from When the resources in the partition are fully occupied, resources are wasted caused by unreasonable allocation of resources to the target resource partition.

进一步的,在一些实施例中,上述作业请求包括执行目标计算类型的计算时所需的参数文件,以及调用计算模型时所需的模型调用参数。上述预测作业队列中的作业请求全部执行完成时所需的总时长,包括:Further, in some embodiments, the above-mentioned job request includes a parameter file required when performing the calculation of the target calculation type, and a model calling parameter required when calling the calculation model. The total time required for the execution of all job requests in the above forecast job queue to be completed, including:

将作业队列中各个作业请求对应的参数文件大小以及模型调用参数输入预测模型,由预测模型输出总时长。Input the parameter file size corresponding to each job request in the job queue and the model calling parameters into the prediction model, and the prediction model outputs the total duration.

具体的,参数文件可以包括执行目标计算类型的计算时所需的数据。比如计算建筑的钢筋量时,可能需要将建筑各个墙面的长、宽、高等信息存储至参数文件中,并将参数文件发送给云服务器,以便于云服务器根据参数文件中的数据,进行钢筋量的计算。可以理解的是,针对同一计算类型的不同计算来说,这个参数文件的大小可以是不同的。比如,计算10栋楼的钢筋量与计算1栋楼的钢筋量相比,10栋楼的参数文件明显会大于1栋楼的参数文件。故参数文件大小可以反映待处理的数据量。参数文件越大,表示待处理的数据量越大,那么计算的执行时长也相应的会越长。Specifically, the parameter file may include data required for performing calculations of the target calculation type. For example, when calculating the amount of steel bars in a building, it may be necessary to store the length, width, and height information of each wall of the building in a parameter file, and send the parameter file to the cloud server, so that the cloud server can perform reinforcement based on the data in the parameter file. Quantity calculation. It can be understood that, for different calculations of the same calculation type, the size of the parameter file may be different. For example, comparing the calculation of the reinforcement quantity of 10 buildings with the calculation of the reinforcement quantity of 1 building, the parameter file of 10 buildings will obviously be larger than the parameter file of 1 building. Therefore, the parameter file size can reflect the amount of data to be processed. The larger the parameter file, the larger the amount of data to be processed, and the correspondingly longer execution time of the calculation.

类似的,模型调用参数可以表征待调用的计算模型。可以理解的是,由于不同计算模型的计算逻辑不同,那么每个计算模型的运行时长也可以是不同的。即计算模型与计算的执行时长是相关的。Similarly, model call parameters can represent the computing model to be called. It can be understood that since the calculation logic of different calculation models is different, the running time of each calculation model may also be different. That is, the calculation model is related to the execution time of the calculation.

综上所述,各个作业请求对应的参数文件大小以及模型调用参数,与总时长相关,基于各个作业请求对应的参数文件大小以及模型调用参数预测总时长,可以使预测得到的总时长与实际更相符,提高预测准确度。To sum up, the parameter file size corresponding to each job request and the model call parameters are related to the total duration. Based on the parameter file size corresponding to each job request and the model call parameters to predict the total duration, the predicted total duration can be compared with the actual time. , which improves the prediction accuracy.

进一步的,在一些实施例中,预测模型可以基于如下方法得到:Further, in some embodiments, the prediction model can be obtained based on the following method:

获取已执行完成的历史作业请求对应的历史参数文件、历史模型调用参数以及历史执行时长;Obtain the historical parameter files, historical model call parameters, and historical execution time corresponding to the executed historical job requests;

将历史参数文件、历史模型调用参数以及历史执行时长作为训练数据,训练得到预测模型。Use historical parameter files, historical model call parameters, and historical execution time as training data to train a predictive model.

具体的,可以将历史参数文件、历史模型调用参数作为自变量,历史执行时长作为因变量,基于机器学习线性回归的方法训练得到预测模型。将历史数据作为训练数据,训练数据的获取方式较为简单。Specifically, historical parameter files and historical model call parameters can be used as independent variables, and historical execution time as dependent variables, and the prediction model can be obtained by training based on the method of machine learning linear regression. Using historical data as training data, the way to obtain training data is relatively simple.

其中,作业请求的历史执行时长可以基于如下方法得到:记录作业请求的提交时间,以及作业请求执行结束时的结束时间,并将结束时间减去提交时间,便可以得到作业请求的历史执行时长。Among them, the historical execution time of the job request can be obtained based on the following method: record the submission time of the job request and the end time when the job request execution ends, and subtract the submission time from the end time to obtain the historical execution time of the job request.

进一步的,在一些实施例中,上述用于对预测模型进行训练的历史数据中,可能部分数据存在量纲差异的问题。比如,使用8核处理器和4核处理器分别执行同一个作业请求A,很显然,8核处理器对应的执行时长会短于4核处理器对应的执行时长,即作业请求A在不同的资源配置下,会有不同的执行时长,且这些执行时长之间存在量纲差异。为避免这种量纲差异,在基于历史数据训练预测模型之前,可以对至少部分训练数据进行归一化处理。比如,将8核处理器对应的执行时长和4核处理器对应的执行时长都归一化为1核处理器对应的执行时长。如此,可以避免训练数据中存在量纲差异的数据,提高训练精度。Further, in some embodiments, among the above-mentioned historical data used for training the prediction model, some data may have a problem of dimensional differences. For example, if an 8-core processor and a 4-core processor are used to execute the same job request A, obviously, the execution time corresponding to the 8-core processor will be shorter than the execution time corresponding to the 4-core processor, that is, the job request A is executed in different Under resource configuration, there will be different execution times, and there are dimensional differences between these execution times. To avoid this dimensional difference, at least part of the training data can be normalized before training a predictive model on historical data. For example, the execution time corresponding to the 8-core processor and the execution time corresponding to the 4-core processor are normalized to the execution time corresponding to the 1-core processor. In this way, data with dimensional differences in the training data can be avoided and the training accuracy can be improved.

以上示例性的对本申请的资源分配策略以及资源分配方法进行了说明。可以理解的是,可以根据实际情况对资源分配策略以及资源分配方法进行调整,凡是基于计算类型进行资源分配的方案均应该在本申请的保护范围内。The resource allocation strategy and the resource allocation method of the present application are exemplarily described above. It can be understood that resource allocation strategies and resource allocation methods can be adjusted according to actual conditions, and any resource allocation scheme based on computing type should be within the scope of protection of this application.

请参阅图2,为本申请的一个实施例提供的资源分配装置的模块示意图。资源分配装置包括:Please refer to FIG. 2 , which is a schematic diagram of modules of a resource allocation device provided by an embodiment of the present application. Resource allocation devices include:

接收模块,用于接收待进行资源分配的目标计算类型,其中,不同的计算类型用于区分不同计算方式的计算;A receiving module, configured to receive target computing types to be allocated for resources, wherein different computing types are used to distinguish computing in different computing modes;

分区分配模块,用于为所述目标计算类型分配目标资源分区,其中,所述目标资源分区表征执行所述目标计算类型的计算时允许使用的资源集合,不同的计算类型具有各自对应的资源分区;A partition allocation module, configured to allocate a target resource partition for the target computing type, wherein the target resource partition represents a set of resources allowed to be used when performing the calculation of the target computing type, and different computing types have respective corresponding resource partitions ;

策略获取模块,用于获取所述目标资源分区的资源分配策略,其中,不同的资源分区具有各自对应的资源分配策略;及a policy acquisition module, configured to acquire the resource allocation policy of the target resource partition, wherein different resource partitions have their own corresponding resource allocation policies; and

资源分配模块,用于按照所述目标资源分区的资源分配策略,给所述目标资源分区分配资源。A resource allocation module, configured to allocate resources to the target resource partition according to the resource allocation policy of the target resource partition.

请参阅图3,为本申请的一个实施例提供的电子设备的示意图。电子设备包括处理器和存储器,所述存储器用于存储计算机程序,所述计算机程序被所述处理器执行时,实现上述的方法。Please refer to FIG. 3 , which is a schematic diagram of an electronic device provided by an embodiment of the present application. The electronic device includes a processor and a memory, and the memory is used to store a computer program. When the computer program is executed by the processor, the above method is realized.

其中,处理器可以为中央处理器(Central Processing Unit,CPU)。处理器还可以为其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等芯片,或者上述各类芯片的组合。Wherein, the processor may be a central processing unit (Central Processing Unit, CPU). The processor can also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application-specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate array (Field-Programmable Gate Array, FPGA) or other Chips such as programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations of the above-mentioned types of chips.

存储器作为一种非暂态计算机可读存储介质,可用于存储非暂态软件程序、非暂态计算机可执行程序以及模块,如本发明实施方式中的方法对应的程序指令/模块。处理器通过运行存储在存储器中的非暂态软件程序、指令以及模块,从而执行处理器的各种功能应用以及数据处理,即实现上述方法实施方式中的方法。As a non-transitory computer-readable storage medium, the memory can be used to store non-transitory software programs, non-transitory computer-executable programs and modules, such as program instructions/modules corresponding to the methods in the embodiments of the present invention. The processor executes various functional applications and data processing of the processor by running non-transitory software programs, instructions, and modules stored in the memory, that is, implements the methods in the above method implementation manners.

存储器可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储处理器所创建的数据等。此外,存储器可以包括高速随机存取存储器,还可以包括非暂态存储器,例如至少一个磁盘存储器件、闪存器件、或其他非暂态固态存储器件。在一些实施方式中,存储器可选包括相对于处理器远程设置的存储器,这些远程存储器可以通过网络连接至处理器。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application program required by at least one function; the data storage area may store data created by the processor, and the like. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory may optionally include memory located remotely from the processor, and such remote memory may be connected to the processor via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

本申请一个实施方式还提供一种计算机可读存储介质,所述计算机可读存储介质用于存储计算机程序,所述计算机程序被处理器执行时,实现上述的方法。An embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the above method is implemented.

虽然结合附图描述了本发明的实施方法,但是本领域技术人员可以在不脱离本发明的精神和范围的情况下作出各种修改和变型,这样的修改和变型均落入由所附权利要求所限定的范围之内。Although the implementation method of the present invention has been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations all fall into the scope of the appended claims. within the limited range.

Claims (11)

1.一种资源分配方法,其特征在于,所述方法包括:1. A resource allocation method, characterized in that the method comprises: 接收待进行资源分配的目标计算类型,其中,不同的计算类型用于区分不同计算方式的计算;Receive the target computing type for resource allocation, where different computing types are used to distinguish the computing of different computing methods; 为所述目标计算类型分配目标资源分区,其中,所述目标资源分区表征执行所述目标计算类型的计算时允许使用的资源集合,不同的计算类型具有各自对应的资源分区;Allocating a target resource partition for the target computing type, wherein the target resource partition represents a set of resources allowed to be used when performing the calculation of the target computing type, and different computing types have respective corresponding resource partitions; 获取所述目标资源分区的资源分配策略,其中,不同的资源分区具有各自对应的资源分配策略;及Obtaining resource allocation strategies of the target resource partition, wherein different resource partitions have respective corresponding resource allocation strategies; and 按照所述目标资源分区的资源分配策略,给所述目标资源分区分配资源。Allocate resources to the target resource partition according to the resource allocation policy of the target resource partition. 2.如权利要求1所述的方法,其特征在于,所述资源分配策略包括基于当前时间所在的时间段,动态给所述目标资源分区分配第一动态资源;2. The method according to claim 1, wherein the resource allocation strategy comprises dynamically allocating the first dynamic resource to the target resource partition based on the time period of the current time; 所述给所述目标资源分区分配资源,包括:The allocating resources to the target resource partition includes: 若当前时间在第一时间段内,给所述目标资源分区分配所述第一动态资源;If the current time is within the first time period, allocate the first dynamic resource to the target resource partition; 若当前时间在所述第一时间段之外的第二时间段内,从所述目标资源分区释放所述第一动态资源。If the current time is within a second time period other than the first time period, releasing the first dynamic resource from the target resource partition. 3.如权利要求2所述的方法,其特征在于,所述第一时间段和所述第二时间段是基于如下方法确定的:3. The method according to claim 2, wherein the first time period and the second time period are determined based on the following method: 基于历史已执行的所述目标计算类型的计算,得到所述目标计算类型的计算对应的历史时间分布;Obtaining a historical time distribution corresponding to the calculation of the target calculation type based on historically executed calculations of the target calculation type; 基于所述历史时间分布,确定所述目标计算类型的计算执行时的波峰时间段和波谷时间段,并将所述波峰时间段作为所述第一时间段,以及将所述波谷时间段作为所述第二时间段。Based on the historical time distribution, determine the peak time period and the valley time period when the calculation of the target calculation type is executed, and use the peak time period as the first time period, and use the valley time period as the first time period. the second time period. 4.如权利要求1所述的方法,其特征在于,所述资源分配策略包括基于所述目标资源分区的作业队列,动态给所述目标资源分区分配第二动态资源,其中,所述作业队列包括作业请求,每个作业请求表征一个待执行的所述目标计算类型的计算;4. The method according to claim 1, wherein the resource allocation strategy comprises dynamically assigning a second dynamic resource to the target resource partition based on a job queue of the target resource partition, wherein the job queue including job requests, each job request representing a computation to be performed of the target computation type; 所述给所述目标资源分区分配资源,包括:The allocating resources to the target resource partition includes: 预测所述作业队列中的作业请求全部执行完成时所需的总时长;predicting the total time required when all the job requests in the job queue are executed; 在所述总时长超过时长阈值的情况下,为所述目标资源分区划分所述第二动态资源。If the total duration exceeds a duration threshold, allocate the second dynamic resource for the target resource partition. 5.如权利要求4所述的方法,其特征在于,所述目标计算类型的计算通过计算模型来执行,所述作业请求包括执行所述目标计算类型的计算时所需的参数文件,以及调用所述计算模型时所需的模型调用参数;5. The method according to claim 4, wherein the calculation of the target calculation type is performed through a calculation model, and the job request includes a parameter file required for performing the calculation of the target calculation type, and calling The model calling parameters required when calculating the model; 所述预测所述作业队列中的作业请求全部执行完成时所需的总时长,包括:The prediction of the total time required for all job requests in the job queue to be executed includes: 将所述作业队列中各个作业请求对应的参数文件大小以及模型调用参数输入已完成训练的预测模型,由所述预测模型输出所述总时长。The size of the parameter file corresponding to each job request in the job queue and the model calling parameters are input into the predicted model that has been trained, and the predicted model outputs the total duration. 6.如权利要求5所述的方法,其特征在于,在由所述预测模型输出所述总时长之前,基于如下方法训练得到所述预测模型:6. The method according to claim 5, wherein, before outputting the total duration by the predictive model, the predictive model is trained based on the following method: 获取已执行完成的历史作业请求对应的历史参数文件、历史模型调用参数以及历史执行时长;Obtain the historical parameter files, historical model call parameters, and historical execution time corresponding to the executed historical job requests; 将所述历史参数文件、所述历史模型调用参数以及所述历史执行时长作为训练数据,训练得到所述预测模型。The prediction model is obtained through training using the historical parameter file, the calling parameters of the historical model, and the historical execution time as training data. 7.如权利要求6所述的方法,其特征在于,在训练所述预测模型之前,所述方法还包括:7. The method according to claim 6, wherein, before training the predictive model, the method further comprises: 对至少部分所述训练数据进行归一化处理。Perform normalization processing on at least part of the training data. 8.如权利要求1所述的方法,其特征在于,所述资源分配策略包括给所述目标资源分区分配在预设时长内均有效的资源;8. The method according to claim 1, wherein the resource allocation strategy comprises allocating resources that are valid within a preset duration to the target resource partition; 所述给所述目标资源分区分配资源,包括:The allocating resources to the target resource partition includes: 分配预设数量大小的目标资源给所述目标资源分区,并将所述目标资源设置为所述预设时长后释放。Allocating a preset number of target resources to the target resource partition, and setting the target resources to be released after the preset duration. 9.一种资源分配装置,其特征在于,所述装置包括:9. A resource allocation device, characterized in that the device comprises: 接收模块,用于接收待进行资源分配的目标计算类型,其中,不同的计算类型用于区分不同计算方式的计算;A receiving module, configured to receive target computing types to be allocated for resources, wherein different computing types are used to distinguish computing in different computing modes; 分区分配模块,用于为所述目标计算类型分配目标资源分区,其中,所述目标资源分区表征执行所述目标计算类型的计算时允许使用的资源集合,不同的计算类型具有各自对应的资源分区;A partition allocation module, configured to allocate a target resource partition for the target computing type, wherein the target resource partition represents a set of resources allowed to be used when performing the calculation of the target computing type, and different computing types have respective corresponding resource partitions ; 策略获取模块,用于获取所述目标资源分区的资源分配策略,其中,不同的资源分区具有各自对应的资源分配策略;及a policy acquisition module, configured to acquire the resource allocation policy of the target resource partition, wherein different resource partitions have their own corresponding resource allocation policies; and 资源分配模块,用于按照所述目标资源分区的资源分配策略,给所述目标资源分区分配资源。A resource allocation module, configured to allocate resources to the target resource partition according to the resource allocation policy of the target resource partition. 10.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质用于存储计算机程序,所述计算机程序被处理器执行时,实现如权利要求1至8中任一所述的方法。10. A computer-readable storage medium, characterized in that the computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the computer program according to any one of claims 1 to 8 can be realized. method. 11.一种电子设备,其特征在于,所述电子设备包括处理器和存储器,所述存储器用于存储计算机程序,所述计算机程序被所述处理器执行时,实现如权利要求1至8中任一所述的方法。11. An electronic device, characterized in that the electronic device comprises a processor and a memory, the memory is used to store a computer program, and when the computer program is executed by the processor, the computer program according to claims 1 to 8 can be realized. any of the methods described.
CN202310315705.1A 2023-03-24 2023-03-24 Resource allocation method, device, electronic device and storage medium Pending CN116339992A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310315705.1A CN116339992A (en) 2023-03-24 2023-03-24 Resource allocation method, device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310315705.1A CN116339992A (en) 2023-03-24 2023-03-24 Resource allocation method, device, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN116339992A true CN116339992A (en) 2023-06-27

Family

ID=86875825

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310315705.1A Pending CN116339992A (en) 2023-03-24 2023-03-24 Resource allocation method, device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN116339992A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2025039530A1 (en) * 2023-08-24 2025-02-27 华为技术有限公司 Training method and apparatus, resource configuration method and apparatus, system and related device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109471727A (en) * 2018-10-29 2019-03-15 北京金山云网络技术有限公司 A task processing method, device and system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109471727A (en) * 2018-10-29 2019-03-15 北京金山云网络技术有限公司 A task processing method, device and system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2025039530A1 (en) * 2023-08-24 2025-02-27 华为技术有限公司 Training method and apparatus, resource configuration method and apparatus, system and related device

Similar Documents

Publication Publication Date Title
CN111625331B (en) Task scheduling method, device, platform, server and storage medium
US10191771B2 (en) System and method for resource management
CN118260053B (en) Memory scheduling method of heterogeneous computing system, heterogeneous computing system and device
CN111104208B (en) Process scheduling management method, device, computer equipment and storage medium
CN106897132A (en) The method and device of a kind of server task scheduling
CN111813523A (en) Duration pre-estimation model generation method, system resource scheduling method, device, electronic equipment and storage medium
CN112860387A (en) Distributed task scheduling method and device, computer equipment and storage medium
WO2024245038A1 (en) Method and apparatus for scheduling virtual cloud computing resources
WO2017166643A1 (en) Method and device for quantifying task resources
CN111930516B (en) Load balancing method and related device
CN111104211A (en) Method, system, device and medium for computing offloading based on task dependency
CN110221775B (en) Method and device for allocating token in storage system
CN118034938B (en) Job scheduling method, intelligent computing cloud operating system and computing platform
CN119088527A (en) Task resource scheduling method, device and storage medium based on containerized environment
CN114489978A (en) Resource scheduling method, device, equipment and storage medium
CN107704310A (en) A kind of method, apparatus and equipment for realizing container cluster management
CN108429704B (en) Node resource allocation method and device
CN120196421A (en) A method and device for GPU resource virtualization computing power scheduling
CN102609316A (en) System and method for managing network computing resources
CN114546587A (en) A method for expanding and shrinking capacity of online image recognition service and related device
CN104598311A (en) Method and device for real-time operation fair scheduling for Hadoop
CN116339992A (en) Resource allocation method, device, electronic device and storage medium
CN117472570A (en) Methods, apparatus, electronic devices and media for scheduling accelerator resources
CN111597044A (en) Task scheduling method and device, storage medium and electronic equipment
CN114448909A (en) OVS-based network card queue polling method, device, computer equipment and medium

Legal Events

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