We are experiencing a period of several "new orders", either in the economic, social, environmental and increasingly also in technology. Life takes on every day new dynamic and greater speed, and with it processes and tools get evolved.
One of these new technological concepts that have been emphasized is called Cloud Computing. This concept has gained great maturity in the market and as new solutions arise, becomes more accessible to the developer the experimentation and also the use in day-to-day.
It is these new possibilities, and how they are now available to us, including free, we will address in this article. Using the example of the practical OpenShift platform, Red Hat, we will publish completly a Java application on the internet and give subsidies so that the reader may have to Cloud Computing in its portfolio of knowledge for future (and current) projects.
Collaboration as revolution
As a society, we have already experienced various eras, quote: Agricultural Age, Industrial, Information, and more recently, the era of collaboration.
Never before has information been so abundant and affordable, new communication and interaction solutions arise all the time, proposed either by large players already consolidated in the market, sometimes by small businesses and startups.
This is what happened with Facebook, Twitter, FourSquare and many others. Imagine these three companies trying to launch their applications for 15 years? The investment in infrastructure they need, and Internet bandwidth; and even the possibilities related to web usability - what were the capabilities of mobile devices that time? It is not impossible to imagine that inevitably (and most likely) they would not have had the same success.
We still live several other new demands: more and more consumers have access to the network, whether to buy products either to operate online services Internet Banking, Government Services and, of course, all means of contact and integration that companies are seeking to create new channels of communication with people. How often do you access a portal of news, and soon after reading the content, you have the option to "share"?
If the hearing of applications grows in scale of new customers, as we have enough room to fit all of this (new) demand? Cloud Computing can bring many benefits, especially for those who have an idea on paper and want to make it a reality with a few clicks and commands, without spending much (or even no) money.
Cloud: A Brief Introduction
Define Cloud is something delicate, as you will find on Google more than 50 definitions that, more than completely valid, are often complementary. Depending on the perspective, Cloud may have different nuances: for Infrastructure Administrator focusing on Operating System, Cloud can be a virtual machine provided and managed by a virtualization tool. As for a Software Developer, Cloud can also be an elastic model, which aims to give more processing resources when they are needed, and of course, also fewer resources as they are not as necessary. For a Professional Business, Cloud can take a quiet "non-technical" summarized as "serving well and always."
Although we have covered some perspective, it is noteworthy that there is also the concept of "pay for what is consumed" (pay-as-you-go), that is, if you have high number of users, will need more resources (processing, memory, storage, etc.), so will somehow pay more for it; whereas if your application does not consume many resources, you will not take up so much room, then pay somehow less for it.
When we talk about this perspective on Cloud, it is impossible not to associate the provision, for example, electricity. In general, consumers do not have the slightest idea where cables pass, how many lines the electricity went through to get to their homes or even where their electricity comes from. In short, they want to simply turn on the light, for this to work whenever you want, and that you can pay for the consumed. Cloud providers emulate the same behavior and, more failures occur, they should remain hidden and contoured so that the consumer always has its contracted services transparently.
Cloud Deployment Models
The Cloud models available on the market in bulk are generally:
- Private Cloud: Usually it is the first model to be adopted when companies start their first initiatives in Cloud Computing. In order to maximize the use of your physical servers (often longstanding investment but not yet paid), companies begin to divide them into logical portions, in other words, in virtual machines being managed by a virtualization tool. These machines can be physically in the company, or they may be in another location through a co-location model - a datacenter ensures that some physical machines are dedicated to atend the demands of the contractor, and these exclusive use of machines of those who hired; in turn, the company that subscribes to this service can also begin to virtualize/partition these machines, to better atend their demands;
- Public Cloud: This is the most commonly available in the market nowadays model. It is the model where the public cloud provider offers an environment we call "multi-tenant". In this type of environment each "tenant" has a secluded and protected virtual machine, sharing a physical machine with several other contractors. This virtual machine can have an elastic capacity and can increase or decrease the processing power on demand through administration tools;
- Hybrid Cloud: When your Private Cloud capacity is not sufficient to meet your demands, you can provision your environment as needed. This means you will combine the power of your Private Cloud with one or more public clouds, giving it more elasticity.
Offers types of Cloud services
Once we understand the adoption of models, it is also important to define the types of service offerings we have available. While in Private Cloud tools can be defined as the customers' own policies, Public Clouds have some kind of pre-established services. To make you understand what we can find on the shelf today, we will introduce them below:
- IaaS (Infrastructure as a Service) - This is the model where you have complete control of the available virtual machine resource.
Just as you have all the power and right of the Administrator user (root), you also have the responsibility to install everything needed to suit your application - from the database, application server, among others - and also take care of all issues and safety aspects.
As an example of these providers of IaaS services, include: Amazon EC2, RackSpace, etc;
- PaaS (Platform as a Service) - When the supplier has the services and software you need already installed and running. Once in the IaaS model, you should take care to install everything from scratch, in PaaS you have some combinations already pre-built, causing you worry more with the business and implementation of its proper application than with the installation of an application server, database, and so on. In short, PaaS offers already prepared the environment for you to install ("deploy") applications without major concerns. Among the suppliers of this category of solutions, we can mention the Microsoft Azure, Heroku and Red Hat OpenShift, which will be the PaaS we will dive into this article;
- SaaS (Software as a Service) - In this mode you don't even care of installing your software, since the supplier already shown you everything ready.
The whole issue of databases, security and the application itself is offered in a single contract or agreement. In this model, while that offers convenience, you also receive almost no control plus some parameterization or customization, once you have to trust that your supplier will take good care of the information of its users, your data and ensure application availability. In this model we have vendors like SalesForce, which offers one of the most widely used CRMs in the market, and Google, with its collaboration solutions like Google Docs and Google Apps.
If we were to create a pyramid to symbolize the control you have on the environment in each of these offers, we would have something like Figure 1.
Figure 1. Control you have in each of the types of Cloud services..
If we consider just the fact you do not want to worry about infrastructure, but have the possibility of management on their application and data in the cloud, then the SaaS model is what will give you the tranquility of more assertively.
The choice of one of these service models takes into account several factors, so you should evaluate which scenario best fits your company and/or project. In this article, let's dive into the Red Hat OpenShift, which is a PaaS that supports the development environment Java EE 6.0 through JBoss AS 7. The intention is that in the end of this article you will be able to develop their applications and publish them to the world through cloud!
OpenShift: A brief story
With the acquisition of Makara California company in 2010 and the hiring of new employees with experience in cloud computing, Red Hat accelerated its entry into the PaaS market. In the annual event, held in Boston in early 2011 (the Red Hat Summit), was officially launched OpenShift. Since then, this platform is only gaining more and more fans, users and features.
First contact with OpenShift
To start, you need to register on OpenShift through the site http://openshift.redhat.com by accessing the Sign In option. If you already have an account, simply enter the username and password, otherwise, choose the option "Click here to register". See Figure 2.
Figure 2. Authentication window or creating a new account in openshift.redhat.com.
By registering you will receive, IN the informed email, all information concerning your account, besides the activation link in the same. Remember, you don't need to pay anything at all for this. The accounts in OpenShift yet have no cost or even forecast for this.
OpenShift aims to offer three modes of use for consumers. Of these, two are already currently available:
- OpenShift Express: Applications in the Express model have some disk space limitations (currently 512MB) and hardware resources (memory, processing), since this is a multi-tenant environment, free, and good relations between application environments must exist. However, these limitations do not prevent you to create rich applications with access to databases such as SQLite and MySQL to, or to make sure your application to access a database or NoSQL solution available on the internet. Democracy is an important factor in OpenShift Express, since many technologies are supported, as well as their frameworks that facilitate the development and use of them. Next we explicit supported languages and some of its frameworks:
OpenShift Express environment offers a Git repository for your applications, which are published automatically when your code is sent to this repository. So just choose your preferred language and framework, develop its local application, and allow it to be available in seconds to any user with access to the internet with a simple git push!
- Java - CDI; - Seam; - Spring; - Java EE 6.0. - Ruby - Rails; - Sinatra. - Python - Pylons; - Django; - TurboGears. - Perl - PerlDancer. - PHP - Zend; - Cake; - Symfony; - CodeIgniter.
- OpenShift Flex: As its name implies, this is the right option for the time you need more flexibility. In this mode you have a more advanced Administration Console, fully web, where you can define an unique environment for your application, allocating the desired number of servers, load balancers, databases and a number of other parameters. To provide this environment, currently OpenShift Flex uses the Amazon EC2 as IaaS provider, so you will need to have a paid account on Amazon Web Services, while not pay anything for the use of OpenShift. In the future, the idea is that Flex can generate this unique environment in many IaaS providers, and not in a Public Cloud only, but also in its Private Cloud.
Installing client tools
In OpenShift Express we use command-line tools. As much as OpenShift team is developing plugins for Eclipse/JBoss Developer Studio and administration panels on the web, these console tools are still the most appreciated by many developers.
Not to influence any player with the operating system issue, OpenShift offers content with all the installation information of the command-line tools at: https://openshift.redhat.com/app/express#install_client_tools.
Tools customer OpenShift are written in Ruby, so among the items that will be installed will be Ruby, besides the most famous today's version controller, Git.
The facility, although quite simple, requires the implementation of some actions on the command line and also allowed to install packages; thus it is essential that the reader knows some basic concepts of your Operating System (Windows, Linux or Mac OS X).
We will now describe the installation on Windows:
- Install Cygwin, which is available at: www.cygwin.com/. - The following sub-components must be available for installation: - Openssh; - Ruby; - Make; - Gcc; - Git.
2. Download the following url: http://rubyforge.org/projects/rubygems the rubygems and unzip the file;
3. Run the Cygwin and within it run the command:
$ Ruby /setup.rb install
4. Install the gem RHC running the command:
$ Gem install rhc
One of the tools with which you will have enough contact during development in OpenShift Express is Git (http://git-scm.com/), a similar source control system to CVS, Subversion, Mercurial and others. All interaction with OpenShift is made using this tool as one of the key points. One of the great examples of Git use today is the portal GitHub (https://github.com/), which you may have heard: it is a kind of "social network to share codes." This environment uses Git as source control, and is today one of the most accessed portals by developers worldwide.
The OpenShift platform, PaaS (Platform as a Service) Red Hat, shows up as a great alternative for developers who want to start their experiments in cloud computing environments. Simple, objective and free in the Express version, seeks to integrate tools already known to developers, as Git repositories, Maven, JBoss Application Server 7, MySQL and others.