Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Workerrole lifecycle

Is the Windows Azure operating system restarting or reseting a running worker role automatically from time to time? Or can I rely on the fact that my Worker role is running infinitely if I have a loop in the Run() method?

like image 243
odehne Avatar asked Oct 10 '22 13:10

odehne


2 Answers

Role instances (whether Worker or Web) are recycled at least once monthly, as the Guest OS is updated on a monthly basis. The Host OS is refreshed on a quarterly basis, potentially resulting in additional role recycles (assuming Host and Guest updates are performed separately).

Having said that: You can choose to not be auto-updated to the latest Guest OS, by specifying a Guest OS version to use. You cannot opt out of Host OS updates.

In general, you should not rely on a role instance running infinitely. You need to assume there will be reboots in your future. Aside from Host OS updates, there are hardware failures that can and will occur.

See here for more information about Guest OS updates, and here for Host OS updates.

like image 55
David Makogon Avatar answered Oct 20 '22 17:10

David Makogon


In no event can you rely on the host machine running continuously - it will be sometimes stopped for updates and it can crash for whatever reason. So your code should be aware and set checkpoints periodically and be able to resume.

So yes, you can have a while( true ) doStuff() loop, but you have to design your code so that its operations that affect global storage - SQL Azure, blobs, queues and tables - leaves that storage in consistent state at all times. This way should your loop be interrupted (by a crash or by an exception for aborting the thread it is running on) your code can resume once the role is restarted.

like image 38
sharptooth Avatar answered Oct 20 '22 15:10

sharptooth