Can we have a worker Role and a web role in a single instance of Azure Cloud Services
S

2

1

I am just about to move my website, database and a background scheduler onto the Azure platform.

I've to use cloud services with web & worker role. Now my question is that do I need separate instances for each type of role, or one instance is capable of hosting multiple types of role ?

Setting answered 4/3, 2013 at 22:13 Comment(1)
P
3

You cannot have a combined web and worker role instance. It can be one or the other. However, it is possible to have the web role do background processing, so it can host the background workload.

See this SO question for a couple of options

Azure WebRole Scheduled Task Every Morning

That talks about running a task each morning. Obviously you can do it more frequently, as appropriate for your application.

Be aware of the scalability limitations of this though. Once your traffic ramps up, it will make sense to break it out into separate web and worker roles.

In fact, even if your background workload is light, it might still make more sense for you to go for a separate architecture from the start and use XS instances for the background processing.

Pathfinder answered 4/3, 2013 at 22:30 Comment(1)
Thanks. There was another post which clarified this in detail. #3583098Setting
S
2

Technically you can't have a role of both types. Yet a web role is just the same as a worker role, it just has IIS configured. So you can merge them into one web role - IIS will run in a separate process and role entry point Run() will run some endless loop for "backend" processing. See this similar question.

This will make scaling more complicated. The whole idea of separate roles (remember you can have not only one web role and one worker role, you can have for example four worker roles and two web roles if that's appropriate for your solution) is that you can scale them separately.

It looks like once you merge two roles into one you no longer can fine scale them. This is not true most of the time - you just have to change metrics.

For example, you wanted to run one web role instance for each thousand HTTP requests per minute and one worker role instance for each ten requests in the backend queue. Okay, this means that each thousand HTTP requests needs the same amount of processing power as ten items in the backend queue. So you craft a new metric that takes both parameters and deduces a number of instances. Like you have five thousand requests per minute and twenty requests in the backend queue - you need seven instances of am merged role.

This won't work for all applications, but most of them will use this approach just fine. The bonus is that you avoid cases when either of the roles in idling because the current load gets onto another role.

Sharpnosed answered 5/3, 2013 at 6:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.