Search code examples
azure-service-fabricjitngen

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


We have a system split into multiple services that are deployed as part of a continuous delivery pipeline into a service fabric cluster. We do experience an impact once deployments are complete, in that the system feels noticeably slower until everything has "warmed up".

We believe this issue to be related to the JITing of the new versions of each service within execution paths, but it may also have an element of serializer generation also.

Normally we would be looking to use ngen.exe in order to alleviate the issue associated with just-in-time compilation but we do not know how it can be achieved in connection with service fabric.

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

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

  • If an upgrade is rolled back, is there cleanup that must be performed? And is it even possible to perform that clean up?

Many thanks for your time, if you require more information, I'd be happy to provide it where I can.


Solution

  • Q1:

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

    A quote from here:

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

    Usually it is NetworkService.

    Q2:

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

    Yes. You can use SetupEntryPoint to execute script with ngen under elevated privileges.