How to run multiple instances of a hosted OWIN service in a development cluster?

I went through the OWIN hosting tutorial and started working, but when I change the InstanceCount value to -1, it seems like every instance of the service is trying to listen on port 80 in the OpenAync method when it calls WebApp.Start.

I suggested that the Service Fabric will manage ports dynamically as it combines services to avoid port collisions, but it doesn't seem to be happening.

+6
source share
1 answer

An InstanceCount of -1 makes sense only for stateless services running on a multi-machine cluster. In this case, each node runs on its own computer, so you do not have port conflicts, and you can configure the Azure load balancer to loop traffic through the machines that host these instances.

In the local cluster, all nodes are on the same machine, so if they try to use a common HTTP prefix, they really conflict. To avoid this, simply install InstanceCount for your non-state 1 services for on-premises deployments.

All this is required only when you want to communicate with your services using a predefined port. If you do not specify a port in the service manifest, the platform will automatically assign it when the service starts. However, clients must dynamically open your endpoints using platform name resolution APIs, which is often undesirable.

As a result, a common pattern is to listen on a pre-assigned port before your application, and then perform name resolution to forward requests to other services. These second-tier services can listen on a port dynamically assigned by the platform.

+8
source

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


All Articles