WO2022178730A1 - Microservice resource allocation method and apparatus, and computer-readable medium - Google Patents

Microservice resource allocation method and apparatus, and computer-readable medium Download PDF

Info

Publication number
WO2022178730A1
WO2022178730A1 PCT/CN2021/077738 CN2021077738W WO2022178730A1 WO 2022178730 A1 WO2022178730 A1 WO 2022178730A1 CN 2021077738 W CN2021077738 W CN 2021077738W WO 2022178730 A1 WO2022178730 A1 WO 2022178730A1
Authority
WO
WIPO (PCT)
Prior art keywords
computing
microservice
microservices
resource
computing resources
Prior art date
Application number
PCT/CN2021/077738
Other languages
French (fr)
Chinese (zh)
Inventor
韩捷
高亮
任文科
Original Assignee
西门子股份公司
西门子(中国)有限公司
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 西门子股份公司, 西门子(中国)有限公司 filed Critical 西门子股份公司
Priority to PCT/CN2021/077738 priority Critical patent/WO2022178730A1/en
Publication of WO2022178730A1 publication Critical patent/WO2022178730A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]

Definitions

  • Embodiments of the present invention relate to the technical field of microservice applications, and in particular, to a method, apparatus, and computer-readable medium for allocating resources for microservices.
  • microservices are becoming the de facto standard way of software development in cloud computing and service-oriented computing, emphasizing self-management and lightweight as a means to improve software agility, scalability, and autonomy.
  • Each microservice is implemented and operated as a small and independent system, providing access to its internal logic and data through a well-defined network interface.
  • microservice resource allocation and adjustment greatly depends on the experience and understanding of system designers.
  • Embodiments of the present invention provide a microservice resource allocation method, apparatus, and computer-readable medium, which are used for microservice resource allocation and adjustment.
  • computing resources are allocated to each microservice in a target application through multiple resource adjustment processes. If the predicted next adjustment process, the sum of the independent service computing time of each microservice is greater than the computing time of each first independent service If the sum is reached, it is determined that the resource adjustment process is over, and it is determined that resources are allocated according to the respective computing resource amounts allocated by the current adjustment process. This makes it possible to achieve the shortest overall running time of the target application under the condition that the total amount of computing resources allocated to each microservice is constant after several adjustments.
  • calculating the independent service computing time of each microservice according to the tracking data and spatial data of each microservice has the advantage of accurate calculation results.
  • the amount of computing resources allocated to each microservice in the current adjustment process and the calculated independent service computing time the amount of computing resources allocated to each microservice in the next resource adjustment process is predicted, so that the next adjustment can depend on the current The adjustment result is adjusted to the best computing resource allocation scheme as soon as possible.
  • the calculation is accurate.
  • a microservice resource allocation method can be used to allocate computing resources to each microservice in a target application through a plurality of resource adjustment processes, wherein the total amount of computing resources allocated to each of the microservices is a preset constant, and the method includes: In the current resource adjustment process, the first computing resource amount allocated for each of the microservices is obtained; the tracking data and spatial data of each of the microservices are obtained; for each of the microservices, according to the tracking data of the microservice Calculate the computing time of the first independent service of the microservice with spatial data; according to the amount of each of the first computing resources and the computing time of each of the first independent services, predict the allocation for each of the microservices in the next resource adjustment process the second computing resource amount; allocate computing resources for each of the microservices according to the corresponding second computing resource amount; deploy the target application; obtain the output of the target application The second independent service computing time; if the sum of the respective second independent service computing times is greater than the sum of the respective first independent service computing times
  • an apparatus including modules for performing the steps in the method provided in the first aspect.
  • an apparatus comprising: at least one memory configured to store computer-readable codes; at least one processor configured to invoke the computer-readable codes to perform steps in the method provided in the first aspect .
  • a computer-readable medium storing computer-readable instructions on the computer-readable medium, the computer-readable instructions, when executed by a processor, cause the processor to perform the method provided in the first aspect in each step.
  • the amount of each of the second computing resources may be determined as having a longer first computing resource.
  • the microservices that independently serve computing time reserve more computing resources. This adjustment can allocate computing resources more reasonably, so that microservices that require longer independent service computing time can obtain more computing resources.
  • a learning rate is set, wherein, the larger the learning rate, the higher the amount of computing resources.
  • the speed of the resource adjustment process can be flexibly set by setting the learning rate.
  • the target application is deployed in a k8s cluster, and when obtaining the first amount of computing resources allocated for each of the microservices, each of the microservices can be obtained through the k8s application programming interface API
  • the computing resource amounts of the end points of the service are respectively taken as the respective first computing resource amounts.
  • FIG. 1 is a schematic structural diagram of a microservice resource allocation apparatus according to an embodiment of the present invention.
  • FIG. 2 is a schematic diagram of interaction between modules in the apparatus for allocating resources for microservices provided by an embodiment of the present invention.
  • FIG. 3 is a flowchart of a method for allocating resources for microservices provided by an embodiment of the present invention.
  • Microservice resource allocation device 101 Memory 102: Processor 103: Communication interface
  • Microservice resource allocation program 201 Configuration collector 202: Timer 203: Resource allocator
  • Deployment module 205 Data processor 30: k8s cluster 40: Control plane of service mesh
  • the term “including” and variations thereof represent open-ended terms meaning “including but not limited to”.
  • the term “based on” means “based at least in part on”.
  • the terms “one embodiment” and “an embodiment” mean “at least one embodiment.”
  • the term “another embodiment” means “at least one other embodiment.”
  • the terms “first”, “second”, etc. may refer to different or the same objects. Other definitions, whether explicit or implicit, may be included below. The definition of a term is consistent throughout the specification unless the context clearly dictates otherwise.
  • k8s and k8s objects are used in the solutions provided by the embodiments of the present invention, but the embodiments of the present invention are not limited to using only k8s and its objects.
  • the computing resources reserved for microservices include resources for things such as CPU, memory, external storage, processes, or other custom resources that can affect the computing power of the service.
  • computing resources can only be allocated and reserved according to the designer's understanding. By changing the resource request, the designer can change the computing power of the microservice.
  • the variables used in the embodiment of the present invention include: n selection variables with one constraint:
  • a trace ID (trace ID) is generated, and the trace ID will follow the request everywhere.
  • a new duration (Span) is generated for each logical work block in the request, which contains the same tracking ID, the new duration ID, and the parent duration ID (the parent duration ID points to this new duration logically). parent duration).
  • This parent duration ID creates a parent-child relationship between durations.
  • the duration also includes the start timestamp and duration, so it can be placed on the timeline.
  • a service mesh is a framework for inter-service communication. With a service mesh, a given microservice does not have to communicate directly with other microservices. Instead, all service-to-service communication will happen on top of a software component called a side-car proxy.
  • the target application 100 may include n microservices 200: Si,i ⁇ [1,n].
  • the Distributed Tracing library, service net and jaeger can track the request and obtain the "independent service computing time" of each microservice 200 (denoted as T i , i ⁇ [1, n]).
  • the microservice resource allocation device 10 provided by the embodiment of the present invention can work with the target application 100, and the target application 100 can be deployed in the k8s cluster where the service mesh and jaeger are installed, which helps the system designer to calculate the resources Allocate and adjust.
  • computing resources can be reserved as much as possible for the microservice 200 with longer independent service computing time T i , and finally a set of computing resources R i corresponding to the minimum total response time T s can be found.
  • the above-mentioned resource allocation apparatus 10 may be implemented as a network of computer processors to execute the microservice resource allocation method 300 in the embodiment of the present invention, or may also be a single computer, a single-chip microcomputer, or a processing chip as shown in FIG.
  • a memory 101 comprising computer readable media such as random access memory (RAM).
  • the apparatus 10 also includes at least one processor 102 coupled with at least one memory 101 .
  • Computer-executable instructions are stored in at least one memory 101 and, when executed by at least one processor 102, can cause at least one processor 102 to perform the steps described herein.
  • At least one memory 101 shown in FIG. 1 may contain a microservice resource allocation program 20, so that at least one processor 102 executes the microservice resource allocation method 300 described in the embodiment of the present invention.
  • the microservice resource allocation program 20 may include:
  • the configuration collector 201 is configured to obtain the amount of computing resources allocated to each microservice 200 of the target application 100 in the rth resource adjustment process (or “current resource adjustment process”) (For example: computing resources (ie, pods) at the endpoints of each microservice 200, where i ⁇ [1,n] and r ⁇ [1,m], and r represents the rth resource adjustment.
  • the k8s application programming interface (API) obtains the data of the above computing resources.
  • the timer 202 is configured to obtain the tracking data and spatial data 50 of each microservice 200 of the target application 100 during the rth resource adjustment process, and calculate the independent service computing time respectively i ⁇ [1,n],r ⁇ [1,m].
  • the above-mentioned tracking data and spatial data 50 can be obtained through the distributed tracking library API.
  • the resource allocator 203 is configured to calculate the amount of computing resources allocated to each microservice 200 in the r+1th resource adjustment process (or referred to as the "next adjustment process")
  • the deployment module 204 is configured to be based on the amount of computing resources allocated to each microservice 200 obtained after m times of resource adjustment
  • the target application 100 is deployed in the k8s cluster 30 .
  • the learning rate ⁇ can be defined, i ⁇ [1,n], where, is the computing resource allocated to each microservice 200 before resource adjustment is performed.
  • the independent service computing time Ti of each microservice 200 is obtained from the output of the target application 100 .
  • the above modules can also be regarded as various functional modules implemented by hardware, which are used to implement various functions involved in the microservice resource allocation apparatus 10 when executing the microservice resource allocation method, such as pre-processing of each process involved in the method.
  • the control logic is fired into a chip such as a Field-Programmable Gate Array (FPGA) or a Complex Programmable Logic Device (CPLD), and these chips or devices perform the functions of the above modules,
  • FPGA Field-Programmable Gate Array
  • CPLD Complex Programmable Logic Device
  • microservice resource allocation apparatus 10 may further include a communication interface 103 for communication between the microservice resource allocation apparatus 10 and other devices.
  • embodiments of the present invention may include apparatuses having architectures different from those shown in FIG. 1 .
  • the above architecture is only exemplary, and is used to explain the microservice resource allocation method 300 provided by the embodiment of the present invention.
  • the at least one processor 102 may include a microprocessor, an application specific integrated circuit (ASIC), a digital signal processor (DSP), a central processing unit (CPU), a graphics processing unit (GPU), a state machine, and the like.
  • ASIC application specific integrated circuit
  • DSP digital signal processor
  • CPU central processing unit
  • GPU graphics processing unit
  • Examples of computer readable media include, but are not limited to, floppy disks, CD-ROMs, magnetic disks, memory chips, ROM, RAM, ASICs, configured processors, all-optical media, all magnetic tapes or other magnetic media, or from which a computer processor can Any other medium from which to read instructions.
  • various other forms of computer-readable media can transmit or carry instructions to a computer, including routers, private or public networks, or other wired and wireless transmission devices or channels. Instructions can include code in any computer programming language, including C, C++, C, Visual Basic, java, and JavaScript.
  • the following describes a microservice resource allocation method 300 provided by an embodiment of the present invention with reference to FIG. 3 .
  • the method can be executed by the aforementioned microservice resource allocation apparatus 10, and is used to allocate computing resources to each microservice 200 in a target application 100 through a plurality of resource adjustment processes, wherein the total amount of computing resources allocated to each microservice 200 is is a preset constant, the method may include: during the current resource adjustment process,
  • -S303 For each microservice 200, calculate the computing time of the first independent service of the microservice 200 according to the tracking data and spatial data of the microservice 200;
  • step S304 when predicting the second computing resources allocated to each user in the next resource adjustment process, the amount of each second computing resource may be determined, so as to predict the microservice 200 with a longer first independent service computing time. Reserve more computing resources.
  • a learning rate may be set when predicting the second amount of computing resources allocated to each user in the next resource adjustment process, wherein the larger the learning rate, the larger the adjustment amount of computing resources.
  • the target application 100 is deployed in the k8s cluster 30.
  • the computing resources of the endpoints of each microservice 200 can be obtained through the k8s application programming interface API.
  • the quantities are respectively used as the associated quantities of the respective first computing resources.
  • the k8s cluster 30 is installed with a service grid and jaeger, and the target application 100 is used to process a request message.
  • the service grid and jaeger can be used to pair with each other.
  • the request message is tracked in a distributed manner to obtain tracking data and spatial data; wherein, the computing time of the first independent service and the computing time of the second independent service are the computing time for each microservice 200 to process the request message.
  • embodiments of the present invention further provide a computer-readable medium, where computer-readable instructions are stored on the computer-readable medium, and when the computer-readable instructions are executed by the processor, the processor executes the aforementioned microservice resources allocation method.
  • Examples of computer-readable media include floppy disks, hard disks, magneto-optical disks, optical disks (eg, CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tape, non- Volatile memory cards and ROMs.
  • the computer readable instructions may be downloaded from a server computer or cloud over a communications network.

Abstract

The embodiments of the present invention relate to microservice application technology, and particularly relate to a microservice resource allocation method and apparatus, and a computer-readable medium. In the microservice resource allocation method, by means of a plurality of resource adjustment processes, computing resources are allocated to each microservice in a target application program; in the current resource adjustment process, the number of computing resources allocated to each microservice, trace data, and spatial data are acquired, and accordingly, the sum of independent service computing times of the microservices is computed and obtained; the number of computing resources allocated to each microservice in the next resource adjustment process is predicted, and accordingly, the target application program is deployed; the independent service computing time of each microservice is obtained from a program output; and if the sum of predicted independent service computing times of the microservices after the next adjustment is greater than the sum of the current independent service computing times of the microservices, it is determined that the resource adjustment process ends, and the number of computing resources, which are currently allocated, is determined so as to conduct resource allocation.

Description

微服务资源分配方法、装置和计算机可读介质Microservice resource allocation method, apparatus and computer readable medium 技术领域technical field
本发明实施例涉及微服务应用技术领域,尤其涉及一种微服务资源分配方法、装置和计算机可读介质。Embodiments of the present invention relate to the technical field of microservice applications, and in particular, to a method, apparatus, and computer-readable medium for allocating resources for microservices.
背景技术Background technique
软件系统设计(software system design)是一个系统元素的设计过程,这些元素可包括:体系结构、组件以及组件之间的相互交互。近年,微服务正在成为云计算和面向服务计算中软件开发的事实标准方式,它强调自我管理和轻量级,作为提高软件敏捷性、可伸缩性和自主性的手段。每个微服务都作为一个小而独立的系统来实现和操作,通过一个定义良好的网络接口提供对其内部逻辑和数据的访问。但另一方面,由于系统中相互独立的微服务越来越多,使得服务间的通信、资源分配和调整变得异常困难。目前,微服务资源分配和调整极大依赖于系统设计人员的经验和理解。Software system design is the process of designing system elements, which can include architecture, components, and the interactions between components. In recent years, microservices are becoming the de facto standard way of software development in cloud computing and service-oriented computing, emphasizing self-management and lightweight as a means to improve software agility, scalability, and autonomy. Each microservice is implemented and operated as a small and independent system, providing access to its internal logic and data through a well-defined network interface. On the other hand, due to the increasing number of independent microservices in the system, it becomes extremely difficult to communicate, allocate and adjust resources between services. Currently, microservice resource allocation and adjustment greatly depends on the experience and understanding of system designers.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供了一种微服务资源分配方法、装置和计算机可读介质,用于微服务资源分配和调整。其中,通过复数次资源调整过程为一个目标应用程序中的各个微服务分配计算资源,若预测得到的下一次调整过程中,各个微服务的独立服务计算时间之和大于各个第一独立服务计算时间之和,则确定资源调整过程结束,并确定按照当前调整过程分配的各个计算资源量进行资源分配。使得经过若干次调整后,在为各个微服务分配的总的计算资源量一定的情况下,能够达到目标应用程序的整体运行时间最短。并且,根据各个微服务的跟踪数据和空间数据来计算各个微服务的独立服务计算时间,具有计算结果准确的优点。此外,根据当前调整过程中为各个微服务分配的计算资源量和计算得到的独立服务计算时间来预测下一次资源调整过程中为各个微服务分配的计算资源量,使得下一次调整能够依赖于当前调整的结果尽快调整到最佳的计算资源分配方案。并且,通过将目标应用程序按照下一次调整过程中为各个微服务分配的计算资源量进行部署,通过目标应用程序的输出来得到下一次调整后的各个微服务的独立服务计算时间,具有计算准确的优点。Embodiments of the present invention provide a microservice resource allocation method, apparatus, and computer-readable medium, which are used for microservice resource allocation and adjustment. Among them, computing resources are allocated to each microservice in a target application through multiple resource adjustment processes. If the predicted next adjustment process, the sum of the independent service computing time of each microservice is greater than the computing time of each first independent service If the sum is reached, it is determined that the resource adjustment process is over, and it is determined that resources are allocated according to the respective computing resource amounts allocated by the current adjustment process. This makes it possible to achieve the shortest overall running time of the target application under the condition that the total amount of computing resources allocated to each microservice is constant after several adjustments. Moreover, calculating the independent service computing time of each microservice according to the tracking data and spatial data of each microservice has the advantage of accurate calculation results. In addition, according to the amount of computing resources allocated to each microservice in the current adjustment process and the calculated independent service computing time, the amount of computing resources allocated to each microservice in the next resource adjustment process is predicted, so that the next adjustment can depend on the current The adjustment result is adjusted to the best computing resource allocation scheme as soon as possible. In addition, by deploying the target application according to the amount of computing resources allocated to each microservice in the next adjustment process, and obtaining the independent service computing time of each microservice after the next adjustment through the output of the target application, the calculation is accurate. The advantages.
第一方面,提供一种微服务资源分配方法。该方法可用于通过复数次资源调整过程为一个目标应用程序中的各个微服务分配计算资源,其中为各个所述微服务分配的总的计算资源 量为一预设的常量,所述方法包括:在当前资源调整过程中,获取为各个所述微服务分配的第一计算资源量;获取各个所述微服务的跟踪数据和空间数据;对于每一个所述微服务,根据该微服务的跟踪数据和空间数据计算得到该微服务的第一独立服务计算时间;根据各个所述第一计算资源量以及各个所述第一独立服务计算时间,预测下一次资源调整过程中为各个所述微服务分配的第二计算资源量;为各个所述微服务按照对应的所述第二计算资源量分配计算资源;部署所述目标应用程序;从所述目标应用程序的输出中获得所述各个微服务的第二独立服务计算时间;若各个所述第二独立服务计算时间之和大于各个所述第一独立服务计算时间之和,则确定资源调整过程结束,并确定按照各个所述第一计算资源量进行资源分配;若各个所述第二独立服务计算时间之和不大于各个所述第一独立服务计算时间之和,则确定继续进行下一次资源调整过程。In a first aspect, a microservice resource allocation method is provided. The method can be used to allocate computing resources to each microservice in a target application through a plurality of resource adjustment processes, wherein the total amount of computing resources allocated to each of the microservices is a preset constant, and the method includes: In the current resource adjustment process, the first computing resource amount allocated for each of the microservices is obtained; the tracking data and spatial data of each of the microservices are obtained; for each of the microservices, according to the tracking data of the microservice Calculate the computing time of the first independent service of the microservice with spatial data; according to the amount of each of the first computing resources and the computing time of each of the first independent services, predict the allocation for each of the microservices in the next resource adjustment process the second computing resource amount; allocate computing resources for each of the microservices according to the corresponding second computing resource amount; deploy the target application; obtain the output of the target application The second independent service computing time; if the sum of the respective second independent service computing times is greater than the sum of the respective first independent service computing times, it is determined that the resource adjustment process is over, and the amount of the first computing resources is determined according to each of the first independent services. Perform resource allocation; if the sum of the calculation time of each of the second independent services is not greater than the sum of the calculation time of each of the first independent services, it is determined to continue the next resource adjustment process.
第二方面,提供一种装置,包括用于执行第一方面提供的方法中各步骤的模块。In a second aspect, an apparatus is provided, including modules for performing the steps in the method provided in the first aspect.
第三方面,提供一种装置,包括:至少一个存储器,被配置为存储计算机可读代码;至少一个处理器,被配置为调用所述计算机可读代码,执行第一方面提供的方法中各步骤。In a third aspect, an apparatus is provided, comprising: at least one memory configured to store computer-readable codes; at least one processor configured to invoke the computer-readable codes to perform steps in the method provided in the first aspect .
第四方面,一种计算机可读介质,所述计算机可读介质上存储有计算机可读指令,所述计算机可读指令在被处理器执行时,使所述处理器执行第一方面提供的方法中各步骤。In a fourth aspect, a computer-readable medium, storing computer-readable instructions on the computer-readable medium, the computer-readable instructions, when executed by a processor, cause the processor to perform the method provided in the first aspect in each step.
对于上述任一方面,可选地,在预测下一次资源调整过程中为各个所述微服务分配的第二计算资源时,可确定各个所述第二计算资源量,以为具有更长的第一独立服务计算时间的所述微服务预留更多的计算资源。这样调整能够更合理地分配计算资源,使得需要较长独立服务计算时间的微服务获得更多的计算资源。For any of the above-mentioned aspects, optionally, when predicting the second computing resources allocated to each of the microservices in the next resource adjustment process, the amount of each of the second computing resources may be determined as having a longer first computing resource. The microservices that independently serve computing time reserve more computing resources. This adjustment can allocate computing resources more reasonably, so that microservices that require longer independent service computing time can obtain more computing resources.
对于上述任一方面,可选地,在预测下一次资源调整过程中为各个所述微服务分配的第二计算资源量时,设置学习速率,其中,所述学习速率越大,则计算资源的调整量越大。通过设置学习速率可灵活设置资源调整过程的速度。For any of the above aspects, optionally, when predicting the second amount of computing resources allocated to each of the microservices in the next resource adjustment process, a learning rate is set, wherein, the larger the learning rate, the higher the amount of computing resources. The larger the adjustment amount. The speed of the resource adjustment process can be flexibly set by setting the learning rate.
对于上述任一方面,可选地,所述目标应用程序部署在k8s集群中,在获取为各个所述微服务分配的第一计算资源量时,可通过k8s应用编程接口API获得各个所述微服务的终点的计算资源量分别作为各个所述第一计算资源量。For any of the above aspects, optionally, the target application is deployed in a k8s cluster, and when obtaining the first amount of computing resources allocated for each of the microservices, each of the microservices can be obtained through the k8s application programming interface API The computing resource amounts of the end points of the service are respectively taken as the respective first computing resource amounts.
附图说明Description of drawings
图1为本发明实施例提供的微服务资源分配装置的结构示意图。FIG. 1 is a schematic structural diagram of a microservice resource allocation apparatus according to an embodiment of the present invention.
图2为本发明实施例提供的微服务资源分配装置中各模块之间相互交互的示意图。FIG. 2 is a schematic diagram of interaction between modules in the apparatus for allocating resources for microservices provided by an embodiment of the present invention.
图3为本发明实施例提供的微服务资源分配方法的流程图。FIG. 3 is a flowchart of a method for allocating resources for microservices provided by an embodiment of the present invention.
附图标记列表:List of reference numbers:
10:微服务资源分配装置  101:存储器    102:处理器  103:通信接口10: Microservice resource allocation device 101: Memory 102: Processor 103: Communication interface
20:微服务资源分配程序  201:配置收集器  202:定时器  203:资源分配器20: Microservice resource allocation program 201: Configuration collector 202: Timer 203: Resource allocator
204:部署模块  205:数据处理器  30:k8s集群  40:服务网格的控制平面204: Deployment module 205: Data processor 30: k8s cluster 40: Control plane of service mesh
50:跟踪数据和空间数据  300:微服务资源分配方法  S301~S309:方法步骤50: Tracking data and spatial data 300: Microservice resource allocation method S301~S309: Method steps
具体实施方式Detailed ways
现在将参考示例实施方式讨论本文描述的主题。应该理解,讨论这些实施方式只是为了使得本领域技术人员能够更好地理解从而实现本文描述的主题,并非是对权利要求书中所阐述的保护范围、适用性或者示例的限制。可以在不脱离本发明实施例内容的保护范围的情况下,对所讨论的元素的功能和排列进行改变。各个示例可以根据需要,省略、替代或者添加各种过程或组件。例如,所描述的方法可以按照与所描述的顺序不同的顺序来执行,以及各个步骤可以被添加、省略或者组合。另外,相对一些示例所描述的特征在其它例子中也可以进行组合。The subject matter described herein will now be discussed with reference to example implementations. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and implement the subject matter described herein, and not to limit the scope of protection, applicability, or examples set forth in the claims. Changes may be made in the function and arrangement of elements discussed without departing from the scope of the present disclosure. Various examples may omit, substitute, or add various procedures or components as desired. For example, the methods described may be performed in an order different from that described, and various steps may be added, omitted, or combined. Additionally, features described with respect to some examples may also be combined in other examples.
如本文中使用的,术语“包括”及其变型表示开放的术语,含义是“包括但不限于”。术语“基于”表示“至少部分地基于”。术语“一个实施例”和“一实施例”表示“至少一个实施例”。术语“另一个实施例”表示“至少一个其他实施例”。术语“第一”、“第二”等可以指代不同的或相同的对象。下面可以包括其他的定义,无论是明确的还是隐含的。除非上下文中明确地指明,否则一个术语的定义在整个说明书中是一致的。As used herein, the term "including" and variations thereof represent open-ended terms meaning "including but not limited to". The term "based on" means "based at least in part on". The terms "one embodiment" and "an embodiment" mean "at least one embodiment." The term "another embodiment" means "at least one other embodiment." The terms "first", "second", etc. may refer to different or the same objects. Other definitions, whether explicit or implicit, may be included below. The definition of a term is consistent throughout the specification unless the context clearly dictates otherwise.
为了便于理解本发明实施例的内容,下面对本发明实施例涉及的一些内容加以描述。需要说明的是,这些内容不应视为对本发明保护范围的限制。To facilitate understanding of the contents of the embodiments of the present invention, some contents involved in the embodiments of the present invention are described below. It should be noted that these contents should not be regarded as limiting the protection scope of the present invention.
1、Kubernetes(k8s:生产级容器编排)1. Kubernetes (k8s: production-level container orchestration)
最流行的开源系统,用于容器化应用的自动部署、调整和管理。k8s和k8s对象作为部署工具和目标的一个例子在本发明实施例提供的方案中使用,但本发明实施例并不限于仅能使用k8s及其对象。The most popular open source system for automated deployment, tuning, and management of containerized applications. As an example of deployment tools and targets, k8s and k8s objects are used in the solutions provided by the embodiments of the present invention, but the embodiments of the present invention are not limited to using only k8s and its objects.
2、为微服务预留的计算资源2. Computing resources reserved for microservices
为微服务预留的计算资源包括用于诸如CPU、内存、外部存储、过程的资源或其他定制资源,其可影响服务的计算能力。目前的K8或其他部署中,只能根据设计者的理解来分配和预留计算资源。通过改变资源请求,设计者可以改变微服务的计算能力。The computing resources reserved for microservices include resources for things such as CPU, memory, external storage, processes, or other custom resources that can affect the computing power of the service. In current K8s or other deployments, computing resources can only be allocated and reserved according to the designer's understanding. By changing the resource request, the designer can change the computing power of the microservice.
3、拉格朗日乘数(Lagrange Multiplier)3. Lagrange Multiplier
是一种寻找等式约束下函数局部极大值和极小值的策略。其基本思想是将约束问题转化为无约束问题。本发明实施例中使用的变量包括:n个具有一个约束条件的选择变量:It is a strategy for finding local maxima and minima of functions under equality constraints. The basic idea is to transform a constrained problem into an unconstrained problem. The variables used in the embodiment of the present invention include: n selection variables with one constraint:
1)为了使g(x 1,x 2,...x n)=0时,f(x 1,x 2,...x n)的值最小,存在唯一的拉格朗日乘数λ。 1) In order to minimize the value of f(x 1 , x 2 , ... x n ) when g(x 1 , x 2 , ... x n )=0, there is a unique Lagrangian multiplier λ .
2)对于λ,有一个函数
Figure PCTCN2021077738-appb-000001
求解
Figure PCTCN2021077738-appb-000002
2) For λ, there is a function
Figure PCTCN2021077738-appb-000001
solve
Figure PCTCN2021077738-appb-000002
3)
Figure PCTCN2021077738-appb-000003
相当于求解具有n+1个未知量的n+1个方程。
3)
Figure PCTCN2021077738-appb-000003
Equivalent to solving n+1 equations with n+1 unknowns.
4)利用x 1,x 2,...,最终得到满足g(x 1,x 2,...x n)=0的f(x 1,x 2,...x n)的最小值。 4) Using x 1 , x 2 , ..., finally obtain the minimum value of f(x 1 , x 2 , ... x n ) that satisfies g(x 1 , x 2 , ... x n )=0 .
4、分布式跟踪(distributed tracing)4. Distributed tracing
是跟踪和分析请求(事务)在其涉及的所有微服务中发生的情况的过程,这些微服务生成并收集每个微服务中的原始数据。分布式跟踪启动时会生成跟踪ID(trace ID),该跟踪ID将跟随请求到任何地方。请求中为每个逻辑工作块生成一个新的持续时间(Span),其中包含相同的跟踪ID、新的持续时间ID和父持续时间ID(该父持续时间ID指向这个新的持续时间逻辑上的父持续时间)。该父持续时间ID创建了持续时间之间的父子关系。此外,持续时间也包含起始时间戳和时长,因此可以放置于时间线上。Is the process of tracking and analyzing what happens to a request (transaction) across all the microservices it involves, which generate and collect raw data from each microservice. When distributed tracing starts, a trace ID (trace ID) is generated, and the trace ID will follow the request everywhere. A new duration (Span) is generated for each logical work block in the request, which contains the same tracking ID, the new duration ID, and the parent duration ID (the parent duration ID points to this new duration logically). parent duration). This parent duration ID creates a parent-child relationship between durations. In addition, the duration also includes the start timestamp and duration, so it can be placed on the timeline.
5、服务网格(service mesh)5. Service mesh
服务网格是一种服务间通信的框架,有了服务网格,给定的微服务不必直接与其他微服务通信。相反,所有服务对服务的通信都将发生在一个名为side-car代理的软件组件之上。A service mesh is a framework for inter-service communication. With a service mesh, a given microservice does not have to communicate directly with other microservices. Instead, all service-to-service communication will happen on top of a software component called a side-car proxy.
6、Jaeger6. Jaeger
是一种开源的、端到端的分布式跟踪工具,可用于监视并为复杂的分布式系统中的事务解决问题。is an open-source, end-to-end distributed tracing tool that can be used to monitor and troubleshoot transactions in complex distributed systems.
7、独立服务计算时间7. Independent service computing time
是微服务的计算时间,典型地,是服务的执行时间——串行的子执行时间。is the computation time of the microservice, typically, the execution time of the service - the serial sub-execution time.
下面结合附图对本发明实施例进行详细说明。The embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
本发明实施例中,可首先进行如下预设置和目标定义:In this embodiment of the present invention, the following presets and target definitions may be performed first:
1)目标应用程序100可包括n个微服务200:Si,i∈[1,n]。1) The target application 100 may include n microservices 200: Si,i∈[1,n].
2)为每一个微服务200预留诸如CPU、内存等计算资源,表示为R i,i∈[1,n]。 2) Reserve computing resources such as CPU and memory for each microservice 200, denoted as R i ,i∈[1,n].
3)定义
Figure PCTCN2021077738-appb-000004
以及常量C,是为该目标应用程序100的所有微服务200预留的计算资源。
3) Definition
Figure PCTCN2021077738-appb-000004
And the constant C is the computing resource reserved for all microservices 200 of the target application 100 .
4)对于预先定义的请求,分布式跟踪库(Distributed Tracing library)、服务网和jaeger可以跟踪该请求并获取各个微服务200的“独立服务计算时间”(表示为T i,i∈[1,n])。 4) For a pre-defined request, the Distributed Tracing library, service net and jaeger can track the request and obtain the "independent service computing time" of each microservice 200 (denoted as T i , i ∈ [1, n]).
5)定义
Figure PCTCN2021077738-appb-000005
作为该请求的总响应时间。
5) Definition
Figure PCTCN2021077738-appb-000005
as the total response time for this request.
6)基于上述预设置,目标是:找到符合约束条件R s=C的资源组合R i,使得能够获得最小的总响应时间T s6) Based on the above presets, the goal is to find a resource combination R i that meets the constraint condition R s =C, so that the minimum total response time T s can be obtained.
系统架构和数据工作流:System Architecture and Data Workflow:
本发明实施例提供的微服务资源分配装置10可与目标应用程序100一起工作,目标应用程序100可部署在安装了服务网格和jaeger的k8s集群中,这有助于系统设计者进行计算资源分配和调整。The microservice resource allocation device 10 provided by the embodiment of the present invention can work with the target application 100, and the target application 100 can be deployed in the k8s cluster where the service mesh and jaeger are installed, which helps the system designer to calculate the resources Allocate and adjust.
其中,可以尽可能预留更多的计算资源给具有更长的独立服务计算时间T i的微服务200,并最终找到对应于最小的总响应时间T s的一组计算资源R iAmong them, more computing resources can be reserved as much as possible for the microservice 200 with longer independent service computing time T i , and finally a set of computing resources R i corresponding to the minimum total response time T s can be found.
对于微服务S iFor microservice S i ,
若(T i/T s-R i/R s)>0,则增加为该微服务200分配的计算资源,要增加计算资源的微服务200的数量记为N; If (T i /T s -R i /R s )>0, then increase the computing resources allocated for the microservice 200, and the number of microservices 200 whose computing resources are to be increased is denoted as N;
若(T i/T s-R i/R s)<0,则减少为该微服务200分配的计算资源,要减少计算资源的微服务200的数量记为M。 If (T i /T s -R i /R s )<0, the computing resources allocated to the microservice 200 are reduced, and the number of microservices 200 whose computing resources are to be reduced is denoted as M.
可定义倍增系数
Figure PCTCN2021077738-appb-000006
Definable multiplication factor
Figure PCTCN2021077738-appb-000006
具体地,设定目标为:在连续m次资源调整中要找到符合约束条件R s=C的最佳资源组合R iSpecifically, the set objective is to find an optimal resource combination R i that meets the constraint condition R s =C in m consecutive resource adjustments.
上述资源分配装置10可实现为计算机处理器的网络,以执行本发明实施例中的微服务资源分配方法300,或者也可以是如图1所示的单台计算机、单片机或处理芯片,包括至少一个存储器101,其包括计算机可读介质,例如随机存取存储器(RAM)。装置10还包括与至少一个存储器101耦合的至少一个处理器102。计算机可执行指令存储在至少一个存储器101中,并且当由至少一个处理器102执行时,可以使至少一个处理器102执行本文所述的步骤。The above-mentioned resource allocation apparatus 10 may be implemented as a network of computer processors to execute the microservice resource allocation method 300 in the embodiment of the present invention, or may also be a single computer, a single-chip microcomputer, or a processing chip as shown in FIG. A memory 101 comprising computer readable media such as random access memory (RAM). The apparatus 10 also includes at least one processor 102 coupled with at least one memory 101 . Computer-executable instructions are stored in at least one memory 101 and, when executed by at least one processor 102, can cause at least one processor 102 to perform the steps described herein.
图1中所示的至少一个存储器101可以包含微服务资源分配程序20,使得至少一个处理 器102执行本发明实施例中所述的微服务资源分配方法300。如图2所示,微服务资源分配程序20可以包括:At least one memory 101 shown in FIG. 1 may contain a microservice resource allocation program 20, so that at least one processor 102 executes the microservice resource allocation method 300 described in the embodiment of the present invention. As shown in FIG. 2, the microservice resource allocation program 20 may include:
配置收集器201,被配置为在第r次资源调整过程(或称为“当前资源调整过程”)中,获取为目标应用程序100的各个微服务200分配的计算资源量
Figure PCTCN2021077738-appb-000007
(比如:各个微服务200的终点(endpoint)的计算资源(即pod),其中,i∈[1,n]且r∈[1,m],r代表第r次资源调整。其中,可通过k8s应用编程接口(API)获得上述计算资源的数据。
The configuration collector 201 is configured to obtain the amount of computing resources allocated to each microservice 200 of the target application 100 in the rth resource adjustment process (or “current resource adjustment process”)
Figure PCTCN2021077738-appb-000007
(For example: computing resources (ie, pods) at the endpoints of each microservice 200, where i∈[1,n] and r∈[1,m], and r represents the rth resource adjustment. The k8s application programming interface (API) obtains the data of the above computing resources.
定时器202,被配置为在第r次资源调整过程中,获取目标应用程序100的各个微服务200的跟踪数据和空间数据50,并分别计算独立服务计算时间
Figure PCTCN2021077738-appb-000008
i∈[1,n],r∈[1,m]。其中,可以通过分布式跟踪库API获得上述跟踪数据和空间数据50。
The timer 202 is configured to obtain the tracking data and spatial data 50 of each microservice 200 of the target application 100 during the rth resource adjustment process, and calculate the independent service computing time respectively
Figure PCTCN2021077738-appb-000008
i∈[1,n],r∈[1,m]. The above-mentioned tracking data and spatial data 50 can be obtained through the distributed tracking library API.
资源分配器203,被配置为计算第r+1次资源调整过程(或称为“下一次调整过程”)中为各个微服务200分配的计算资源量
Figure PCTCN2021077738-appb-000009
The resource allocator 203 is configured to calculate the amount of computing resources allocated to each microservice 200 in the r+1th resource adjustment process (or referred to as the "next adjustment process")
Figure PCTCN2021077738-appb-000009
部署模块204,被配置为按照m次资源调整之后获得的为各个微服务200分配的计算资源量
Figure PCTCN2021077738-appb-000010
在k8s集群30中部署该目标应用程序100。
The deployment module 204 is configured to be based on the amount of computing resources allocated to each microservice 200 obtained after m times of resource adjustment
Figure PCTCN2021077738-appb-000010
The target application 100 is deployed in the k8s cluster 30 .
其中,可采用如下算法进行资源调整:Among them, the following algorithm can be used for resource adjustment:
可定义学习速率η,
Figure PCTCN2021077738-appb-000011
i∈[1,n],其中,
Figure PCTCN2021077738-appb-000012
是未进行资源调整之前为各个微服务200分配的计算资源。
The learning rate η can be defined,
Figure PCTCN2021077738-appb-000011
i∈[1,n], where,
Figure PCTCN2021077738-appb-000012
is the computing resource allocated to each microservice 200 before resource adjustment is performed.
调用数据处理器205计算得到未进行资源调整之前各个微服务200的独立服务计算时间
Figure PCTCN2021077738-appb-000013
i∈[1,n]。
Invoke the data processor 205 to calculate the independent service computing time of each microservice 200 before resource adjustment is performed
Figure PCTCN2021077738-appb-000013
i∈[1,n].
定义
Figure PCTCN2021077738-appb-000014
definition
Figure PCTCN2021077738-appb-000014
重复以下步骤直至(θ ii-1>0): Repeat the following steps until (θ ii-1 >0):
调用数据处理器205计算得到第r次资源调整中各个微服务200的独立服务计算时间
Figure PCTCN2021077738-appb-000015
i∈[1,n];
Invoke the data processor 205 to calculate the independent service computing time of each microservice 200 in the rth resource adjustment
Figure PCTCN2021077738-appb-000015
i∈[1,n];
计算θ rCalculate θ r ;
定义微服务S i的计算资源调整量
Figure PCTCN2021077738-appb-000016
其中γ为前述的倍增系数,可由第r-1次资源调整中的R i和T i的值计算得到;
Define the amount of computing resource adjustment for the microservice Si
Figure PCTCN2021077738-appb-000016
where γ is the aforementioned multiplication factor, which can be calculated from the values of R i and T i in the r-1th resource adjustment;
通过
Figure PCTCN2021077738-appb-000017
i∈[1,n]来更新
Figure PCTCN2021077738-appb-000018
pass
Figure PCTCN2021077738-appb-000017
i∈[1,n] to update
Figure PCTCN2021077738-appb-000018
利用
Figure PCTCN2021077738-appb-000019
来更新目标应用程序100的各微服务200的资源分配;
use
Figure PCTCN2021077738-appb-000019
to update the resource allocation of each microservice 200 of the target application 100;
调用部署模块204将目标应用程序100重新部署到k8s集群30中;Invoke the deployment module 204 to redeploy the target application 100 to the k8s cluster 30;
从目标应用程序100的输出中获得各个微服务200的独立服务计算时间Ti。The independent service computing time Ti of each microservice 200 is obtained from the output of the target application 100 .
上述各模块还也可视为由硬件实现的各个功能模块,用于实现微服务资源分配装置10在执行微服务资源分配方法时涉及的各种功能,比如预先将该方法中涉及的各流程的控制逻辑烧制到诸如现场可编程门阵列(Field-Programmable Gate Array,FPGA)芯片或复杂可编程逻辑器件(Complex Programmable Logic Device,CPLD)中,而由这些芯片或器件执行上述各模块的功能,具体实现方式可依工程实践而定。The above modules can also be regarded as various functional modules implemented by hardware, which are used to implement various functions involved in the microservice resource allocation apparatus 10 when executing the microservice resource allocation method, such as pre-processing of each process involved in the method. The control logic is fired into a chip such as a Field-Programmable Gate Array (FPGA) or a Complex Programmable Logic Device (CPLD), and these chips or devices perform the functions of the above modules, The specific implementation method can be determined according to the engineering practice.
此外,微服务资源分配装置10还可包括一个通信接口103,用于微服务资源分配装置10与其他设备之间的通信。In addition, the microservice resource allocation apparatus 10 may further include a communication interface 103 for communication between the microservice resource allocation apparatus 10 and other devices.
应当提及的是,本发明实施例可以包括具有不同于图1所示架构的装置。上述架构仅仅是示例性的,用于解释本发明实施例提供的微服务资源分配方法300。It should be mentioned that embodiments of the present invention may include apparatuses having architectures different from those shown in FIG. 1 . The above architecture is only exemplary, and is used to explain the microservice resource allocation method 300 provided by the embodiment of the present invention.
其中,至少一个处理器102可以包括微处理器、专用集成电路(ASIC)、数字信号处理器(DSP)、中央处理单元(CPU)、图形处理单元(GPU)、状态机等。计算机可读介质的实施例包括但不限于软盘、CD-ROM、磁盘,存储器芯片、ROM、RAM、ASIC、配置的处理器、全光介质、所有磁带或其他磁性介质,或计算机处理器可以从中读取指令的任何其他介质。此外,各种其它形式的计算机可读介质可以向计算机发送或携带指令,包括路由器、专用或公用网络、或其它有线和无线传输设备或信道。指令可以包括任何计算机编程语言的代码,包括C、C++、C语言、Visual Basic、java和JavaScript。The at least one processor 102 may include a microprocessor, an application specific integrated circuit (ASIC), a digital signal processor (DSP), a central processing unit (CPU), a graphics processing unit (GPU), a state machine, and the like. Examples of computer readable media include, but are not limited to, floppy disks, CD-ROMs, magnetic disks, memory chips, ROM, RAM, ASICs, configured processors, all-optical media, all magnetic tapes or other magnetic media, or from which a computer processor can Any other medium from which to read instructions. In addition, various other forms of computer-readable media can transmit or carry instructions to a computer, including routers, private or public networks, or other wired and wireless transmission devices or channels. Instructions can include code in any computer programming language, including C, C++, C, Visual Basic, java, and JavaScript.
下面结合图3说明本发明实施例提供的微服务资源分配方法300。该方法可由前述的微服务资源分配装置10执行,用于通过复数次资源调整过程为一个目标应用程序100中的各个微服务200分配计算资源,其中为各个微服务200分配的总的计算资源量为一预设的常量,该方法可包括:在当前资源调整过程中,The following describes a microservice resource allocation method 300 provided by an embodiment of the present invention with reference to FIG. 3 . The method can be executed by the aforementioned microservice resource allocation apparatus 10, and is used to allocate computing resources to each microservice 200 in a target application 100 through a plurality of resource adjustment processes, wherein the total amount of computing resources allocated to each microservice 200 is is a preset constant, the method may include: during the current resource adjustment process,
-S301:获取为各个微服务200分配的第一计算资源量;-S301: Obtain the first computing resource amount allocated for each microservice 200;
-S302:获取各个微服务200的跟踪数据和空间数据;-S302: Obtain the tracking data and spatial data of each microservice 200;
-S303:对于每一个微服务200,根据该微服务200的跟踪数据和空间数据计算得到该微服务200的第一独立服务计算时间;-S303: For each microservice 200, calculate the computing time of the first independent service of the microservice 200 according to the tracking data and spatial data of the microservice 200;
-S304:根据各个第一计算资源量以及各个第一独立服务计算时间,预测下一次资源调整过程中为各个微服务200分配的第二计算资源量;- S304: Predict the amount of second computing resources allocated to each microservice 200 in the next resource adjustment process according to the amount of each first computing resource and the computing time of each first independent service;
-S305:为各个微服务200按照对应的第二计算资源量分配计算资源;-S305: Allocate computing resources for each microservice 200 according to the corresponding second computing resource amount;
-S306:部署目标应用程序100;-S306: deploy target application 100;
-S307:从目标应用程序100的输出中获得各个微服务200的第二独立服务计算时间;-S307: Obtain the second independent service computing time of each microservice 200 from the output of the target application 100;
-S308:若各个第二独立服务计算时间之和大于各个第一独立服务计算时间之和,则确定 资源调整过程结束,并确定按照各个第一计算资源量进行资源分配;-S308: if the sum of each second independent service calculation time is greater than the sum of each first independent service calculation time, then determine that the resource adjustment process ends, and determine that resource allocation is performed according to each first calculation resource amount;
-S309:若各个第二独立服务计算时间之和不大于各个第一独立服务计算时间之和,则确定继续进行下一次资源调整过程。-S309: If the sum of the calculation times of the second independent services is not greater than the sum of the calculation times of the first independent services, it is determined to continue the next resource adjustment process.
可选地,步骤S304中在预测下一次资源调整过程中为各个我分配的第二计算资源时可确定各个第二计算资源量,以为具有更长的第一独立服务计算时间的微服务200预留更多的计算资源。Optionally, in step S304, when predicting the second computing resources allocated to each user in the next resource adjustment process, the amount of each second computing resource may be determined, so as to predict the microservice 200 with a longer first independent service computing time. Reserve more computing resources.
可选地,步骤S304中在预测下一次资源调整过程中为各个我分配的第二计算资源量时可设置学习速率,其中,学习速率越大,则计算资源的调整量越大。Optionally, in step S304, a learning rate may be set when predicting the second amount of computing resources allocated to each user in the next resource adjustment process, wherein the larger the learning rate, the larger the adjustment amount of computing resources.
可选地,目标应用程序100部署在k8s集群30中,步骤S301中获取为各个微服务200分配的第一计算资源量时,可通过k8s应用编程接口API获得各个微服务200的终点的计算资源量分别作为各个第一计算资源联量。Optionally, the target application 100 is deployed in the k8s cluster 30. When obtaining the first amount of computing resources allocated for each microservice 200 in step S301, the computing resources of the endpoints of each microservice 200 can be obtained through the k8s application programming interface API. The quantities are respectively used as the associated quantities of the respective first computing resources.
可选地,k8s集群30安装了服务网格和jaeger,目标应用程序100用于处理一个请求消息,步骤S302汇总获取各个微服务200的跟踪数据和空间数据时,可利用服务网格和jaeger对请求消息进行分布式跟踪,以获得跟踪数据和空间数据;其中,第一独立服务计算时间和第二独立服务计算时间为各个微服务200处理请求消息的计算时间。Optionally, the k8s cluster 30 is installed with a service grid and jaeger, and the target application 100 is used to process a request message. In step S302, when the tracking data and spatial data of each microservice 200 are collected and obtained, the service grid and jaeger can be used to pair with each other. The request message is tracked in a distributed manner to obtain tracking data and spatial data; wherein, the computing time of the first independent service and the computing time of the second independent service are the computing time for each microservice 200 to process the request message.
此外,本发明实施例实施例还提供一种计算机可读介质,该计算机可读介质上存储有计算机可读指令,计算机可读指令在被处理器执行时,使处理器执行前述的微服务资源分配方法。计算机可读介质的实施例包括软盘、硬盘、磁光盘、光盘(如CD-ROM、CD-R、CD-RW、DVD-ROM、DVD-RAM、DVD-RW、DVD+RW)、磁带、非易失性存储卡和ROM。可选地,可以由通信网络从服务器计算机上或云上下载计算机可读指令。In addition, embodiments of the present invention further provide a computer-readable medium, where computer-readable instructions are stored on the computer-readable medium, and when the computer-readable instructions are executed by the processor, the processor executes the aforementioned microservice resources allocation method. Examples of computer-readable media include floppy disks, hard disks, magneto-optical disks, optical disks (eg, CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tape, non- Volatile memory cards and ROMs. Optionally, the computer readable instructions may be downloaded from a server computer or cloud over a communications network.
需要说明的是,上述各流程和各系统结构图中不是所有的步骤和模块都是必须的,可以根据实际的需要忽略某些步骤或模块。各步骤的执行顺序不是固定的,可以根据需要进行调整。上述各实施例中描述的系统结构可以是物理结构,也可以是逻辑结构,即,有些模块可能由同一物理实体实现,或者,有些模块可能分由多个物理实体实现,或者,可以由多个独立设备中的某些部件共同实现。It should be noted that not all steps and modules in the above-mentioned processes and system structure diagrams are necessary, and some steps or modules may be omitted according to actual needs. The execution order of each step is not fixed and can be adjusted as required. The system structure described in the above embodiments may be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or may be implemented by multiple physical entities. Some components in separate devices are implemented together.

Claims (12)

  1. 一种微服务资源分配方法(300),其特征在于,用于通过复数次资源调整过程为一个目标应用程序(100)中的各个微服务(200)分配计算资源,其中为各个所述微服务(200)分配的总的计算资源量为一预设的常量,所述方法包括:在当前资源调整过程中,A microservice resource allocation method (300), characterized in that it is used for allocating computing resources to each microservice (200) in a target application (100) through a plurality of resource adjustment processes, wherein for each of the microservices (200) The total amount of computing resources allocated is a preset constant, and the method includes: during the current resource adjustment process,
    -获取(S301)为各个所述微服务(200)分配的第一计算资源量;- obtaining (S301) the first amount of computing resources allocated for each of the microservices (200);
    -获取(S302)各个所述微服务(200)的跟踪数据和空间数据;- obtaining (S302) tracking data and spatial data of each of the microservices (200);
    -对于每一个所述微服务(200),根据该微服务(200)的跟踪数据和空间数据计算(S303)得到该微服务(200)的第一独立服务计算时间;- For each of the microservices (200), calculate (S303) according to the tracking data and spatial data of the microservice (200) to obtain the first independent service computing time of the microservice (200);
    -根据各个所述第一计算资源量以及各个所述第一独立服务计算时间,预测(S304)下一次资源调整过程中为各个所述微服务(200)分配的第二计算资源量;- predicting (S304) the amount of second computing resources allocated to each of the micro-services (200) in the next resource adjustment process according to the amount of each of the first computing resources and the computing time of each of the first independent services;
    -为各个所述微服务(200)按照对应的所述第二计算资源量分配(S305)计算资源;- Allocate (S305) computing resources for each of the microservices (200) according to the corresponding second computing resource amount;
    -部署(S306)所述目标应用程序(100);- deploying (S306) the target application (100);
    -从所述目标应用程序(100)的输出中获得(S307)所述各个微服务(200)的第二独立服务计算时间;- Obtaining (S307) the second independent service computing time of each microservice (200) from the output of the target application (100);
    -若各个所述第二独立服务计算时间之和大于各个所述第一独立服务计算时间之和,则确定(S308)资源调整过程结束,并确定按照各个所述第一计算资源量进行资源分配;- If the sum of the computing time of each of the second independent services is greater than the sum of the computing time of each of the first independent services, determine (S308) that the resource adjustment process ends, and determine to perform resource allocation according to the amount of each of the first computing resources ;
    -若各个所述第二独立服务计算时间之和不大于各个所述第一独立服务计算时间之和,则确定继续(S309)进行下一次资源调整过程。- If the sum of the calculation times of each of the second independent services is not greater than the sum of the calculation times of the first independent services, it is determined to continue (S309) to perform the next resource adjustment process.
  2. 如权利要求1所述的方法,其特征在于,所述预测(S304)下一次资源调整过程中为各个所述微服务(200)分配的第二计算资源,包括:The method according to claim 1, characterized in that, predicting (S304) the second computing resources allocated to each of the microservices (200) in the next resource adjustment process, comprising:
    -确定各个所述第二计算资源量,以为具有更长的第一独立服务计算时间的所述微服务(200)预留更多的计算资源。- Determining each of the second computing resource amounts to reserve more computing resources for the microservice (200) with a longer first independent service computing time.
  3. 如权利要求1所述的方法,其特征在于,所述预测(S304)下一次资源调整过程中为各个所述微服务(200)分配的第二计算资源量,包括:The method according to claim 1, wherein the predicting (S304) the second amount of computing resources allocated to each of the microservices (200) in the next resource adjustment process comprises:
    -设置学习速率,其中,所述学习速率越大,则计算资源的调整量越大。- Setting a learning rate, wherein the greater the learning rate, the greater the adjustment of computing resources.
  4. 如权利要求1所述的方法,所述目标应用程序(100)部署在k8s集群(30)中,所述获取(S301)为各个所述微服务(200)分配的第一计算资源量,包括:The method according to claim 1, wherein the target application (100) is deployed in a k8s cluster (30), and the acquiring (S301) the first computing resource amount allocated for each of the microservices (200), including :
    -通过k8s应用编程接口API获得各个所述微服务(200)的终点的计算资源量分别作为各个所述第一计算资源量。- Obtaining the computing resource amounts of the endpoints of each of the microservices (200) through the k8s application programming interface API as each of the first computing resource amounts.
  5. 如权利要求4所述的方法,其特征在于,所述k8s集群(30)安装了服务网格和jaeger,所述目标应用程序(100)用于处理一个请求消息,所述获取(S302)各个所述微服务(200)的跟踪数据和空间数据,包括:The method according to claim 4, characterized in that, the k8s cluster (30) is installed with a service mesh and jaeger, the target application (100) is used to process a request message, and the acquisition (S302) each The tracking data and spatial data of the microservice (200) include:
    -利用所述服务网格和所述jaeger对所述请求消息进行分布式跟踪,以获得所述跟踪数据和所述空间数据;- Distributed tracing of the request message using the service mesh and the jaeger to obtain the tracing data and the spatial data;
    其中,所述第一独立服务计算时间和所述第二独立服务计算时间为各个所述微服务(200)处理所述请求消息的计算时间。Wherein, the computing time of the first independent service and the computing time of the second independent service are the computing time of each of the microservices (200) for processing the request message.
  6. 一种微服务资源分配装置(10),其特征在于,用于通过复数次资源调整过程为一个目标应用程序(100)中的各个微服务(200)分配计算资源,其中为各个所述微服务(200)分配的总的计算资源量为一预设的常量,所述装置包括配置收集器(201)、定时器(202)、数据处理器(205)、资源分配器(203)、部署模块(204),在当前资源调整过程中,A microservice resource allocation device (10), characterized in that it is used for allocating computing resources to each microservice (200) in a target application (100) through a plurality of resource adjustment processes, wherein each of the microservices (200) The total amount of computing resources allocated is a preset constant, and the device includes a configuration collector (201), a timer (202), a data processor (205), a resource allocator (203), and a deployment module (204), during the current resource adjustment process,
    -所述配置收集器(201),被配置为获取为各个所述微服务(200)分配的第一计算资源量;- said configuration collector (201), configured to obtain a first amount of computing resources allocated for each of said microservices (200);
    -所述定时器(202),被配置为获取各个所述微服务(200)的跟踪数据和空间数据;- said timer (202), configured to obtain tracking data and spatial data of each of said microservices (200);
    -所述数据处理器(205),被配置为:- said data processor (205), configured to:
    -对于每一个所述微服务(200),根据该微服务(200)的跟踪数据和空间数据计算得到该微服务(200)的第一独立服务计算时间;- for each of the microservices (200), calculating the first independent service computing time of the microservice (200) according to the tracking data and spatial data of the microservice (200);
    -根据各个所述第一计算资源量以及各个所述第一独立服务计算时间,预测下一次资源调整过程中为各个所述微服务(200)分配的第二计算资源量;- predicting the second amount of computing resources allocated to each of the micro-services (200) in the next resource adjustment process according to the amount of each of the first computing resources and the computing time of each of the first independent services;
    -所述资源分配器(203),被配置为为各个所述微服务(200)按照对应的所述第二计算资源量分配计算资源;- the resource allocator (203) is configured to allocate computing resources for each of the microservices (200) according to the corresponding second computing resource amount;
    -所述部署模块(204),被配置为部署所述目标应用程序(100);- the deployment module (204) configured to deploy the target application (100);
    -所述数据处理器(205),还被配置为:- said data processor (205), further configured to:
    -从所述目标应用程序(100)的输出中获得所述各个微服务(200)的第二独立服务计算时间;- obtaining the second independent service computation time of the respective microservices (200) from the output of the target application (100);
    -若各个所述第二独立服务计算时间之和大于各个所述第一独立服务计算时间之和,则确定资源调整过程结束,并确定按照各个所述第一计算资源量进行资源分配;- if the sum of the calculation times of each of the second independent services is greater than the sum of the calculation times of each of the first independent services, determining that the resource adjustment process ends, and determining that resource allocation is performed according to each of the first computing resource amounts;
    -若各个所述第二独立服务计算时间之和不大于各个所述第一独立服务计算时间之和,则确定继续进行下一次资源调整过程。- If the sum of the calculation times of each of the second independent services is not greater than the sum of the calculation times of the first independent services, it is determined to continue the next resource adjustment process.
  7. 如权利要求6所述的装置,其特征在于,所述数据处理器(205)在预测下一次资源调整过程中为各个所述微服务(200)分配的第二计算资源量时,被具体配置为:The apparatus according to claim 6, wherein the data processor (205) is specifically configured when predicting the second amount of computing resources allocated to each of the microservices (200) in the next resource adjustment process for:
    -确定各个所述第二计算资源量,以为具有更长的第一独立服务计算时间的所述微服务(200)预留更多的计算资源。- Determining each of the second computing resource amounts to reserve more computing resources for the microservice (200) with a longer first independent service computing time.
  8. 如权利要求6所述的装置,其特征在于,所述数据处理器(205)在预测下一次资源调整过程中为各个所述微服务(200)分配的第二计算资源量时,被具体配置为:The apparatus according to claim 6, wherein the data processor (205) is specifically configured when predicting the second amount of computing resources allocated to each of the microservices (200) in the next resource adjustment process for:
    -设置学习速率,其中,所述学习速率越大,则计算资源的调整量越大。- Setting a learning rate, wherein the greater the learning rate, the greater the adjustment of computing resources.
  9. 如权利要求6所述的装置,所述目标应用程序(100)部署在k8s集群(30)中,所述配置收集器(201)在获取为各个所述微服务(200)分配的第一计算资源量时,被具体配置为:The apparatus according to claim 6, wherein the target application (100) is deployed in a k8s cluster (30), and the configuration collector (201) acquires the first computing allocated for each of the microservices (200). The amount of resources is specifically configured as:
    -通过k8s应用编程接口API获得各个所述微服务(200)的终点的计算资源量分别作为各个所述第一计算资源量。- Obtaining the computing resource amounts of the endpoints of each of the microservices (200) through the k8s application programming interface API as each of the first computing resource amounts.
  10. 如权利要求9所述的装置,其特征在于,所述k8s集群(30)安装了服务网格和jaeger,所述目标应用程序(100)用于处理一个请求消息,所述定时器(202)在获取各个所述微服务(200)的跟踪数据和空间数据时,被具体配置为:The apparatus according to claim 9, characterized in that the k8s cluster (30) is installed with a service mesh and jaeger, the target application (100) is used to process a request message, and the timer (202) When acquiring the tracking data and spatial data of each of the microservices (200), it is specifically configured as:
    -利用所述服务网格和所述jaeger对所述请求消息进行分布式跟踪,以获得所述跟踪数据和所述空间数据;- Distributed tracing of the request message using the service mesh and the jaeger to obtain the tracing data and the spatial data;
    其中,所述第一独立服务计算时间和所述第二独立服务计算时间为各个所述微服务(200)处理所述请求消息的计算时间。Wherein, the computing time of the first independent service and the computing time of the second independent service are the computing time for each of the microservices (200) to process the request message.
  11. 一种微服务资源分配装置(10),用于通过复数次资源调整过程为一个目标应用程序(100)中的各个微服务(200)分配计算资源,其特征在于,包括:A microservice resource allocation device (10) for allocating computing resources to each microservice (200) in a target application (100) through a plurality of resource adjustment processes, characterized in that it comprises:
    至少一个存储器(101),被配置为存储计算机可读代码;at least one memory (101) configured to store computer readable code;
    至少一个处理器(102),被配置为调用所述计算机可读代码,执行权利要求1~5中任一项所述的方法。At least one processor (102) configured to invoke the computer-readable code to perform the method of any of claims 1-5.
  12. 一种计算机可读介质,其特征在于,所述计算机可读介质上存储有计算机可读指令, 所述计算机可读指令在被处理器执行时,使所述处理器如权利要求1~5任一项所述的方法。A computer-readable medium, characterized in that, computer-readable instructions are stored on the computer-readable medium, and when the computer-readable instructions are executed by a processor, the processor can cause the processor to perform any one of claims 1 to 5. one of the methods described.
PCT/CN2021/077738 2021-02-24 2021-02-24 Microservice resource allocation method and apparatus, and computer-readable medium WO2022178730A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/077738 WO2022178730A1 (en) 2021-02-24 2021-02-24 Microservice resource allocation method and apparatus, and computer-readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/077738 WO2022178730A1 (en) 2021-02-24 2021-02-24 Microservice resource allocation method and apparatus, and computer-readable medium

Publications (1)

Publication Number Publication Date
WO2022178730A1 true WO2022178730A1 (en) 2022-09-01

Family

ID=83048607

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/077738 WO2022178730A1 (en) 2021-02-24 2021-02-24 Microservice resource allocation method and apparatus, and computer-readable medium

Country Status (1)

Country Link
WO (1) WO2022178730A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116932233A (en) * 2023-09-19 2023-10-24 金网络(北京)数字科技有限公司 Micro-service architecture of intelligent contract

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108234589A (en) * 2016-12-22 2018-06-29 瞻博网络公司 The auto zoom of micro services application
CN108664378A (en) * 2018-05-10 2018-10-16 西安电子科技大学 A kind of most short optimization method for executing the time of micro services
CN111522661A (en) * 2020-04-22 2020-08-11 腾讯科技(深圳)有限公司 Micro-service management system, deployment method and related equipment
CN111913800A (en) * 2020-07-15 2020-11-10 东北大学秦皇岛分校 Resource allocation method for optimizing cost of micro-service in cloud based on L-ACO
CN112000460A (en) * 2020-04-14 2020-11-27 华为技术有限公司 Service capacity expansion method based on improved Bayesian algorithm and related equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108234589A (en) * 2016-12-22 2018-06-29 瞻博网络公司 The auto zoom of micro services application
CN108664378A (en) * 2018-05-10 2018-10-16 西安电子科技大学 A kind of most short optimization method for executing the time of micro services
CN112000460A (en) * 2020-04-14 2020-11-27 华为技术有限公司 Service capacity expansion method based on improved Bayesian algorithm and related equipment
CN111522661A (en) * 2020-04-22 2020-08-11 腾讯科技(深圳)有限公司 Micro-service management system, deployment method and related equipment
CN111913800A (en) * 2020-07-15 2020-11-10 东北大学秦皇岛分校 Resource allocation method for optimizing cost of micro-service in cloud based on L-ACO

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116932233A (en) * 2023-09-19 2023-10-24 金网络(北京)数字科技有限公司 Micro-service architecture of intelligent contract
CN116932233B (en) * 2023-09-19 2023-12-08 金网络(北京)数字科技有限公司 Micro-service architecture of intelligent contract

Similar Documents

Publication Publication Date Title
EP3637733B1 (en) Load balancing engine, client, distributed computing system, and load balancing method
US10904319B2 (en) Dynamic deployment of an application based on micro-services
US9843485B2 (en) Monitoring dynamic networks
US10841241B2 (en) Intelligent placement within a data center
US10412023B2 (en) Resource allocation method under heterogeneous network under intermediate processing constraints
WO2017045472A1 (en) Resource prediction method and system, and capacity management apparatus
WO2018176385A1 (en) System and method for network slicing for service-oriented networks
CN105743962A (en) End-to-end datacenter performance control
US11509601B2 (en) Intent-based orchestration using network parsimony trees
US20170286861A1 (en) Structured machine learning framework
CN109189572B (en) Resource estimation method and system, electronic equipment and storage medium
CN116980139A (en) Techniques for accelerated orchestration and attestation of edge device trust chains
KR20180028004A (en) Method and apparatus for analyzing and processing data stream in environment where worker nodes are distributed, and method and apparatus for managing task
US20150134799A1 (en) Path selection for network service requests
CN115914392A (en) Computing power network resource scheduling method and system
US20230136612A1 (en) Optimizing concurrent execution using networked processing units
WO2022178730A1 (en) Microservice resource allocation method and apparatus, and computer-readable medium
Ahvar et al. NACER: a Network-Aware Cost-Efficient Resource allocation method for processing-intensive tasks in distributed clouds
KR101702218B1 (en) Method and System for Allocation of Resource and Reverse Auction Resource Allocation in hybrid Cloud Server
WO2021000694A1 (en) Method for deploying services and scheduling apparatus
EP2565788B1 (en) Method and apparatus for selecting optimum computing resources
CN115658287A (en) Method, apparatus, medium, and program product for scheduling execution units
US10616374B2 (en) Client attachment to an overlay network
CN117201319B (en) Micro-service deployment method and system based on edge calculation
JP2005122616A (en) Network-type grid computing system

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21927174

Country of ref document: EP

Kind code of ref document: A1