Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cloud Computing Software Engineering Fundamentals

Similar presentations


Presentation on theme: "Cloud Computing Software Engineering Fundamentals"— Presentation transcript:

1 Cloud Computing Software Engineering Fundamentals
Upper Austria University of Applied Sciences School of Informatics, Communications, and Media © J. Heinzelreiter, W. Kurschl Version 1.1, 2010

2 Outline Introduction History Key Terms and Definitions
Key (Software) Technologies Cloud Software Architecture Issues Google App Engine Microsoft Windows Azure Simple Sample App (Google App Engine versus Windows Azure) Comparison of Google App Engine and Windows Azure Open Issues Summary References Cloud Computing Fundamentals v.1.1

3 Introduction

4 Cloud Computing in the News
Tom Vanderbilt, Data Center Overload, NY Times, June 14, 2009 “And so when you think about Hotmail supporting 375 million users, or search supporting three billion queries a month, or Messenger supporting hundreds of millions of users, you can easily assume that those properties are very large properties for our company.” In his book “The Big Switch,” Nicholas Carr draws an analogy between the rise of mega-data centers and the Industrial Revolution. Just as nascent industries, once powered by water wheels, were by the 20th century able to “run their machines with electric current generated in distant power plants,” advances in technology and transmission speeds are permitting computing to function like a utility, a distant but ever-accessible cloud of services. Instead of buying software and hiring I.T. employees, companies can outsource things like customer relationship management, or C.R.M., the database software that companies use to track client interactions, to an Internet company like salesforce.com, which sells subscriptions, or seats, to its services. “Customers who have two seats on salesforce.com, like a mom-and-pop flower shop, have access to the same application as a customer that has 65,000 seats … Cloud Computing Fundamentals v.1.1

5 Cloud Computing in the News
Kelly Fiveash, Microsoft calls in the builders for Dublin data centre, The Register, 7th November 2007 Microsoft is shelling out $500m on a new European data centre in Ireland to support its growing online business. There will be tens of thousands of servers pumping out web-based apps to internet fanciers all over the world, the company says. But it only needs to hire between 15 and 20 staff to run the behemoth's first Windows Live data centre not on US soil, because much of the system will be automated. Microsoft, which already has some 1,200 staff at a separate office in Ireland, said work would begin later this month and it expects the centre to open for business by 2009. Crain's Chicago Business reports that construction on a new $500m site large enough to hold eight [American] football fields was already underway Cloud Computing Fundamentals v.1.1

6 Data Centers Traditional Data Centers – e.g. Microsoft Dublin Datacenter 27,300 m2 22.2 Megawatt (final phase) Container-based Data Centers – e.g. Chicago Data Center 65,000 m2 60 Megawatt (final phase) Containers with up to 2500 servers © © Cloud Computing Fundamentals v.1.1

7 Cloud Computing in the News
Wired, Cloud Computing. Available at Amazon.com Today, 4/12/2008 Click on "Amazon Web Services." Key in your Amazon ID and password and behold: a data center's worth of computing power carved into megabyte-sized chunks and wired straight to your desktop. Clones of that HP tower cost 10 cents per hour — 10 cents! — and they're set to start spitting out widgets as soon as you upload the code. Virtual quad cores are a princely 80 cents an hour. Need storage? All you can eat for 15 cents per gigabyte per month. And there's even a tool for monitoring your virtual stack with an iPhone. No precious cash tied up in soon-to-be-obsolete silicon, no 3 am runs to the colo cage. Outsource your infrastructure to Amazon! Cloud Computing Fundamentals v.1.1

8 Cloud Computing in the News
Steven Levy, Ray Ozzie Wants to Push Microsoft Back Into Startup Mode, Wired, 11/24/2008 According to Microsoft, one example of a successful service is Windows Update, which automatically installs patches and bug fixes on users' operating systems. Hotmail, like all Web‐based mail applications, is also a service. Virtual Earth? A service. Software, but not from a box. Still, Ozzie draws the line at the idea that you can do anything and everything in the cloud, that every application can become Web based, that the desktop is dead. Some things, he says, still require local computation, offline persistence, and the control that only one's own desktop processor offers. Ray's Plan: 4 Ways to Win Not long after Ray Ozzie arrived at Microsoft in 2005, he wrote a memo declaring that the company's survival hinged on a shift to cloud computing. Three years later, Ozzie and Microsoft are finally announcing (though for the most part not yet releasing) key products designed to fulfill that promise. Cloud Computing Fundamentals v.1.1

9 Cloud Computing in the News
Nicholas Carr , The Big Switch: Rewiring the World, from Edison to Google , Norton, 2008 General purpose technologies Used by all companies to do all sorts of things Potential for vast economies of scale if supply can be consolidated Steam power: must be supplied locally Electricity and IT: can be centralized Consolidation requires new technologies and fresh business models Companies abandon their private generators Cloud Computing Fundamentals v.1.1

10 Driving Forces Economist , IT's global “cloud”, October 23, 2008
According to a recent study, 69% of Americans connected to the web use some kind of “cloud service”, including web-based or online data storage (see chart). The best example is Google, the biggest online search company by far, which now offers a plethora of web-based applications such as word-processing or online spreadsheets.  Web and Cloud applications are very important Cloud Computing Fundamentals v.1.1

11 Driving Forces Virtualization (see [Oracle 2009] p. 3)
Enhances flexibility because it abstracts the hardware to the point where software stacks can be deployed and redeployed without being tied to a specific physical server With application deployment decoupled from server deployment, applications can be deployed and scaled rapidly, without having to first procure physical servers. Using virtual machines as deployment objects is sufficient for 80 percent of usage, and it helps to satisfy the need to rapidly deploy and scale applications. Hosting Why should a SME run its own IT infrastructure for a small Web shop, a blog, etc.?  No IT staff is necessary Cloud Computing Fundamentals v.1.1

12 Driving Forces Economies of scale (see [Velte2009] p. 78)
Major cloud suppliers can purchase hardware much cheaper as “regular“ business If you need more computational power or storage you needn`t buy more servers just buy more from cloud provider Cloud provider scales computing power and storage Ease of scaling up/down based on demand within the same logical system Case Study: ShareThis, [ShareThis2007] ShareThis team did a comprehensive cost analysis across three scenarios: Option 1. Build a proprietary storage framework Option 2. Buy network storage devices Option 3. Use a cloud based-approach on Amazon Web Services. In the first two scenarios, time and money became big blockers, but in Option 3, AWS eliminated the time and cost constraints Cloud Computing Fundamentals v.1.1

13 Driving Forces Pay as you go
If you have more customers/users, you might need more processing power and storage  pay more If your business is running “slower” (e.g. economic downturn) you might need fewer processing power and storage  pay less Low entry costs There is no long-term financial commitment High availability Your cloud app runs 24/7/365 Enterprise Software as a Service A single instance of the software runs on the cloud and services multiple end users or client organizations E.g. CRM from salesforce.com, Microsoft Business Productivity Online Standard Suite Cloud Computing Fundamentals v.1.1

14 Example Applications Microsoft Business Productivity Online Standard Suite Exchange Online , shared calendar, shared tasks, and contacts Sharepoint Online Portal, collaboration, content management, site search, and forms capabilities Blog site templates that support article posting, reader comments, and RSS feed generation Office Live Meeting Interactive application/desktop sharing and whiteboard tools Rich media presentations, native video conferencing, high-fidelity recording, and Web cam capabilities Office Communications Online Instant messaging with text based chat using Microsoft Office Communicator 2007 client Seamless presence awareness enabling users to check another user’s availability on the network Cloud Computing Fundamentals v.1.1

15 Players in the Field Commercial
Microsoft Azure (Computing and Storage) Amazon EC2 (Computing), S3 (Storage) Google AppEngine (Computing), BigTable (Storage) But also Yahoo, Salesforce, IBM, etc. Open Source Eucalyptus Systems (University of California, Santa Barbara spin off) Globus (open-source grid software) Etc. Cloud Computing Fundamentals v.1.1

16 Confusion about „Cloud Computing“
Hakan Erdogmus, Cloud Computing - Does Nirvana hide behind the nebula, IEEE Software, March/April 2009, [Erdogmus2009] Simply application delivery as an on-demand service, is no longer novel The benefits of scalability, reliability, security, ease of deployment, and ease of management for customers, traded off against worries of trust, privacy, availability, performance, ownership, and supplier persistence, still stand. The dream of platform independence Platforms such as Google App Engine promise application deployment on large, robust server bases for instant scalability, security, and performance, but that’s only an ideal for now. Cloud Computing Fundamentals v.1.1

17 Confusion about „Cloud Computing“
Big words According to The Economist, “Let it Rise,” October 2008 Substitute “cloud” with “Internet” and it will look familiar How will cloud computing affect software development? Opportunities for developers Cloud computing opens up exciting new possibilities based on a mix of old and new technologies for the next generation of software developers Let smaller players tap into a larger user base that prefers the comfort of operating under the wings of a major player with lots of resources The rise of the cloud is more than just another platform shift that gets geeks excited. It will undoubtedly transform the information technology (IT) industry, but it will also profoundly change the way people work and companies operate. It will allow digital technology to penetrate every nook and cranny of the economy and of society, creating some tricky political problems along the way. Cloud Computing Fundamentals v.1.1

18 Goals We want to look at the Software Engineering aspects of a Cloud Computing application/architecture because Scalability and efficiency are coming not for free A sound architecture helps in Keeping CPU cycle and storage requirements at a minimum Guarantying satisfying response times for customers Keeping the data in a consistent state Better using the scalable infrastructure of the cloud provider Reducing the expenses for a cloud application service provider (i.e. customer of the cloud infrastructure) Migration of existing solution into the cloud We don`t cover Cloud economics Security issues Law related issues Cloud Computing Fundamentals v.1.1

19 History

20 Enterprise Applications
Characteristics of Enterprise Applications complex (business) logic, huge, complex data, special security requirements, focus is on transactions , many clients, support for different platforms, heterogeneous development environments: C, C++, Java, C#, COBOL, ... Application Requirements are a driving force for Software Architecture. Cloud Computing Fundamentals v.1.1

21 Mainframe Applications
Terminals: UI Approach Mainframe provides all resources and logic Terminals for user interaction (thin clients) Advantages Simple deployment Problems and Limitations Limited GUI capabilities Every client allocates server resources  Limited scalability Mainframe: Application and Data Cloud Computing Fundamentals v.1.1

22 Client/Server Architecture
Thick Clients : UI + Logic Approach Increased capabilities of PCs Logic was (partially) transferred to clients  thick clients Central database server Advantages Better user experience (GUIs) Problems and Limitations Every client has a permanent stateful connection Every client holds server resources (db connections, …)  Limited scalability Mac Linux-Workstation PC Server: Data Cloud Computing Fundamentals v.1.1

23 Middle-Tier Architecture
Thin Clients Approach Logic bundled in Middle-tier Clients have no permanent connection to Middle-tier  stateless connections Advantages Factoring of business logic Middleware provides services (pooling, security, …) Resources are shared between clients  improved scalability Problems New programming model Middle-Tier: Logic + Services (Middleware) Data-Tier Cloud Computing Fundamentals v.1.1

