Search code examples
azureazure-web-rolesazure-worker-roles

Understanding how apps in roles are served in Azure


The company I work for is looking to develop a few apps against the cloud.

  • An ASP.NET Web Api application hosted in an Azure web role.
  • A Windows Server type application hosted in an Azure worker role.

We are completely new to web or cloud development and would like to know the following:

When being served to the consumer, is the same instance of the application being served to all, is it one per request or are multiple roles being created and served to consumers?


Solution

  • When being served to the consumer, is the same instance of the application being served to all?

    That depends on how many instances you've asked Azure to run your application on. If you've only deployed to 1 instance, then it will of course be the same instance that responds to all requests. But if you deploy to multiple instances, requests will be load-balanced, which means you have no guarantee that multiple requests from the same user will be handled by the same instance.

    When you're asking this question, it could be because you might be tempted to store local data on the machine running the instance. However, this is not a good idea. Windows Azure can at any time tear down your instance and start your application on a completely different machine. They call this "healing", because it usually happens because Windows Azure tries to be helpful and avoid any potential problem that could mean downtime for your instance. But it also happens if your machine for some reason locks up or something else bad happens. This process of healing means that anything that's not part of your deployment package will be lost. So for example, if you're logging to a file on the disk, this log will be lost if Azure "heals" your instance.

    is it one per request or are multiple roles being created and served to consumers?

    I'm not completely sure what you mean here, so I'll take a guess and risk interpreting your question wrongly. My guess is that you're asking if there will be one instance per user request. No, there will only be the number of instances that you have decided. Remember that you have to pay per instance that's running, so it's only fair that the number of instances running is dictated by you.

    When you have your application packaged and ready to be deployed to Windows Azure, you can decide how many instances of each role you want to have running. You set this number in the deployment package, so that when your package is deployed, Azure will automatically start the requested number of instances. However, you can change the number of running instances of each role after deployment and on-the-fly. This makes it possible for you to scale with more instances within minutes.

    I hope this helps and that I understood your questions correctly. :-)