Sie sind auf Seite 1von 38

Practical Cloud Computing Patterns

Session S311528

John Stanford
Principal Field Technologist

Scott Mattoon
Principal Field Technologist

Ken Pepple
Principal Engineer

Learn How To Combine Software and Infrastructure Patterns to Effectively Leverage Cloud Computing With Your Application

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

Agenda

Software and Infrastructure Pattern Introduction Common Web Functional Patterns Cloud Provisioning Patterns Cloud Monitoring Patterns Cloud Resource Patterns

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

Software and Infrastructure Patterns

Most famously described in Design Patterns: Elements of Reusable Object-Oriented Software for software Single solution that could be implementing many different ways to solve many problems Also applied to infrastructure problems Building blocks of applications and architectures
2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 4

Web 2.0 Application Functional Architecture

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

Cloud Compute Instance Provisioning

Cloud APIs transform provisioning from a procedure mostly done by system admins to code executed in response to events (Deployment Engineering) Need to be heavily automated so that they can be invoked dozens of times per day Need to be flexible to cover all tiers of application architecture

Application servers refreshed daily Database servers updated yearly Application code pushed System image static

Sometimes a combination of patterns


2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

Cloud Provisioning Elements & Participants

Provisioned Elements

Base OS Utilities and agents Platforms and frameworks Custom application code Configuration files Data and volumes Console Cloud interface Compute instance Image repository CMDB Provisioning system
2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 7

Participants

Static Image Provisioning


Very simple scripted provisioning from golden images Deploys full stack to cloud compute image with little customisation Appropriate for low complexity, low volatility code bases Easy integration into existing monitoring processes May be more secure could run keyless External orchestration left to console (load balancer) Requires very good Test/QA procedures and management of golden images May be used for small parts of the larger strategy

Appliances like DNS or monitoring servers Low code volatility, highly available servers like databases
2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 8

Static Image Provisioning Sequence

magic happens

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

Static Implementation: Simple Ruby Script (EC2)


#!/usr/bin/env ruby require 'rubygems' require 'ec2' ACCESS_KEY_ID = ENV['AWS_KEY_ID'] SECRET_ACCESS_KEY = ENV['AWS_SEKRIT_ACCESS_KEY'] IMAGE_ID = ARGV[0] # identifies image to be launched ec2 = EC2::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY) # opens cloud connection ec2.run_instances( :image_id => IMAGE_ID, :min_count => 1, :user_data allows us to pack :max_count => 5, payload with post-boot data or :key_name => nil, scripts for instance customisation :group_id => [], :user_data => nil, :addressing_type => "public", :instance_type => "m1.small", :availability_zone => nil) # launches 1-5 small instances
2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 10

Push Provisioning

Builds on static pattern by pushing additional provisioning instructions from console Usually implemented as scripted shell commands over SSH Requires more administrative knowledge and substantial scripting (error handling) Easy integration into existing system administration and developer processes Appropriate for higher codebase volatility and architectural complexity but may not scale

Have to login into each new instance from console for many long transactions

Many open source tools available


2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 11

Push Provisioning Sequence

This process may interact with other systems as part of the commands. For example, install scripts may pull down packages from the Internet.

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

12

Push Provisioning: Simple Ruby Script (EC2)


#!/usr/bin/env ruby require 'rubygems' require 'ec2' require 'net/ssh' ACCESS_KEY_ID = ENV['AMAZON_ACCESS_KEY_ID'] SECRET_KEY = ENV['AMAZON_SECRET_ACCESS_KEY'] KEY_NAME = ARGV[0] # which key to bind to instance for login KEY_FILE_NAME = ARGV[1] # name of the keyfile ec2 = EC2::Base.new(:access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_KEY) instance = ec2.run_instances(:image_id => ami-3c47a355, :key_name => KEY_NAME) my_instance_id = instance.instancesSet.item[0].instanceId loop do begin instance_status = ec2.describe_instances(:instance_id => my_instance_id) break if instance_status.reservationSet.item[0].instancesSet.item[0].instanceState.name.m atch("running") sleep(30) end end sleep(30) # to let sshd fully load instance_status = ec2.describe_instances(:instance_id => my_instance_id) Net::SSH.start(instance_status.reservationSet.item[0].instancesSet.item[0].dnsNa me , "root", :keys => KEY_FILE_NAME, :verbose => :info) do |ssh| output = ssh.exec!("touch ~/snuffy.conf") end
2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 13

Pull Provisioning

Builds on static pattern by introducing client/server interactions between compute instance and separate provisioning server