24 What should we learn from History?
Changes in hardware architecture often have an impact on software architecture: Improved capabilities of PCs  client/server architecture New requirements influence software and hardware architecture: Web applications have to serve many clients  middle tier architecture  stateless programming model Middle tier solutions and cloud computing platforms have many common characteristics. Its worthwhile to study patterns and best practices for Web platforms. Knowledge how to build modern multi tier (service-oriented) applications becomes even more important. Cloud Computing Fundamentals v.1.1

25 Cloud Software Architecture Issues

26 Stateful vs. Stateless Components
method1 object = methods + data Methods perform actions on objects Methods modify data fields (= state) OO application = set of objects that change their state by method invocations Early RPC-basted remoting such as CORBA DCOM RMI, .NET Remoting apply the OOP paradigm to distributed applications. Developers like this approach because they are used to apply it, and it causes less implementation effort. (object) methodn state Cloud Computing Fundamentals v.1.1

27 Stateful Services The service host provides a service instance for every client during the whole lifetime of a session. Service Host Instance 1 Instance 2 Client 1 Proxy Client 2 Proxy Comparable to client/server architecture The services is an “extension” of the client Technologies EJB: Stateful Session Beans WCF: Per-Session Services CORBA Java RMI Cloud Computing Fundamentals v.1.1

28 Stateful Services – Problems
Every service instance holds server resources Only a limited number of clients can be served. What happens with the service instance when the client dies unexpectedly? Distributed garbage collection, session timeouts, … What was the state of the instance when the connection was interrupted? Reestablishing a connection may be painful. Transactions may manage state differently Transactions should be bound to service operations, not to sessions. When the transaction is rolled back, database state and session state are not in synch. Cloud Computing Fundamentals v.1.1

29 Stateless Services A service instance is created for each invocation of a service operation. Service Host Instance 1 Instance 2 Instance 3 Client 1 Proxy t=0 Client 2 Proxy t=0 t=1 There is no permanent connection between the client an the service Resources can be shared between clients  Improved scalability. Technologies EJB: Stateless Session Beans WCF: Per-Call Services Cloud Computing Fundamentals v.1.1

