3

I am new to Windows Azure and confused about web / worker roles and instances. I plan on deploying a web application that uses WCF services for the back end. I have a few questions:

  1. Am I correct in saying that I need one web role to host the web app and another secondary web or worker role to host internal WCF services?
  2. How many instances of each should I start with? Is it a good idea to have two instances of each web / worker role i.e. incase one is unavailable?
  3. I would imagine having more than one instance also allows for automatic load balancing?
Cool Breeze
  • 1,289
  • 11
  • 34

1 Answers1

2

Am I correct in saying that I need one web role to host the web app and another secondary web or worker role to host internal WCF services?

Yes. Web Roles are suitable for hosting web applications (websites, web services etc.) and Worker Roles are suitable for hosting background applications which does not require user interaction (think of them as hosting Services like applications running on your local computer).

How many instances of each should I start with? Is it a good idea to have two instances of each web / worker role i.e. in case one is unavailable?

Yes. In fact to get SLA guarantee from Microsoft, you would need to have 2 instances of your role running.

I would imagine having more than one instance also allows for automatic load balancing?

Yes. By default all web role instances are load-balanced using round-robin load balancing. AFAIK, worker role instances are not load balanced.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Thanks for the clarification. I think if you have internal wcf services in a web role they won't be load balanced either...? – Cool Breeze Apr 02 '15 at 15:06
  • Web roles are load balanced. – Gaurav Mantri Apr 02 '15 at 15:10
  • It's not strictly necessary to have separate roles if you don't need to scale them separately http://stackoverflow.com/q/6266560/57428 – sharptooth Apr 02 '15 at 15:46
  • 1
    @GauravMantri have a look at this post here: http://stackoverflow.com/questions/10747863/how-to-host-wcf-service-programmatically-on-azure/10747994#10747994 If they are on a internal endpoint they will not be load balanced? – Cool Breeze Apr 03 '15 at 03:56
  • @sharptooth I wasn't aware that you could actually do that might be worthwhile to start off like that and save some $$$ do you have any links to on how to do this? – Cool Breeze Apr 03 '15 at 03:57
  • 1
    @CoolBreeze You don't need any links for that. Just put the infinite loop from the worker role `Run()` into the web role `Run()`. The deal is a web role is a worker role with IIS enabled, that's all the difference. – sharptooth Apr 03 '15 at 07:01
  • Makes sense but what if I want to have a wcf service web role and website in a single web role? – Cool Breeze Apr 03 '15 at 07:04
  • @CoolBreeze I haven't tried this myself, but I guess you can configure them on different ports and open up two different endpoints for them. – sharptooth Apr 03 '15 at 07:07