Compute instance checks periodically with provisioning server for it's configuration Provisioning server tracks, compiles and distributes configuration rules CMDB may be separate or combined for reporting

Appropriate for high codebase volatility and architectural complexity at great scale Adds several new participants which introduce administrative overhead and points of failure Provisioning server handles external orchestration
2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 14

Pull Provisioning Sequence

This loops at interval depending on implementation

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

15

Pull Provisioning Example: Puppet

Node runs facter and puppetd

Server runs puppetmasterd

More info on puppet at http://reductivelabs.com/


2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 16

Comparing Provisioning Patterns Suitability


Static High Volatility High Scale Repeatability Maintainability Ideal Use low high high high appliances Push medium low low low small apps Pull high high high medium large apps

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

17

Monitoring Apps in the Cloud

Crucial Function of Application Service Operations Forces (Business Inputs)


SLA Margin Analysis

Primary Stategies

Agent Based Polling

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

18

Cloud Service Monitoring Elements & Participants

Monitored Elements:
Availability Utilization Latency / Throughput Integrity

Running Instances * *

Images

Object Storage

Network

Participants

Scripts and Agents Management Frameworks Rules Logs Console Gateways / Proxies Cloud interface

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

19

Agent Based

Pros

Rich data High control over what's observed Realtime event detection Resource overhead on every instance Data traverses public network Lifecycle sustaining implications

Cons

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

20

Agent Based

Pros

Rich data High control over what's observed Realtime event detection Resource overhead on every instance Data traverses public network Lifecycle sustaining implications

Cons

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

21

Watch Polling

Pros

No resource overhead Simple Scope is dimensionable No sustaining implications Costs 1.5 / Instance / Hr Limited data Lock in

Cons

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

22

Watch Polling Sequence

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

23

Example: Watch Polling Driven Elasticity

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

24

Cloud Resource Administration Patterns


Need to answer complex questions to perform actions Must move away from spreadsheet management Don't want to leave decision making to end customer

Exposes complexity Opens door to collisions Consistency Repeatability Singleton, pooled, generated Owned, shared

Do want to enable

Resource Types

Allocation Types

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

25

Resource Administration The Big Picture

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

26

Singleton Resource Overview


Only one instance of the resource Many to one mapping with consumers Examples of resources:

DNS server name Load balancer IP Firewall IP Future-proofing Capacity planning Depend on consumer good behavior Implement an auditor to determine which resources are in use Consider TTLs on reservations that fail the audit
2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 27

Why bother?

Risks

Mitigation

Singleton Resource Structural Pattern

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

28

Singleton Resource Sequence Pattern

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

29

Pooled Resource Overview


Discrete number of resource instances Defined/Created outside the system Examples of resources:

IP range VLAN range Instance ID (when there is a max # of instances) Better than a spreadsheet Depend on consumer good behavior to release instances Depends on admin good behavior to define unique instances Implement an auditor to determine which resources are in use Consider TTLs on reservations that fail the audit
2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 30

Why bother?

Risks

Mitigation

Pooled Resource Structural Pattern

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

31

Pooled Resource Sequence Pattern

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

32

Generated Resource Overview


Unlimited number of resource instances Created within the system based on policies Examples of resources:

Host names Instance ID (when there is no max # of instances) Correlated to external information (date, time, moon phase) Avoids duplication Promotes consistency Dependent on policy accuracy Sample data generator Testing
2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 33

Why bother?

Risks

Mitigation

Generated Resource Structural Pattern

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

34

Generated Resource Sequence Pattern

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

35

Summary

There is substantial reuse of traditional software and infrastructure patterns in cloud applications Characteristics of cloud computing force many of the operational patterns to be formalized and addressed through code during development There are some new functional and non-functional areas of patterns for cloud applications The composition of these patterns have new and unexpected non-functional implications Architecture is more important than ever

2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone

36

Call to Action

Visit the pattern library


Propose a pattern Comment on an existing pattern Propose an anti-pattern https://wikis.sun.com/display/cloud/Patterns Storage Compute OpenOffice Netbeans/Kenai http://www.sun.com/cloud http://kenai.com/projects/suncloudapis
2009 CommunityOne WEST Conference | san francisco, ca | developers.sun.com/events/communityone 37

Learn About The Sun cloud


Build your own cloud

Practical Cloud Computing Patterns


Session S311528

John Stanford
john.stanford@sun.com

Scott Mattoon
scott.mattoon@sun.com

Ken Pepple
ken.pepple@sun.com

Das könnte Ihnen auch gefallen