www.it-ebooks.info www.it-ebooks.info Cloud Architecture Patterns Bill Wilder www.it-ebooks.info Cloud Architecture Patterns by Bill Wilder Copyright © 2012 Bill Wilder All rights reserved Printed in the United States of America Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O’Reilly books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (http://my.safaribooksonline.com) For more information, contact our corporate/ institutional sales department: 800-998-9938 or corporate@oreilly.com Editor: Rachel Roumeliotis Production Editor: Holly Bauer Proofreader: BIM Publishing Services Indexer: BIM Publishing Services Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Elizabeth O’Connor, Rebecca Demarest Revision History for the First Edition: 2012-09-20 First release See http://oreilly.com/catalog/errata.csp?isbn=9781449319779 for release details Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc Cloud Architecture Patterns, the image of a sand martin, and related trade dress are trademarks of O’Reilly Media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade mark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein ISBN: 978-1-449-31977-9 [LSI] www.it-ebooks.info Table of Contents Preface ix Scalability Primer Scalability Defined Vertically Scaling Up Horizontally Scaling Out Describing Scalability The Scale Unit Resource Contention Limits Scalability Easing Resource Contention Scalability is a Business Concern The Cloud-Native Application Cloud Platform Defined Cloud-Native Application Defined Summary 3 6 9 10 11 Horizontally Scaling Compute Pattern 13 Context Cloud Significance Impact Mechanics Cloud Scaling is Reversible Managing Session State Managing Many Nodes Example: Building PoP on Windows Azure Web Tier Stateless Role Instances (or Nodes) Service Tier Operational Logs and Metrics 13 14 14 14 14 17 20 22 23 23 24 25 iii www.it-ebooks.info Summary 26 Queue-Centric Workflow Pattern 27 Context Cloud Significance Impact Mechanics Queues are Reliable Programming Model for Receiver User Experience Implications Scaling Tiers Independently Example: Building PoP on Windows Azure User Interface Tier Service Tier Synopsis of Changes to Page of Photos System Summary 28 28 28 28 30 31 36 37 38 38 39 40 41 Auto-Scaling Pattern 43 Context Cloud Significance Impact Mechanics Automation Based on Rules and Signals Separate Concerns Be Responsive to Horizontally Scaling Out Don’t Be Too Responsive to Horizontally Scaling In Set Limits, Overriding as Needed Take Note of Platform-Enforced Scaling Limits Example: Building PoP on Windows Azure Throttling Auto-Scaling Other Resource Types Summary 43 44 44 44 45 46 47 47 48 48 48 50 50 51 Eventual Consistency Primer 53 CAP Theorem and Eventual Consistency Eventual Consistency Examples Relational ACID and NoSQL BASE Impact of Eventual Consistency on Application Logic User Experience Concerns Programmatic Differences iv | Table of Contents www.it-ebooks.info 53 54 55 56 57 57 Summary 58 MapReduce Pattern 59 Context Cloud Significance Impact Mechanics MapReduce Use Cases Beyond Custom Map and Reduce Functions More Than Map and Reduce Example: Building PoP on Windows Azure Summary 60 61 61 61 62 63 64 64 65 Database Sharding Pattern 67 Context Cloud Significance Impact Mechanics Shard Identification Shard Distribution When Not to Shard Not All Tables Are Sharded Cloud Database Instances Example: Building PoP on Windows Azure Rebalancing Federations Fan-Out Queries Across Federations NoSQL Alternative Summary 67 68 68 68 70 70 71 71 72 72 73 74 75 76 Multitenancy and Commodity Hardware Primer 77 Multitenancy Security Performance Management Impact of Multitenancy on Application Logic Commodity Hardware Shift in Emphasis from MTBF to MTTR Impact of Commodity Hardware on Application Logic Homogeneous Hardware Summary 77 78 78 79 79 80 81 82 82 Busy Signal Pattern 83 Context 83 Table of Contents www.it-ebooks.info | v Cloud Significance Impact Mechanics Transient Failures Result in Busy Signals Recognizing Busy Signals Responding to Busy Signals User Experience Impact Logging and Reducing Busy Signals Testing Example: Building PoP on Windows Azure Summary 84 84 84 85 87 87 88 89 89 90 91 10 Node Failure Pattern 93 Context Cloud Significance Impact Mechanics Failure Scenarios Treat All Interruptions as Node Failures Maintain Sufficient Capacity for Failure with N+1 Rule Handling Node Shutdown Recovering From Node Failure Example: Building PoP on Windows Azure Preparing PoP for Failure Handling PoP Role Instance Shutdown Recovering PoP From Failure Summary 93 94 94 94 94 95 96 96 98 99 99 101 104 104 11 Network Latency Primer 105 Network Latency Challenges Reducing Perceived Network Latency Reducing Network Latency Summary 105 107 107 107 12 Colocate Pattern 109 Context Cloud Significance Impact Mechanics Automation Helps Cost Considerations Non-Technical Considerations vi | Table of Contents www.it-ebooks.info 109 110 110 110 111 111 111 Example: Building PoP on Windows Azure Affinity Groups Operational Logs and Metrics Summary 111 112 112 113 13 Valet Key Pattern 115 Context Cloud Significance Impact Mechanics Public Access Granting Temporary Access Security Considerations Example: Building PoP on Windows Azure Public Read Access Shared Access Signatures Summary 115 116 116 117 118 119 120 121 121 122 123 14 CDN Pattern 125 Context Cloud Significance Impact Mechanics Caches Can Be Inconsistent Example: Building PoP on Windows Azure Cost Considerations Security Considerations Additional Capabilities Summary 126 127 127 127 128 129 130 130 130 131 15 Multisite Deployment Pattern 133 Context Cloud Significance Impact Mechanics Non-Technical Considerations in Data Center Selection Cost Implications Failover Across Data Centers Example: Building PoP on Windows Azure Choosing a Data Center Routing to the Closest Data Center Replicating User Data for Performance 133 134 134 134 135 136 136 137 138 138 138 Table of Contents www.it-ebooks.info | vii Replicating Identity Information for Account Owners Data Center Failover Colocation Alternatives Summary 140 141 142 143 A Further Reading 145 Index 153 viii | Table of Contents www.it-ebooks.info ...www.it-ebooks.info Cloud Architecture Patterns Bill Wilder www.it-ebooks.info Cloud Architecture Patterns by Bill Wilder Copyright © 2012 Bill Wilder All... seldom used patterns Cloud platform services simplify building cloud- native applications The architecture patterns described in this book were selected because they are useful for building cloud- native... users to benefit from cloud- native patterns Architecting an application using the patterns in this book will lead to a cloud- native application Applications using these patterns should have advantages