Previously, I have written about cloud applications and how the distributed environment works. In this article I want to get a little more in-depth with how these multi-computer or multicore environments work from a development point of view. I will look at some of the mechanics that help with scalability, reliability and load balancing. Through better knowledge of the platform, you will be able to develop applications, have a better understanding of the environment, how it works and how you can write your cloud-based applications to take advantage of it.
In a previous article, I discussed the four areas that programmers need to focus on when designing and writing cloud-based applications in order to take advantage of the features of the environment. These four areas were:
While I covered each area in depth, it may not be clear how these features help you in the cloud environment. Since applications in the cloud perform differently from the underlying architecture it helps to have an understanding of that architecture so that you can take advantage of capabilities such as scaling, load balancing, availability, reliability, etc…Here we will have a look at how these systems work and create these benefits.
The Cloud Platform
The cloud platform is broken down into simple architectural layers.
As you can see from the above figure, the cloud is broken down into three layers: Application, Platform and Infrastructure. Some products may touch more than one layer, and it is important to remember they are interconnected, but it is good to have a visual idea of where these applications reside in the “big picture”.
Starting at the bottom, the infrastructure layer is where infrastructure-as-a-service (IAAS) offerings reside. These features are usually virtualized systems and on-demand computing services such as Amazon EC2, which is a web service that provides resizable computing capacity in the cloud. It is designed to make web-scale computing easier for developers. In this domain, the user can request Linux and Windows based systems on the fly to be able to scale up their computing power for a particular task. These virtual machines can have associated resources and configurations but the user does not always know anything about the hardware, physical location or other parameters.
In the platform area, platform-as-a-service (PAAS) services allow developers to take a platform-oriented approach in which cloud applications run atop the underlying cloud infrastructure. This allows applications to abstract away from the infrastructure and the cloud provides support services and functionality for those applications. This is where the majority of the benefits of using cloud computing takes place, so we will look at each one of these areas.
Examples of the PAAS approach would be Google’s App Engine (GAE) and Saleforce’s Force.com. In both of these examples, users are only concerned with the application they are running on the platform. Applications are packaged to run in the particular cloud environment and deployment happens as a single step. As a user of the application, it would be transparent how the application is being run whether on one physical machine or 10 virtual machines at any given time. Since the platform layer provides services to these hosted applications, they can take advantage of services such as authentication or data access to further enhance their functionality.
The benefit of this service is mainly to the developer. They no longer have to worry about the underlying hardware that their application is running on. You do not have to worry about implementing scalability and reliability features since the clouds distributed environment will handle that for you. The programmer’s focus is now on the business logic of the application while the cloud manages lifecycle and virtualization problems.
However, what most people do not realize is there is a difference between PAAS and Cloud Platform applications. Cloud platforms allow the developer to focus only on the application problems and nothing else. They will often offer some of the same features of PAAS but there is a key difference in deployment, portability across cloud infrastructures and the use of tools. Typical cloud platforms will allow you the flexibility to choose languages, tools and IDEs.
Remember from the previous article, that in order for the cloud platform to do its best for your application, your code should be atomic, stateless, idempotent and parallelizable. This allows for the platform to do the heavy lifting with its powers of distributed computing that are otherwise hard to achieve in code.
Cloud Platforms – Scaling
There are different forms of scaling that can happen in the cloud computing platform. Horizontally, your application can scale out between many servers (also known as workers) when transaction loads are high. When loads drop down again, you can reduce the number of workers which can be turned over to other applications that may need them.
The ambiguity for programmers is often the idea that “your code doesn’t know it’s in the cloud”. None of these scalability features need to be implemented in the code. The code only needs to be designed well to function in this kind of environment. This same idea applies when scaling across multiple cores. If your code has been written with the basic principles previously outlined, you will be able to use the platform capabilities to scale up and down gracefully.
Cloud Platforms – Availability
Availability is the idea of having the code available and ready to execute at any given time. Cloud platforms can distribute your code across the cloud and use its resources to keep the parts of your application available when it’s needed. Depending on the platform your code may reside on all workers so that any worker can implement a process at any time. Sometimes, all of the processing for a transaction will take place on one worker. This makes your code highly available and responsive.
When we have atomic and stateless code, then the code can reside anywhere the cloud wants to put it and it will be available when needed. This is the ideal setup since a computer worker could die at any time and your processes may have to be shunted around to keep the same level of availability. No one worker is more important than any other worker and other nodes can always fulfill a request.
Cloud Platforms – Reliability
Reliability happens when code can recover from problems or errors and the requested work still gets done. The environment should be designed to help recover from problems or errors without giving up and dying or losing the work.
There are different models for providing reliability, depending on your cloud provider. You may be able to define how you want reliability to behave during runtime. The benefit that the cloud platform is providing is the management of this reliability. Having to code reliability into distributed applications without the processes to “manage” them can be a very difficult task.
Here is an example: The user has made a request. The request is sent to the available worker but a failure occurs. The worker suffers a hardware failure and cannot complete the request. The cloud platform then detects the failure and (depending on your configuration) retires the request on a different worker. This process will repeat itself until the request has been successfully handled instead of just returning to the user with a failure. You can also configure the threshold for the maximum number of tries before a failure is reported to the user.
This is where our principles of writing cloud applications really come into play. Since the cloud may have to retry the request several times to get a successful response, we cannot have our code performing state management tasks or performing in a way that is non-atomic. Without programming our applications with this in mind, we are limiting our platform capabilities and our options when recovering from failure. We do not want our application having to go back to the beginning in a series of steps to perform an action instead of just picking up at the point of failure.
Cloud Platforms – Manageability
As we move into a distributed environment, it can be more complex for the developer to deploy and manage code in the runtime environment. Cloud platforms take this into account and attempt to make this a smooth and easy process so that developers working on cloud applications are not burdened with extra overhead during the development process. When testing applications in the cloud, you can choose to test only on one server and if you want to do your development locally, you can do so using your own development tools. This is often not the case with any PAAS environments.
Depending on your cloud platform provider, your deployment scenario may be different so I won’t get into that. However, it can be noted that the management of cloud based applications often takes less administration time due to the ease of use of the cloud platform tools. As your application scales, your administration time and/or staff, doesn’t have to.
Cloud Platforms – Load Balancing
Cloud platforms use various types of load balancing and can take the form of software- or hardware-based load balancing between the application and the client or the cloud could be using its own built-in software-based load balancing process. Since load balancing affects our scalability and reliability, we want to be sure that our resources of each worker are being fully utilized when needed. It doesn’t help to have workers that are under-utilized when your application is under heavy load.
This situation is straight-forward with a cloud of servers all the same speed and capacity but instantly becomes more complex when the cloud is made up of various types of server nodes. Some cloud platforms take care of this for you. Do you not want your application to be slowed down by the slowest of your nodes, so it is important to take this idea into account and not let slower machines try to handle more than they are capable of. Utilize the stronger of your pack to carry the heavy loads and keep the worker processes balanced across your nodes for greater stability.
There are differences in cloud platforms from provider to provider, so it is important to understand the requirements of your application and what you are looking for before choosing a particular one. Typically a cloud platform provider will hide the cloud infrastructure from your application so it can be independent, virtualizes your application so it can be managed in the cloud and leverages some of the features of availability and reliability as well as provides the tools and services necessary to prevent you from having to do any of the hard work.
Hopefully you now have a thorough understanding of cloud platforms and how you can become a better developer when designing code to work on these platforms. Leveraging the features available will allow your applications to work better and smarter as technology in cloud computing continues to grow.
Help us spread the word!
If you liked this article, consider enrolling in one of these related courses:
|Jun 27||Cloud Computing Introduction|
|Aug 08||Cloud Computing Introduction|
|Sep 27||Cloud Computing Introduction|
|- Classroom - Online|