Multiple work roles in one instance

How to configure Windows Azure for multiple employee roles in one instance? Is it possible?

+7
source share
3 answers

I think you misunderstood what a working role is. Web and worker roles are Windows Server virtual machines, the main difference between which is that IIS acts as a web role. You can have multiple instances of each.

In fact, there is no such thing as "multiple work roles in one instance." Think about the role of the worker as a template for your virtual machine: startup scripts and event handling code for processing messages such as startup and shutdown, as well as the code you write that is packaged and run inside the virtual machine.

From OnStart() or Run() you can run almost any code you want. Delete multiple threads, run server code (e.g. Tomcat), etc. No matter what code you run in each instance. As you scale to multiple instances, the same virtual machine template is used for each of these instances.

See this answer for a bit more details.

+8
source

As David mentioned in his answer, you can start multiple threads. One of my clients did this using the ThreadedRoleEntryPoint class.

This class allows you to use several classes of workgroup entry points (even from several assemblies) and run them in the same role:

  public override void Run() { Trace.TraceInformation("WebRole::Run begin", "Information"); List<WorkerEntryPoint> workers = new List<WorkerEntryPoint>(); workers.Add(new Worker1()); workers.Add(new Worker2()); base.Run(workers.ToArray()); Trace.TraceInformation("WebRole::Run end", "Information"); } 

The advantage is that you can start small and run all work roles (not work roles, but let them handle processes or workers) in one role (which you are actually deploying).

Then, when your business begins to grow, you can begin to use the allocated roles, which means that you will have at least 1 instance running as a worker. And when this should happen, the impact on your code will be minimal, as the workers passed ThreadedRoleEntryPoint to inherit from WorkerEntryPoint, which is very similar to the RoleEntryPoint class.

+5
source
-2
source

All Articles