简体   繁体   English

服务结构-每个服务实例的动态资源管理

[英]Service Fabric - Dynamic resource government per service instance

TL;DR : Is there a way to dynamically set the parameters or resource policies for ServicePackageResourceGovernancePolicy and/or ResourceGovernancePolicy when we create a new instance of a certain ServiceType at runtime? TL; DR :当我们在运行时创建某个ServiceType的新实例时,是否有一种方法可以动态设置ServicePackageResourceGovernancePolicy和/或ResourceGovernancePolicy的参数或资源策略?

We have a use case to have dynamic resource government per service instance (not type). 我们有一个用例,可以对每个服务实例(而非类型)进行动态资源管理。

So basically, we have a service type: VotingDataType . 因此,基本上,我们有一个服务类型: VotingDataType

So you describe the resource government in the ApplicationManifest , taken from the docs here is an example: 因此,您在ApplicationManifest描述了资源管理, 摘自文档,这里是一个示例:

<ApplicationManifest>
   ... 
   <ServiceManifestImport>
      <ServiceManifestRef ServiceManifestName="VotingDataPkg" ServiceManifestVersion="1.0.0" />
      ...  
      <!-- Set resource governance at the service package level. -->
      <ServicePackageResourceGovernancePolicy CpuCores="[CpuCores]" MemoryInMB="[Memory]"/>

      <!-- Set resource governance at the code package level. -->
      <ResourceGovernancePolicy CodePackageRef="Code" CpuPercent="10" MemoryInMB="[Memory]" BlockIOWeight="[BlockIOWeight]" 
                                MaximumIOBandwidth="[MaximumIOBandwidth]" MaximumIOps="[MaximumIOps]" MemoryReservationInMB="[MemoryReservationInMB]" 
                                MemorySwapInMB="[MemorySwapInMB]"/>

    </Policies>
  </ServiceManifestImport>
  ...
</ApplicationManifest

Now for every customer, my custom placement service will instantiate a new instance of the VotingDataType. 现在,对于每个客户,我的自定义放置服务将实例化VotingDataType的新实例。 However, by some meta data we get before we are about to instantiate a new instance, we decide if it needs a bigger instance to begin with. 但是,通过将要实例化新实例之前获得的一些元数据,我们可以决定是否需要更大的实例作为开始。 so instead of 10% CPU limit, we want a 20% CPU limit. 因此,我们希望将CPU限制为20%,而不是10%CPU限制。

Our placement service will then use the following method to create a new instance of that VotingDataType service. 然后,我们的展示位置服务将使用以下方法创建该VotingDataType服务的新实例。 fabricClient.ServiceManager.CreateServiceAsync(...) . fabricClient.ServiceManager.CreateServiceAsync(...) However, we're not able to customize the Parameters for the ResourceGovernancePolicy . 但是,我们无法为ResourceGovernancePolicy自定义参数。

Is there a way to dynamically set the parameters or resource policies for ServicePackageResourceGovernancePolicy and/or ResourceGovernancePolicy when we create a new instance of a certain ServiceType at runtime? 当我们在运行时创建某个ServiceType的新实例时,是否可以动态设置ServicePackageResourceGovernancePolicy和/或ResourceGovernancePolicy的参数或资源策略?

Application parameters are defined at Application Level, so the values are valid to all services inside the named application. 应用程序参数是在应用程序级别定义的,因此这些值对命名应用程序内的所有服务均有效。

In your case, is suitable if you have one named application(instance) per tenant, even though they are the same AppType. 对于您的情况,如果每个租户有一个命名的应用程序(实例),即使它们是相同的AppType,也很合适。 This way you deploy once and create multiple services with different configuration or versions. 这样,您只需部署一次并创建具有不同配置或版本的多个服务。

One app per tenant is also better, because you can update them individually, so each tenant can decide when they want to apply the update. 每个租户一个应用程序也更好,因为您可以单独更新它们,因此每个租户可以决定他们何时应用更新。

ie: 即:

ApplicationTypes    
  ApplicationType  | Version
  ----------------------------
  SalesAppType       1.0
  SalesAppType       1.1

Applications (Named Applications)
  Application   | ApplicationType  | Version
  -------------------------------------------
  Ten1-SalesApp   SalesAppType       1.0
  Ten2-SalesApp   SalesAppType       1.0
  Ten3-SalesApp   SalesAppType       1.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM