Multiple roles on the same instance in Windows Azure
Asked Answered
S

4

19

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?

Siegbahn answered 18/2, 2012 at 17:40 Comment(0)
G
14

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.

Glossographer answered 18/2, 2012 at 18:27 Comment(1)
If I deploy all my websites and wcf services as a webrole in one instance - I can't redeploy parts of the system? Correct? For example if I want to make change in WCF services - I have to redeploy all: wcf services and website?Siegbahn
C
7

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)

Citric answered 18/2, 2012 at 18:12 Comment(3)
This is not strcitly true. as 'user728584' pointed out a web role is always also a worker role. now - I don't necessarily thing it's a good idea to combine the two - but it certainly is possible as every web role as a Run() method - 31a2ba2a-b718-11dc-8314-0800200c9a66.com/2010/12/…Cricoid
Combining web and worker roles is a hack. Is the definition of a role the .NET assembly or how the Azure fabric deals with it? While examples show that it seems to work, you have to understand how the fabric handles shutdowns, recycles, monitoring etc. I don't understand those details but suspect that there are, em, 'issues'Citric
The definition of Role is "virtual machine." And there is no hack, combining functionality into a single server (whether physical or virtual). People have been doing that for years. In Windows Azure, it comes down to your degree of scalability and availability. It's no hack to run a website and background tasks in a single role with multiple instance, just like it's not a hack to separate functionality into separate VMs, each scaled independently.Glossographer
B
4

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

Bergin answered 19/2, 2012 at 7:42 Comment(0)
W
2

Check out this blog post 'Combining Multiple Azure Worker Roles into an Azure Web Role' http://www.31a2ba2a-b718-11dc-8314-0800200c9a66.com/2012/02/combining-multiple-azure-worker-roles.html

I think this is what you need to do...

Also Wayne has variations of this on his blog: http://www.31a2ba2a-b718-11dc-8314-0800200c9a66.com/2010/12/how-to-combine-worker-and-web-role-in.html

HTH

Whereto answered 18/2, 2012 at 18:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.