Senin, 13 Oktober 2014

Cloud Services



What the reader will learn:
      How service-oriented architectures relate to cloud computing
      About the ‘cloud stack’
      Details of the three service models
      About the kind of services that are being offered by the major vendors
      How to create a basic cloud application on Google App Engine

5.1            Introduction




 Wikipedia de fi nes cloud computing as:
the delivery of computing as a service rather than a product, whereby shared resources, software, and information are provided to computers and other devices as a metered service over a network (typically the Internet). ( http://en.wikipedia.org/wiki/Cloud_computing )
 The GartnerGroup similarly lists ‘servicebased’ as one of the key de fi ning  attributes of cloud computing. Indeed, we could say that one of the defi n ing c haracteristics that makes cloud computing different from traditional software development and deployment is the focus on service delivery. The National Institute for Standards and Technology (NIST) also sites services as an essential component of cloud computing and defi n es three service models.
I n this chapter we are going to explore the different ways in which you can build and use services in the cloud. We will examine what is known as the SPI model where the letters stand for ‘services’, ‘platforms’ and ‘infrastructures’ and see how the model applies to the systems currently available in the cloud. As an emerging and rapidly advancing area, a number of key terms used in cloud computing do not yet have an agreed designation. However, NIST provides the most widely used defi n itions, particularly relating to the SPI model, and so we include them in the relevant sections below. We also include a number of example technologies for each
R. Hill et al., Guide to Cloud Computing: Principles and Practice, Computer                          91
Communications and Networks, DOI 10.1007/978-1-4471-4603-2_5,
© Springer-Verlag London 2013
of the service types. However, the list is far from exhaustive, and of course, new services and providers are continually emerging and transforming the rapidly changing ‘cloudscape’. At the end of this chapter, you will develop the virtual machine you created previously and then use it to create and deploy your own applications in the cloud. We should note that although we do touch on data storage issues in this chapter, the topic is discussed in detail in Chap.  6 .
T here are a number of technologies which have been identifi e d as precursors to cloud computing such as grids, utility computing, autonomic computing and virtualisation. Perhaps the most relevant to cloud services is the development of web services and service-oriented architectures (SOAs). We begin this chapter by examining these technologies which are still highly relevant to the ongoing evolution of cloud services.

5.2           Web Services

 A web service refers to software which provides a standardised way of integrating facilities offered by web applications and supports communication between organisations without requiring detailed knowledge of how the services are implemented or even which language or platform they are implemented on. Services should perform easily describable, focused and isolated tasks such that they are independent of the particular state of other services. Unlike traditional client–server architectures, web services provide a programmatic and machine-friendly interface rather than a graphical user-friendly interface presented in a browser or desktop application.
 XML is the typical format of communication for web services which provides the signi fi cant advantage of platform independence. The Web Service Description Language (WSDL) can be used to describe the services available, to structure requests and responses and to provide information regarding the kind of protocol needed in order to invoke the service. Implementations for working with WSDL based on C#, Java and other languages are available.
 Many web services are completely free, whereas others may charge for their use. If you create a web service, it is obviously useful if you can publish this fact such that potential users are able to locate, evaluate and use the web service you are offering. The most widely used directory of web services is available via UDDI (Universal Description, Discovery and Integration) specifi c ation which defi n es a way to publish and discover information about web services. SOAP(Simple Object Access Protocol) is a standardised XML format commonly used to tag the information and transport the data. The collection of standards (developed by the World Wide Web Consortium (W3C)) used for web services are collectively known as the WS* stack.
 Perhaps it is easier to understand web services by looking at some examples. If you go to the home page of WebserviceX.NET (h ttp://www.webservicex.net) , h undreds of web services are listed. You can search by keyword or browser by popularity or subject category. You should be able to see commonly used examples such as barcode generators, currency converters and suppliers of weather data. If you are interested, you can use the site to obtain the WSDL service description together with the required SOAP structuring and other useful information regarding the services.
5.5    Composability

5.3             Service-Oriented Architecture

T he goal of service-oriented architecture is to bring together various pieces of f unctionality to form new applications which are built largely from existing software services. SOA provides a set of methodologies for designing software as a set of loosely coupled interoperable services suitable for use in a distributed computing environment. In a somewhat similar way to other software engineering approaches such as object orientation, service-oriented architectures enable us to create components or building blocks that make sense to human users and designers and can be reused for different purposes. The complex internal working of the components is hidden, and a simple interfacewith well-de fi ned behaviour is presented. The  services are self-contained modules that provide standard business functionality and are independent of the state or context of other services. Services are described in a standard de fi nition language and have a published interface.
 The W3C refers to SOA simply as:
A set of components which can be invoked, and whose interface descriptions can be published and discovered. ( http://www.w3.org/TR/ws-gloss/ )
 SOA enables communication between providers and consumers and gives a mechanism to manage available services. The communication should be in the form of loosely coupled services or software functionalities that can be reused for different purposes. In summary we can say that an enterprise application that follows the SOA paradigm is a collection of services that together perform complex business logic.

5.4            Interoperability

I nteroperability is a key SOA requirement. SOA components should be independent of programming language and platform and should be unassociated with each other. SOA aims to allow users to combine or mesh collaborating services from a number of sources to build new, potentially complex applications. SOA allows organisations to expose and access an application’s services and to consume information bound to those services using well-de fi ned interfaces.

5.5            Composability

 Applications are frequently built from a collection of components: a feature called composability. A composable system uses components to assemble services that can be tailored for a speci fi c purpose using standard parts. One of the compelling advantages of the SOA approach is the way that services can be composed when creating applications. Combining and interleaving of services is the heart of serviceoriented computing. SOA implies that services can participate equally well in simple or complex compositions. Composability has been taken to a new level with cloud computing; for example, fundamental computing resources such as storage and  processing power are provided as services which can be composed to create a required application environment (see below).

5.6              Representational State Transfer (REST)

R epresentational state transfer (REST) is a style of software architecture originally introduced by Roy Fielding who was one of the principal authors of HTTP speci fi cations 1.0 and 1.1. As with HTTP, the REST architecture envisions clients and servers in a conversation or request/response cycle. Requests are centred on representations of the resource and use existing HTTP methods. This is in contrast to other systems, such as SOAP where users can de fi ne their own methods and resource identifi e rs. In REST a given URI is used to access the representational state of a resource and also to modify the resource. For example, a URL on the web can be used to provide information to users about the resource or to modify the resource:
      GET is used to transfer the current representational state of a resource from a server to a client.
      PUT is used to transfer the modi fi ed representational state of a resource from the client to the server.
      POST is used to transfer the new representational state of a resource from the client to the server.
      DELETE is used to transfer the information needed to change a resource to a deleted representational state.
 REST uses HTTP for all CRUD (Create/Read/Update/Delete) operations. REST is an increasingly popular lightweight alternative to mechanisms like RPC (remote procedure calls) and SOAP. Like SOAP and RPC, a ‘RESTful’ service is platform and language independent but is considered simpler and easier to use. Whilst REST services might use XML in their responses (as one way of organising structured data), REST requests rarely use XML; indeed we can think of the web page itself as the service. A good example is given by a site offering an ISBN service which returns the details of a book on receipt of an ISBN number. Isbndb.com offers such a service which requires you to simply use an HTTP GET with parameters including an access key to allow use of the service (to gain an access key and use isbndb.com, you need to complete the free registration at h ttp://isbndb.com/ and follow the instructions to gain a veri fi ed account).
 If you enter a URL as shown below:
 but replace the value for the access key with one you have generated at isnbdb.com, the result returned in XML format as shown below:
<?xml version=”1.0” encoding=”UTF-8”?>
 <ISBNdb server_time=”2012-02-22T13:19:46Z”>
  <BookList total_results=”1” shown_results=”1”>   <BookData book_id=”alan_turing_a04” isbn=”0045100608” isbn13=”9780045100606”>
5.7    The Cloud Stack
   <Title>Alan Turing</Title>
   <TitleLong>Alan Turing: the enigma of intelli-gence</
TitleLong>
   <AuthorsText>Andrew Hodges</AuthorsText>
   <PublisherText publish-er_id=”unwin_paperbacks”>
London : Unwin Paperbacks,
   1985.</PublisherText>
  </BookData>
  </BookList>
 </ISBNdb>
A t the end of this chapter, we will build a small web application using Google App Engine (see below) which will use the RESTful service provided by isbndb. com to retrieve and process book information in XML based on ISBN numbers entered by the user.
U nlike SOAP services which require responses packaged in XML, REST does not require the response to be in any particular format. A simple illustration is provided by Twitter which will return the results in various formats (RSS, ATOM and JSON) using the URLs shown below to send a REST request to Twitter’s search service.
 http://search.twitter.com/search.atom?q=turing&count=5  http://search.twitter.com/search.rss?q=turing&count=5  http://search.twitter.com/search.json?q=turing&count=5
 The ‘ q ’ following the question mark is the query term (‘ turing ’), and the count represents the maximum number of items to return.
 REST is based on the HTTP protocol and so is a ‘stateless’ architecture. It is straightforward to make AJAX-based applications RESTful, and returning the response in JSON format makes the applications simple to program whilst minimising the bandwidth required for the response. REST is ubiquitous in cloud services, for example, Amazon.com offers a RESTful API with HTTP verbs for their S3 storage solution (see below).
 Resources are the key element of a RESTful approach. Resources are identi fi ed by the URLs, and both the state and functionality of the application are represented using resources. SOAs can be built using REST services—an approach sometimes referred to as ROA (REST-oriented architecture). The main advantage of ROA is ease of implementation, agility of the design and the lightweight approach. The latest version of WSDL now contains HTTP verbs and is considered an acceptable method of documenting REST services. There is also an alternative known as WADL (Web Application Description Language).

5.7            The Cloud Stack

 It is useful to view cloud offerings as a stack, where each layer has distinct features and capabilities. This is sometimes referred to as the ‘cloud ontology’, and various models of differing complexity have been proposed. We present a relatively simple model here as shown in Fig.  5.1 .
 Fig. 5.1 The cloud stack                        
A t the top of the stack is the application with the user interface delivered to the user via a web browser. At the base of the stack lies the hardware of the physical machines actually running the application, normally located in a large data centre. Virtualisation technology allows for the abstraction and presentation of the hardware resources in a discrete and scalable manner to the higher layers. Actually, a particular layer can be defi n ed according to the level of abstraction, so we can say that a layer is classi fi ed higher in the cloud stack if the services offered by that layer can be composed from the services of the underlying layer. The layer can also be identifi e d according to the type of user targeted by the layer. The service models build on one another and defi n e the areas of responsibility amongst vendors, end users and developers.
 In this chapter, we are primarily interested in the three service layers in the middle of the stack, and the following sections describe each of these with examples.

5.8             Software as a Service (SaaS)

The capability provided to the consumer is to use the provider’s applications running on a cloud infrastructure. The applications are accessible from various client devices through either a thin client interface, such as a web browser (e.g., web-based email), or a program interface. The consumer does not manage or control the underlying cloud infrastructure including network, servers, operating systems, storage, or even individual application capabilities, with the possible exception of limited user-speci fi c application con fi guration setting. NIST ( http://csrc.nist.gov/publications/nistpubs/800-145/SP800-145.pdf )
 Software as a service (SaaS) is a hosted application that is available over the Internet via a web browser. SaaS, sometimes referred to as ‘on-demand software’, is the most complete of the cloud services. Computing hardware, software and the solution are offered by a vendor. The cloud application layer is the only layer visible to end users
5.8     Software as a Service (SaaS)
who are the target users for this layer. The end user does not manage or control the underlying infrastructure. Their only responsibility is for entering and managing their data based on interactions with the software. The user interacts directly with the hosted software via the browser. We should note that SaaS existed well before the concept of cloud computing emerged; nevertheless, it is now an integral part of the cloud model.
C reating and delivering software via the SaaS layer is an attractive alternative to the more traditional desktop applications which must be installed on the users’ machine. With SaaS the application is deployed in the cloud so the work of testing, maintaining and upgrading software is greatly simpli fi ed since it can all occur in one place rather than being rolled out to the desktops of potentially thousands of users. Con fi guration and testing is reduced in complexity due to centralisation and the preset restrictions in the deployment environment. Developers can also use a simpli fi ed strategy when applying upgrades and  fi xes. Furthermore, composition, as discussed above, becomes a straightforward option as soon as the cloud services are developed. Last but not least, the providers also bene fi t from greater protection to their intellectual property as the application is not deployed locally and pirated  versions of the software will be much harder to obtain and distribute.  A number of typical characteristics of SaaS are listed below:
      Software is available globally over the Internet either free or paid for by subscription based on customer usage.
      Collaborative working is easily provided and generally encouraged.
      Automatic upgrades are handled by the vendor with no required customer input.
      All users have the same version of the software.
      The software will automatically scale on demand.
      Distribution and maintenance costs are signi fi cantly reduced.
T here are a huge variety of SaaS applications already available, and their number appears to be growing at an exponential rate. A small selection of prominent examples of SaaS are discussed below, which hopefully give a good illustration of the SaaS approach. We recommend that you investigate for yourself by viewing the sites mentioned, even if only brie fl y.

5.8.1       Salesforce.com

S alesforce.com (h ttp://www.salesforce.com ) provides the most widely used customer relationship management (CRM) service used for managing  fi nancial, logistics and staf fi ng issues related to business system operation. A CRM consists of a set of business processes together with software that helps manage customerrelated activities, information and analysis. These activities include:
      Sales
      Marketing and leads
      Content analysis
      Accounts
      Forecasting
      Partnerships and collaboration
      Customer service
 Salesforce.com offers a comprehensive list of features which can be integrated with applications from Google. The Salesforce.com SaaS offering is highly customisable and tailored for particular industries.

5.8.2       Dropbox

 Dropbox ( https://www.dropbox.com ) uses cloud storage to enable users to store and share  fi les and folders across the Internet. Dropbox starts with a free tier with up to 2 GB of storage and supports multiple user clients across desktop and mobile operating systems, including versions for Windows, Linux, Mac OS X, Android and iPhone. Any  fi les or folders the user places or updates in the dropbox folder of their local machine are synchronised with the web version. When a user logs onto another machine with dropbox installed, any updates are automatically applied. Dropbox also provides a revision history so that user can revert to older versions of their fi l es. Dropbox currently uses Amazon’s S3 storage (see below) although it may switch to a different storage provider in the future.

5.8.3       Google Services

 Google ( http://www.google.com/services/ ) offers a wide range of cloud applications including email, web hosting and, of course, searching. A number of Google services target business users, such as Google Analytics which support its targeted advertising business.
 Google Docs is somewhat similar to Microsoft Of fi ce and contains a word processor, spreadsheet, drawing and presentation program and is free to use up to a certain data size. With Google Docs, collaborators can share documents and work in real time from different locations. REST APIs enable users to directly access the Google Data Protocol (which underlies Google products) and to search Google Docs contents. Once published to the web, the users are provided with the public URL and the HTML code required to embed the document in a web page.
G oogle Apps Script gives users a high level of control over a number of Google products. Google spreadsheets amongst other products can be accessed and controlled using JavaScript programs which run directly on Google servers. Actually this means that the Google spreadsheet is offering more than ‘user-specifi c  application con fi guration settings’ and so strictly speaking is falling outside the NIST defi n ition of SaaS. This is not an uncommon situation for products which otherwise naturally fall into the SaaS category.

5.8.4       Prezi

 Prezi ( http://prezi.com/ ) is a collaborative technology, which is free to use when creating and showing publicly available non-linear presentations (a ‘prezi’) in the

cloud up to 100 MB in size. Users may simply replace Microsoft PowerPoint with Prezi for interactive presentations but much more is on offer. The service also allows users to collaborate in real time for editing or brainstorming, and Prezi allows the user to upload video  fi les and image  fi les.
A  fee is payable for greater storage and for additional features such as the ability to create Prezis of fl ine and to make the Prezis private.

5.9             Platform as a Service (PaaS)

The capability provided to the consumer is to deploy onto the cloud infrastructure consumer-created or acquired applications created using programming languages, libraries, services, and tools supported by the provider. The consumer does not manage or control the underlying cloud infrastructure including network, servers, operating systems, or storage, but has control over the deployed applications and possibly confi g uration settings for the application-hosting environment. NIST
F or many businesses, specifi c  rather than general requirements may mean that a generic SaaS application will not suf fi ce. PaaS creates a managed environment in the cloud where complex, tailor-made applications can be constructed, tested and deployed. The provider supplies a hardware platform together with software environments speci fi cally designed to support cloud application development. The target users are developers who build, test, deploy and tune applications on the cloud platform (for the end user the result is still a browser-based application). Automatic scalability, monitoring and load balancing are provided so that an increase in demand for a resource such as a web application will not result in degradation in performance (of course, this may mean an increased charge is incurred). PaaS vendors will also ensure the availability of applications, so, for example, should there be any problems on the underlying hardware, the application will be automatically redeployed to a working environment, without a detrimental effect on the end users experience. PaaS should accelerate development and deployment and result in a shorter time to market when compared with traditional software development using an organisations’ own data centre.
 The developer does not control and has no responsibility for the underlying cloud infrastructure but does have control over the deployed applications. The vendor is responsible for all operational and maintenance aspects of the service and will also provide billing and metering information. The vendor commonly offers a range of tools and utilities to support the design, integration, testing, monitoring and deployment of the application. Typically the tool set will include services to support:
      Collaboration and team working
      Data management—sometimes referred to as data as a service (DaaS)
      Authentication or identi fi cation—sometimes referred to as authentication as a service (AaaS)
      Performance monitoring and management
      Testing
      Queue services
      Email and messaging
      User interface components
 Often the supporting tools are con fi gured as RESTful services which can readily be composed when building applications. It is important that developers are able to write applications without needing to know the details of the underlying technology of the cloud to which they will be deployed. Standard programming languages are often available, although normally with some restrictions based on security and scalability concerns. Additional support for programming and confi g uration tasks is often available from a developer community speci fi c to the PaaS offering.

5.9.1       Portability

P ortability is a concern to many organisations considering developing PaaS applications due to the differing requirements of the various vendors, so, for example, if you build an application using Google App Engine, there may be signifi c ant work involved if you later decide to move to Microsoft Azure. Using an established language like Java goes some way to ameliorate concerns about application portability but does not necessarily eliminate them as the code will often need to be adjusted to  fi t in with the vendor’s particular requirements and it is quite likely that the program will only work within the specifi c  environment. The way in which data is persisted is especially prone to quite distinct strategies between the vendors.

5.9.2       Simple Cloud API

T he Simple Cloud aims to provide a set of common interfaces for fi l e storage  services, document storage services, simple queue services and infrastructure services, or in their own words, ‘the Simple Cloud API brings cloud technologies to PHP and the PHP philosophy to the cloud’ ( http://simplecloud.org/ ). Zend has invited the open source community and software vendors of all sizes to participate. IBM, Microsoft, Rackspace, Nirvanix, and GoGrid have already joined the project as contributors.

5.9.3       Java

M any programming languages are available on the various PaaS offerings, but Java would currently seem to be the most popular. Although Java is sometimes referred to somewhat mockingly by developers as ‘the COBOL of the twenty-fi r st century’, Java is nevertheless a powerful object-oriented language which is freely available and offers a number of attractive features such as automatic memory management. Perhaps most importantly there is a huge pool of developers with Java expertise: currently a reported ten million Java users. The language has particular appeal to those building client–server web applications.
 Java applications are typically compiled to form a Java source  fi le to Java  bytecode. Once in this format the code can run on any Java Virtual Machine (JVM) regardless of computer architecture. One of the main goals of the language is summarised in the famous ‘write once, run anywhere’ adage, meaning that code that runs on one platform (e.g. Windows) does not need to be edited to run on a different one (e.g. Linux). Another of the reasons for its appeal is the large number of supporting tools, libraries and frameworks also freely available and generally open source. These include the widely used open source and freely available Eclipse Integrated Development Environment (IDE) which supports rapid development and debugging. The JUnit library (which can be easily integrated into Eclipse) supports test-driven development and an agile approach to software production. The Web application ARchive (WAR) is a standard format used to package and distribute resources used for Java Web applications which aims to facilitate development, testing and deployment.
 A number of vendors such as Amazon, Google and VMForce have developed ‘plug-ins’ for Eclipse so that their Java PaaS offerings can be developed, tested, debugged and deployed in an environment already familiar to many developers. The WAR  fi le format is also frequently used by a number of PaaS vendors, again supporting a familiar style of development and reducing portability concerns.

5.9.4        Google App Engine

A  few years ago before cloud really hit the headlines, Google famously gave away stickers saying ‘My other computer is a data center’. Google App Engine (GAE) is a good example of PaaS and allows users to write and deploy their applications on the same infrastructure which powers Google’s products. We are going to give a little more time here to discuss GAE as this is the product we will use at the end of this chapter when you will develop your own GAE cloud application.
G oogle, of course, has great fl e xibility in terms of dynamic reallocation of resources required to meet changing needs and demands. GAE applications are not hosted on a single server but will run in a distributed environment (see Chap.  4 ) even whilst the developer is completely unaware of the production con fi guration of the data centres and is totally free from capacity management, server maintenance and load-balancing tasks. As the number of requests for the web application increases, GAE automatically allocates more resources without the developer needing to change their code.
G AE applications can currently be built using three different programming languages:
1.   The Python programming language was the fi r st to appear when GAE was initially made available to developers. Python System Development Kit (SDK) is still available and widely used.
2.   Java has been added together with integration with Eclipse. Using the Eclipse plug-in developers can run and test their Java applications locally and deploy to the cloud with a single click. Google uses the Java Virtual Machine with the Jetty servlet engine and a standard WAR fi l e structure. Any programming language which can run on a JVM-based interpreter, such as JRuby, Groovy, JavaScript (Rhino) and Scala, can also be run on GAE although there may be a little more work in terms of initial con fi guration. GAE also supports many of the Java standards and frameworks such as servlets, the Spring Framework and Apache Struts.
3.   Most recently an ‘experimental’ environment has been added for the new ‘Go’ ( http://golang.org/ ) concurrent programming language developed by Google.
 Java, Python and Go runtime environments are provided with APIs (application program interface) to interact with Google’s runtime environment. Google App Engine provides developers with a simulated environment to build and test applications locally with any operating system that supports a suitable version of the Python, Java or Go language environments. However, there are a number of important restrictions. Developers cannot write to the  fi le system, Java applications cannot create new threads, and only a subset of the standard Java classes and packages are available (you can view the list of supported classes at  http://code.google.com/ appengine/docs/java/jrewhitelist.html ).
R estrictions such as these have led to portability concerns, but recently a number of projects such as AppScale have been able to run Python, Java and Go GAE applications on EC2 and other cloud vendors.
 The GAE platform also allows developers to write code and integrate customdesigned applications with other Google services. GAE also has a number of composable supporting services including:
      Integrated web services
      Authentication using Google Accounts
      Scalable non-relational, schema-less storage using standard Java persistence models
      Fast in-memory storage using a key-value cache (memcache)
      Task queues and scheduling
 GAE allows applications to be served from the developers own domain name although by default this will be the name the developer assigns to their application at appspot.com, for example,  http://myApp.appspot.com .
 The URL can be shared publicly or selectively. The code required for an application can be stored on Google code which can be managed by various open source version control systems such as SVN ( http://subversion.apache.org/ ).
A  great advantage, particularly to new developers, is that you can begin using GAE for free with no credit card required before continuing onto a graduated fee based on usage (this is one of the reasons we choose a tutorial using GAE). At the time of writing, each developer can host up to ten free applications. An application on a free account can use up to 1 GB of storage and up to  fi ve million page views a month.
T o persist data using GAE, the application must use the provided app engine services. The data store is a key-value storage system similar to Amazon SimpleDB and Windows Azure Table Service (see below). GAE provides high availability by data replication and synchronisation. The memcache service is used to improve performance by using a short term, in memory local cache rather than going to the data store. Although data cannot be read from the fi l e system, it is possible to read  fi les that are packages as part of a WAR.

5.9.5       Google Web Toolkit

 Google Web Toolkit (GWT) is a set of open source libraries under Apache 2.0 licence, which allows web developers to write AJAX web applications entirely in Java. GWT will compile the Java to optimised JavaScript code which will run in the user’s browser whilst allowing for mature Java testing strategies, for example, using JUnit. GWT aims to improve developer productivity and web application maintenance issues and includes support for asynchronous communication (AJAX), history management, bookmarking, internationalisation and cross-browser portability. A GWT application using HTML5 can have separate views for tablets and mobile phones. There is also a GWT plug-in to the eclipse IDE and a straightforward procedure for deploying GWT applications to GAE.

5.9.6       Microsoft Azure

 The Azure Services Platform provides a wide array of Windows-based services for developing and deploying Windows-based applications on the cloud. Whilst Azure is primarily designed as a PaaS offering where users can build host and scale web applications on Microsoft’s global data centres, it also includes Infrastructure as a Service (IaaS) features. The platform consists of compute, storage and fabric (network resources). Azure provides scaling, load balancing and a number of support services such as identity and authentication, message encryption, monitoring and management.
 Three main brands have been developed:
1.   The Windows Azure scalable cloud operating system
2.   SQL Azure which is a cloud-based scalable version of Microsoft SQL Server
3.   AppFabric which is a collection of services supporting the cloud service
A zure applications are typically written either as a ‘web role’, a ‘worker role’ or both. Web role is used for typical web applications that are hosted on servers running Microsoft’s IIS web server, whilst the worker role is used for applications that require compute intensive operations. The virtual machine role is currently in beta but enables the developer to deploy a custom-built Windows Server machine image to Windows Azure potentially saving signi fi cant time on installation-related tasks.
A zure uses a combination of standard web service technologies REST, HTTP and XML and integrates with Microsoft Visual Studio. By using the Microsoft Azure SDK, developers can create services that leverage the .NET Framework. The aim is to allow developers to be able to choose the language or framework and to integrate public cloud applications with existing applications. These applications have to be uploaded through the Microsoft Azure portal in order to be executed on top of WindowsAzure. Additional services are available, such as work fl ow  execution and management, web services orchestration and access to SQL data stores. Microsoft also offers system development kits for other languages such as Java, PHP and Ruby.

5.9.7       Force.com

F orce.com from SalesForce.com is an approach to PaaS for developing CRM systems and applications for social enterprise with built-in support for social and mobile functionality. The design of its platform and the runtime environment is based on Java technology. The platform uses a proprietary programming language and environment called Apex Code, which has a reputation for simplicity in learning and rapid development and execution. Users of Force.com can build their own applications which are either stand-alone or integrated with Salesforce.com.

5.9.8       VMForce

 Salesfoce.com and VMware have partnered to introduce VMForce, one of the  fi rst enterprise cloud platforms for Java developers. VMForce uses Eclipse and allows for development with standard Java Web technology such as JSPs and servlets. Once developed applications can be deployed to the cloud with a single click.

5.9.9       Heroku

 Heroku is a cloud platform for instant deployment of Ruby on Rails web  applications. Ruby on Rails provides a complete framework for web application development including a template and rendering system and methods to persist and retrieve data. Ruby on Rails is popular amongst developers, has a good track record for rapid web application production and sits particularly well with agile methods of software production. Heroku servers are invisibly managed and applications automatically scaled and balanced.

5.9.10 Cloud Foundry

 Cloud Foundry claims to be the  fi rst open source scalable PaaS offering, using industry-standard frameworks such as Spring (Java) and Scala and a choice of application infrastructure services. The project was initiated by VMware but has gained broad industry support. The Cloud Foundry aims to minimise restrictions on development and deployment in the cloud so that developers need not be concerned with middleware or vendor infrastructure.

5.10    Infrastructure as a Service (IaaS)

5.10           Infrastructure as a Service (IaaS)

The capability provided to the consumer is to provision processing, storage, networks, and other fundamental computing resources where the consumer is able to deploy and run arbitrary software, which can include operating systems and applications. The consumer does not manage or control the underlying cloud infrastructure but has control over operating systems, storage, and deployed applications; and possibly limited control of select networking components (e.g., host  fi rewalls). NIST ( http://csrc.nist.gov/publications/nistpubs/800-145/SP800-145.pdf )
 IaaS provides developers with on-demand infrastructure resources such as c ompute, storage and communication as virtualised services in the cloud. The provider actually manages the entire infrastructure and operates data centres large enough to provide seemingly unlimited resources. The client is responsible for all other aspects of deployment which can include the operating system itself, together with programming languages, web servers and applications. IaaS normally employs a pay-as-you-go model with vendors typically charging by the hour.
O nce connected the developers work with the resources as if they owned them. IaaS has been largely facilitated by the advances in operating system virtualisation which enables a level of indirection or abstraction with regard to direct hardware usage (see Chap.  4 ). The virtual machine (VM) is the most common form for providing computational resources, and users normally get super-user access to their virtual machines.
 Virtualised forms of fundamental resources such as computing power, storage or network bandwidth are provided and can be composed in order to construct new cloud software environments or applications. Virtualisation enables the IaaS provider to control and manage the effi c ient utilisation of the physical resources and allows users unprecedented  fl exibility in con fi guration whilst protecting the physical infrastructure of the data centre. The IaaS model allows for existing applications to be directly migrated from an organisation’s servers to the cloud supplier’s hardware, potentially with minimal or no changes to the software.

5.10.1 Virtual Appliances

 A virtual appliance is a virtual machine image which is designed to run on a particular virtualised platform, typically supplied via IaaS. The virtual appliance may have software such as an operating system, compilers, web server, database system and any required applications already installed, con fi gured and optimised to solve the particular problem for which it was designed. In practice many virtual appliances are often used to run a single application. We can think of an appliance as an application combined with everything else it needs to actually run. Often the operating system is a stripped down version of its all-purpose counterpart, a process sometimes referred to as ‘just-enough-operating-system’ or ‘Juice’. Virtual appliances are normally controlled using a web interface and can be used as a starting point for building a more complex server.
 A number of online marketplaces have been set up to allow the exchange of ready-made appliances containing a wide range of operating system and software combinations. VMWare has the largest selection of appliances (available at  http:// www.vmware.com/appliances/directory/)  which can be readily deployed to the VMWare hypervisor. In Chap.  4 tutorial, we used VMWare to create an Ubuntu virtual machine and then installed Java and Eclipse to our machine. An alternative approach would have been to download the appropriate appliance with the software we required already installed.
 Amazon Machine Image (AMI) is used to store copies of particular virtual machines which can run on Amazon’s Elastic Compute Cloud (EC2) and other IaaS platforms which support the format. Amazon Web Services offer hundreds of readymade AMIs, which Amazon refers to as ‘pre-built solutions’ containing common combinations of operating systems and application software.

5.10.2 Amazon Web Services

A mazon Web Services (AWS) is one of the most successful cloud-based businesses based on SOA standards and includes a whole family of related services. The  computational needs of an organisation are of course extremely variable, and some applications are likely to be compute intensive, whilst others will emphasise storage. EC2 is renowned for its ability to provide scalable solutions for diverse requirements.

5.10.3 Amazon Elastic Compute Cloud (EC2)

 EC2 provides virtualised computing power as a service and is considered the central application of the AWS offering and is often referred to as the ‘model example’ of IaaS. Users can rent computing power on Amazon’s infrastructure and pay with an hourly rate using EC2. EC2 can be customised in a similar way to a physical server and can run a variety of operating systems including Linux, Solaris and Windows server. The users gain administrator privileges and can perform numerous activities on the server such as starting and stopping, con fi guration and installation of any database system, programming language or software package.
T he computing resources available on EC2 instances consist of combinations of computing power and other resources such as memory. EC2 is offered as a metered service, and an EC2 Compute Unit (CU) is used as a standard measure of computing power. EC2 users can select from a number of different instance types to best match particular computing needs. Amazon Auto Scaling is a set of command line tools that allows scaling EC2 capacity up or down automatically and according to conditions speci fi ed by the end user.
 Standard instances are currently offered with the following resources as illustrated in Table  5.1 .
 There are many other instance types designed to meet nonstandard requirements. EC2 also offers users the ability to select from a number of regions and within each
5.10 Infrastructure as a Service (IaaS) Table 5.1 Standard EC2 instance types
 Instance type
 Memory
(GB)
C ompute
 Instance storage
(GB)
 Platform
 Small
 1.7
 1 EC2 Compute Unit (1 virtual core with 1 EC2 Compute Unit)
 160
 32-bit
 Large
 7.5
 4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each)
 850
 64-bit
 Extra large
 15
 8 EC2 Compute Units (4 virtual cores with 2 EC2 Compute Units each)
 1,690
 64-bit
region a number of availability zones where the virtual data centres on which the EC2 instances will be running.

5.10.4 Amazon Storage Services

 Various forms of data storage are also provided by Amazon ‘as-a-service’. Amazon’s Simple Storage Service (S3) is a pure object-based storage system which can be accessed via a REST-based web interface. S3 does not provide the ability to run programs and does not even provide any  fi le system or indexing, but has the advantages of reliability, availability and scalability. The user can allocate a block of storage up to 5 TB in size that has a unique user-assigned identifi e r and can then read or write to the block. S3 is often cited as a good example of a perfectly focused cloud service which does exactly one thing in a very narrow way. The service can then be composed with others to provide the resources required for development.
T he S3 user is charged according to the volume of data and network bandwidth used when storing and retrieving data. S3 is a popular choice amongst web application developers and can easily be used to replace existing web hosting infrastructure. The Apache Hadoop fi le system (see Chap.  4)  can also be hosted on S3 for running MapReduce jobs. At the time of writing Amazon S3 is reported to store more than 762 billion objects. Dropbox and Ubuntu One are examples of online backup and synchronisation serviceswhich use S3 for storage and transfer. Amazons SimpleDB is a key-value NoSQL data store (see Chap.  6)  and Amazon Relational Database Service provides a MySQL database instance in the cloud.
A s mentioned above Amazon S3 works over HTTP. Amazon also offers block storage systems where resources appear to be physical discs on the EC2 server. This provides improved performance over S3 and is more suitable to the case where multiple disc operations are required. Instance storage is attached to a particular EC2 instance, can only be accessed by that particular EC2 and will be lost as soon as the EC2 instance stops. The Elastic Block Storage (EBS) provides block storage for EC2 but is independent of a particular instance and can be shared between EC2 instances.
 EC2 provides the Elastic Load Balancer which as the name suggests  automatically balances the load across multiple servers. The load balancer also scales the number of servers up or down depending on the requirements of the particular load.

5.10.5 Amazon Elastic Beanstalk

 AWS Elastic Beanstalk is currently in beta but promises to provide ‘an even easier way for you to quickly deploy and manage applications in the AWS cloud’. The developer need only upload their applications, and the Elastic Beanstalk will handle the deployment details, load balancing and scaling. In some ways this makes the product more like a PaaS offering although in this case the developer can control the underlying infrastructure if required (Beanstalk will use resources such as EC2 and S3 when deploying applications). Amazon clearly states that the aim is to offer the developer the best of both the PaaS and IaaS worlds.
 The current release of Elastic Beanstalk is built for Java developers, and the Elastic beanstalk application should be packaged using the standard Java WAR structure. An AWS plug-in is available for Eclipse which also allows you to test and deploy your application to one or more EC2 instances running the Apache Tomcat web server.

5.10.6 FlexiScale

 FlexiScale ( http://www. fl exiscale.com/ ) offers on-demand hosting and operates in a somewhat similar manner to Amazon EC2. FlexiScale supports both Windows and Linux servers and uses the Xen hypervisor.

5.10.7 GoGrid

G oGrid (h ttp://www.gogrid.com/ ) allows users to utilise a range of premade windows and Linux images in a range of  fi xed instance sizes and also offers stacks on top for applications such as high-volume web applications, e-commerce and databases.
5.10.8 Eucalyptus (‘Elastic Utility Computing Architecture

for Linking Your Programs to Useful Systems’) 

 Eucalyptus ( http://www.eucalyptus.com/ ) is an open source Linux-based software platform for creating cloud computing IaaS systems based on computer clusters. The project has an interface that can be connected to Amazon’s compute and storage cloud system (EC2 and S3), and users can interact with Eucalyptus clouds using the same tools used on Amazon. Eucalyptus supports multiple hypervisor technologies within the same cloud and provides a range of cloud administration

tools for system management and accounting. Eucalyptus is currently supported by most Linux distributions. Ubuntu enterprise cloud is a new initiative to make it easier to provide, deploy, con fi gure and use cloud infrastructures based on Eucalyptus.

5.10.9 Rackspace

 Rackspace ( http://www.rackspace.com/ ) offers an IaaS solution fi x ed size instances in the cloud. Rackspace cloud servers offer a range of Linux-based premade images, and users can request different sized images.

5.11           Chapter Summary

I n this chapter, we have looked at how using web services and service-oriented architectures has contributed to the rise of cloud computing. We have reviewed the SPI model and examined how it can be useful to view cloud computing as consisting of various layers which are most easily identifi e d by considering the particular responsibilities of vendors, developers and end users. We should note that although the SPI model is extremely useful in categorising and understanding cloud-based systems, the layers are rather blurred as, for example, some SaaS offerings can be programmed and some PaaS products offer the developers the option of direct control of the underlying hardware.

5.11.1 End of Chapter Exercises

 In this tutorial we are going to work with Google’s cloud offering to create a simple web application. This choice is due partly to the availability of Google’s free tier as we appreciate that many students of cloud computing may be put off by having to purchase cloud resources or supply credit card details.
 Create a Google App Engine account (free) by clicking the Sign up link under Getting Started on  http://code.google.com/appengine/ and follow the instructions. No credit card is required for the free tier, but you will need to be able to receive an SMS text message.
 There are currently three programming languages which you can use on GAE, but we are going to use Java. One advantage of this is that we can use the GAE plugin to the freely available eclipse IDE which we installed to our VM previously.

5.11.2 Task 1: Prepare Eclipse and Install GAE Plug-In

 We need to install some add-ons to eclipse. Whilst the install takes place, you will need to agree to run unsigned content and agree to licence conditions. You will also need to restart eclipse when requested (if at any point you hit a problem, you should restart eclipse and try again).
1.   Open your VM and go to the Ubuntu software centre. Type in eclipse and install.
2.   Open eclipse and select the default Workspace location and then go to Help/ Install New Software. Click on the ‘Available Software Sites’ link and enable the entry whose location is  http://download.eclipse.org/releases/helios
3.   After the list populates (this may take some time depending on your Internet connection speed), in the text box below ‘work with’, type ‘xml’ to  fi lter the entries and then select ‘Eclipse XML Editors and Tools’ which should be available in the ‘programming languages’.
4.   Select ‘next’ twice, agree the licence and ‘ fi nish’ (again this may take some time to complete).
5.   Restart eclipse when prompted.
6.   You are now ready to install the plug-in for Google App Engine. Again, open eclipse and go to Help/Install New Software and enter this URL:  http://dl.google. com/eclipse/plugin/3.7
7.   Select the Google plug-in for eclipse and the SDKs as shown below.
8.   Select ‘next’ twice, agree the licence and ‘ fi nish’ (again this may take some time to complete) (Fig.  5.2 ).

5.11.3 Task 2: Create the First Web Application

1.   Click on the Google icon and select ‘new web application project’ (Fig.  5.3 ). We are not going to use GWT (Google Web Toolkit), so make sure this option is unchecked. Fill in a project name and a package name and make sure the ‘Use Google App Engine’ is selected (Fig.  5.4 ).
2.   You can then select ‘Finish’. This will create a new eclipse project with a structure similar to that shown below (once you have expanded the elements) (Fig.  5.5) . As you can see GAE uses a standard Java web archive folder (WAR).
3.   Open the sample Java servlet code which has been generated for you (again you may need to expand by clicking the ‘+’ sign) (Fig.  5.6 ).
You can run the project locally by right clicking the project node in the package explorer (GAE_isbn) and then selecting ‘run as’ and then selecting ‘web application’.  If successful you will see the message appear in the console window:
INFO: The server is running at  http://localhost:8888/_ah/admin
4.   Open a browser session and open  http://localhost:8888/ . Hopefully you will see a page similar to that shown below in Fig.  5.7 .
I f you click on the servlet, you should see the ‘hello world’ message returned by the sample servlet. Even if you are not familiar with Java, take a look at the code for the servlet and see if you can change the text of the message sent from the server.
W e are now going to try and create a simple ISBN lookup service on GAE. This will be a limited application and really is only intended to give you a fl a vour of the type of thing you can do with app engine.
Fig. 5.2 GAE Install Dialogue

5.11.4 Task 3: ISBN App

 Our GAE application is going to prompt the user for an ISBN number. Once the user submits the number, we will perform some very basic validation and then return the title, author and publisher of the book.
 We are going to achieve this by composition. We will use the REST-based service offered by  http://isbndb.com . The service is free, although you will need to complete the simple sign up procedure to obtain an access key. Once you have the key, you can test the service by pasting a URL similar to the following into your browser but replacing the value for key with your own key:
Fig. 5.3 New Web Application dialogue
 If all goes well you should see an XML  fi le similar to the following:
 <?xml version=”1.0” encoding=”UTF-8”?>
 <ISBNdb server_time=”2012-02-22T13:19:46Z”>
 <BookList total_results=”1” shown_results=”1”>  <BookData book_id=”alan_turing_a04” isbn=”0045100608” isbn13=”9780045100606”>   <Title>Alan Turing</Title>
  <TitleLong>Alan Turing: the enigma of intelli-gence</
TitleLong>
  <AuthorsText>Andrew Hodges</AuthorsText>
 <PublisherText publish-er_id=”unwin_paperbacks”>
London : Unwin Paperbacks, 1985.</PublisherText>
 </BookData>
 </BookList>
 </ISBNdb>
 Now return to eclipse and the GAE project you created earlier where we have three updates to make:
1. We need to update the index.html fi l e (in the WAR folder) which is the default starting place for the web application. Replace the existing contents with the following:
<html>
 <head>
 <script type=”text/javascript”>  var xmlhttp;
Fig. 5.4 New Web Application Project dialogue
 function lookupISBN(isbn) {  xmlhttp = null;  if (window.XMLHttpRequest) {   xmlhttp = new XMLHttpRequest();
 } else if (window.ActiveXObject){//code for IE6,IE5    xmlhttp = new ActiveXObject(“Microsoft.XMLHTTP”);
 }
   if (xmlhttp != null) {     xmlhttp.onreadystatechange = state_Change;     var url = “/isbnservice?isbn=” + isbn;     xmlhttp.open(“GET”, url, true);     xmlhttp.send(null);
Fig. 5.5 Eclipse Package
Explorer
 
Fig. 5.6 Servlet code
    } else {   alert(“Your browser does not support XMLHTTP.”);
 }  }
  function state_Change() {   if (xmlhttp.readyState == 4) {// 4 = “loaded”    if (xmlhttp.status == 200) {// 200 = “OK”  docment.getElementById(
   ‘ISBNServiceResponse’).innerHTML =      xmlhttp.responseText;
  } else {
Fig. 5.7 Hello App Engine                      
  alert(“Problem looking up ISBN Service :” +      xmlhttp.statusText);
  }
 }
 }
 </script>
 </head>
< title>ISBN Lookup</title>
< body>
 <h2>ISBN Lookup</h2>
 <hr />
 <h4>
   (Powered by ISBNdb
 <a href=”http://isbndb.com/”>ISBN Service</a>)
 </h4>
 <hr />
 <p>
  <b>Lookup ISBN:</b><input type=”text”     id=”isbn”></input>
 </p>
 <p>
  <b>Book details :</b> <br />
  <span id=”ISBNServiceResponse”></span>
 </p>
 <button onclick=”lookupISBN(isbn.value)”>
   Lookup ISBN</button>
 </body>
 </html>
 The above includes html and JavaScript. The JavaScript function called  lookupISBN will use AJAX to update the page with the information returned by the  isbnservice .
2. We now need to update the servlet code. The code below might look complex but in fact is simply using some standard libraries to make a call to the ISBNdb URL, navigate the XML returned and write out the data from the selected elements. Update the servlet code with the following: package com.cloudtest.isbn;  import java.io.BufferedReader;  import java.io.IOException;  import java.io.InputStreamReader;  import java.io.StringReader;  import java.net.URL;  import javax.servlet.ServletException;  import javax.servlet.http.HttpServlet;  import javax.servlet.http.HttpServletRequest;  import javax.servlet.http.HttpServletResponse;  import javax.xml.parsers.DocumentBuilder;  import javax.xml.parsers.DocumentBuilderFactory;  import org.w3c.dom.Document;  import org.w3c.dom.Element;  import org.w3c.dom.Node;  import org.w3c.dom.NodeList;  import org.xml.sax.InputSource;  @SuppressWarnings(“serial”)  public class ISBNService extends HttpServlet {  public void doGet(HttpServletRequest req,  HttpServletResponse resp)   throws IOException {  String strCallResult = “”;  resp.setContentType(“text/plain”);  try {
 // Extract out the user entered ISBN number
 String strISBN = req.getParameter(“isbn”);  // Do basic validation - could be much more thorough   if (strISBN == null)   throw new Exception(“ISBN  fie ld cannot be empty.”);
 // Trim  strISBN = strISBN.trim();  if (strISBN.length() == 0)
  throw new Exception(“ISBN  fie ld empty.”);
 String strISBNServiceCall =
  “http://isbndb.com/api/books.xml?access_key=123&index1= isbn&value1=”;  strISBNServiceCall += strISBN;
 URL url = new URL(strISBNServiceCall);  BufferedReader reader =   new BufferedReader(new InputStreamReader(   url.openStream()));
 StringBuffer response = new StringBuffer();  String line;  while ((line = reader.readLine()) != null) {   response.append(line);
 }
 reader.close();
 strCallResult = response.toString();  DocumentBuilderFactory builderFactory =
  DocumentBuilderFactory.newInstance();  DocumentBuilder builder =   builderFactory.newDocumentBuilder();  Document doc =   builder.parse(new InputSource(new StringReader(   strCallResult.toString())));  doc.getDocumentElement().normalize();  NodeList nList =   doc.getElementsByTagName(“BookData”);  if (nList.getLength() < 1)   throw new Exception(“no books: check the ISBN.”);  for (int temp = 0; temp < nList.getLength(); temp++)
{
 Node nNode = nList.item(temp);
 if (nNode.getNodeType() == Node.ELEMENT_NODE) {   Element eElement = (Element) nNode;   resp.getWriter().println(   “<br />Title : “+   getTagValue(“TitleLong”, eElement));   resp.getWriter().println(“<br />Author : “ +   getTagValue(“AuthorsText”, eElement));   resp.getWriter().println(“<br />Publisher : “+   getTagValue(“PublisherText”, eElement));
 }
 resp.getWriter().println(strCallResult);
 }
 } catch (Exception ex) {  strCallResult = “Error: “ + ex.getMessage();  resp.getWriter().println(strCallResult);
 }
 }
 @Override  public void doPost(HttpServletRequest req,
               
Fig. 5.8 ISBN Lookup
 HttpServletResponse resp)  throws ServletException, IOException {   doGet(req, resp);
 }
 private static String getTagValue(String sTag,
 Element eElement) {  NodeList nlList =         eEle-ment.getElementsByTagName(sTag).item(0).
getChildNodes();
  Node nValue = (Node) nlList.item(0);   return nValue.getNodeValue();
 }
 }
3.   Change the package statement (if required) at the top so that it refl e cts the name of the package you created when setting up your GAE project.
4.   Update the value of the string for the strISBNServiceCall so that your access code for isbndb.com is used.

References
5.   Finally, you need to update the web.xml (also in the WAR folder)  fi le such that it includes the following:
   <servlet>
   <servlet-name>ISBNService</servlet-name>
   <servlet-class>com.cloudtest.isbn.ISBNService</ servlet-class>   </servlet>
  <servlet-mapping>
   <servlet-name>ISBNService</servlet-name>
   <url-pattern>/isbnservice</url-pattern>
  </servlet-mapping>
Y ou need to ensure that the packages specifi e d for the servlet-class matches your own package. Once you have saved these updates, you can test the application locally. Run the web application and open in the browser. Hopefully now the page will look something like that shown below in Fig.  5.8 .
 Test the application by entering ISBN numbers (e.g. 1884133320).
 Finally, we are ready to deploy the application. Click on the Google icon in eclipse and select the deploy option. You will need to give a name for your application that has not been used before. Once deployed you should be able to open and test the application in your browser using a URL such as  http://lazaruscloud.appspot. com/isbn.html

References

Chu-Carrol C.: Code in the Cloud: Programming Google App Engine. Pragmatic Programmers (2011)
Marcel, C.B., Marcel, K., Mimis, J., Tai, S.: Cloud Computing: Web-based Dynamic IT Services.
Springer, Heidelberg (2011)

0 komentar:

Posting Komentar