30 Design of Stateless Services
Stateless services must not store their state in fields of the service instance. The service method is responsible for state management The state must be persisted on some external media: public class MyService : IMyService { public BusinessMethod(long stateId) { LoadState(stateId); DoWork(); SaveState(stateId); } Implementation of stateless services can be complex and expensive Only use this pattern if scalability is an important issue. Cloud Computing Fundamentals v.1.1

31 Separation of Concerns
Applications have different concerns Application code represents business requirements Technology code builds the basis for application code It’s bad architecture to mix application and technology code Changes in technology code also have an impact on the business logic. Techniques for the separation of concerns Dependency Injection Domain Objects Layered Architecture Aspect-oriented Programming (AOP) Interception an Runtime Containers Cloud Computing Fundamentals v.1.1

32 Coupling of Components
uses Tight Coupling ComponentA ComponentB public class ComponentA { public ComponentB ComponentB { get; set; } public ComponentA() { ComponentB = new ComponentB(); } } uses ComponentA IComponentB Less Tight Coupling Decrease dependency by using interfaces Component is still dependent on its environment ComponentB public class ComponentA { public IComponentB ComponentB { get; set; } public ComponentA() { ComponentB = NamingContext.Lookup("name of ComponentB") } Cloud Computing Fundamentals v.1.1

33 Coupling of Comp. – Dependency Injection
Loose Coupling Components are only dependent on interfaces Assignment of dependencies is done from “outside”. uses ComponentA IComponentB creates injects dep. creates ObjectFactory ComponentB public class ComponentA { public IComponentB ComponentB { get; set; } // setter injection public ComponentA(IComponentB compB) { // constructor injection ComponentB = compB; } public class ObjectFactory { public GenerateComponents() { ComponentA compA = new ComponentA(); ComponentB compB = new ComponentB(); compA.ComponentB = compB; } Cloud Computing Fundamentals v.1.1

34 Layered Architecture Presentation Layer Business Layer
Data Access Layer The application is split into different layers Every layer can only access its direct predecessor Layers are loosely coupled Presentation Layer UI: Thin Client, Rich Client, RIA Business Layer Provides logic Responsible for transactions, security, validation Data Access Layer (Persistence Layer) Synchs data with database through Data Access Objects Cloud Computing Fundamentals v.1.1

35 Domain Objects Domain Objects model the application’s data.
Project Name Members Domain Objects model the application’s data. Requirements Domain Objects should not be dependent on a specific (data access) technology. Domain Objects must be serializable. The serialization format should be interoperable. Types of Domain Objects Change Sets (e.g. ADO.NET DataSets) Simple Entities (POJOs/POCOs) Self-Tracking Entities Data Transfer Objects (DTOs) * * Employee Name DateOfBirth LogbookEntries * LogBookEntry Employee Activity StartTime EndTime Cloud Computing Fundamentals v.1.1

36 The Role of Domain Objects
Presentation Layer Business Layer Data Access Layer Domain Objects Object1 Object 3 Object 2 Domain Objects Object 1 Object 3 Object 2 Domain Objects are used to transfer application data between layers. Since the are used in every layer the should be technology agnostic. Cloud Computing Fundamentals v.1.1

37 Loosely Coupled Layers
Each Layer is statically dependent on interfaces of the preceding layer only. Dependencies should be injected. Presentation Layer EmployeeController Worklog { get; set; } ListEmployees() Mvc.Controller Business Layer WorkLogImpl EmployeeDao { get; set; } ProjectDao { get; set; } FindEmplyoeeById() FindProjectsOfEmployee() IWorklogFacade FindEmployeeById() Data Access Layer EmployeeDAOImpl IEmployeeDAO ProjectDAOImpl IProjectDAO Cloud Computing Fundamentals v.1.1

38 Aspect-oriented Programming (AOP)
Motivation Some technological tasks are spread over the whole application  Cross-cutting Concerns Module 1 Logging Module 2 Security Module 3 Transactions Cloud Computing Fundamentals v.1.1

39 AOP in Application Frameworks
An aspect defines cross module functionality that’s implemented by an advice. The advice that can be executed at well-defined places in a program, so-called joinpoints. A pointcut is a subset of joinpoints where an advice gets executed. Many application frameworks and runtime containers have built-in aspects for resource and instance management handling transactions securing applications Pointcuts are most commonly defined by attributes/annotations. The main goal is again the separation of concerns. Cloud Computing Fundamentals v.1.1

40 AOP Examples EJB WCF @Stateless
public class WorklogBean implements WorklogRemote { @PersistenceContext private EntityManager manager; @TransactionAttribute(TransactionAttributeType.REQUIRED) @RolesAllowed({"Managers"}) public Long saveEmployee(Employee empl) { … } } WCF [ServiceBehaviour(InstanceContextMode=InstanceContextMode.PerCall] public class WorklogService : IWorklogFacade { [OperationBehavior(TransactionScopeRequired=true)] [PrincipalPermission(SecurityAction.Demand, public int SaveEmployee(Employee empl) { … } } Cloud Computing Fundamentals v.1.1

41 Asynchronous Message Processing
Client Message Message Broker Queue Service Instance 1 Instance 2 Message Client Message Messages are stored in a persistent queue and are processed asynchronously. Advantages Clients are not blocked while message is processed. Client and service do not have to be alive simultaneously. Distribution of workload on the server side (load balancing). Programming model is quite different The client gets no result values and no feedback in case of errors. Cloud Computing Fundamentals v.1.1

42 Key Terms and Definitions

43 What is Cloud Computing?
A lot of terms are used in the Cloud Computing domain like Platform as a Service (Paas) Infrastructure as a Service (Iaas) Communication as a Service (CaaS) Software as a Service (Saas) Public cloud, private cloud, hybrid cloud Etc. But it lacks the understanding of the classification of cloud systems, their correlation and inter-dependency  Cloud Ontology Cloud Computing Fundamentals v.1.1

44 Classification Method
[Youseff 08] proposed a stack of layers Each layer encompasses one or more cloud services Cloud services belong to the same layer if they have equivalent levels of abstraction One cloud layer is higher in stack, if its services can be composed of services from the underlying layers Cloud Applications Firmware / Hardware Software Kernel Cloud Software Environment Cloud Software Infrastructure Storage Communications Computational Resources Cloud Computing Fundamentals v.1.1

45 Layer 1: Firmware/Hardware Layer
Physical computing, switching, and routing hardware forms the backbone Hardware as a Service (HaaS) HaaS provider operates, manages and upgrades the hardware on behalf of its consumers HaaS providers have the technical expertise as well as the cost-effective infrastructure to host the systems Cloud Applications Firmware / Hardware Software Kernel Cloud Software Environment Cloud Software Infrastructure Storage Communications Computational Resources © Cloud Computing Fundamentals v.1.1

46 Layer 2: Software Kernel
Basic software management of physical servers E.g. OS kernel, hypervisor (virtual machine monitor, VMM), virtual machines (VM), clustering middleware VMM provides a uniform view of underlying hardware, making machines from different vendors look the same, which means that virtual machines can run on any available computer. See [Rosenblum2009] Software Kernel Cloud Applications Firmware / Hardware Cloud Software Environment Cloud Software Infrastructure Storage Communications Computational Resources [Rosenblum2009] Cloud Computing Fundamentals v.1.1

47 Layer 2: Software Kernel
VMM also offers complete encapsulation of a VM’s software state (see [Rosenblum2009]): VMM layer can map and remap virtual machines to available hardware resources VMM layer can migrate virtual machines across machines Load balancing among a collection of machines thus becomes trivial It is a robust model for dealing with hardware failures or for scaling systems Virtual machines are also easy to replicate, or bring new services online as needed Various products for virtualization VMware, Parallels, Microsoft Virtual PC, etc. [Rosenblum2009] Cloud Computing Fundamentals v.1.1

48 Layer 3: Cloud Software Infrastructure
Provides fundamental software resources Computational Resources, often called Infrastructure as a Service (IaaS) Enabled by virtualization  virtual machines are the key elements E.g. Amazon`s Elastic Compute Cloud (EC2) (see [Vogels2008]), Enomaly elastic computing infrastructure, etc. And several academic open-source cloud projects to build a private cloud Globus, Eucalyptus (UCSB), etc. Eucalyptus allows you to run Amazon Machine Image (AMI) instances on your VMware-based hypervisor/VMM on-premise Enomaly.com Cloud Applications Firmware / Hardware Software Kernel Cloud Software Environment Cloud Software Infrastructure Storage Communications Computational Resources Cloud Computing Fundamentals v.1.1

49 Layer 3: Cloud Software Infrastructure
Data Storage, often called Data Storage as a Service (DaaS) Manage data at remote disks at anytime from any place while shielding customers from complexities such as geo-replication, capacity planning, and performance management at high scale. Availability, reliability, performance, replication, and data consistency, at a high level is a requirement but not found in most systems Service Level Agreements (SLA) usually specify those requirements Cloud Applications Firmware / Hardware Software Kernel Cloud Software Environment Cloud Software Infrastructure Storage Communications Computational Resources Cloud Computing Fundamentals v.1.1

50 Layer 3: Cloud Software Infrastructure
A service must provide characteristics formally negotiated in Service Level Agreement (SLA) Example SLA from Amazon [DeCandia2007]: A service is guaranteeing that it will provide a response within 300ms for 99.9% of its requests for a peak client load of 500 requests per second. Key-value stores offer a relaxed consistency model in favor of availability and scalability (see [DeCandia2007]) It is intended to store relatively small objects (size < 1M) Are easier to configure on a per-application basis E.g. Amazon`s Simple Storage (S3) [Vogels2010], Amazon`s Dynamo [DeCandia2007] Cloud Computing Fundamentals v.1.1

51 Layer 3: Cloud Software Infrastructure
Replicated RDBS have a stricter consistency model at the cost of availability and scalability (see [Gray1996]) These systems are not capable of handling network partitions because they typically provide strong consistency guaranties But there are several applications and services that do need the feature richness of an RDBMS E.g. Amazon RDS provides a MySQL 5.1 relational database in the cloud Distributed File Systems (e.g. Google File System, [Ghemawat2003]) usually guarantee eventual consistency (see [Vogels2007a]) The storage system guarantees that if no new updates are made to the object eventually all accesses will return the last updated value. E.g. Domain Name System (DNS) Updates to a name are distributed according to a configured pattern and in combination with time controlled caches, eventually all client will see the update. Cloud Computing Fundamentals v.1.1

52 Layer 3: Cloud Software Infrastructure
Communications, often called Communication as a Service (CaaS) Communication networks with Network security, virtual overlays for traffic isolation, dedicated bandwidth Guaranteed message delay, communication encryption, network monitoring, etc. Some include also Unified Communication (VOIP, Video, etc.) Cloud Applications Firmware / Hardware Software Kernel Cloud Software Environment Cloud Software Infrastructure Storage Communications Computational Resources Cloud Computing Fundamentals v.1.1

53 Layer 4: Cloud Software Environment
The users of this layer are cloud applications’ developers, implementing their applications for the cloud The providers supply the developers with a programming-language-level environment with a set of well-defined APIs to facilitate the interaction between the environments This is often called Platform as a Service (PaaS) Providers/Platforms Microsoft Windows Azure Google App Engine Salesforce/Force.com Etc. PaaS can sometimes bypass the cloud software infrastructure Cloud Applications Firmware / Hardware Software Kernel Cloud Software Environment Cloud Software Infrastructure Storage Communications Computational Resources Cloud Computing Fundamentals v.1.1

54 Layer 4: Cloud Software Environment
PaaS offers also some basic services Deployment and instance management Dashboard CPU times Queues Datastores Quotas (Bandwidth, Data, CPU, etc.) [Pum2010] Google App Engine Cloud Computing Fundamentals v.1.1

55 Layer 4: Cloud Software Environment
Development fabric The development fabric simulates the cloud on your local computer so that you can run and test your service locally before deploying it. The development fabric allows you to debug and fine-tune the behavior of your service before it is deployed. Authentication Logging Billing Versioning Cloud Computing Fundamentals v.1.1

56 Layer 4: Cloud Software Environment
Programming languages C# (Microsoft Windows Azure) Java, Python (Google App Engine) Web technologies ASP.NET, Silverlight (Microsoft Windows Azure) JavaServer Pages, Python (Google App Engine) Additional services Service Bus Web service hosting infrastructure (e.g. Microsoft Windows Azure) Cloud Computing Fundamentals v.1.1

57 Layer 5: Cloud Applications
Software as a Service (SaaS) provides specific applications like Microsoft Business Productivity Online Standard Suite CRM (e.g. Salesforce) Shop (e.g. Amazon) Picture management (e.g. FlickR) Sales forecasting (e.g. Lokad) (e.g. Google Mail, Microsoft Exchange Online) Storage (e.g. Dropbox, Microsoft Mesh, Skydrive, Gladinet, etc.) Etc. Cloud Applications Firmware / Hardware Software Kernel Cloud Software Environment Cloud Software Infrastructure Storage Communications Computational Resources Cloud Computing Fundamentals v.1.1

58 Classification of Clouds
Cloud services can also be categorized into three types based on access and location (see [Chaganti2009]) A public cloud is available to anyone on the Internet Any user can sign up to use the public cloud (e.g. Microsoft Windows Azure) A private cloud is a proprietary cloud environment that only provides cloud services to a limited number of users Private clouds are usually within your own data center behind your firewall [Oracle 2009] [Oracle 2009] Cloud Computing Fundamentals v.1.1

59 Classification of Clouds
A hybrid cloud, sometimes called a virtual private cloud, provides services that run on a public cloud infrastructure, but limits access to it with a virtual private network (VPN) [Oracle 2009] Cloud Computing Fundamentals v.1.1

60 Public Cloud The main benefits of using a public cloud service are:
Managed Infrastructure Easy and inexpensive set-up because hardware (+storage) is managed by the provider Scalability/Elasticity  you get more/less processing power, storage, etc. when needed Eliminates complex procurement cycles improving the time-to-market for its users [Vogels2010] Removes Undifferentiated "Heavy Lifting“  let its users focus on delivering differentiating business value instead of wasting valuable resources on the undifferentiated heavy lifting that makes up most of IT infrastructure [Vogels2010] Pay as you go  No wasted resources because you pay for what you use Public clouds are run by third parties, and applications from different customers are likely to be mixed together on the cloud’s servers, storage systems, and networks [Oracle 2009] Cloud Computing Fundamentals v.1.1

61 Public Cloud The main drawbacks of using a public cloud service are
Vendor lock-in for PaaS  e.g. you cannot easily change your software environment (e.g. from Windows Azure with C# to Google App Engine with Java) Examples of public clouds Amazon Elastic Compute Cloud (EC2) Google App Engine Microsoft Windows Azure Cloud Computing Fundamentals v.1.1

62 Private Cloud The main benefits of using a private cloud service are
Exclusive use providing the utmost control over data, security, and quality of service Ownership  has control over infrastructure and how applications are deployed Managed by companies own IT organization High level of control The main drawbacks are Infrastructure costs (e.g. capital expenses for storage) Operating costs for running the data center Average utilization is not always known in advance  right scale? Examples of private clouds Eucalyptus Cloud Computing Fundamentals v.1.1

63 Hybrid Cloud The main benefits of using a hybrid cloud service are
Augment a private cloud with the resources of a public cloud  provide on-demand, externally provisioned scale [Oracle 2009] The main drawbacks are Complexity how to distribute applications across both a public and private cloud [Oracle 2009] [Oracle 2009] Cloud Computing Fundamentals v.1.1

64 Software Engineering Focus
Cloud Applications Firmware / Hardware Software Kernel Cloud Software Environment Cloud Software Infrastructure Storage Communications Computational Resources Cloud Computing Fundamentals v.1.1

65 Google App Engine

66 Google App Engine App Engine Limited Preview Release [GoogleAppEngine] Conceptually Google App Engine (GAE) is a Platform as a Service (PaaS) Programming-language-level environment with a set of well-defined APIs Java and Python Primarily for Web Applications Simple configuration Cloud Applications Cloud Software Environment Cloud Software Infrastructure Storage Communications Computational Resources Cloud Computing Fundamentals v.1.1

67 Services Stateful Services Datastore Blobstore Memcache
Schemaless object datastore, with a query engine and atomic transactions Java SDK includes the Java Data Objects (JDO) and Java Persistence API (JPA) interfaces, as well as a low-level datastore API Blobstore Serve data objects, called blobs (binary large objects), that are much larger than the size allowed for objects in the Datastore service Blobs are created by uploading a file through an HTTP request Memcache Distributed in-memory data cache based on JCache JCache provides a Map-like interface to cached data Stateless Services URL Fetch Can fetch resources and communicate with other hosts over the Internet using HTTP and HTTPS requests Cloud Computing Fundamentals v.1.1

68 Services Images Mail Task Queues XMPP Google Accounts
Can resize, rotate, flip, and crop images Can also enhance photographs using an predefined algorithm Mail Apps can send and receive messages in the form of HTTP requests initiated by App Engine and posted to the app Task Queues Can perform background processing by inserting tasks (modeled as web hooks; i.e. a URL to a servlet) into a queue. Automatically dispatch tasks for execution XMPP Can send and receive instant messages to and from users of XMPP-compatible instant message services, including Google Talk Google Accounts Can authenticate users with Google Accounts Can detect whether the current user has signed in with a Google Account, and can redirect the user to the Google Accounts sign-in page to sign in or create a new account Cloud Computing Fundamentals v.1.1

69 Google App Engine Architecture
Request/Response Python/Java VM process App Stdlib Stateless service APIs Stateful service APIs Memcache Datastore Blobstore URL Fetch Mail Images Task Queues XMPP Google Accounts See [Rossum2008] Cloud Computing Fundamentals v.1.1

70 Basic Concepts App Engine handles HTTP(S) requests, nothing else
Think RPC: request in, processing, response out Works well for the web and AJAX App configuration is dead simple No performance tuning needed Everything is built to scale “infinite” number of apps, requests/sec, storage capacity APIs are simple, stupid See [Rossum2008] Cloud Computing Fundamentals v.1.1

71 Cloud Software Infrastructure Computational Resources
Scaling Low-usage apps: many apps per physical host High-usage apps: multiple physical hosts per app Stateless APIs are trivial to replicate Memcache is trivial to shard Datastore built on top of Bigtable (see [Chang2006]) Designed to scale well Abstraction on top of Bigtable API influenced by scalability No joins If needed Denormalize schema Precompute joins See [Rossum2008] Firmware / Hardware Software Kernel Cloud Software Infrastructure Storage Communications Computational Resources Cloud Computing Fundamentals v.1.1

72 Automatic Scaling You don’t need to configure resource needs
One CPU can handle many requests per second Apps are hashed (really mapped) onto CPUs: One process per app, many apps per CPU Creating a new process is a matter of cloning a generic “model” Process and then loading the application code (in fact the clones are pre-created and sit in a queue) The process hangs around to handle more requests (reuse) Eventually old processes are killed (recycle) Busy apps (many QPS) get assigned to multiple CPUs This automatically adapts to the need as long as CPUs are available See [Rossum2008] Cloud Computing Fundamentals v.1.1

73 Datastore Entities have a key and properties
Entity ~~ Record ~~ Java object Property ~~ Column or Field Has a type Dynamically typed Property types are recorded per Entity Key has either id or name id is auto-assigned Alternatively, the name is set by app Java Data Objects (JDO) Java Persistence API (JPA) Limit Maximum entity size: 1 MB Maximum size of a datastore API call request or response: 1MB @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Person { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long key; @Persistent private String name; public Person() {} public Long getKey() {return key;} public void setKey(Long key) { this.key = key;} public String getName() { return name;} public void setName(String name) { this.name = name; } Cloud Computing Fundamentals v.1.1

74 Blobstore (BigTable) Serve data objects, called blobs (binary large objects), that are much larger than the size allowed for objects in the Datastore service Blobs are created by uploading a file through an HTTP request Based on BigTable (see [Chang2006]) not a relational database BigTable stores all entities by sorted key Key sorts similar kinds of data together BigTable can perform only two kinds of queries: Prefix and range A prefix query returns all entities whose key starts with a given string. Limit Queries never return more than 1000 records Maximum object size 50 megabytes Cloud Computing Fundamentals v.1.1

75 Security Constrain direct OS functionality
No processes, threads, dynamic library loading No sockets (use urlfetch API) Can’t write files (use datastore) Limit resource usage (Quota) Limit 1000 files per app, each at most 1MB Hard time limit of 10 seconds per request Most requests must use less than 300 msec CPU time Hard limit of 1MB on request/response size, API call size, etc. Quota system for number of requests, API calls, s sent, etc. Cloud Computing Fundamentals v.1.1

76 Web-based Admin Console
Cloud Computing Fundamentals v.1.1

77 Development Environment
Eclipse: Integrated Development Environment (IDE) Java Plugin for Google App Engine Cloud Computing Fundamentals v.1.1

78 Google App Developer Account
App Gallery: dozens of examples Tools, Communication, Games, News, Finance, Sports, Lifestyle, Technology, Enterprise Developer Account Resources: free to get started 500 MB storage 2 GB bandwidth / day ~ 5 million page views / month Pay-per-use if you need more Cloud Computing Fundamentals v.1.1

79 Microsoft Windows Azure

80 Data Centers Traditional Data Centers – e.g. Microsoft Dublin Datacenter 27,300 m2 22.2 Megawatt (final phase) Container-based Data Centers – e.g. Chicago Data Center 65,000 m2 60 Megawatt (final phase) Containers with up to 2500 servers © © Cloud Computing Fundamentals v.1.1

81 Windows Azure Architecture (1)
Cloud Application Windows Azure Compute Storage Network Fabric Controller Windows Azure Fabric Cloud Computing Fundamentals v.1.1

82 Windows Azure Architecture (2)
The Fabric a network of interconnected nodes: Commodity servers High-speed switches, rooters, load balancers fiber-optic connections From the distance the network looks like a weave, or a fabric. The Azure Fabric Controller is the service which monitors, maintains and provisions machines. Core Services of Windows Azure Compute: Hosting of scalable Services on Windows Server 2008. Storage: Management of highly available data (not relational). Network: Resources for communicating with external applications (Service Bus). Cloud Computing Fundamentals v.1.1

83 Fault Tolerance and Availability [Kommalapati2010]
Fabric Controller Windows Azure Fabric Fault Domain 1 Power Supply 1 Switch 1 Server11 App 1/Instance 1 App 2/Instance 1 Server1n App 3/Instance 1 Fault Domain 2 Power Supply 2 Switch 2 Server21 App 1/Instance 2 App 3/Instance 2 Server2n App 4/Instance 1 Fault Domain m Serverm1 App 2/Instance 2 App 3/Instance 2 Servermn App 1/Instance 2 Switch m Power Supply m Cloud Computing Fundamentals v.1.1

84 The Role of the Fabric Controller
Fault Domains: Unit of failure in datacenter (e.g. rack of machines). Update Domains: only one update domain will be updated simultaneously during upgrades (OS, services). Application owners specify required resources in resource descriptors (service models). The Fabric Controller automatically provisions the requested resources. The Fabric Controller makes commodity resources fault tolerant and highly available. Early detects application failures. Spawns additional instances if needed. Instances are allocated across fault and update domains. Cloud Computing Fundamentals v.1.1

85 Compute Resources: Web and Worker Roles
Physical Machine 1 Physical Machine 2 HTTP/HTTPS Virtual Machine 2 Virtual Machine 2 Hardware Load Balancer Virtual Machine 1 Web Role Instance IIS Fabric Agent Virtual Machine 1 Worker Instance Fabric Agent Fabric Controller Web Role: Interactive .NET application hosted in IIS: Web Application or Web Service (WCF) Worker Role: Durable background process Often isolated from outside world There are ways to make it reachable for external application Fabric Agent collects resource metrics (usage, failures, …) Cloud Computing Fundamentals v.1.1

86 Service Model: Service Definition
The ServiceDefiniton.csdef file defines the overall structure of a service: vmsize: CPU cores (1 – 8) and memory for VM (1.7 – 15 GB) full/partial trust: native code execution supported Endpoint: internal and external endpoints (http, https, tcp) LocalStorage: temporary storage on server running the instance ConfigurationSettings: names of configuration parameters The Service Definition is processed at deployment time. <ServiceDefinition name="MyService" …> <WebRole name="MyWebRole" enableNativeCodeExecution="false" vmsize="Medium"> <InputEndpoints> <InputEndpoint name="HttpIn" protocol="http" port="80" /> </InputEndpoints> <ConfigurationSettings> <Setting name="name1" /> </ConfigurationSettings> </WebRole> </ServiceDefinition> Cloud Computing Fundamentals v.1.1

87 Service Model: Service Configuration
The ServiceConfiguration.csdef file specifies the number of instances for each role, and defines the values for the configuration settings. The Service Configuration can be updated at runtime. <ServiceConfiguration serviceName="MyService" xmlns= "…"> <Role name="MyWebRole"> <Instances count="3" /> <ConfigurationSettings> <Setting name="name1 " value="value1" /> </ConfigurationSettings> </Role> </ServiceConfiguration> Cloud Computing Fundamentals v.1.1

88 Windows Azure Role API – Classes
RoleEnvironment CurrentRoleInstance Roles GetConfigurationSettingValue() RequestRecycle() Changed (Event) Changing (Event) Stopping (Event) BasicEntryPoint OnStart() OnStop() Run() CurrentRoleInstance Roles MyWebRole OnStart() MyWorkerRole OnStart() Run() Role Instances Names RoleInstance Id Role FaultDomain UpdateDomain InstanceEndpoints * Cloud Computing Fundamentals v.1.4

89 Implementation of Roles
Derive class from RoleEntryPoint and override lifecycle methods. Typically OnStart() is overridden A handler is registered that listens to changes in the configuration of the cloud storage account. When a change is observed the role is restarted (recycled). public class MyRole: RoleEntryPoint { public override bool OnStart() { CloudStorageAccount.SetConfigurationSettingPublisher( (configName, configSetter) => { configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)); RoleEnvironment.Changed += (sender, arg) => { if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>() .Any((change) => (change.ConfigurationSettingName == configName))) { if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName))) RoleEnvironment.RequestRecycle(); }; // handler for Changed event }); // SetConfigurationSettingPublisher return base.OnStart(); } Cloud Computing Fundamentals v.1.4

90 Implementation of Web and Worker Roles
Web Role No difference to standard ASP.NET Web Forms, ASP.NET MVC, or WCF application Worker Role Override Run() method of RoleEntryPoint. This method serves as the main thread of execution for the role. public class WorkerRole : RoleEntryPoint { public override void Run() { while (true) { // get next message // process message // delete Message Thread.Sleep(1000); } Alternatively you can listen to an external HTTP(S) or TCP endpoint for incoming messages. Cloud Computing Fundamentals v.1.4

91 Inter-role Communication
Role instances can communicate asynchronously via queues. Preferred method for reliable messaging See section Azure Queues for details Role Instance 1 Role Instance 3 Queue Role Instance 2 Role Instance 4 Role instances can also communicate directly using TCP or HTTP(S) connections. Role Instance 1 Role Instance 3 External App Load Balancer External Endpoint Internal Endpoint Role Instance 2 Role Instance 4 Cloud Computing Fundamentals v.1.4

92 Inter-role Communication using WCF/TCP (1)
Implementation of the service xxx [ServiceContract(Namespace="…")] public interface ICalculator { [OperationContract] double Add(double a, double b); } public class CalculatorService : ICalculator { public double Add(double a, double b) { return a + b; } Configuration of the worker role Add external or internal endpoints <ServiceDefinition name="CalcService" ...> <WorkerRole name="CalcRole" enableNativeCodeExecution="true"> <Endpoints> <InputEndpoint name="CalcServiceEP" port="5000" protocol="tcp" /> <InternalEndpoint name="MyInternalEP" protocol="tcp"/> </Endpoints> </WorkerRole> </ServiceDefinition> Cloud Computing Fundamentals v.1.4

93 Inter-role Communication using WCF/TCP (2)
Hosting of the WCF service Windows Azure Role Instance CalcService External App Load Balancer net.tcp://myProject. cloudapp.net:5000/CalcService CurrentRoleInstance. InstanceEndpoints["CalcService"] public class WorkerRole : RoleEntryPoint { private ServiceHost serviceHost; public override void Run() { this.serviceHost = new ServiceHost(typeof(CalcService)); NetTcpBinding binding = new NetTcpBinding(SecurityMode.None); RoleInstanceEndpoint externalEndPoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["CalcServiceEP"]; this.serviceHost.AddServiceEndpoint( typeof(ICalcService), binding, String.Format("net.tcp://{0}/CalcService", externalEndPoint.IPEndpoint)); // hostname and port } Cloud Computing Fundamentals v.1.4

94 Inter-role Communication using WCF/TCP (3)
Implementation of the client NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, false); using (ChannelFactory<ICalcService> cf = new ChannelFactory<ICalcService>(binding, "net.tcp://5000/CalcService")) { ICalcService calcProxy = cf.CreateChannel(); double sum = calcProxy.Add(1,2); } When using internal endpoints the sender must do the load balancing manually. Use RoleEnvironment.Roles[“TargetRole”] to discover the endpoints foreach (RoleInstance ri in RoleEnvironment.Roles["CalcRole"].Instances) { RoleInstanceEndpoint ep = ri.InstanceEndpoints["MyInternalEP"]; string address = String.Format("net.tcp://{0}/MyService", ep.IPEndpoint); var cf = new ChannelFactory<IMyService>(binding, address); } Cloud Computing Fundamentals v.1.4

95 Storage Cloud Applications have no access to the VM’s file system.
Cloud Applications can store data in Blobs, Tables Queues Relational database (SQL Azure) Blobs provide storage for unstructured data. Blobs are organized in containers. Tables are structured collections of entities. Entities are collections of name/value pairs. Tables have no schema. Queues provide storage for small data items on a FIFO basis. Queues enable communication between service instances. Cloud Computing Fundamentals v.1.1

96 Storage Architecture Cloud Application/External Application
Windows Azure Storage .NET API (StorageClient) REST API REST API Storage Account Blob Container Queue Table Blob Blob Entity Entity Blob Blob Entity Cloud Computing Fundamentals v.1.1

97 Storage Features Windows Azure Storage
provides huge storage resources, is massively scalable, and is a highly reliable persistence mechanism. Data is stored in large server farms comprising commodity hardware. Scalability Data can be distributed across many storage nodes. Storage access is load-balanced. Reliability Data is replicated to different storage nodes when a write operation occurs (3 replicas in different fault domains). When a device fails, data is replicated to a new storage node. Cloud Computing Fundamentals v.1.1

98 Storage Account The storage account is the entry point for all storage services. Storage accounts can be created on the Azure Development Portal. Storage accounts can be accessed with one of two secret keys: On the client side a hash code is computed (with SHA256). The hash code and the secret key is used to compute a HMAC-SHA256 signature (Hash Message Authentication Code). The HAMAC is attached to the REST request. The storage server uses the signature to authenticate the request. Cloud Computing Fundamentals v.1.1

99 Accessing Storage via REST
Every storage item is identified by a Request URI: Blob: <http|https>://<account name>.blob.core.windows.net/<container>/<blob name> Table: <http|https>://<account name>.table.core.windows.net/<table name>() Queue: <http|https>://<account name>.queue.core.windows.net/<queue name> HTTP verb represents the action executed on the resource: PUT: create container/queue/table, save blob/entity/queue item, set metadata, … GET: list blobs in container, get blob/entity/queue item, … DELETE: delete container/queue/table/blob/entity/queue item, … The REST API provides a platform-independent interface to Azure storage. Example: PUT HTTP/1.1 x-ms-version: x-ms-date: Sun, 27 Sep :33:35 GMT Content-Type: application/octet-stream x-ms-blob-type: BlockBlob x-ms-meta-m1: some metadata Authorization: SharedKey myaccount:YjN4fAR8/AmBrqBz7MG2uFinQh4dscbj598g= Content-Length: nn Request Body Cloud Computing Fundamentals v.1.1

100 Blobs [Calder2009] Blob Containers provide a grouping of a set of blobs. Sharing policies are set a container level: public read or private. Containers can have metadata. Blob store big chunks of data. Blobs can have metadata. Blob Types Block Blobs are optimized for streaming Maximum blob size: 200 GB Blobs are uploaded in blocks (max. 4 MB) Page Blobs are optimized for random access Maximum blob size: 1TB Container for Azure Drives (XDrive). Storage Account Blob Container 1 Block Blob 1 B1 B2 B3 Block Blob 1 B1 B2 B3 Page Blob 1 Page Blob 2 Blob Container 2 Cloud Computing Fundamentals v.1.1

101 Blob Storage API – Classes
CloudBlobClient ListContainers() GetContainerReference() GetBlobReference() GetBlockBlobReference() GetPageBlobReference() CloudStorageAccount FromConfigurationSetting() CreateCloudBlobClient() creates CloudBlobContainer GetBlobReference() GetBlockBlobReference() GetPageBlobReference() Create[IfNotExist]() ListBlobs() Delete() Metadata SetMetadata() Get/SetPermissions() CloudBlob OpenRead/Write() DownloadFromStream() UploadFromStream() Delete[IfExists]() CopyFromBlob() Metadata SetMetadata() CloudBlockBlob CloudPageBlob Cloud Computing Fundamentals v.1.1

102 Blob Storage API – Sample
Create Blob Container CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); blobContainer = blobClient.GetContainerReference(containerName); blobContainer.CreateIfNotExist(); BlobContainerPermissions perm = blobContainer.GetPermissions(); perm.PublicAccess = BlobContainerPublicAccessType.Container; blobContainer.SetPermissions(perm); Create Blob CloudBlob blob = blobContainer.GetBlobReference(blobName); Stream stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, obj); blob.UploadFromStream(stream); Read Blob CloudBlob blob = blobContainer.GetBlobReference(blobName); Stream stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); blob.DownloadToStream(stream); MyType obj = (MyType)formatter.Deserialize(stream); Cloud Computing Fundamentals v.1.4

103 Tables [Haridas2009] Tables provide (semi-)structured storage.
Tables contain a set of entities. Entities contain a set of properties. Properties have a name, and a typed value (Int32, Int64, double, string, bool, DateTime, GUID, byte array). Tables have no fixed schema, i.e. the structure of each entity may be different. Each entity has two key properties: The partition key, and the row key. An entity’s size is limited to 1MB. Storage Account Table1 Entity 1 Property 1 Property 2 Entity 2 Property 1 Property 2 Table 2 Cloud Computing Fundamentals v.1.1

104 Partitioning of Tables
The application controls the distribution of entities by assigning partition keys to entities. If two entities have different partition keys they may be stored in different storage nodes. Only entities stored within the same table and the same partition can take part in an entity group transaction. Storage Node 2 Person Name Meyers DOB 1999/5/5 Row Key 1 Partition Key 2 Name Gates DOB 1955/4/3 Row Key 2 Storage Node 1 Person Name Gosling DOB 1955/9/6 Row Key 3 Partition Key 1 Problem: What’s the right granularity for partitions? Improved scalability when many clients access entities in disjoint storage nodes. Poor performance when one client accesses entities in different storage nodes. Cloud Computing Fundamentals v.1.1

105 Table Storage API – Classes
CloudStorageAccount FromConfigurationSetting() CreateCloudTableClient() DataServiceContext AttachTo/Detach() CreateQuery<T>() AddObject() DeleteObject() UpdateObject() SaveChanges() TableServiceEntity PartitionKey RowKey TimeStamp creates/uses creates MyEntity Property1 Property2 CloudTableClient Attach() CreateTable[IfNotExist]() DeleteTable[IfExist]() DoesTableExist() ListTables() TableServiceContext SaveTablesWithRetries() Cloud Computing Fundamentals v.1.1

106 Table Storage API – Sample (1)
Define entity classes: [DataServiceKey("PartitionKey", "RowKey")] public class Person : TableServiceEntity { public Person(string name, DataTime dob) { this.PartitionKey = "1"; this.RowKey = Guid.NewGuid().ToString(); this.Name = name; this.DOB = dob; } public string Name { get; set; } public DateTime DOB { get; set; } Cloud Computing Fundamentals v.1.1

107 Table Storage API – Sample (2)
Make changes to table schema: CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); tableClient.CreateTableIfNotExist("Person"); Create context that allows you to access entities: TableServiceContext ctx = new TableServiceContext(storageBaseAddress, storageCredentials); Load entities using LINQ queries: IQueryable<Person> persons = ctx.CreateQuery<Person>("Person"); Person person1 = (from p in persons where p.RowKey == personKey select p).FirstOrDefault<Person>(); Update/add/remove entities: person1.Name = "Jackson"; ctx.UpdateObject("Person", person1); ctx.AddObject("Person", person2); ctx.DeleteObject(person3); ctx.SaveChanges(); Cloud Computing Fundamentals v.1.1

108 Queues [Microsoft2008] Queues provide a reliable asynchronous message delivery mechanism. Reliability Messages are redelivered until a consumer confirms that it has been successfully processed  Messages are processed at least once. Decoupling of producer and consumer Different parts of the system can be implemented using different technologies and languages. Producer and consumer needn’t be alive at the same time. Scalability Queues compensate traffic bursts and mitigate component failures. Queue length grows  number of consumer instances can be increased. Message Producer CloudQueue Message Queue CloudQueue Message Message Consumer Cloud Computing Fundamentals v.1.1

109 Queues – Features and Limitations
The number of messages is not limited. Metadata can be associated. There is no guaranteed return order of messages. Messages are delivered at least once  consumer must be able to deal with messages that are delivered more than once. Message Message can be up to 8KB in size. Message structure: MessageID: a GUID VisibilityTimeout: If processing of message is not confirmed within this time range the message reappears in the queue (default = 30 seconds) MessageTTL: Time-to-live interval for messages (maximum = default = 7 days) Payload: String or byte array. Cloud Computing Fundamentals v.1.1

110 Queue API – Classes CloudStorageAccount CloudQueue CloudQueueMessage
FromConfigurationSetting() CreateCloudQueueClient() CloudQueue AddMessage() Clear() Create[IfNotExist]() Delete() Exists() DeleteMessage() GetMessage() PeekMessage() CloudQueueMessage CloudQueueMessage() AsBytes AsString DequeCount ExpirationTime Id InsertionTime NextVisibleTime uses creates creates CloudQueueClient GetQueueReference() ListQueues() Cloud Computing Fundamentals v.1.1

111 Communication between Role Instances
Web Role Instance Queue Worker Role Instance CloudQueue Message CloudQueue Message CloudQueueClient queueClient = storageAccount. CreateCloudQueueClient(); CloudQueue queue = queueClient.GetQueueReference( "myQueue"); queue.CreateIfNotExist(); queue.AddMessage( new CloudQueueMessage( messageContent)); public class WorkerRole : RoleEntryPoint { public override void Run() { ... CloudQueue queue = queueClient.GetQueueReference("myQueue"); queue.CreateIfNotExist(); // create queue while (true) { CloudQueueMessage msg = queue.GetMessage(); if (msg != null) { ProcessMessage(msg); queue.DeleteMessage(msg); } else Thread.Sleep(1000); Cloud Computing Fundamentals v.1.1

112 SQL Azure [Lee2009] SQL Azure is a relational database system that is offered as a cloud-based service. SQL Azure basically provides the same features as Microsoft SQL Server running on-premise. SQL Azure exposes a Tabular Data Stream (TDS) endpoint. TDS is the network protocol used SQL Server. Windows Azure SQL Azure Web/Worker Role TDS TDS On-premise ADO.NET App Cloud Computing Fundamentals v.1.1

113 SQL Azure Key Features Manageability Less administrative overhead
Low provisioning time High Availability The services replicates data to multiple physical servers No need for backup Scalability Its easy to scale up and down the number of databases. A single database is located in one storage node  limited scalability within a database  use table storage instead. Familiar Development Environment Relational data model SQL Server technology Database size is limited to 50GB Cloud Computing Fundamentals v.1.1

114 Windows Azure Service Bus [Skonnart2009]
The idea behind an Enterprise Service Bus (ESB) Enterprise Service Bus Security Orchestration Workflow Engine Messaging Routing + Transformation Registry SOAP/HTTP RMI/IIOP JMS JCA WCF-Service EJB App Java App Legacy App The Windows Azure Service Bus provides many of the features of an ESP at Internet scope ( Internet Service Bus): Identity and access control Uniform naming scheme, service registry Messaging fabric Cloud Computing Fundamentals v.1.1

115 Bidirectional Communication over the Internet
Bidirectional communication at internet scope is limited: Network Address Translation (NAT): IP addresses are note publicly addressable. Firewalls: Only some outbound ports and even a smaller set of inbound ports are allowed (typically 80 (HTTP) and 443 (HTTPS)). Basic idea to circumvent these restrictions: A relay service mediates between the client and the service. Client and Service only need (bidirectional) outbound connections. Relay Service (4) relay (1) outbound connect (bidirectional socket) Msg Msg (2) outbound connect (3) send (5) receive Client Service Cloud Computing Fundamentals v.1.1

116 Naming and the Service Registry
DNS relies on public IP addresses, hosts behind NAT rooters cannot be identified. The Service Bus naming is used for identifying service endpoints in a host independent way. Naming system: [scheme]://[service-namespace] servicebus.windows.net/name1/name2 [scheme]: “http”/”https” for HTTP endpoints, “sb” for TCP endpoints [service-namespace]: created when signing-up a Service Bus account name1, name2: defines the name hierarchy in the user’s namespace Example: sb://hagenberg.servicebus.windows.net/azure/calculator Service Registry Service Endpoints can be made publicly discoverable. Endpoints information is returned as an Atom 1.0 feed. Cloud Computing Fundamentals v.1.1

117 The Relay Service The relay service supports bindings that are quite similar to the corresponding WCF bindings. It supports many protocols, standards, and patterns: Different message versions (SOAP 1.1, SOAP 1.2) WS-Security, WS-Reliable Messaging Different messaging patterns (one-way, request/response, …) Different Web Services architecture patterns: SOAP, REST. But there is no support for transactions across services. The relay service requires the following outbound ports: HTTP: 80 HTTPS: 443 TCP one-way: 808, 828 (SSL) TCP bidirectional/TCP hybrid: 818, 819 Cloud Computing Fundamentals v.1.1

118 Messaging with WCF Relay Bindings
The messaging fabric is a service that handles connections and relays messages. The Service Bus is platform independent (there are SDKs for Java and Ruby). It is optimized for WCF by supporting different relay bindings. The most commonly used WCF bindings have corresponding Service bus bindings: BasicHttpRelayBinding: based on basic HTTP/SOAP WebHttpRelayBinding: based on HTTP/REST WS2007HttpRelayBinding: based on HTTP/SOAP, support for WS-* protocols NetTcpRelayBinding: based on TCP/SOAP There are also two new bindings: NetOnewaRelayBinding: supports only one-way messages NetEventRelayBinding: several services can register for one-way messages. Cloud Computing Fundamentals v.1.1

119 NetTcpRelayBinding – Establishing a Connection
Service Bus Ctrl Frontend Nodes (load balanced) (3) Ctrl (2) (4) (4) (1) Msg Msg Client Service Service creates an outbound bidirectional connection to a service bus node Client creates an outbound bidirectional connection to another node A control message is sent to the service indicating how to create a rendezvous connection with the client’s frontend node. The client’s node relays the messages from the client and the service Cloud Computing Fundamentals v.1.1

120 Simple Service Bus Application (1)
Definition of the service interface [ServiceContract(Namespace = " public interface ICalculator { [OperationContract] double Add(double a, double b); } Implementation of the interface public class CalculatorService : ICalculator { public double Add(double a, double b) { return a + b; } Cloud Computing Fundamentals v.1.1

121 Simple Service Bus Application (2)
Hosting of the service using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService))) { serviceHost.Open(); Console.ReadLine(); } Implementation of the client using (ChannelFactory<Icalculator> cf = new ChannelFactory<ICalculator>("CalcEndPoint")) { calcProxy = cf.CreateChannel(); double result = calcProxy.Add(5, 3); } Cloud Computing Fundamentals v.1.1

122 Simple Service Bus Application (3)
Configuration of the service <services> <service name="ServiceBus.Sample.CalculatorService"> <endpoint address="sb://hagenberg.servicebus.windows.net/calc" behaviorConfiguration="sharedSecretConfig" binding="netTcpRelayBinding" contract="ServiceBus.Sample.ICalculator" /> </service> </services> <behaviors><endpointBehaviors> <behavior name="sharedSecretConfig"> <transportClientEndpointBehavior credentialType="SharedSecret"> <clientCredentials> <sharedSecret issuerName="issuer name" issuerSecret="issuer key" /> </clientCredentials> </transportClientEndpointBehavior> </behavior></endpointBehaviors> </behaviors> Cloud Computing Fundamentals v.1.1

123 Simple Service Bus Application (4)
Configuration of the client <client> <endpoint name="CalcEndPoint" address="sb://hagenberg.servicebus.windows.net/calc" binding="netTcpRelayBinding" behaviorConfiguration="sharedSecretConfig" contract="ServiceBus.Sample.ICalculator " /> </client> <behaviors><endpointBehaviors> <behavior name="sharedSecretConfig"> <transportClientEndpointBehavior credentialType="SharedSecret"> <clientCredentials> <sharedSecret issuerName="issuer name" issuerSecret="issuer key" /> </clientCredentials> </transportClientEndpointBehavior> </behavior></endpointBehaviors> </behaviors> Cloud Computing Fundamentals v.1.1

124 NetTcpRelayBinding – Hybrid Connection Mode
Service Bus Ctrl Frontend Nodes (3) Ctrl (2) (4) (4) (1) Msg Msg (5) Client Service (1) – (4) Initial communication is relayed through the relay service while client and server negotiate a direct socket connection. (5) If a direct connection can be established the relayed connection is automatically upgraded. Cloud Computing Fundamentals v.1.1

125 Configuring Hybrid Connection Mode
<bindings> <netTcpRelayBinding> <binding name="connectionModeConfig" connectionMode="Hybrid"> <security mode="None" /> </binding> </netTcpRelayBinding> </bindings> <services> <service name="ServiceBus.Sample.CalculatorService"> <endpoint address="sb://hagenberg.servicebus.windows.net/calc" behaviorConfiguration="sharedSecretConfig" bindingConfiguration="connectionModeConfig" binding="netTcpRelayBinding" contract="ServiceBus.Sample.ICalculator" /> </service> </services> Cloud Computing Fundamentals v.1.1

126 Playground App: A comparison of Google App Engine and Microsoft Windows Azure

127 Goals Compare Microsoft Windows Azure (C#) and Google App Engine (Java) Build a simple, but state-of-the web application for the cloud Web user interface User authentication Use important services of the platform Database Blobstore Task Queue Cache Use a three-tier architecture Show timing/performance information E.g. show how long it has taken to get x objects from the database/blobstore, etc. Push to the limits  exceptions Feel the behavior and performance Compare applications regarding different aspects APIs, tools, documentation, deployment, to get started with, etc. Cloud Computing Fundamentals v.1.1

128 Basic Architecture User Interface Business Logic Data Access Layer
Stateless service APIs Stateful service APIs RDBMS Blobstore Stateless Services Cloud Computing Fundamentals v.1.1

129 Web Application Architecture
Services …. ?cmd=AddPersonToDb&number=100 Request Controller Action Browser Action Model/Data Response View Cloud Computing Fundamentals v.1.1

130 Controller Servlet Takes a the command parameter from the URL
Passes on the URL to the corresponding action object And calls the corresponding action object …. ?cmd=AddPersonToDb&number=100 public class PlaygroundServlet extends HttpServlet { protected void service(HttpServletRequest req, HttpServletResponse resp) { String actionClass = DefaultAction.class.getCanonicalName(); // parse cmd String cmd = req.getParameter("cmd"); if (cmd != null) { actionClass = String.format("%s.%sAction", WebAction.class.getPackage().getName(), cmd); } // call cmd try { Class<WebAction> clazz = (Class<WebAction>) Class.forName(actionClass); WebAction action = clazz.newInstance(); action.perform(req, resp); } catch (Exception ex) { } Cloud Computing Fundamentals v.1.1

131 Action Objects Action object calls Business logic Service(s)
Forward result data objects to the appropriate view The basic structure is as follows public class AddPersonToDbAction implements WebAction { public void perform(HttpServletRequest request, HttpServletResponse response) throws Exception { try { // get request parameters paramNumber = request.getParameter("number"); // call service or business logic personDao.insertPerson( new Person()); } catch (Exception e) {} // put result data into request request.setAttribute("timing_CpuMegaCylcles", cpuEnd-cpuStart); request.setAttribute("timing_CpuSeconds", qs.convertMegacyclesToCpuSeconds(cpuEnd-cpuStart)); request.setAttribute("timing_duration", timeStop-timeStart); // forward request RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/jsp/showTimingMeasurements.jsp"); rd.forward(request, response); } Cloud Computing Fundamentals v.1.1

132 Views (JavaServer Pages)
Take result data objects and display them accordingly The basic structure is as follows include file="inc/header.jsp"%> <h3>Timing measurements</h3> The current action has taken: <ul> <li><%=request.getAttribute("timing_duration") %> milliseconds </li> <li><%=request.getAttribute("timing_CpuMegaCylcles") %> CPU mega cycles </li> <li><%=request.getAttribute("timing_CpuSeconds") %> CPU seconds </li> </ul> <% if(request.getAttribute("exception_Message") != null ) { %> Exception: <%=request.getAttribute("exception_Message") %> <% } %> include file="inc/footer.jsp"%> Cloud Computing Fundamentals v.1.1

133 Actions Action object calls Business logic and service(s)
Forward result data objects to the appropriate view The basic structure is as follows public class AddPersonAction : IAction { /// <summary> /// Method to add Person objects. /// </summary> /// <param name="result">TimingResult object</param> /// <param name="args">Arguments for action</param> public void Perform(TimingResult result, ActionArgs args) result.Name = "Add Person to TableStorage"; for (int i = 0; i < args.Count; i++) DAOFactory.PersonDAO.AddPerson(new Person() { Name = "TestName", Biography = "TestBiography" }); } result.Items = args.Count; Cloud Computing Fundamentals v.1.1

134 Views (ASP.NET) Take result data objects and display them accordingly
The basic structure is as follows Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<PlaygroundShared.Entities.TimingResult>>" %> <asp:Content ID="Content3" ContentPlaceHolderID="TitleContent" runat="server"> Timing Results </asp:Content> <asp:Content ID="Content4" ContentPlaceHolderID="MainContent" runat="server"> <h2>List of Timing Results</h2> <table> <% foreach (var item in Model) { %> <tr> <td> <%= Html.Encode(item.Tester) %> </td> <%= Html.Encode(item.Name) %> <%= Html.Encode(String.Format("{0:F}", item.Duration)) %> </tr> <% } %> </table> Cloud Computing Fundamentals v.1.1

135 Datastore Class (e.g. Person) Entity to be stored and retrieved
Java attributes (metadata) Entity attributes to be persisted Key generation Key has either id or name id is auto-assigned Alternatively, the name is set by app Java Data Objects (JDO) Java Persistence API (JPA) Limit Maximum entity size: 1 MB Maximum size of a datastore API call request or response: 1M @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Person { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long key; @Persistent private String name; public Person() {} public Long getKey() {return key;} public void setKey(Long key) { this.key = key;} public String getName() { return name;} public void setName(String name) { this.name = name; } Cloud Computing Fundamentals v.1.1

136 Datastore JDO pattern deals with datastore access
Wraps JPA specific issues public class PersonJdoDao implements PersonDao { private static final PersistenceManagerFactory pmf = PMF.getFactory(); public void insertPerson(Person p) { PersistenceManager pm = pmf.getPersistenceManager(); try { pm.makePersistent(p); } finally { pm.close(); } public Person findById(Long key) { Person p = null; p = pm.getObjectById(Person.class, key); return p; Cloud Computing Fundamentals v.1.1

137 Datastore Action class uses required JDO(s) for datastore access
public class AddPersonToDbAction implements WebAction { public void perform(HttpServletRequest request, HttpServletResponse response) throws Exception { try { // get request parameters // call service or business logic PersonDao personDao = ServiceLocator.getInstance().getPersonDao(); Person p = new Person(); Long key = 0L; for (int i=1; i <= toBeCreated; i++) { key++; String name = "Dummy name" + key.toString(); String biography = "Dummy biography"; p.setKey(key); p.setName(name); p.setBiography(biography); personDao.insertPerson(p); } catch (Exception ex) { request.setAttribute("exception_Message", ex.getMessage()); } } } catch (Exception e) {} // put result data into request // forward request Cloud Computing Fundamentals v.1.1

138 Datastore (= TableStorage)
Class (e.g. Person) Entity to be stored and retrieved Tables provide (semi-)structured storage Tables contain a set of entities Entities contain a set of properties Tables have no fixed schema, i.e. the structure of each entity may be different Each entity has a two key properties: the partition key, and The row key An entity’s size is limited to 1MB. [DataServiceKey("PartitionKey", "RowKey")] public class Person : TableServiceEntity { public Person() PartitionKey = "1"; RowKey = Guid.NewGuid().ToString(); } public Person(string name, string biography) : this() Name = name; Biography = biography; public string Name get; set; public string Biography Cloud Computing Fundamentals v.1.1

139 Datastore (= TableStorage)
TableServiceContextEntity (=ServiceContext ) for access to TableStorage public class PersonServiceContext : TableServiceContext { public readonly string tableName = "Persons"; // name of Azure Table /// <param name="baseAddress">address of endpoint</param> /// <param name="credentials">credentials for account</param> public PersonServiceContext(String baseAddress, StorageCredentials credentials) : base(baseAddress, credentials) { } /// Get Person objects from TableStorage as Enumerable public IQueryable<Person> Persons get { return this.CreateQuery<Person>(tableName); } } /// Adds Person to ServiceContext. public void AddPerson(Person person) this.AddObject(tableName, person); this.SaveChanges(); /// Deletes Person from ServiceContext. public void DeletePerson(Person person) this.DeleteObject(person); Cloud Computing Fundamentals v.1.1

140 Datastore (= TableStorage)
Action class uses required ServiceContext for TableStorage access public class AddPersonAction : IAction { /// <summary> /// Method to add Person objects. /// </summary> /// <param name="result">TimingResult object</param> /// <param name="args">Arguments for action</param> public void Perform(TimingResult result, ActionArgs args) result.Name = "Add Person to TableStorage"; for (int i = 0; i < args.Count; i++) DAOFactory.PersonDAO.AddPerson(new Person() { Name = "TestName", Biography = "TestBiography" }); } result.Items = args.Count; Cloud Computing Fundamentals v.1.1

141 Blobstore Action class forwards request to a specific JSP (the UI)
public class AddBlobAction implements WebAction { private static final Logger log = Logger.getLogger(AddBlobAction.class.getName()); @Override public void perform(HttpServletRequest request, HttpServletResponse response) throws Exception { String page = "WEB-INF/jsp/uploadImage.jsp"; RequestDispatcher rd = request.getRequestDispatcher(page); if (rd == null) log.log(Level.SEVERE, "cannot get " + page); rd.forward(request, response); } Cloud Computing Fundamentals v.1.1

142 Blobstore JSP asks the user for the location of the Blob
Form posts Blob data to an upload servlet, which finally puts the data into the Blobstore page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %> page import="com.google.appengine.api.blobstore.BlobstoreService" %> page import="java.util.*" %> include file="inc/header.jsp"%> <% BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); %> <h3>Upload a picture and store it in the Blobstore</h3> <form action="<%= blobstoreService.createUploadUrl("/upload") %>" method="post“ enctype="multipart/form-data"> Text : <input type="text" name="fileID"/> <input type="file" name="mypicture"/> <input type="submit" value="Upload Picture"/> </form> include file="inc/footer.jsp"%> Cloud Computing Fundamentals v.1.1

143 Blobstore Upload servlet finally puts the data into the Blobstore
public class UploadBlobServlet extends HttpServlet { private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String key = "mypicture"; Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req); BlobKey blobKey = blobs.get(key); // this is the same name as in the uploadImage.jsp if (blobKey == null) { res.sendRedirect("/"); } else { // do something with the Blob if needed here // e.g. put the key into the cache Cache cache; try { cache = CacheManager.getInstance().getCache("myBlobstorage"); if (cache == null) { cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap()); CacheManager.getInstance().registerCache("myBlobstorage", cache); } cache.put("blobsX", blobs); } catch (CacheException e) {} // we show the picture in a separate view res.sendRedirect("/showImage.jsp?blob-key="+blobKey.getKeyString() ); Cloud Computing Fundamentals v.1.1

144 Blobstore JSP uses key to access Blobstore
The data is provided by the ServeBlobServlet (serve) include file="WEB-INF/jsp/inc/header.jsp"%> page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %> page import="com.google.appengine.api.blobstore.BlobstoreService" %> <% BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); String blobKey = (String)request.getParameter("blob-key"); %> </p> Here is the <a href="/serve?blob-key=<%= blobKey %>">link</a> to the picture String linkToPic = "/serve?blob-key=" + (String)request.getParameter("blob-key"); <img width="200" height="150" src="<%= linkToPic%>" ></img> include file="WEB-INF/jsp/inc/footer.jsp"%> Cloud Computing Fundamentals v.1.1

145 Blobstore ServeBlobServlet retrieves the Blob from the Blobstore and puts it into the response public class ServeBlobServlet extends HttpServlet { private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { BlobKey blobKey = new BlobKey(req.getParameter("blob-key")); blobstoreService.serve(blobKey, resp); } Cloud Computing Fundamentals v.1.1

146 Blobstore Action class uses specific BlobDAO for Blobstore access
/// <summary> /// Action for uploading file. /// </summary> public class UploadFileAction { /// Method for uploading file. /// <param name="result">TimingResult object</param> /// <param name="args">Arguments</param> public CloudBlob Perform(TimingResult result, string text, HttpPostedFileBase file) result.Name = "Upload file to BlobStorage"; result.Items = file.ContentLength; return DAOFactory.BlobDAO.UploadBlob(text, file); } Cloud Computing Fundamentals v.1.1

147 Blobstore BlobDAO for BlobStorage access
public class BlobDAO : IBlobDAO { private readonly string containerName = "playgroundfiles"; private CloudBlobContainer blobContainer; public BlobDAO() { // get account CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting(ConfigurationManager.AppSettings["ConnectionString"]); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); blobContainer = blobClient.GetContainerReference(containerName); blobContainer.CreateIfNotExist(); BlobContainerPermissions perm = blobContainer.GetPermissions(); perm.PublicAccess = BlobContainerPublicAccessType.Container; blobContainer.SetPermissions(perm); } /// Upload blob to current BlobContainer. public CloudBlob UploadBlob(string text, HttpPostedFileBase file) CloudBlob blob = blobContainer.GetBlobReference(file.FileName); blob.DeleteIfExists(); blob.UploadFromStream(file.InputStream); // upload file blob.Metadata["Text"] = text; blob.SetMetadata(); // update metadata file.InputStream.Close(); // close stream return blob; Cloud Computing Fundamentals v.1.1

148 Task Queue A task is a Java servlet A task has an associated URL
Tasks are put into a queue i.e. you put the URL with parameters into the queue A task queue has a name and a configurable rate for starting tasks Task queues can be configured in the queue.xml file /addPersonToDBTaskWorker <?xml version="1.0" encoding="UTF-8"?> <queue-entries> <queue> <name>default</name> <rate>5/s</rate> </queue> <name>dummytask-queue</name> </queue-entries> Cloud Computing Fundamentals v.1.1

149 Task Queue Putting a task into a task queue is done in an action class (e.g. AddTaskToQueueAction ) public class AddTaskToQueueAction implements WebAction { public void perform(HttpServletRequest request, HttpServletResponse response) throws Exception { Queue queue = null; String queueName = "dummytask-queue"; String taskParam1 = "DummyParam1"; // put task into queue String taskWorkerName = "addPersonToDBTaskWorker"; queue = QueueFactory.getQueue(queueName); try { TaskOptions taskOptions = TaskOptions.Builder.withDefaults(); taskOptions.url("/"+taskWorkerName ); taskOptions.method(Method.GET); taskOptions.param("taskParam1", taskParam1); queue.add(taskOptions); } catch (Exception ex) { } // forward request Cloud Computing Fundamentals v.1.1

150 Task Queue The implementation of a task is done in a servlet class (e.g. AddPersonTaskWorkerServlet ) public class AddPersonTaskWorkerServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { try { // get request parameters // call service or business logic PersonDao personDao = ServiceLocator.getInstance().getPersonDao(); Person p = new Person(); Long key = 0L; for (int i=1; i <= toBeCreated; i++) { key++; String name = "Dummy name" + key.toString(); String biography = "Dummy biography"; p.setKey(key); p.setName(name); p.setBiography(biography); personDao.insertPerson(p); } catch (Exception ex) { request.setAttribute("exception_Message", ex.getMessage()); } } } catch (Exception e) {} Cloud Computing Fundamentals v.1.1

151 Task Queue Tasks are modeled as Worker Roles
The worker role is a specialized application (e.g. thread) executing a .NET application in the background Run method extracts messages from a queue in a loop public class WorkerRole : RoleEntryPoint { public override void Run() // get account and and clients CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting(ConfigurationManager.AppSettings["ConnectionString"]); CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); // create tasks queue CloudQueue queue = queueClient.GetQueueReference("tasks"); queue.CreateIfNotExist(); // create queue // create person context PersonServiceContext personContext = new PersonServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials); tableClient.CreateTableIfNotExist(personContext.tableName); // create table Cloud Computing Fundamentals v.1.1

152 Task Queue while (true) { // process messages
CloudQueueMessage msg = queue.GetMessage(); if (msg != null) { // message in queue try { string[] content = msg.AsString.Split(';'); // split message if (content.Length == 4) { // valid content string type = content[0]; // type of message int amount = int.Parse(content[1]); // parse amount switch (type) { case "addPersonMsg": // add person task // create persons for (int i = 0; i < amount; i++) { personContext.AddPerson(new Person("WorkerPerson", "Created in a Worker")); } break; default: catch (Exception e) { } } else { Thread.Sleep(10000); // sleep for specific time Cloud Computing Fundamentals v.1.1

153 Cache To improve the performance, objects can be kept in a cache
A cache is organized as key/value pairs Key/values must be serializable (for distributing them) A cache offers put and get methods for access Interface is described by JSR 107 but is not yet an official standard App Engine provides this interface using the net.sf.jsr107 interface package A cache is managed by the CacheManager class import javax.cache.Cache; import javax.cache.CacheManager; Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap()); for (int i=1; i <= toBeAdded; i++) { // cache the data String key = paramKey + i; cache.put(key, value); } Cloud Computing Fundamentals v.1.1

154 Cache Specific configuration Maximum size of cache and time settings
Limit Maximum size of a cached value: 1 MB Cloud Computing Fundamentals v.1.1

155 Cache Intentionally left out until distributed caching with Windows Server AppFabric (Codename Velocity) is finally released (see [Sampathkumar2009]) Windows Server AppFabric provides a distributed in-memory application cache platform for developing scalable, available, and high-performance applications. It runs as a service accessed over the network. AppFabric fuses memory across multiple computers to give a single unified cache view to applications. Applications can store any serializable CLR object without worrying about where the object gets stored. Scalability can be achieved by simply adding more computers on demand. The cache also allows for copies of data to be stored across the cluster, thus protecting data against failures. Cloud Computing Fundamentals v.1.1

156 Cache Preview // CacheFactory class provides methods to return cache objects // Create instance of CacheFactory (reads appconfig) DataCacheFactory fac = new DataCacheFactory(); // Get a named cache from the factory DataCache catalog = fac.GetCache("catalogcache"); // // Simple Get/Put catalog.Put("toy-101", new Toy("thomas", .,.)); // From the same or a different client Toy toyObj = (Toy)catalog.Get("toy-101"); // // Region based Get/Put catalog.CreateRegion("toyRegion", true); // Both toy and toyparts are put in the same region catalog.Put("toy-101", new Toy( .,.), "toyRegion"); catalog.Put("toypart-100", new ToyParts(…), "toyRegion"); Toy toyObj = (Toy)catalog.Get("toy-101", "toyRegion"); [Sampathkumar2009]) Cloud Computing Fundamentals v.1.1

157 Comparison of Google App Engine and Microsoft Windows Azure

158 Criteria Documentation Services Tablestore Blobstore Tasks Cache
Programming Model / API Development Environment Deployment To get started Cloud Computing Fundamentals v.1.1

159 Evaluation: Documentation
Online Documentation Good Code examples Books and Journals on Azure A lot of books available MSDN Magazine is good Developer Forum Available Online Documentation Ok, but quite compact Code examples Available, but the 3rd party examples are often more helpful Books on Google App Engine Some books available, but level and quality may vary Developer Forum Available Cloud Computing Fundamentals v.1.1

160 Evaluation: Tablestore Services
.NET Data Services over REST API No fixed schema in the database Schema is supported by attributes LINQ as query language Highly optimized for availability Data partitioning with partition key No transactions across partitions Limit Maximum entity size: 1 MB Size of table is unlimited A table can have at most 255 properties Fixed schema in the database Java Data Objects (JDO) Java Persistence API (JPA) O/R Mapping concepts Limit Maximum entity size: 1 MB Maximum size of a datastore API call request or response: 1M Cloud Computing Fundamentals v.1.1

161 Evaluation: Blobstore Services
Highly optimized for availability Blob Containers provide a grouping of a set of blobs. Sharing policies are set a container level public read or private Provides different types of Blobs Block Blobs are optimized for streaming 200 GB Page Blobs are optimized for random access 1 TB .NET Data Services over REST API At least 2 Java servlets are involved Limit Queries never return more than 1000 records Maximum object size 50 megabytes Cloud Computing Fundamentals v.1.1

162 Evaluation: Tasks Tasks a modeled as Worker Roles
The worker role is a specialized application (e.g. thread) executing a .NET application in the background Run method extracts messages from queue in a loop The rate for starting tasks is coded into the Run method Can be put into a config file A task is a Java servlet A task has an associated URL URL with parameters is put into the queue A task queue has a name and a configurable rate for starting tasks Task queues can be configured in the queue.xml file Cloud Computing Fundamentals v.1.1

163 Evaluation: Caching Local caching Local caching
Any local object (e.g. collection) or .NET cache can be used for caching Distributed caching (service) Windows Server AppFabric (Codename Velocity) is currently in Beta stadium Local caching Any local object (e.g. collection) or JCache can be used for caching Distributed caching (service) Interface is described by JSR 107 but is not yet an official standard App Engine provides this interface using the net.sf.jsr107 interface package Cloud Computing Fundamentals v.1.1

164 Evaluation: API / Programming Model
Web application (UI) (Web) Services Many protocols like WS*, SOAP, REST Good integration with on-premise components Programming Languages .NET languages like C#, VB.NET, etc. Additionally: PHP, Ruby, etc. Execution Model Compute instances API Comprehensive Programming Model Web application (UI) Programming Languages Python and Java Execution Model Compute cycles API Not fully released Simple Cloud Computing Fundamentals v.1.1

165 Evaluation: Development Environment
Microsoft Visual Studio 2010 Mature IDE Must run in elevated mode Windows Azure Tools Easy installation Development Fabric Some limitations and differences E.g. cloud instance is running in a 64 bit environment Eclipse 3.x Mature IDE Google Plugin for Eclipse Easy installation Development App Fabric Some limitations and differences E.g. compute cycles retrieved over API always return 0 Cloud Computing Fundamentals v.1.1

166 Evaluation: Deployment
Windows Azure account necessary Easy set up Deployment via Azure Developer Portal Service endpoint configuration must be adapted 10-20 min time for provisioning compute instances Web portal for further management Good Google account necessary Easy set up Deployment via Eclipse Easy Web portal for further management Good Cloud Computing Fundamentals v.1.1

167 Evaluation: To get started
Developer Account Free resources to get started 500 MB storage 500 MB (in/out) / month 10,000 storage transaction 100,000 access control transactions 25 h of a small compute instance Developer Account Free resources to get started 500 MB storage 2 GB bandwidth / day ~ 5 million page views / month Cloud Computing Fundamentals v.1.1

168 Open Issues

169 Open Issues Software Engineering
Migrating existing apps into the cloud Programming for large distributed systems Data lock-in Scalable structured storage Performance variability, predictability Cloud Economics Appropriate use cases Total cost of ownership (TCO) Appropriate business model Availability / business continuity Cloud Computing Fundamentals v.1.1

170 Open Issues Data center operation Workloads and power management
Scale up and down Energy efficiency Thermal management Virtualization Law related issues Some laws or regulations prohibits that data is stored outside a country/business unit E.g. Michigan State University (see [Gift2008]) is defining the use of cloud computing services as follows: “Cloud-computing services must NOT be used with any of these confidential data types, unless an appropriate contractual agreement can be negotiated with the service provider by the University” E.g. Italian law requires complete knowledge on the location of the data Cloud Computing Fundamentals v.1.1

171 Open Issues Service Level Agreements Security issues
Example SLA from Amazon [DeCandia2007]: A service is guaranteeing that it will provide a response within 300ms for 99.9% of its requests for a peak client load of 500 requests per second. Security issues How can we keep control of the data? data leakage Encryption Cloud Computing Fundamentals v.1.1

172 Summary

173 Summary We discussed Cloud Computing fundamentals
Software Engineering skills needed Algorithms and programming languages Software architectures Database concepts Web architectures and frameworks Lot`s of platforms are available, but which technology or platform should be chosen? Remember the .com bubble Technology or platform should not be the driving force for a specific solution Open issues: cloud economics, security and law related issues may have a great impact Cloud Computing Fundamentals v.1.1

174 Questions

175 References [Youseff2008] L. Youseff, M. Butrico, and D. Da Silva, Towards a Unified Ontology of Cloud Computing, Grid Computing Environments Workshop (GCE08), held in conjunction with SC08, November, 2008 [Velte2009] Anthony T. Velte, Toby J. Velte, Robert Elsenpeter, Cloud Computing – A Practical Approach, McGraw Hill, 2009 [Jennings2009] Roger Jennings, Cloud Computing with the Windows Azure Platform, Wiley, 2009 [Rosenblum2005] Mendel Rosenblum, Tal Garfinkel, Virtual Machine Monitors: Current Technologies and Future Trends, IEEE Computer, May, 2005 Cloud Computing Fundamentals v.1.1

176 References [Vogels2007a] Werner Vogels, Eventually Consistent, December 23, 2008, [Vogels2008] Werner Vogels, Consolidation, ACM Queue, January/February, 2008 [Vogels2010] Werner Vogels' weblog on building scalable and robust distributed systems, [DeCandia2007] G. DeCandia, D. Hastorun, M. Jampani, G. Kakulapati, A. Lakshman, A. Pilchin, S. Sivasubramanian, P. Vosshall, and W. Vogels, Dynamo: amazon's highly available key-value store, SIGOPS Oper. Syst. Rev., vol. 41, no. 6, pp , [Online]. Available: Cloud Computing Fundamentals v.1.1

177 References [Gray1996] Jim Gray, Pat Helland , Pat O'Neil, Dennis Shasha, The Dangers of Replication and a Solution, In Proceedings of the 1996 ACM SIGMOD International Conference on Management of Data, 1996 [Ghemawat2003] Sanjay Ghemawat, Howard Gobioff, Shun-Tak Leung, The Google file system, ACM SIGOPS Operating Systems Review archive, Volume 37 , Issue 5, December 2003 [Pum2010] Martin Pum, Cloud Computing – Windows Azure Platform, Bachelor Thesis, Upper Austria University of Applied Sciences, 2010 [Oracle 2009] Oracle, Introduction to Cloud Computing Architecture, White Paper, 1st Edition, June 2009 Cloud Computing Fundamentals v.1.1

178 References [Chaganti2009]
Prabhakar Chaganti, Cloud services for your virtual infrastructure, Part 1: Infrastructure-as-a-Service (IaaS) and Eucalyptus, IBM developerWorks, December 15, 2009 [Erdogmus2009] Hakan Erdogmus, Cloud Computing - Does Nirvana Hide Behind The Nebula, IEEE Software, March/April 2009 [ShareThis2007] Amazon, AWS Case Study: ShareThis, 2007 Cloud Computing Fundamentals v.1.1

179 References [GoogleAppEngine] [Rossum2008]
[Rossum2008] Guido van Rossum, Google App Engine, Stanford EE380 Colloquium, Nov 5, 2008 [Kunze2009] Marcel Kunze, Cloud Computing mit mathematischen Anwendungen (Sommersemester 2009), Karlsruhe Institute of Technology, Fakultät für Mathematik, 2009 [Sampathkumar2009] Nithya Sampathkumar, Muralidhar Krishnaprasad, Anil Nori, Introduction to Caching with Windows Server AppFabric (Beta 1), November 2009 Cloud Computing Fundamentals v.1.1

180 References [Gift2008] David Gift, "Appropriate Use of “Cloud Computing” Services by the Michigan State University Community," Michigan State University, WORKING DRAFT 2008. [Chang2006] Fay Chang, Jeffrey Dean, Sanjay Ghemawat, Wilson C. Hsieh, Deborah A. Wallach, Mike Burrows, Tushar Chandra, Andrew Fikes, and Robert E. Gruber, Bigtable: A Distributed Storage System for Structured Data, OSDI'06: Seventh Symposium on Operating System Design and Implementation, 2006 Cloud Computing Fundamentals v.1.1

181 References [Microsoft2008]
Windows Azure Queue, Microsoft, December 2008 [Calder2009] Brad Calder, Tony Wang, Shane Mainali, and Jason Wu, Windows Azure Blob, Microsoft, May 2009 [Haridas2009] Jai Haridas, Niranjan Nilakantan, and Brad Calder, Windows Azure Table, May 2009, Microsoft [Sconnard2009] Aaron Skonnard, Developer’s Guide to Service Bus in the Windows Azure Platform AppFabric, Pluralsight, November 2009 Cloud Computing Fundamentals v.1.1

182 References [Kommalapati2010]
Hanu Kommalapati, Windows Azure Platform for Enterprises, MSDN Magazine, February 2010 [Lee2009] Jason Lee, Graeme Malcolm, and Alistair Methew, Overview of Microsoft SQL Azure Database, September 2009 Cloud Computing Fundamentals v.1.1


Download ppt "Cloud Computing Software Engineering Fundamentals"

Similar presentations


Ads by Google