TWI676374B - Server and method for assigning job for microservices thereof - Google Patents

Server and method for assigning job for microservices thereof Download PDF

Info

Publication number
TWI676374B
TWI676374B TW107131774A TW107131774A TWI676374B TW I676374 B TWI676374 B TW I676374B TW 107131774 A TW107131774 A TW 107131774A TW 107131774 A TW107131774 A TW 107131774A TW I676374 B TWI676374 B TW I676374B
Authority
TW
Taiwan
Prior art keywords
microservice
global
microservices
lock
service request
Prior art date
Application number
TW107131774A
Other languages
Chinese (zh)
Other versions
TW202011717A (en
Inventor
辛永森
Yung-Sen Hsin
劉哲育
Jhe-Yu Liou
Original Assignee
中華電信股份有限公司
Chunghwa Telecom 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 中華電信股份有限公司, Chunghwa Telecom Co., Ltd. filed Critical 中華電信股份有限公司
Priority to TW107131774A priority Critical patent/TWI676374B/en
Application granted granted Critical
Publication of TWI676374B publication Critical patent/TWI676374B/en
Publication of TW202011717A publication Critical patent/TW202011717A/en

Links

Abstract

本發明提供一種伺服器及其對微服務安排工作的方法。所述方法包括:取得服務請求;從多個微服務中挑選第一微服務,其中第一微服務包括多個處理程序;將服務請求指派予前述處理程序中的第一處理程序;對第一微服務施加第一全域鎖,以及對第一處理程序施加第一區域鎖,其中第一全域鎖的第一全域鎖定時間相同於第一區域鎖的第一區域鎖定時間,前述微服務中的第二微服務因應於第一全域鎖而停止要求處理服務請求,而前述處理程序中的第二處理程序因應於第一區域鎖而停止要求處理服務請求。The invention provides a server and a method for arranging work for a microservice. The method includes: obtaining a service request; selecting a first microservice from a plurality of microservices, wherein the first microservice includes a plurality of processing programs; assigning a service request to a first processing program of the foregoing processing programs; The microservice applies a first global lock and applies a first region lock to a first processing program. The first global lock time of the first global lock is the same as the first region lock time of the first regional lock. The second micro service stopped requesting to process the service request because of the first global lock, and the second processing program in the foregoing processing program stopped requesting to process the service request because of the first zone lock.

Description

伺服器及其對微服務安排工作的方法Server and method for arranging work for microservices

本發明是有關於一種伺服器及其對微服務安排工作的方法,且特別是有關於一種基於微服務的全域鎖及區域鎖對微服務安排工作的方法及伺服器。The invention relates to a server and a method for arranging work for microservices, and in particular, to a method and a server for arranging work for microservices based on global locks and area locks of microservices.

微服務(Microservices)是一種軟體架構風格,它是以專注於單一責任與功能的小型功能區塊(Small Building Blocks)為基礎,利用模組化的方式組合出複雜的大型應用程式,各功能區塊使用與語言無關(Language-Independent/Language agnostic)的 API 集相互通訊。Microservices is a software architecture style. It is based on small building blocks that focus on a single responsibility and function. It uses a modular approach to compose complex large-scale applications. Each functional area Blocks communicate with each other using a language-independent / language agnostic API set.

然而,在雲端系統開始導入微服務架構及採用無狀態(Stateless)方式進行設計後,將可能會遇到微服務擴展及同質微服務間可用性的問題。並且,由於微服務還包括主動/主動(Active/Active)和主動/待命(Active/Standby)等兩種可用性模式,因此,如何經由適當的設計來讓微服務的整體處理效能、可用性和服務品質能夠提升,實為本領域技術人員關注的重要議題。However, after the cloud system begins to introduce the microservice architecture and design in a stateless manner, it may encounter problems with microservice expansion and availability between homogeneous microservices. And, since microservices also include two availability modes, Active / Active and Active / Standby, how to make the overall processing performance, availability, and service quality of microservices through proper design Being able to improve is indeed an important issue of concern to those skilled in the art.

有鑑於此,本發明提供一種對微服務安排工作的方法,其可用於提高微服務系統的可用性及性能。In view of this, the present invention provides a method for arranging work for a microservice, which can be used to improve the availability and performance of a microservice system.

本發明提供一種對微服務安排工作的方法,包括:取得一服務請求;從多個微服務中挑選一第一微服務,其中第一微服務包括多個處理程序;將服務請求指派予前述處理程序中的一第一處理程序;對第一微服務施加一第一全域鎖,以及對第一處理程序施加一第一區域鎖,其中第一全域鎖的一第一全域鎖定時間相同於第一區域鎖的一第一區域鎖定時間,前述微服務中的一第二微服務因應於第一全域鎖而停止要求處理服務請求,而前述處理程序中的一第二處理程序因應於第一區域鎖而停止要求處理服務請求。The invention provides a method for arranging work for a microservice, including: obtaining a service request; selecting a first microservice from a plurality of microservices, wherein the first microservice includes a plurality of processing programs; and assigning a service request to the aforementioned processing A first processing program in the program; applying a first global lock to the first microservice, and applying a first region lock to the first processing program, wherein a first global lock time of the first global lock is the same as the first A first area lock time of the area lock, a second micro service in the foregoing micro service stops requesting to process a service request due to the first global lock, and a second processing program in the foregoing processing program corresponds to the first area lock And stop asking to process service requests.

基於上述,本發明提出的伺服器及其對微服務安排工作的方法可在挑選用於處理服務請求的第一微服務之後,透過全域鎖將此服務請求鎖定於第一微服務,以及透過區域鎖來將此服務請求鎖定於第一微服務中的第一處理程序。藉此,可避免其他的微服務及處理程序耗費多餘的時間在重複發出處理服務請求的請求,進而能夠改善微服務系統架構的工作效能。Based on the above, the server and method for arranging work of the microservice provided by the present invention can lock the service request to the first microservice through global lock after selecting the first microservice for processing the service request, and through the area Lock to lock this service request to the first handler in the first microservice. In this way, other microservices and processing programs can be prevented from spending extra time in repeatedly sending requests for processing service requests, thereby improving the working efficiency of the microservice system architecture.

為讓本發明的上述特徵和優點能更明顯易懂,下文特舉實施例,並配合所附圖式作詳細說明如下。In order to make the above features and advantages of the present invention more comprehensible, embodiments are hereinafter described in detail with reference to the accompanying drawings.

請參照圖1及圖2,其中圖1是依據本發明之一實施例繪示的伺服器功能方塊圖,圖2是依據圖1繪示的微服務系統架構圖。在圖1中,伺服器100包括儲存電路102及處理器104。儲存電路102例如是記憶體、硬碟或是其他任何可用於儲存資料的元件,而可用以記錄多個程式碼或模組。處理器104耦接於儲存電路102,並可為一般用途處理器、特殊用途處理器、傳統的處理器、數位訊號處理器、多個微處理器(microprocessor)、一個或多個結合數位訊號處理器核心的微處理器、控制器、微控制器、特殊應用集成電路(Application Specific Integrated Circuit,ASIC)、場可程式閘陣列電路(Field Programmable Gate Array,FPGA)、任何其他種類的積體電路、狀態機、基於進階精簡指令集機器(Advanced RISC Machine,ARM)的處理器以及類似品。Please refer to FIG. 1 and FIG. 2, where FIG. 1 is a functional block diagram of a server according to an embodiment of the present invention, and FIG. 2 is a microservice system architecture diagram according to FIG. 1. In FIG. 1, the server 100 includes a storage circuit 102 and a processor 104. The storage circuit 102 is, for example, a memory, a hard disk, or any other component that can be used to store data, and can be used to record multiple codes or modules. The processor 104 is coupled to the storage circuit 102 and may be a general-purpose processor, a special-purpose processor, a conventional processor, a digital signal processor, a plurality of microprocessors, and one or more integrated digital signal processors. Microprocessor core, controller, microcontroller, Application Specific Integrated Circuit (ASIC), Field Programmable Gate Array (FPGA), any other kind of integrated circuit, State machines, processors based on Advanced Reduced Instruction Set (ARM) machines, and the like.

本實施例的伺服器100可用於建構如圖2所示的微服務系統架構200,其包括請求佇列210、微服務管理端220、微服務231、232、233、…、23n。在一實施例中,處理器104可在伺服器100上建立多個虛擬機器(virtual machine,VM),並以其中一個作為微服務管理端220,而其餘的VM則作為微服務231~23n,但本發明可不限於此。The server 100 of this embodiment may be used to construct a microservice system architecture 200 as shown in FIG. 2, which includes a request queue 210, a microservice management terminal 220, and a microservice 231, 232, 233,..., 23n. In one embodiment, the processor 104 may establish multiple virtual machines (VMs) on the server 100, and use one of them as the microservice management end 220, and the remaining VMs as the microservices 231 ~ 23n. However, the present invention is not limited to this.

如圖2所示,當接收到來自使用者所發出的服務請求RQ時,處理器104可相應地將服務請求RQ儲存至請求佇列210。在一實施例中,服務請求RQ例如是建置新的VM的請求,但可不限於此。請求佇列210可以是一堆疊結構,其可用於序列地儲存來自一或多個使用者的不同服務請求。As shown in FIG. 2, when receiving a service request RQ from a user, the processor 104 may store the service request RQ in the request queue 210 accordingly. In an embodiment, the service request RQ is, for example, a request to build a new VM, but it is not limited thereto. The request queue 210 may be a stacked structure that can be used to serially store different service requests from one or more users.

在一實施例中,處理器104可透過微服務管理端220來將上述服務請求分配予微服務231~23n,以讓各微服務231~23n中的處理程序協助完成上述服務請求對應的工作,以下將輔以圖3作進一步說明。In an embodiment, the processor 104 may allocate the service request to the microservices 231 to 23n through the microservice management terminal 220, so that the processing programs in the microservices 231 to 23n assist in completing the work corresponding to the service request. The following will be supplemented by FIG. 3 for further explanation.

請參照圖3,其是依據圖2繪示的對微服務安排工作的方法流程圖。本實施例的方法可由圖2所示的架構執行,以下即搭配圖2的元件來說明本方法的步驟細節。Please refer to FIG. 3, which is a flowchart of a method for arranging work for a microservice according to FIG. 2. The method of this embodiment may be executed by the architecture shown in FIG. 2. The details of the steps of the method are described below with reference to the elements of FIG. 2.

首先,微服務管理端220可取得服務請求RQ1。應了解的是,雖圖2中的微服務管理端220係從請求佇列210取得服務請求RQ1,但在其他實施例中,微服務管理端220亦可直接從使用者取得服務請RQ1,但本發明可不限於此。First, the micro service management terminal 220 can obtain the service request RQ1. It should be understood that although the microservice management terminal 220 in FIG. 2 obtains the service request RQ1 from the request queue 210, in other embodiments, the microservice management terminal 220 may also obtain the service directly from the user and request RQ1, but The present invention may not be limited to this.

在步驟S220中,微服務管理端220可從多個微服務231~23n中挑選第一微服務,其中所述第一微服務例如是一閒置微服務,亦即未被分配工作的微服務。在不同的實施例中,微服務管理端220挑選第一微服務的方式可依微服務系統架構運作的模式而有所不同,如下所示。In step S220, the microservice management terminal 220 may select a first microservice from a plurality of microservices 231 to 23n, where the first microservice is, for example, an idle microservice, that is, a microservice to which no work is assigned. In different embodiments, the manner in which the microservice management terminal 220 selects the first microservice may vary according to the mode in which the microservice system architecture operates, as shown below.

請參照圖4A,其是依據本發明之一實施例繪示的在主動/主動模式下挑選第一微服務的示意圖。在圖4A中,微服務系統架構200係假設為運作於主動/主動模式,且微服務管理端220用於管理6個微服務231~236。在主動/主動模式下,微服務管理端200可將微服務231~236區分為多個群組GP1、GP2及GP3。在本實施例中,微服務管理端220可先依據各微服務231~236的全域可用性分數來將微服務231~236降冪排序,再將排序後的微服務231~236區分為預設數量個群組。各微服務231~236的全域可用性分數的相關計算機制將在之後的篇幅中詳述。Please refer to FIG. 4A, which is a schematic diagram of selecting a first microservice in an active / active mode according to an embodiment of the present invention. In FIG. 4A, the microservice system architecture 200 is assumed to operate in an active / active mode, and the microservice management terminal 220 is used to manage six microservices 231-236. In the active / active mode, the microservice management end 200 can divide the microservices 231 to 236 into multiple groups GP1, GP2, and GP3. In this embodiment, the microservice management end 220 may first sort the microservices 231-236 according to the global availability score of each microservice 231-236, and then sort the sorted microservices 231-236 into a preset number. Groups. The relevant computer system for the global availability scores of each microservice 231 ~ 236 will be detailed in the following pages.

為便於說明,在圖4A中係假設微服務231~236的全域可用性分數係由高至低,而上述預設數量為3,因此群組GP1、GP2及GP3所包括的微服務分別如圖4A所示,但其並非用以限定本發明可能的實施方式。基於以上假設可知,群組GP1中的微服務231及232的全域可用性分數皆高於群組GP2中的微服務233及234的全域可用性分數,而群組GP2中的微服務233及234的全域可用性分數皆高於群組GP3中的微服務235及236的全域可用性分數。相應地,微服務管理端220可分別設定群組GP1~GP3的優先權為高、中、低,並在挑選用於處理服務請求RQ1的第一微服務時依各群組GP1~GP3的優先權進行挑選。For ease of illustration, in FIG. 4A, it is assumed that the global availability scores of microservices 231 to 236 are from high to low, and the preset number is 3, so the microservices included in groups GP1, GP2, and GP3 are shown in Figure 4A. It is shown, but it is not intended to limit the possible embodiments of the present invention. Based on the above assumptions, the global availability scores of microservices 231 and 232 in group GP1 are higher than the global availability scores of microservices 233 and 234 in group GP2, and the global availability of microservices 233 and 234 in group GP2 The availability scores are higher than the global availability scores of microservices 235 and 236 in group GP3. Correspondingly, the micro service management terminal 220 can set the priorities of the groups GP1 to GP3 as high, medium, and low respectively, and select the first micro service for processing the service request RQ1 according to the priorities of the groups GP1 to GP3. Right to pick.

由於微服務231位於群組GP1中,且具有最高的全域可用性分數,因此微服務管理端220可挑選微服務231作為用於處理服務請求RQ1的微服務(即,第一微服務)。Since the microservice 231 is located in the group GP1 and has the highest global availability score, the microservice management end 220 can select the microservice 231 as the microservice (ie, the first microservice) for processing the service request RQ1.

請參照圖4B,其是依據本發明之一實施例繪示的在主動/待命模式下挑選第一微服務的示意圖。與圖4A不同之處在於,圖4B中的微服務系統架構200係假設為運作於主動/待命模式。在主動/待命模式下,微服務管理端200可將微服務231~236可先依據各微服務231~236的全域可用性分數來將微服務231~236降冪排序,再將排序後的微服務231~236區分為主(master)群組GP1’及僕(slave)群組GP2’。在本實施例中,假設微服務231及232被分配至主群組GP1’,而微服務233~236被分配至僕群組GP2’。在此情況下,當微服務管理端200欲挑選用於處理服務請求RQ1的第一微服務時,微服務管理端200僅會在主群組GP1’中以輪替(round robin)的原則進行挑選。並且,即便主群組GP1’中的微服務231及232皆已被用於處理其他的服務請求,微服務管理端220仍不會挑選僕群組GP2’中的微服務234~236來處理服務請求RQ1。Please refer to FIG. 4B, which is a schematic diagram of selecting a first microservice in an active / standby mode according to an embodiment of the present invention. The difference from FIG. 4A is that the microservice system architecture 200 in FIG. 4B is assumed to operate in an active / standby mode. In the active / standby mode, the microservice management terminal 200 can first sort the microservices 231-236 according to the global availability scores of each microservice 231-236, and then sort the microservices 231-236, and then sort the sorted microservices. 231 ~ 236 are divided into a master group GP1 'and a slave group GP2'. In this embodiment, it is assumed that microservices 231 and 232 are allocated to the main group GP1 ', and microservices 233 to 236 are allocated to the slave group GP2'. In this case, when the micro service management terminal 200 wants to select the first micro service for processing the service request RQ1, the micro service management terminal 200 will only perform the round robin principle in the main group GP1 '. Pick. In addition, even if the microservices 231 and 232 in the main group GP1 'have been used to process other service requests, the microservice management terminal 220 will still not select the microservices 234 ~ 236 in the slave group GP2' to process services. Request RQ1.

在圖4B中,由於微服務231位於主群組GP1’中,因此微服務管理端220可挑選微服務231作為用於處理服務請求RQ1的微服務(即,第一微服務)。In FIG. 4B, since the microservice 231 is located in the main group GP1 ', the microservice management terminal 220 can select the microservice 231 as the microservice (ie, the first microservice) for processing the service request RQ1.

請再次參照圖3,在進行步驟S320以挑選第一微服務之後,微服務管理端220可將服務請求RQ1指派予第一微服務中的第一處理程序。Please refer to FIG. 3 again. After step S320 is performed to select the first microservice, the microservice management terminal 220 may assign the service request RQ1 to the first processing program in the first microservice.

並且,在步驟S330中,可對第一微服務施加第一全域鎖,以及對第一處理程序施加第一區域鎖,其中第一全域鎖的第一全域鎖定時間相同於第一區域鎖的第一區域鎖定時間。並且,微服務231~236中的第二微服務將因應於第一全域鎖而停止要求處理服務請求RQ1,而第一微服務中的第二處理程序也將因應於第一區域鎖而停止要求處理服務請求RQ1。Moreover, in step S330, a first global lock may be applied to the first microservice, and a first region lock may be applied to the first processing program. The first global lock time of the first global lock is the same as that of the first region lock. A zone lock time. In addition, the second microservice in microservices 231 to 236 will stop requesting to process the service request RQ1 due to the first global lock, and the second processing program in the first microservice will also stop requesting due to the first regional lock. Process service request RQ1.

在一實施例中,微服務管理端220可將第一全域鎖及第一全域鎖定時間的相關資訊記錄在微服務管理端220維護的一全域鎖資料表中。相似地,第一微服務亦可將第一區域鎖及第一區域鎖定時間的相關資訊記錄在第一微服務維護的區域鎖快取表中。為使以上概念更為清楚,以下另搭配圖5作進一步說明。In one embodiment, the micro service management terminal 220 may record the related information of the first global lock and the first global lock time in a global lock data table maintained by the micro service management terminal 220. Similarly, the first microservice may also record information about the first region lock and the first region lock time in the region lock cache table maintained by the first microservice. In order to make the above concepts clearer, a further description is given below with reference to FIG. 5.

請參照圖5,其是依據本發明之一實施例繪示的為微服務分配工作的示意圖。在本實施例中,假設微服務231被挑選用於處理服務請求RQ1。相應地,微服務管理端220可對用於處理服務請求RQ1的微服務231施加全域鎖GL1,並將微服務231與服務請求RQ1的對應關係,以及全域鎖GL1的全域鎖定時間GT1記錄在微服務管理端220維護的全域鎖資料表220a中。Please refer to FIG. 5, which is a schematic diagram of allocating work for microservices according to an embodiment of the present invention. In this embodiment, it is assumed that the microservice 231 is selected for processing the service request RQ1. Correspondingly, the microservice management end 220 may apply a global lock GL1 to the microservice 231 for processing the service request RQ1, and record the correspondence between the microservice 231 and the service request RQ1, and the global lock time GT1 of the global lock GL1 in the micro The global lock data table 220a maintained by the service management terminal 220.

在微服務231得知其被指派用於處理服務請求RQ1之後,微服務231可指派其所包括的多個處理程序中的處理程序231a(例如,執行緒)來處理服務請求RQ1。相應地,微服務231可對處理程序231a施加區域鎖LL1,並將處理程序231a與服務請求RQ1的對應關係,以及區域鎖LL1的區域鎖定時間LT1記錄在微服務231維護的區域鎖資料表231b中。After the microservice 231 learns that it is assigned to process the service request RQ1, the microservice 231 may assign a handler 231a (eg, a thread) among a plurality of handlers included in it to process the service request RQ1. Correspondingly, the microservice 231 may apply the area lock LL1 to the processing program 231a, and record the correspondence between the processing program 231a and the service request RQ1, and the area lock time LT1 of the area lock LL1 in the area lock information table 231b maintained by the microservice 231. in.

此外,亦假設微服務232被挑選用於處理服務請求RQ2。相應地,微服務管理端220可對用於處理服務請求RQ2的微服務232施加全域鎖GL2,並將微服務232與服務請求RQ2的對應關係,以及全域鎖GL2的全域鎖定時間GT2記錄在微服務管理端220維護的全域鎖資料表220a中。In addition, it is also assumed that the microservice 232 is selected to process the service request RQ2. Correspondingly, the microservice management terminal 220 may apply the global lock GL2 to the microservice 232 for processing the service request RQ2, and record the correspondence between the microservice 232 and the service request RQ2, and the global lock time GT2 of the global lock GL2 in the micro The global lock data table 220a maintained by the service management terminal 220.

在微服務232得知其被指派用於處理服務請求RQ2之後,微服務232可指派其所包括的多個處理程序中的處理程序232a(例如,執行緒)來處理服務請求RQ2。相應地,微服務232可對處理程序232a施加區域鎖LL2,並將處理程序232a與服務請求RQ2的對應關係,以及區域鎖LL2的區域鎖定時間LT2記錄在微服務232維護的區域鎖資料表232b中。After the microservice 232 learns that it is assigned to process the service request RQ2, the microservice 232 may assign a handler 232a (eg, a thread) of a plurality of handlers included in it to process the service request RQ2. Accordingly, the microservice 232 can apply the area lock LL2 to the processing program 232a, and record the correspondence between the processing program 232a and the service request RQ2, and the area lock time LT2 of the area lock LL2 in the area lock data table 232b maintained by the microservice 232. in.

基於全域鎖資料表220a所記錄的內容,微服務管理端220所管理的其他微服務(例如微服務233~236)即可得知服務請求RQ1及RQ2已分別鎖定於微服務231及232,因此不會再重複地向微服務管理端220提出處理服務請求RQ1或RQ2的請求。藉此,可提升微服務系統架構200的工作效能。Based on the content recorded in the global lock data table 220a, other microservices managed by the microservice management terminal 220 (for example, microservices 233 to 236) can learn that service requests RQ1 and RQ2 have been locked to microservices 231 and 232, respectively. The request for processing the service request RQ1 or RQ2 will not be repeatedly submitted to the microservice management end 220. Thereby, the working efficiency of the microservice system architecture 200 can be improved.

同時,基於區域鎖資料表231b所記錄的內容,微服務231中的其他處理程序即可得知服務請求RQ1已鎖定於處理程序231a,因此不會再重複地提出處理服務請求RQ1的請求。同理,基於區域鎖資料表232b所記錄的內容,微服務232中的其他處理程序即可得知服務請求RQ2已鎖定於處理程序232a,因此不會再重複地提出處理服務請求RQ2的請求。藉此,可提升微服務231及232的工作效能。At the same time, based on the content recorded in the area lock data table 231b, other processing programs in the microservice 231 can know that the service request RQ1 has been locked to the processing program 231a, so the request for processing the service request RQ1 will not be repeated. Similarly, based on the content recorded in the area lock data table 232b, other processing programs in the microservice 232 can know that the service request RQ2 has been locked to the processing program 232a, so the request for processing the service request RQ2 will not be repeated. This can improve the working efficiency of microservices 231 and 232.

由上可知,本發明提出的伺服器及其對微服務安排工作的方法可在挑選用於處理服務請求的第一微服務(其需為未被全域鎖鎖定的微服務)之後,透過全域鎖將此服務請求鎖定於第一微服務,以及透過區域鎖來將此服務請求鎖定於第一微服務中的第一處理程序。藉此,可避免其他的微服務及處理程序耗費多餘的時間在重複發出處理服務請求的請求,進而能夠改善微服務系統架構的工作效能。It can be known from the above that the server and the method for arranging work of the microservice provided by the present invention can select the first microservice (which needs to be a microservice that is not locked by the global lock) for processing the service request, and then use the global lock The service request is locked to the first microservice, and the service request is locked to the first handler in the first microservice through an area lock. In this way, other microservices and processing programs can be prevented from spending extra time in repeatedly sending requests for processing service requests, thereby improving the working efficiency of the microservice system architecture.

在一實施例中,處理器104可採用docker技術來實現微服務系統架構200,並使用spring boot開發且提供網頁服務。微服務管理端220可基於Eureka來實現對於微服務231~23n的工作分配,而請求佇列210可由微服務231~23n搭配Redis來實現,並由定期排程(schedule thread)來實現非同步的工作處理。另外,微服務管理端220可由Redisson來實現Semaphore鎖機制,以實現對於第一微服務施加的第一全域鎖。並且。第一微服務則可利用concurrent hash map並搭配有效時間戳記來實現第一區域鎖。由微服務管理端220維護的全域鎖資料表則可由建立mongodb來實現。In one embodiment, the processor 104 may use docker technology to implement the microservice system architecture 200, and use spring boot to develop and provide web services. The microservice management terminal 220 can implement the work distribution for microservices 231 ~ 23n based on Eureka, and the request queue 210 can be implemented by microservices 231 ~ 23n combined with Redis, and is realized asynchronously by a schedule thread. Work processing. In addition, the microservice management end 220 may implement a Semaphore lock mechanism by Redisson to implement the first global lock applied to the first microservice. and. The first microservice may use a concurrent hash map and a valid time stamp to implement the first region lock. The global lock data table maintained by the microservice management terminal 220 can be implemented by setting up mongodb.

在圖5實施例中,若微服務231無法在全域鎖定時間GL1或區域鎖定時間LL1完成服務請求RQ1,微服務管理端220可減少微服務231的全域可用性分數,並將未完成的服務請求RQ1排入請求佇列210。藉此,可讓服務請求RQ1未來仍能有機會再被其他的微服務處理到,進而完成使用者所要求的工作。In the embodiment of FIG. 5, if the microservice 231 cannot complete the service request RQ1 at the global lock time GL1 or the regional lock time LL1, the microservice management terminal 220 may reduce the global service score of the microservice 231 and send the outstanding service request RQ1 Queued to request queue 210. In this way, the service request RQ1 can still have the opportunity to be processed by other microservices in the future, and then complete the work required by the user.

此外,在圖5實施例中,在微服務管理端220將未完成的服務請求RQ1排入請求佇列210中時,微服務管理端220還可記錄微服務231對於服務請求RQ1的處理進度。之後,當服務請求RQ1再次被指派予另一微服務處理時,所述另一微服務即可依據服務請求RQ1的處理進度接續處理服務請求RQ1。藉此,可加速處理服務請求RQ1的速度,進而以更佳的效率完成使用者所要求的工作。In addition, in the embodiment of FIG. 5, when the microservice management terminal 220 ranks the outstanding service request RQ1 into the request queue 210, the microservice management terminal 220 may also record the processing progress of the microservice 231 for the service request RQ1. After that, when the service request RQ1 is again assigned to another microservice for processing, the another microservice can continue to process the service request RQ1 according to the processing progress of the service request RQ1. This can speed up the processing of the service request RQ1, and then complete the work required by the user with better efficiency.

在圖5實施例中,若微服務231在區域鎖定時間LT1逾時之前完成服務請求RQ1,則微服務231可解除區域鎖LL1,並回報服務請求RQ1的處理結果至微服務管理端220。相應地,微服務管理端220可因應於微服務231回報的服務請求RQ1的處理結果而解除全域鎖GL1。藉此,可令微服務231能夠再次地被挑選用於處理其他的服務請求,以較佳地利用微服務系統架構200的資源。In the embodiment of FIG. 5, if the microservice 231 completes the service request RQ1 before the area lock time LT1 expires, the microservice 231 may release the area lock LL1 and report the processing result of the service request RQ1 to the microservice management end 220. Correspondingly, the microservice management terminal 220 may release the global lock GL1 according to the processing result of the service request RQ1 returned by the microservice 231. Thereby, the micro service 231 can be selected again for processing other service requests, so as to better utilize the resources of the micro service system architecture 200.

承先前實施例中所提及的,各微服務231~236皆具有一全域可用性分數,以下將輔以圖6A及圖6B說明各微服務231~236的全域可用性分數的計算機制。As mentioned in the previous embodiment, each of the microservices 231 to 236 has a global availability score. The computer system of the global availability scores of each of the microservices 231 to 236 will be described below with reference to FIGS. 6A and 6B.

請參照圖6A及圖6B,其中圖6A是依據本發明之一實施例繪示的調整區域可用性分數的示意圖,圖6B是依據圖6A繪示的調整全域可用性分數的示意圖。為便於說明,在本實施例中將僅圖5的微服務231及232作為實例,但本發明的方法亦可適用於其他的微服務(例如圖5的微服務233~236)。Please refer to FIG. 6A and FIG. 6B, wherein FIG. 6A is a schematic diagram of adjusting a regional availability score according to an embodiment of the present invention, and FIG. 6B is a schematic diagram of adjusting a global availability score according to FIG. 6A. For convenience of explanation, only microservices 231 and 232 of FIG. 5 are taken as examples in this embodiment, but the method of the present invention can also be applied to other microservices (for example, microservices 233 to 236 of FIG. 5).

在圖6A中,微服務管理端220可向微服務231及232發送詢問信號QS。在本實施例中,微服務管理端220可在詢問信號QS(其例如是以HTTP/HTTPS服務請求信號實現的心跳(heartbeat)信號)中加上發送時間戳記,以指示詢問信號QS是在哪個時間點被發送。In FIG. 6A, the microservice management terminal 220 may send an inquiry signal QS to the microservices 231 and 232. In this embodiment, the microservice management end 220 may add a sending timestamp to the query signal QS (which is, for example, a heartbeat signal implemented by an HTTP / HTTPS service request signal), to indicate where the query signal QS is. The point in time is sent.

在微服務231接收到詢問信號QS之後,可回傳另一個HTTP/HTTPS服務請求信號,其可帶有回傳時間戳記。並且,在微服務231回傳上述另一個HTTP/HTTPS服務請求信號時,可計算對於詢問信號QS的處理時間(例如圖6A所示的10ms),其中所述處理時間例如可藉由以回傳時間戳記減去發送時間戳記來計算,但可不限於此。相似地,微服務232亦可基於以上教示而計算出微服務232對於詢問信號QS的處理時間(例如圖6A所示的66ms)。After the microservice 231 receives the query signal QS, it may return another HTTP / HTTPS service request signal, which may carry a return time stamp. In addition, when the microservice 231 returns the above-mentioned another HTTP / HTTPS service request signal, a processing time (for example, 10ms shown in FIG. 6A) for the inquiry signal QS may be calculated, where the processing time may be returned by, for example, The time stamp is calculated by subtracting the transmission time stamp, but it is not limited thereto. Similarly, the microservice 232 can also calculate the processing time of the microservice 232 for the query signal QS (for example, 66ms shown in FIG. 6A) based on the above teaching.

在不同的實施例中,微服務231及232可依據各自的處理時間來更新區域可用性分數。以圖6A為例,由於微服務231的處理時間(即,10ms)未超過預設時間(例如20ms),因此微服務231可增加微服務231的區域可用性分數(例如,加10分)。增加後的微服務231的區域可用性分數例如是56分,但可不限於此。在一實施例中,圖6A例示的56分可以是微服務231在接收多個詢問信號之後,依據這些詢問信號對應的多個處理時間而累計而得的分數。In different embodiments, the microservices 231 and 232 may update the regional availability scores according to their respective processing times. Taking FIG. 6A as an example, since the processing time (ie, 10 ms) of the micro service 231 does not exceed a preset time (for example, 20 ms), the micro service 231 can increase the regional availability score of the micro service 231 (for example, add 10 points). The area availability score of the increased microservice 231 is, for example, 56 points, but it is not limited thereto. In an embodiment, the 56 points illustrated in FIG. 6A may be points that the microservice 231 accumulates after receiving a plurality of query signals according to a plurality of processing times corresponding to the query signals.

另一方面,由於微服務232的處理時間(即,66ms)超過預設時間(例如20ms),因此微服務232可減少微服務232的區域可用性分數(例如,減5分)。減少後的微服務232的區域可用性分數例如是80分,但可不限於此。在一實施例中,圖6A例示的80分可以是微服務232在接收多個詢問信號之後,依據這些詢問信號對應的多個處理時間而累計而得的分數。On the other hand, since the processing time (ie, 66 ms) of the micro service 232 exceeds a preset time (eg, 20 ms), the micro service 232 may reduce the regional availability score (eg, minus 5 points) of the micro service 232. The area availability score of the reduced microservice 232 is, for example, 80 points, but it is not limited thereto. In an embodiment, the 80 points illustrated in FIG. 6A may be points that the microservice 232 accumulates after receiving multiple query signals according to multiple processing times corresponding to the query signals.

在其他實施例中,設計者亦可依需求而採用其他的機制來增加或減少微服務231及231的區域可用性分數,並不限於以上教示所記載的機制。In other embodiments, the designer may also use other mechanisms to increase or decrease the regional availability scores of the microservices 231 and 231 according to requirements, and is not limited to the mechanism described in the above teaching.

之後,微服務管理端220可要求微服務231回傳其區域可用性分數與區域預設分數之間的差值,並據以調整微服務231的全域可用性分數,以下輔以圖6B進行詳細說明。After that, the microservice management terminal 220 may request the microservice 231 to return the difference between its regional availability score and the regional preset score, and adjust the global availability score of the microservice 231 accordingly, which will be described in detail below with reference to FIG. 6B.

在圖6B中,微服務管理端220可將微服務231的全域可用性分數記錄在微服務管理端220維護的全域可用性分數資料表220b中。如圖6B所示,微服務管理端220可要求微服務231回傳區域可用性分數(即,56分)與區域預設分數(即,300分)之間的差值(即,-244分)。接著,假設微服務231原始的全域可用性分數為圖6B所示的700分,則微服務管理端220可以全域可用性分數與差值的總和作為更新的全域可用性分數(即,700分-244分=456分)。相應地,微服務231可將自己的區域可用性分數從56分回補至區域預設分數(即,300分),用以作為後續依據上述處理時間調整區域可用性分數的額度。藉此,可令微服務管理端220更易於掌控微服務231的全域可用性分數。In FIG. 6B, the microservice management terminal 220 may record the global availability score of the microservice 231 in the global availability score data table 220b maintained by the microservice management terminal 220. As shown in FIG. 6B, the microservice management terminal 220 may request the microservice 231 to return the difference between the regional availability score (ie, 56 points) and the regional preset score (ie, 300 points) (ie, -244 points). . Next, assuming that the original global availability score of the microservice 231 is 700 points shown in FIG. 6B, the microservice management terminal 220 can use the sum of the global availability score and the difference value as the updated global availability score (ie, 700 points-244 points = 456 points). Correspondingly, the micro service 231 may supplement its own regional availability score from 56 points to the regional preset score (ie, 300 points), which is used as a subsequent adjustment of the amount of the regional availability score according to the above processing time. With this, the microservice management terminal 220 can more easily control the global availability score of the microservice 231.

在一實施例中,在微服務231將其區域可用性分數回補至300分之後,可作為對微服務管理端220後續發送的其他詢問信號增減全域可用性分數的基礎。藉此,可達到分散式管理之效果。In an embodiment, after the microservice 231 returns its regional availability score to 300 points, it can be used as a basis for adding or subtracting the global availability score to other query signals subsequently sent by the microservice management terminal 220. This can achieve the effect of decentralized management.

在另一實施例中,若微服務管理端220未在一預設時間內接收到微服務231回傳的上述差值,即代表微服務231的工作效能可能極為不佳,因此微服務管理端220可直接將微服務231的全域可用性分數減去一預設分數(例如,600分),以表徵微服務231的低工作效能。In another embodiment, if the microservice management terminal 220 does not receive the above-mentioned difference value returned by the microservice 231 within a preset time, it means that the performance of the microservice 231 may be extremely poor, so the microservice management terminal 220 may directly subtract a global score of the microservice 231 from a preset score (for example, 600 points) to characterize the low working efficiency of the microservice 231.

此外,本發明實施例更提出可依據微服務的性能來適時汰除性能較差的微服務的機制,以下搭配圖7A及7B作進一步說明。In addition, the embodiment of the present invention further proposes a mechanism for timely eliminating poorly performing microservices according to the performance of the microservices, which will be further described below with reference to FIGS. 7A and 7B.

請參照圖7A,其是依據本發明之一實施例繪示的在主動/主動模式下的微服務汰除機制。在本實施例中,假設微服務管理端220維護的全域可用性分數資料表220b記錄的微服務231~233的全域可用性分數分別是456分、1100分及30分。承先前實施例的教示,由於微服務的全域可用性分數與微服務處理詢問信號QS的處理時間呈現負相關,因此越高的全域可用性分數代表越短的處理時間,亦即越高的工作效能。Please refer to FIG. 7A, which illustrates a microservice elimination mechanism in an active / active mode according to an embodiment of the present invention. In this embodiment, it is assumed that the global availability scores of the microservices 231 to 233 recorded by the global availability score data table 220b maintained by the microservice management terminal 220 are 456 points, 1100 points, and 30 points, respectively. Following the teachings of the previous embodiment, since the global availability score of the microservice has a negative correlation with the processing time of the microservice processing the query signal QS, a higher global availability score represents a shorter processing time, that is, a higher work efficiency.

在圖7A中,假設微服務管理端220可將全域可用性分數大於1000分的微服務232區分至群組GP1、將全域可用性分數介於1000分至300分的微服務231區分至群組GP2,以及將全域可用性分數小於300分的微服務233區分至群組GP3。由於越高的全域可用性分數代表越高的工作效能,因此群組GP1~GP3亦可視為分別對應於高效能、中效能及低效能。In FIG. 7A, it is assumed that the microservice management terminal 220 can distinguish the microservices 232 with a global availability score greater than 1000 points into the group GP1, and the microservices 231 with the global availability score between 1000 and 300 points into the group GP2. And the micro service 233 with a global availability score of less than 300 points is divided into the group GP3. Since higher global availability scores indicate higher work efficiency, the groups GP1 ~ GP3 can also be regarded as corresponding to high performance, medium performance, and low performance, respectively.

接著,微服務管理端220可判斷被歸類至低效能群組GP3的微服務233是否已被歸類至群組GP3達一預設週期。若是,即代表微服務233已長期處於低工作效能,因此微服務管理端220可判定將微服務233汰除;若否,即代表微服務233未長期處於低工作效能,因此微服務管理端220可判定不需將微服務233汰除。Then, the microservice management terminal 220 can determine whether the microservice 233 classified into the low-performance group GP3 has been classified into the group GP3 for a preset period. If it is, it means that the microservice 233 has been in low working efficiency for a long time, so the microservice management end 220 can decide to eliminate the microservice 233; if not, it means that the microservice 233 has not been in low working efficiency for a long time, so the microservice management end 220 It may be determined that microservices 233 do not need to be eliminated.

在一實施例中,若微服務管理端220判斷需汰除微服務233,則微服務管理端220可刪除微服務233,並新增一個新的微服務來取代微服務233。In one embodiment, if the microservice management terminal 220 determines that the microservice 233 needs to be eliminated, the microservice management terminal 220 may delete the microservice 233 and add a new microservice to replace the microservice 233.

請參照圖7B,其是依據本發明之一實施例繪示的在主動/待命模式下的微服務汰除機制。與圖7A不同之處在於,圖7A實施例可將工作性能較高的微服務232歸類至主群組GP1’,並將工作效能較不佳的微服務231及233歸類至僕群組GP2’。Please refer to FIG. 7B, which illustrates a microservice elimination mechanism in an active / standby mode according to an embodiment of the present invention. 7A differs from FIG. 7A in that the embodiment of FIG. 7A can classify microservices 232 with higher working performance into the main group GP1 ′, and classify microservices 231 and 233 with poor working performance into the slave group GP2 '.

接著,微服務管理端220可判斷被歸類至低效能的僕群組GP2’的微服務231(或233)是否已被歸類至僕群組GP2’達一預設週期。若是,即代表微服務231(或233)已長期處於低工作效能,因此微服務管理端220可判定將微服務231(或233)汰除;若否,即代表微服務231(或233)未長期處於低工作效能,因此微服務管理端220可判定不需將微服務231(或233)汰除。Then, the micro service management terminal 220 may determine whether the micro service 231 (or 233) classified into the slave group GP2 'having low performance has been classified into the slave group GP2' for a preset period. If it is, it means that the microservice 231 (or 233) has been in a low working efficiency for a long time, so the microservice management end 220 can determine that the microservice 231 (or 233) is eliminated; if not, it means that the microservice 231 (or 233) has not been Due to low working efficiency for a long time, the microservice management terminal 220 may determine that the microservice 231 (or 233) does not need to be eliminated.

在一實施例中,若微服務管理端220判斷需汰除微服務231(或233),則微服務管理端220可刪除微服務231(或233),並新增一個新的微服務來取代微服務231(或233)。In an embodiment, if the microservice management terminal 220 determines that the microservice 231 (or 233) needs to be eliminated, the microservice management terminal 220 may delete the microservice 231 (or 233) and add a new microservice to replace it. Microservices 231 (or 233).

綜上所述,本發明提出的伺服及其對微服務安排工作的方法可依據各微服務的全域可用性分數來決定用於處理服務請求的第一微服務,並建立對應的全域鎖及區域鎖來令所建立的微服務系統架構具備高可用性。並且,上述全域鎖及區域鎖還分別具有對應的全域鎖定時間及區域鎖定時間,而當其中之一逾期時,全域鎖及區域鎖將同時失效,以令微服務管理端可重新為上述服務請求安排其他的微服務以進行處理。藉此,可使微服務在水平擴展時,相關的邏輯服務能保有高可用性,並可應用於主動/主動以及主動/待命等兩種高可用性模式。In summary, the servo and the method for arranging work for the microservices provided by the present invention can determine the first microservice for processing service requests according to the global availability score of each microservice, and establish corresponding global locks and area locks. To make the built microservices system architecture highly available. In addition, the global lock and area lock also have corresponding global lock time and area lock time, and when one of them expires, the global lock and area lock will be invalidated at the same time, so that the microservice management can re-request for the service. Arrange other microservices for processing. In this way, when microservices are horizontally expanded, related logical services can maintain high availability, and can be applied to two high availability modes such as active / active and active / standby.

另外,本發明還可基於微服務對於詢問信號的處理時間來決定微服務的全域可用性分數,以作為指派服務請求的依據。並且,上述全域可用性分數還可作為是否即時汰除此微服務的依據,藉以令整體微服務維持高處理效能。In addition, the present invention can also determine the global availability score of the microservice based on the processing time of the microservice for the interrogation signal, as a basis for assigning a service request. In addition, the above-mentioned global availability score can also be used as a basis for whether to immediately eliminate this microservice, so that the overall microservice can maintain high processing performance.

雖然本發明已以實施例揭露如上,然其並非用以限定本發明,任何所屬技術領域中具有通常知識者,在不脫離本發明的精神和範圍內,當可作些許的更動與潤飾,故本發明的保護範圍當視後附的申請專利範圍所界定者為準。Although the present invention has been disclosed as above with the examples, it is not intended to limit the present invention. Any person with ordinary knowledge in the technical field can make some modifications and retouching without departing from the spirit and scope of the present invention. The protection scope of the present invention shall be determined by the scope of the attached patent application.

100‧‧‧伺服器100‧‧‧Server

102‧‧‧儲存電路102‧‧‧Storage Circuit

104‧‧‧處理器104‧‧‧Processor

200‧‧‧微服務系統架構200‧‧‧microservice system architecture

210‧‧‧請求佇列210‧‧‧ Request queue

220‧‧‧微服務管理端220‧‧‧Micro-service management terminal

220a‧‧‧全域鎖資料表220a‧‧‧Global Lock Data Sheet

220b‧‧‧全域可用性分數資料表220b‧‧‧Global Availability Score Data Sheet

231、232、233、…、23n‧‧‧微服務231, 232, 233, ..., 23n‧‧‧ microservices

231a、232a‧‧‧處理程序231a, 232a‧‧‧Process

231b、232b‧‧‧區域鎖資料表231b, 232b‧‧‧ Zone Lock Data Sheet

GL1、GL2‧‧‧全域鎖GL1, GL2‧‧‧Global lock

GT1、GT2‧‧‧全域鎖定時間GT1, GT2‧‧‧Global lock time

GP1、GP2、GP3‧‧‧群組GP1, GP2, GP3‧‧‧ group

GP1’‧‧‧主群組GP1’‧‧‧Main group

GP2’‧‧‧僕群組GP2’‧‧‧ servant group

LL1、LL2‧‧‧區域鎖LL1, LL2‧‧‧area lock

LT1、LT2‧‧‧區域鎖定時間LT1, LT2‧‧‧ Zone lock time

RQ、RQ1、RQ2‧‧‧服務請求RQ, RQ1, RQ2‧‧‧ Service Request

S310~S340‧‧‧步驟S310 ~ S340‧‧‧step

QS‧‧‧詢問信號QS‧‧‧Inquiry signal

圖1是依據本發明之一實施例繪示的伺服器功能方塊圖。 圖2是依據圖1繪示的微服務系統架構圖。 圖3是依據圖2繪示的對微服務安排工作的方法流程圖。 圖4A是依據本發明之一實施例繪示的在主動/主動模式下挑選第一微服務的示意圖。 圖4B是依據本發明之一實施例繪示的在主動/待命模式下挑選第一微服務的示意圖。 圖5是依據本發明之一實施例繪示的為微服務分配工作的示意圖。 圖6A是依據本發明之一實施例繪示的調整區域可用性分數的示意圖。 圖6B是依據圖6A繪示的調整全域可用性分數的示意圖。 圖7A是依據本發明之一實施例繪示的在主動/主動模式下的微服務汰除機制。 圖7B是依據本發明之一實施例繪示的在主動/待命模式下的微服務汰除機制。FIG. 1 is a functional block diagram of a server according to an embodiment of the present invention. FIG. 2 is a microservice system architecture diagram according to FIG. 1. FIG. 3 is a flowchart of a method for arranging work for a microservice according to FIG. 2. FIG. 4A is a schematic diagram of selecting a first microservice in an active / active mode according to an embodiment of the present invention. FIG. 4B is a schematic diagram of selecting a first microservice in an active / standby mode according to an embodiment of the present invention. FIG. 5 is a schematic diagram illustrating a microservice allocation task according to an embodiment of the present invention. FIG. 6A is a schematic diagram of adjusting an area availability score according to an embodiment of the present invention. FIG. 6B is a schematic diagram of adjusting the global availability score according to FIG. 6A. FIG. 7A illustrates a microservice elimination mechanism in an active / active mode according to an embodiment of the present invention. FIG. 7B illustrates a microservice elimination mechanism in an active / standby mode according to an embodiment of the present invention.

Claims (13)

一種對微服務安排工作的方法,包括:取得一服務請求;從多個微服務中挑選一第一微服務,其中該第一微服務包括多個處理程序;將該服務請求指派予該些處理程序中的一第一處理程序;對該第一微服務施加一第一全域鎖,以及對該第一處理程序施加一第一區域鎖,其中該第一全域鎖的一第一全域鎖定時間相同於該第一區域鎖的一第一區域鎖定時間,該些微服務中的一第二微服務因應於該第一全域鎖而停止要求處理該服務請求,而該些處理程序中的一第二處理程序因應於該第一區域鎖而停止要求處理該服務請求,其中若該第一微服務無法在該第一全域鎖定時間或該第一區域鎖定時間完成該服務請求,所述方法更包括減少該第一微服務的一第一全域可用性分數,並將未完成的該服務請求排入一請求佇列。A method for arranging work for a microservice includes: obtaining a service request; selecting a first microservice from a plurality of microservices, wherein the first microservice includes a plurality of processing programs; and assigning the service request to the processings A first processing program in the program; applying a first global lock to the first microservice and applying a first region lock to the first processing program, wherein a first global lock time of the first global lock is the same At a first area lock time of the first area lock, a second micro service of the micro services stops requesting to process the service request due to the first global lock, and a second process of the processing programs The program stops requesting to process the service request due to the first region lock, and if the first microservice cannot complete the service request within the first global lock time or the first region lock time, the method further includes reducing the A first global availability score for the first microservice, and queue outstanding service requests into a request queue. 如申請專利範圍第1項所述的方法,更包括:記錄未完成的該服務請求的一處理進度;以及將位於該請求佇列中的該服務請求指派予該些微服務的其中之一者,以令該些微服務的其中之該者依據該處理進度接續處理該服務請求。The method according to item 1 of the scope of patent application, further comprising: recording a processing progress of the service request outstanding; and assigning the service request in the request queue to one of the microservices, In order to make one of the microservices continue to process the service request according to the processing progress. 如申請專利範圍第1項所述的方法,更包括:發送一詢問信號至該些微服務中的一第三微服務,以令該第三微服務計算對於該詢問信號的一處理時間,並依據該處理時間更新該第三微服務的一區域可用性分數;要求該第三微服務回傳該區域可用性分數與一區域預設分數之間的一差值,並據以調整該第三微服務的一全域可用性分數;依據該第三微服務的該全域可用性分數判斷是否汰換該第三微服務;若是,刪除該第三微服務,並新增一新微服務至該些微服務;以及若否,將該第三微服務保留於該些微服務中。The method according to item 1 of the scope of patent application, further comprising: sending an inquiry signal to a third micro service of the micro services, so that the third micro service calculates a processing time for the inquiry signal, and according to The processing time updates a region availability score of the third microservice; the third microservice is required to return a difference between the region availability score and a region preset score, and adjust the third microservice's A global availability score; judging whether to replace the third microservice based on the global availability score of the third microservice; if so, delete the third microservice and add a new microservice to the microservices; and if not , Retain the third microservice in the microservices. 如申請專利範圍第3項所述的方法,其中:當該第三微服務處理該詢問信號的該處理時間超過一預設時間時,該第三微服務減少該區域可用性分數;以及當該第三微服務處理該詢問信號的該處理時間未超過該預設時間時,該第三微服務增加該區域可用性分數。The method according to item 3 of the scope of patent application, wherein: when the processing time for processing the interrogation signal by the third microservice exceeds a preset time, the third microservice reduces the area availability score; and when the When the processing time for the three microservices to process the interrogation signal does not exceed the preset time, the third microservice increases the area availability score. 如申請專利範圍第4項所述的方法,其中要求該第三微服務回傳該區域可用性分數與該區域預設分數的該差值,並據以調整該第三微服務的該全域可用性分數的步驟包括:以該全域可用性分數與該差值的一總和作為更新的該全域可用性分數。The method according to item 4 of the scope of patent application, wherein the third microservice is required to return the difference between the regional availability score and the regional preset score, and adjust the global availability score of the third microservice accordingly. The step includes: using a sum of the global availability score and the difference as the updated global availability score. 如申請專利範圍第4項所述的方法,其中若未在一預設時間內接收該第三微服務回傳的該差值,所述方法更包括將該第三微服務的該全域可用性分數減去一預設分數。The method according to item 4 of the scope of patent application, wherein if the difference value returned by the third microservice is not received within a preset time, the method further includes the global availability score of the third microservice Subtract a preset score. 申請專利範圍第3項所述的方法,其中該些微服務個別具有一全域可用性分數,而依據該第三微服務的該全域可用性分數判斷是否汰換該第三微服務的步驟包括:依據各該微服務的該全域可用性分數將該些微服務降冪排序;將排序後的該些微服務區分為多個群組,其中該些群組至少包括一第一群組及一第二群組,且被歸類至該第二群組的各該微服務的該全域可用性分數低於被歸類至該第一群組的各該微服務的該全域可用性分數;判斷該第三微服務是否已被歸類至該第二群組達一預設週期;若是,判定汰換該第三微服務;以及若否,判定不汰換該第三微服務。The method described in claim 3, wherein the microservices each have a global availability score, and the step of determining whether to replace the third microservice based on the global availability score of the third microservice includes: The global availability score of the microservices ranks the microservices in descending order; the sorted microservices are divided into multiple groups, where the groups include at least a first group and a second group, and are The global availability score of each microservice classified to the second group is lower than the global availability score of each microservice classified to the first group; judging whether the third microservice has been classified Class to the second group for a preset period; if yes, determine to replace the third microservice; and if not, determine not to replace the third microservice. 如申請專利範圍第7項所述的方法,其中若該些微服務基於一主動/待命模式運作,則該第一群組為一主群組,該第二群組為一僕群組。The method according to item 7 of the scope of patent application, wherein if the microservices operate based on an active / standby mode, the first group is a main group and the second group is a slave group. 如申請專利範圍第1項所述的方法,其中若該第一微服務在該第一區域鎖定時間逾時之前完成該服務請求,該第一微服務解除該第一區域鎖,並回報該服務請求的一處理結果。The method of claim 1, wherein if the first microservice completes the service request before the first region lock time expires, the first microservice releases the first region lock and returns the service A requested processing result. 如申請專利範圍第6項所述的方法,更包括因應於該第一微服務回報的該處理結果而解除該第一全域鎖。The method according to item 6 of the scope of patent application, further comprising releasing the first global lock in response to the processing result returned by the first microservice. 如申請專利範圍第1項所述的方法,其中若該些微服務基於一主動/主動模式運作,該第一微服務的該第一全域可用性分數在該些微服務中為最高。The method of claim 1, wherein if the microservices operate based on an active / active mode, the first global availability score of the first microservice is the highest among the microservices. 如申請專利範圍第1項所述的方法,其中各該微服務具有一全域可用性分數,而若該些微服務基於一主動/待命模式運作,則該些微服務被依據各該微服務的該全域可用性分數區分為一主群組及一僕群組,其中該主群組中的各該微服務的該全域可用性分數皆高於該僕群組中的各該微服務的該全域可用性分數,且從該些微服務中挑選該第一微服務的步驟包括:僅從位於該主群組中的該些微服務中挑選該第一微服務。The method according to item 1 of the scope of patent application, wherein each microservice has a global availability score, and if the microservices operate based on an active / standby mode, the microservices are based on the global availability of each microservice The score is divided into a master group and a slave group, wherein the global availability score of each microservice in the master group is higher than the global availability score of each microservice in the slave group, and from The step of selecting the first microservice among the microservices includes: selecting the first microservice only from the microservices located in the main group. 一種伺服器,包括:一儲存電路,儲存多個模組;以及一處理器,耦接該儲存電路,存取該些模組以執行下列步驟:取得一服務請求;從多個微服務中挑選一第一微服務,其中該第一微服務包括多個處理程序;將該服務請求指派予該些處理程序中的一第一處理程序;對該第一微服務施加一第一全域鎖,以及對該第一處理程序施加一第一區域鎖,其中該第一全域鎖的一第一全域鎖定時間相同於該第一區域鎖的一第一區域鎖定時間,該些微服務中的一第二微服務因應於該第一全域鎖而停止要求處理該服務請求,而該些處理程序中的一第二處理程序因應於該第一區域鎖而停止要求處理該服務請求,其中若該第一微服務無法在該第一全域鎖定時間或該第一區域鎖定時間完成該服務請求,該處理器更經配置以減少該第一微服務的一第一全域可用性分數,並將未完成的該服務請求排入一請求佇列。A server includes: a storage circuit storing a plurality of modules; and a processor coupled to the storage circuit and accessing the modules to perform the following steps: obtaining a service request; selecting from a plurality of microservices A first microservice, wherein the first microservice includes a plurality of processing programs; assigning the service request to a first processing program among the processing programs; applying a first global lock to the first microservice, and A first region lock is applied to the first processing program, wherein a first global lock time of the first global lock is the same as a first region lock time of the first regional lock, and a second micro of the micro services The service stops requesting to process the service request due to the first global lock, and a second processing program among the processing programs stops requesting to process the service request due to the first regional lock. If the first microservice The service request cannot be completed within the first global lock time or the first regional lock time, the processor is further configured to reduce a first global availability score of the first microservice, and The completion of the service request into a request queue.
TW107131774A 2018-09-10 2018-09-10 Server and method for assigning job for microservices thereof TWI676374B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW107131774A TWI676374B (en) 2018-09-10 2018-09-10 Server and method for assigning job for microservices thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW107131774A TWI676374B (en) 2018-09-10 2018-09-10 Server and method for assigning job for microservices thereof

Publications (2)

Publication Number Publication Date
TWI676374B true TWI676374B (en) 2019-11-01
TW202011717A TW202011717A (en) 2020-03-16

Family

ID=69188721

Family Applications (1)

Application Number Title Priority Date Filing Date
TW107131774A TWI676374B (en) 2018-09-10 2018-09-10 Server and method for assigning job for microservices thereof

Country Status (1)

Country Link
TW (1) TWI676374B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112799803A (en) * 2021-01-14 2021-05-14 深圳市瞬点科技有限公司 Micro-service architecture operation maintenance method, device, equipment and readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5745747A (en) * 1995-02-06 1998-04-28 International Business Machines Corporation Method and system of lock request management in a data processing system having multiple processes per transaction
US20130132627A1 (en) * 2011-11-22 2013-05-23 Futurewei Technologies, Inc. System and Method for Implementing Locks Shared Between Kernel and User Space
US20170063933A1 (en) * 2015-03-13 2017-03-02 Varmour Networks, Inc. Context aware microsegmentation

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5745747A (en) * 1995-02-06 1998-04-28 International Business Machines Corporation Method and system of lock request management in a data processing system having multiple processes per transaction
US20130132627A1 (en) * 2011-11-22 2013-05-23 Futurewei Technologies, Inc. System and Method for Implementing Locks Shared Between Kernel and User Space
US20170063933A1 (en) * 2015-03-13 2017-03-02 Varmour Networks, Inc. Context aware microsegmentation

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112799803A (en) * 2021-01-14 2021-05-14 深圳市瞬点科技有限公司 Micro-service architecture operation maintenance method, device, equipment and readable storage medium
CN112799803B (en) * 2021-01-14 2023-11-17 深圳市瞬点科技有限公司 Micro-service architecture operation maintenance method, device, equipment and readable storage medium

Also Published As

Publication number Publication date
TW202011717A (en) 2020-03-16

Similar Documents

Publication Publication Date Title
US11487698B2 (en) Parameter server and method for sharing distributed deep learning parameter using the same
US11687555B2 (en) Conditional master election in distributed databases
CN115422284B (en) Storage device, distributed storage system, and data processing method
US9092266B2 (en) Scalable scheduling for distributed data processing
US20170024251A1 (en) Scheduling method and apparatus for distributed computing system
CN110597639B (en) CPU distribution control method, device, server and storage medium
CN108900626B (en) Data storage method, device and system in cloud environment
CN106462593B (en) System and method for massively parallel processing of databases
JP6468499B2 (en) Distributed computing architecture
WO2019056771A1 (en) Distributed storage system upgrade management method and device, and distributed storage system
WO2023231345A1 (en) Method for grouping a plurality of transactions, and blockchain node
WO2023231336A1 (en) Method for executing transaction and blockchain node
EP4184324A1 (en) Efficient accelerator offload in multi-accelerator framework
KR20190028210A (en) Cloud service method and system for deployment of artificial intelligence application using container
US20220300323A1 (en) Job Scheduling Method and Job Scheduling Apparatus
TWI676374B (en) Server and method for assigning job for microservices thereof
US9594782B2 (en) Hierarchical file block variant store apparatus and method of operation
CN115640113A (en) Multi-plane flexible scheduling method
Cheng et al. Dynamic resource provisioning for iterative workloads on Apache Spark
Guo et al. The improved job scheduling algorithm of Hadoop platform
JP3429582B2 (en) Multiprocessor system
US10824640B1 (en) Framework for scheduling concurrent replication cycles
WO2018188958A1 (en) A method and a host for managing events in a network that adopts event-driven programming framework
CN115063282A (en) GPU resource scheduling method, device, equipment and storage medium
US20160357780A1 (en) Hierarchical file block variant tracker apparatus coupled to a Librarian and to a remote file service