Pergunta

I need the ability to target a specific Web Role Instance on Azure. We have a data cache and occasionally I need to be able to dump the cache if it gets stale.

Do to this we hit a page over and over again and check

Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CurrentRoleInstance.Id

We check to see that this changes from 0 to 1 to make sure the cache is dumped on both instances. It's not an ideal solution. I'd really like to be able to direct the request to Instance 0 or Instance 1.

Is there any way to specifically target the request to an instance?

Foi útil?

Solução

No you can't really and, even if you could, it still doesn't seem scalable. I would suggest you go about this a slightly diff. way: instead of knowing how many servers there are and how to reach each one, instead just have a single Azure Service Bus Topic. Then, part of the startup logic for your web application goes out and subscribes to this Topic. Next, when it's time to clear something, you send a single message to the Topic. That message will then be fanned out to each subscriber (web app instance that's listening) which, in turn, will take care of clearing the specified cache entry from its local cache.

The contents of the message will depend on your caching scheme, but I imagine all that it needs to contain is the key of the cached item you want to force the refresh of.

Outras dicas

Drew's answer is a good one, but it is also possible to directly address individual instances. Check out the InstanceInputEndpoint - http://msdn.microsoft.com/en-us/library/windowsazure/gg557553.aspx#InstanceInputEndpoint.

This lets you specify a port range for all of your instances, and then within that range you can address each instance by using the correct port number.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top