views:

122

answers:

3

I know that you can only have 1 web role per instance but does this apply to Background roles as well? In more detail can 1 instance run a background role and a web role?

+2  A: 

By default one web role can have 20 instances. If you need more you can contact the Azure Service Desk and they will turn it up!

Björn Eriksen
Thanks I wasn't aware there was an upper limit.
bleevo
+4  A: 

You can have only one role per instance.

However, you can host Http endpoint in your worker role, effectively turning it into Web+Worker role.

References and samples:

Rinat Abdullin
+1 for useful links.
bleevo
+3  A: 

I think the terminology used in your question is confusing the other responders.

In Windows Azure compute, you have a cloud service. A cloud service can be thought of as your overall architecture, or at least the front end, the middle tier, etc (any tier where there is compute as opposed to storage). For example your application might have a presentation front end (ASP.Net MVC web application) and a middle tier (WCF service layer over basic http). We liken each of these tiers to "roles". So in my example above, I would have 2 web roles in my cloud service. I might also have some back end processing which does some sort of batch work, this would be a "role" also. Roles that respond to user interaction such as web sites, service layers, etc are hosted as "web roles" while those back end services are "worker roles".

Then we have instances. An instance is how many virtual machines are provisioned to provide the functionality of a given role. For example, I might need my presentation tier to have 5 instances because it takes a lot of load. So, my 1 web role has 5 instances. Likewise my middle tier, a service layer, might only need 3 instances (because of presentation tier caching) and so therefore my 1 web role has 3 instances. My back end service might only need 1 instance since its job can be done whenever, but if the back log gets too big, it could scale up to 10 instances to get through the work, then scale back down to 1 instance again.

So the key here is that you can have 1 or more instances per role. Because of this relationship it makes sense that you can have only one role per instance (since an instance is 'instantiated' from a single role template).

What Rinat was trying to say above was that you can cheat with the worker role and actually host a http end point in WCF, thus getting web role type behavior, however you don't get the load balancing of a web role when you do this. Likewise, a web role can have worker role style behavior by overriding the OnStart method in the WebRole.cs. However I would still argue this is just one role in both cases, and you can have multiple instances of that role.

Bjorn was indicating that by default you are capped at 20 instances per role, however you can get more (so he doesn't deserve a -1 IMHO).

Hope this clears it up.

DarkwingDuck
Yes I think you are right people are confused. I understand what a role is it just seems that in some cases 1 instance per role would be overkill, especially when the smallest instance has almost 2gb of ram. But I you have and others answered my question thanks !
bleevo