SYS-CON MEDIA Authors: Zakia Bouachraoui, Liz McMillan, Carmen Gonzalez, Roger Strukhoff, David Linthicum

Blog Feed Post

Understanding Windows Azure Runtime: Part II


In part I of the article, I introduced the concepts and terminology of Windows Azure runtime. In this part, we will take a closer look at the Roles and the way to control the lifecycle of the Roles.

Most of the modern applications are logically partitioned into individual layers. Each layer is responsible for a specific function. UI rendering, business logic, data access and database are the common layers of these applications. These layers may or may not be running on dedicated machines. For maximum scalability, each layer can run on a cluster of machines or all these layers can be running on the same machine. Windows Azure Roles are modeled around these application layers or tiers. Each role instance is actually a dedicated Azure VM. Based on the role, the VM is customized for specific tasks.

Let’s understand more about Windows Azure Roles.

  • Web Role– This is a VM that is designed to primarily host web applications. Whatever layer you host on IIS can be easily moved into the Web Role. As of now, Web Role runs the Hosted Web Core (HWC) to host web applications. That’s the reason why you cannot host multiple websites within one Web Role. Going forward, Web Role will support IIS 7.x and this brings parity with the on-premise deployment scenarios. Web Role can also host WCF services and CGI applications like PHP and Perl. They only support HTTP/S based communication.
  • Worker Role – This Role is typically mapped to the application tier or the business logic layer of the application. Though Worker Roles can expose TCP, HTTP/S endpoints, they are mostly reached via the Web Role. Worker Role will never have any UI and does the ‘heavy lifting’ required by the application. They can execute external processes and act as a surrogate process for legacy executables. Worker Roles are used to bootstrap other runtimes like Java and Python. They can also host databases like MySQL or MongoDB and expose the ports of these database servers as external endpoints.
  • VM Role – This is the new Role that got announced at PDC 2010. This is used to host legacy applications that do not fit into Web Role or Worker Role. We will get more details once the VM Roles go into the CTP mode. Since it is too early to include this in the discussion, I am not going to discuss this in detail.

Lifecycle of Role Instances

The lifecycle of the role is managed by the Windows Azure runtime. There are certain implicit and explicit factors that may force the runtime to reboot or re-launch the role instances. Implicit factors are internal to Azure environment and explicit factors are those that are initiated through the change in configuration files or by performing an in-place upgrade. As developers, it is important for us to know when the instance is going to be recycled and how to gracefully handle these changes.

Worker Roles implement an abstract class called RoleEntryPoint. This is optional for Web Roles but is mandatory for Worker Roles. RoleEntryPoint is the prescriptive interface between the Windows Azure Runtime and the Role instances. This interface has three methods – 1) OnStart(), 2) Run() and 3) OnStop(). During the initialization of a Role, the OnStart() method is called. To ensure that the Role is ‘awake’ all the time, there is a while(true) construct in the Run() method. This is comparable to the static void main() method in a classic C# program. After exiting from the Run() method, the Windows Azure environment calls the OnStop() method. This is where the cleanup code will be placed. Implementing RoleEntryPoint class is optional in a Web Role because of a few reasons. Web Roles function in a typical Request/Response pattern and may not long running processes. Web Roles also rely on ASP.NET lifecycle management methods for initialization and clean up. Technically, Web Roles can be forced to act like Worker Roles by implementing the RoleEntryPoint class and overriding the required methods. This is particularly useful in scenarios where an extra Worker Role is not required and the Web Role can easily manage few other tasks including processing messages. Steve Marx has written an excellent post discussing the scenario for combining roles.

By overriding the methods of RoleEntryPoint we can make Worker Roles very efficient and intelligent. Within the OnStop() method, the state of the Role can be dumped into a Azure Table. During the startup phase of the Worker Role, we can read the previous state of the application from an Azure Table and continue from the same point where the last execution was left. It is entirely possible to externalize the tasks of Worker Role to Azure Storage and every time the Worker Role boots, it will learn what it is supposed to execute by querying an external state machine. This will be the basis of building efficient Map/Reduce scenarios on Windows Azure.

Generic Worker Role

Windows Azure Runtime also offers mechanism to intercept and control the reboot of the Roles. This done by subscribing to the RoleEnvironment.Changing, RoleEnvironment.Changed and RoleEnvironment.Stopping events. By detecting the factor that forced the event to take place, we can either reboot and cancel the reboot and continue with the process. I will cover the factors and conditions that typically force a reboot in a separate article.

I want to summarize this article with a few tips on leveraging the RoleEntryPoint and RoleEnvironment classes –

  • OnStart()
    • Wire-up event handlers in the OnStart() method
    • Initialize Azure storage and perform mandatory check of resources
    • Initialize Windows Azure Diagnostics
  • Run()
    • Never exit the Run() method as the OnStop() method is called immediately and the Role will be terminated
    • Try to parallelize and multithread the operations in the Run() method
  • OnStop()
    • Only perform quick cleanup in OnStop() that doesn’t take too long
    • The method must return within 30 sec. or there will be a forced shutdown

Hope you found this article useful! If you have any questions/queries, feel free to drop a comment.

Read the original blog entry...

More Stories By Janakiram MSV

