SYS-CON MEDIA Authors: Yeshim Deniz, Roger Strukhoff, Jason Bloomberg, Pat Romanski, Liz McMillan

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
In his session at 23rd International CloudEXPO, Raju Shreewastava, founder of Big Data Trunk, will provide a fun and simple way to introduce Machine Leaning to anyone and everyone. Together we will solve a machine learning problem and find an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/busine...
CloudEXPO has been the M&A capital for Cloud companies for more than a decade with memorable acquisition news stories which came out of CloudEXPO expo floor. DevOpsSUMMIT New York faculty member Greg Bledsoe shared his views on IBM's Red Hat acquisition live from NASDAQ floor. Acquisition news was announced during CloudEXPO New York which took place November 12-13, 2019 in New York City. Our Silicon Valley 2019 schedule will showcase 200 keynotes, sessions, general sessions, power panels, and...
ShieldX's CEO and Founder, Ratinder Ahuja, believes that traditional security solutions are not designed to be effective in the cloud. The role of Data Loss Prevention must evolve in order to combat the challenges of changing infrastructure associated with modernized cloud environments. Ratinder will call out the notion that security processes and controls must be equally dynamic and able to adapt for the cloud. Utilizing four key factors of automation, enterprises can remediate issues and impro...
Intel is an American multinational corporation and technology company headquartered in Santa Clara, California, in the Silicon Valley. It is the world's second largest and second highest valued semiconductor chip maker based on revenue after being overtaken by Samsung, and is the inventor of the x86 series of microprocessors, the processors found in most personal computers (PCs). Intel supplies processors for computer system manufacturers such as Apple, Lenovo, HP, and Dell. Intel also manufactu...
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...
BMC has unmatched experience in IT management, supporting 92 of the Forbes Global 100, and earning recognition as an ITSM Gartner Magic Quadrant Leader for five years running. Our solutions offer speed, agility, and efficiency to tackle business challenges in the areas of service management, automation, operations, and the mainframe.
The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait for long development cycles that produce software that is obsolete at launch. DevOps may be disruptive, but it is essential. DevOpsSUMMIT at CloudEXPO expands the DevOps community, enable a wide sharing of knowledge, and educate delegates and technology providers alike.
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...
Cloud-Native thinking and Serverless Computing are now the norm in financial services, manufacturing, telco, healthcare, transportation, energy, media, entertainment, retail and other consumer industries, as well as the public sector. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait for long development cycles that pro...
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...
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...
OpsRamp is an enterprise IT operation platform provided by US-based OpsRamp, Inc. It provides SaaS services through support for increasingly complex cloud and hybrid computing environments from system operation to service management. The OpsRamp platform is a SaaS-based, multi-tenant solution that enables enterprise IT organizations and cloud service providers like JBS the flexibility and control they need to manage and monitor today's hybrid, multi-cloud infrastructure, applications, and wor...
Apptio fuels digital business transformation. Technology leaders use Apptio's machine learning to analyze and plan their technology spend so they can invest in products that increase the speed of business and deliver innovation. With Apptio, they translate raw costs, utilization, and billing data into business-centric views that help their organization optimize spending, plan strategically, and drive digital strategy that funds growth of the business. Technology leaders can gather instant recomm...
The Master of Science in Artificial Intelligence (MSAI) provides a comprehensive framework of theory and practice in the emerging field of AI. The program delivers the foundational knowledge needed to explore both key contextual areas and complex technical applications of AI systems. Curriculum incorporates elements of data science, robotics, and machine learning-enabling you to pursue a holistic and interdisciplinary course of study while preparing for a position in AI research, operations, ...
After years of investments and acquisitions, CloudBlue was created with the goal of building the world's only hyperscale digital platform with an increasingly infinite ecosystem and proven go-to-market services. The result? An unmatched platform that helps customers streamline cloud operations, save time and money, and revolutionize their businesses overnight. Today, the platform operates in more than 45 countries and powers more than 200 of the world's largest cloud marketplaces, managing mo...