Q25. What is a Worker role?

A Worker role instance is also a VM instance just like a Web role instance. The Worker role instance runs only windows server OS and is not loaded with IIS.

Worker roles are best suited for hosting backend processing and a wide variety of web services. A Worker role once started, keeps running all the time just as a Windows Service. To keep it running, the worker role uses a simple while (true) loop. Some of the tasks which can be performed using worker roles are transaction processing, processing of images and processing of datasets etc. Applications which do not require IIS can be hosted in the worker roles, which are usually backend processing applications.

worker role in a cloud application

Refer above figure. You will observe that there is a box on the left side and one on the right side. The right one is an instance of a worker role Virtual machine. The operating system windows server is installed on this VM instance and an application is hosted on this worker role instance. The worker role instance is a back end of a cloud application and can take data from a queue placed by web role and process it. The worker role persists data in Windows Azure Storage or SQL database.

Important words:


Persist data in this context is attempting to save data till another action happens. Note that persistent data means data which is not regularly accessed.