Opening ports dynamically in Azure, is the load balancer smart enough to route to the correct one?
As far as I know I can only open 5 endpoints in an Azure application, but what if I open those ports dynamically? Example: I have a WorkerRole
with an <Instances count="2" />
, then the instance number one open a socket in one of the 5 available endpoints I declared in the ".csdef" file, when a connection goes to "myapp.cloudapp.net" ... is there a chance that the connection goes to the second instance where there is not a listening socket?
I guess that yes, as the load balancer is using a round robin schedul开发者_开发知识库ing, it doesn't care and it could forward the connection to the second one, but I may be wrong.
Regards.
You guessed correctly. There's absolutely no way to direct traffic to a specific instance, and the load balancer has no idea if your instance has a listener running. The only way to make that work is for your client app (the one connecting to your Windows Azure deployment) to keep retrying until it gets a successful connection.
The general guidance is to 1) have each instance operate in the same manner, in this case opening listeners on the port for each instance and 2) setting up the listeners in the OnStart() method, prior to being added to the Load Balancer.
I guess that you are talking about an InputEndpoint. But InternalEndpoints do not go via the load balancer and can be addressed specifically by other roles. Therefore you could set up a handler on a web role that could forward the request to the specific worker role instance you want.
精彩评论