Initial call to ServiceFabric proxy VERY slow

Whenever I call one service from another service, the first proxy call is VERY slow, that is, 100 times slower than all subsequent calls. I set the timings in this record immediately before the call, and then immediately when the call method is called, and this can be more than 60 seconds! A service workspace cluster is a standalone cluster running on 12 nodes / virtual machines.

Interestingly, the time it takes for the first call seems to be related to the number of nodes, that is, if I deactivate half of the nodes, the time decreases (although not by half). In addition, when running the same code in a dev cluster running on my local PC, the time it takes for the first call is usually about 8 seconds with subsequent calls, 10 ms on any system. In addition, creating a different proxy server for the same service in the same client process still leads to faster talk time, it looks like a factory proxy (which, in my opinion, SF caches to the client process) It is created during the first use of the proxy server and takes a very long time.

Interestingly, no exceptions are possible, and the services really work!

So my question is: why does this happen the first time a call is made from one service to another on a proxy server created using ServiceProxy.Create ()?

+4
source share
2 answers

According to SF Remote Access Documents (see below, focus), ServiceProxy.Create is a wrapper around ServiceProxyFactory and the first call also includes setting up the factory for subsequent calls.

ServiceProxyFactory - factory, . API ServiceProxy.Create -, Singleton ServiceProxyFactory. , IServiceRemotingClientFactory. factory - . ServiceProxyFactory . ServiceProxyFactory .

+3

, , , API .

, , API ( asp.net) SF.

, , , , , , .

    private void InitializeContainer(IApplicationBuilder app)
    {
        // Add application presentation components:
        Container.RegisterMvcControllers(app);
        Container.RegisterMvcViewComponents(app);

        // Add application services.
        Container.Register(() => ServiceProxy.Create<IContestService>(FabricUrl.ContestService), Lifestyle.Transient);
        Container.Register(() => ServiceProxy.Create<IFriendService>(FabricUrl.FriendService), Lifestyle.Transient);
        Container.Register(() => ServiceProxy.Create<IUserService>(FabricUrl.UserService), Lifestyle.Transient);
        Container.Register(() => ServiceProxy.Create<IBillingService>(FabricUrl.BillingService), Lifestyle.Transient);
        Container.RegisterSingleton(AutoMapperApi.Configure());

        // Cross-wire ASP.NET services (if any). For instance:
        Container.RegisterSingleton(app.ApplicationServices.GetService<ILoggerFactory>());
        // NOTE: Prevent cross-wired instances as much as possible.
        // See: https://simpleinjector.org/blog/2016/07/
    }
+1

Source: https://habr.com/ru/post/1676734/


All Articles