Janakiram MSV heads the Cloud Infrastructure Services at Aditi Technologies. He was the founder and CTO of Get Cloud Ready Consulting, a niche Cloud Migration and Cloud Operations firm that recently got acquired by Aditi Technologies. In his current role, he leads a highly talented engineering team that focuses on migrating and managing applications deployed on Amazon Web Services and Microsoft Windows Azure Infrastructure Services.
Janakiram is an industry analyst with deep understanding of Cloud services. Through his speaking, writing and analysis, he helps businesses take advantage of the emerging technologies. He leverages his experience of engaging with the industry in developing informative and practical research, analysis and authoritative content to inform, influence and guide decision makers. He analyzes market trends, new products / features, announcements, industry happenings and the impact of executive transitions.
Janakiram is one of the first few Microsoft Certified Professionals on Windows Azure in India. Demystifying The Cloud, an eBook authored by Janakiram is downloaded more than 100,000 times within the first few months. He is the Chief Editor of a popular portal on Cloud called www.CloudStory.in that covers the latest trends in Cloud Computing. Janakiram is an analyst with the GigaOM Pro analyst network where he analyzes the Cloud Services landscape. He is a guest faculty at the International Institute of Information Technology, Hyderabad (IIIT-H) where he teaches Big Data and Cloud Computing to students enrolled for the Masters course. As a passionate speaker, he has chaired the Cloud Computing track at premier events in India.
He has been the keynote speaker at many premier conferences, and his seminars are attended by thousands of architects, developers and IT professionals. His sessions are rated among the best in every conference he participates.
Janakiram has worked at the world-class product companies including Microsoft Corporation, Amazon Web Services and Alcatel-Lucent. Joining as the first employee of Amazon Web Services in India, he was the AWS Technology Evangelist. Prior to that, Janakiram spent 10 years at Microsoft Corporation where he was involved in selling, marketing and evangelizing the Microsoft Application Platform and Tools.

Latest Stories
Moroccanoil®, the global leader in oil-infused beauty, is thrilled to announce the NEW Moroccanoil Color Depositing Masks, a collection of dual-benefit hair masks that deposit pure pigments while providing the treatment benefits of a deep conditioning mask. The collection consists of seven curated shades for commitment-free, beautifully-colored hair that looks and feels healthy.
The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
We all love the many benefits of natural plant oils, used as a deap treatment before shampooing, at home or at the beach, but is there an all-in-one solution for everyday intensive nutrition and modern styling?I am passionate about the benefits of natural extracts with tried-and-tested results, which I have used to develop my own brand (lemon for its acid ph, wheat germ for its fortifying action…). I wanted a product which combined caring and styling effects, and which could be used after shampo...
The precious oil is extracted from the seeds of prickly pear cactus plant. After taking out the seeds from the fruits, they are adequately dried and then cold pressed to obtain the oil. Indeed, the prickly seed oil is quite expensive. Well, that is understandable when you consider the fact that the seeds are really tiny and each seed contain only about 5% of oil in it at most, plus the seeds are usually handpicked from the fruits. This means it will take tons of these seeds to produce just one b...
Steaz, the nation's top-selling organic and fair trade green-tea-based beverage company, announces its 2017 "Mind. Body. Soul." tour, which will bring authentic experiences inspired by the brand's signature Mind. Body. Soul. tagline to life across the country. The tour will inform, educate, inspire and entertain through events, digital activations and partner-curated experiences developed to support the three pillars of complete health and wellness.
The platform combines the strengths of Singtel's extensive, intelligent network capabilities with Microsoft's cloud expertise to create a unique solution that sets new standards for IoT applications," said Mr Diomedes Kastanis, Head of IoT at Singtel. "Our solution provides speed, transparency and flexibility, paving the way for a more pervasive use of IoT to accelerate enterprises' digitalisation efforts. AI-powered intelligent connectivity over Microsoft Azure will be the fastest connected pat...
There are many examples of disruption in consumer space – Uber disrupting the cab industry, Airbnb disrupting the hospitality industry and so on; but have you wondered who is disrupting support and operations? AISERA helps make businesses and customers successful by offering consumer-like user experience for support and operations. We have built the world’s first AI-driven IT / HR / Cloud / Customer Support and Operations solution.
ScaleMP is presenting at CloudEXPO 2019, held June 24-26 in Santa Clara, and we’d love to see you there. At the conference, we’ll demonstrate how ScaleMP is solving one of the most vexing challenges for cloud — memory cost and limit of scale — and how our innovative vSMP MemoryONE solution provides affordable larger server memory for the private and public cloud. Please visit us at Booth No. 519 to connect with our experts and learn more about vSMP MemoryONE and how it is already serving some of...
Darktrace is the world's leading AI company for cyber security. Created by mathematicians from the University of Cambridge, Darktrace's Enterprise Immune System is the first non-consumer application of machine learning to work at scale, across all network types, from physical, virtualized, and cloud, through to IoT and industrial control systems. Installed as a self-configuring cyber defense platform, Darktrace continuously learns what is ‘normal' for all devices and users, updating its understa...
Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
As you know, enterprise IT conversation over the past year have often centered upon the open-source Kubernetes container orchestration system. In fact, Kubernetes has emerged as the key technology -- and even primary platform -- of cloud migrations for a wide variety of organizations. Kubernetes is critical to forward-looking enterprises that continue to push their IT infrastructures toward maximum functionality, scalability, and flexibility. As they do so, IT professionals are also embr...
Platform9, the leader in SaaS-managed hybrid cloud, has announced it will present five sessions at four upcoming industry conferences in June: BCS in London, DevOpsCon in Berlin, HPE Discover and Cloud Computing Expo 2019.
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
When you're operating multiple services in production, building out forensics tools such as monitoring and observability becomes essential. Unfortunately, it is a real challenge balancing priorities between building new features and tools to help pinpoint root causes. Linkerd provides many of the tools you need to tame the chaos of operating microservices in a cloud native world. Because Linkerd is a transparent proxy that runs alongside your application, there are no code changes required. I...