Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple roles on the same instance in Windows Azure

Is it possible to deploy multiple roles in the same instance?

I have three web roles (website in asp.net mvc3, and two WCF services instances) and two worker roles (windows services).

The load for this application is very small, so I don't want to create so many instances in Windows Azure and pay for all of the instances now. Instead I want to deploy all my application in the same instance and change it later if I will get some income from my applications.

I Googled and found some forum posts than it's possible and some than it's not possible... but I can't find information how to do it...

So two questions: Is it possible? How can I do it?

like image 431
Yaplex Avatar asked Feb 18 '12 17:02

Yaplex


People also ask

What is a role instance in Azure?

Define role instance in Azure. A role instance is nothing but a virtual machine where the application code runs with the help of running role configurations. There can also be multiple instances of a role as per the definition in the cloud service configuration files.

What is Web Role and Worker Role in Azure?

There are two types of Azure Cloud Services roles. The only difference between the two is how your role is hosted on the VMs: Web role: Automatically deploys and hosts your app through IIS. Worker role: Does not use IIS, and runs your app standalone.


3 Answers

A slightly different answer than @Simon's... A Role is actually a template for a Windows Server 2008 VM (see my answer on this SO question as well). Each role has one or more instances, and you can run whatever you want on any role.

You can absolutely run your website and all your WCF services in a single role. You'll now scale your application up/down (VM size) and out/in (# of instances) as a single scale unit. If, say, your WCF services are CPU-intensive, causing the VM instances to slow down for your web visitors, you'll need to scale out enough to handle those visitors.

Once you reach a significant traffic load, it's worth considering separate roles. That way, you can decide on VM size and quantity per role. Maybe you have 2 or 3 Small instances of a Web role to handle your user traffic on the website, and maybe 2 Medium instances of a Worker role to handle WCF services (just as an example). The more roles you have, the finer-grain scaling you have, but you must run at least one instance of each role, which elevates your "system at rest" baseline cost.

like image 138
David Makogon Avatar answered Oct 14 '22 23:10

David Makogon


No, roles are instances and each one takes up an entire VM. You can however deploy a number of websites into a single role, which will allow you to deploy all your MVC and WCF apps into a single web role. You need to add websites to the sites element in the ServiceDefinition. There seem to be a few blog posts on how this is done - here and here.

For worker roles, I suggest you create a single worker role and combine the work done in those roles, such as starting a separate thread for each queue being monitored. This StackOverflow answer by Eugenio Pace.

I wouldn't recommend trying to combine worker role functionality into the web role. Apart from it not making architectural sense, sense to the physical infrastructure (IIS vs not IIS), there are potential issues such as the with termination of running threads when worker roles recycle (a thread not started by IIS may terminate abruptly)

like image 20
Simon Munro Avatar answered Oct 14 '22 23:10

Simon Munro


Check this episode of cloud cover. you can put couple of web role in the same instance. worker role you can always put multiple thread to work the data.

http://channel9.msdn.com/Shows/Cloud+Cover/Cloud-Cover-Episode-37-Multiple-Websites-in-a-Web-Role.

Note that each time you upload a new version to azure you need to upload all the web roles/ worker roles to azure again

like image 36
Naz Avatar answered Oct 14 '22 21:10

Naz