我们如何提高部署到 Service Fabric 集群的应用程序的早期响应能力

How can we improve the early responsiveness of applications deployed to a service fabric cluster

我们有一个系统分为多个服务,这些服务作为持续交付管道的一部分部署到服务结构集群中。一旦部署完成,我们确实会受到影响,因为系统感觉明显变慢,直到一切都完成 "warmed up"。

我们认为此问题与执行路径中每个服务的新版本的 JITing 有关,但它也可能与序列化程序生成有关。

通常我们会寻求使用 ngen.exe 来缓解与即时编译相关的问题,但我们不知道如何在服务结构中实现它。

非常感谢您抽出宝贵时间,如果您需要更多信息,我很乐意尽可能提供。

您可以在此处使用的是控制应用程序升级的参数之一 - HealthCheckWaitDurationSec。根据 Application upgrade parameters 文档 -

"This duration can also be considered as the time an application should be running before it can be considered healthy"

至于permissions

By default, Service Fabric applications run under the account that the Fabric.exe process runs under. Service Fabric also provides the capability to run applications under a local user or system account. In the application manifest, you define the user accounts required to run services or secure resources in the Principals section.

至于清理,这取决于你的意思。代码工件最终将被擦除。您还可以在您的部署脚本中使用 UnregisterUnusedApplicationVersionsAfterUpgrade 参数来取消注册升级完成后存在的任何未使用的应用程序版本,这应该有助于清理不再使用的东西。

Q1:

What trust level are services within service fabric running under? As ngen requires full trust.

引自here

By default, Service Fabric applications run under the account that the Fabric.exe process runs under.

通常是NetworkService

Q2:

Is it possible to deploy the service but ngen it BEFORE requests are serviced by the new version of the service?

是的。您可以使用 SetupEntryPoint 在提升的权限下使用 ngen 执行脚本。