Azure service fabric Instance count

风流意气都作罢 提交于 2019-11-30 23:31:58

According to the official Microsoft documentation , you need to ensure that only one instance of the service is running when you deploy to a local cluster.Otherwise you will run into conflicts with multiple processes listening to same port .You can set multiple instances when you deploy to Azure.

Refer the documentation :- https://azure.microsoft.com/en-us/documentation/articles/service-fabric-add-a-web-frontend/

When you are using local sf cluster and if you have fixed the service endpoint port, use only one instance. For example:

Service.Endpoint uses port 8090. This is defined in ServiceManifest.xml. In a local cluster actually everything just runs on one node i.e. your development machine. If you try to create 2 instances of same service with hard defined port, then you will get Port already in use error.

Try changing to one instance or move it to actual Azure cluster or remove hard coded port numbers.

I have not experienced this issue.

You can change the instance count programatically using the fabric client:

var fabricClient = new FabricClient();
var instanceCount = 3;
var services = await fabricClient.QueryManager.GetServiceListAsync(new Uri("fabric:/MyMicroServiceApp"));
var service = services.FirstOrDefault(e => e.ServiceName.AbsolutePath.Contains("MyService"));
var updateDescription = new StatelessServiceUpdateDescription();
updateDescription.InstanceCount = instanceCount;
await fabricClient.ServiceManager.UpdateServiceAsync(new Uri(service.ServiceName.AbsoluteUri), updateDescription);

I used this to develop a proof of concept to increase the number of worker processes depending on the size of a queue. As soon as you change the instance count of a service, the Service Fabric framework will automatically deploy / remove an instance of the service to / from a node.

If you are running some type of ASP.Net or Owin hosted service. You have to use an instance count of -1. This will setup one instance on each node. With an instance count of 2, you get 2 instances, which may or may not be on the same node.

We have a similar problem and solved it with build scripts. You can either replace the ServiceManififest via a build script or use Tokenizer to replace the port value.

Locally you can create and install the updated/adjsuted package files and deploy them with DeployFabricApplciation and test against it that way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!