0
votes

Suppose I have a stateless service running in service fabric and I have 5 nodes in my service fabric cluster. Now since each node in the cluster has an instance of stateless service, this means there will be 5 instances of my stateless service on 5 nodes.

But since each node has a different IP address and port number where it can host the service, there can be multiple different endpoint addresses at which my service is hosted.

Now my service is actually a REST API providing some crud functionalities. Now I have set the port no to be 8080 in servicemanifest.xml file.

Now my question is, does setting port no specifically in servicemanifest.xml disable dynamically selection of port? Will this make every node on cluster use same port i.e. 8080 in endpoint address of the service?

Another question is that if the service is shifted to some another machine and deployed there and having 8080 as port can cause conflict if some other service on its cluster is already using the same port i.e. 8080?

How will we let the client know at which endpoint address my API is hosted?

1

1 Answers

0
votes

Does setting port no specifically in servicemanifest.xml disable dynamically selection of port?

Yes it does

Will this make every node on cluster use same port i.e. 8080 in endpoint address of the service?

Yes, if you set instance count to -1 all nodes will run the service at that port. You can call them by using the external load balancer (external to service) or directly on the node IP / localhost (service to service).

If the service is shifted to some another machine and deployed there and having 8080 as port can cause conflict if some other service on its cluster is already using the same port i.e. 8080?

There will never be more that 1 instance of 1 stateless service on 1 node, within the same application. SF takes care of this. However, if another service is using the port, it cannot be used by another service unless you use a server that supports port sharing like http.sys.

To deal with port conflicts, have a look at the built-in reverse proxy or Traefik. Using a reverse proxy takes away the pain of managing ports, and allows you to call your service by its application and service name.