Practical Load Balancing
The emergence of the cloud and modern, fast corporate networks demands that you perform judicious balancing of computational loads. Practical Load Balancing presents an entire analytical framework to increase performance not just of one machine, but of your entire infrastructure. Practical Load BalaPractical Load BalancingCopyright o 2012 by Peter Embrey, David Hows, and Eelco PluggeThis work is subject to copyright All rights are reserved by the Publisher, whether the whole or part of thematerial is concerned, specifically the rights of translation, reprinting, reuse ofillustrations, recitation,broadcasting, reproduction on microfilms or in any other physical way, and transmission or informationstorage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology nowknown or hereafter developed Exempted from this legal reservation are brief excerpts in connection withreviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed ona computer system, for exclusive use by the purchaser of the work. Duplication of this publication or partsthereof is permitted only under the provisions of the Copyright Law of the Publisher's location, in its currentversion, and permission for use must always be obtained from Springer. Permissions for use may be obtainedthrough RightsLink at the Copyright Clearance Center Violations are liable to prosecution under therespective Copyright law.ISBN978-1-4302-3680-1ISBN978-1-4302-3681-8( e Book)Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol withevery occurrence of a trademarked name, logo, or image we use the names, logos, and images only in aneditorial fashion and to the benefit of the trademark owner, with no intention of infringement of thetrademarkThe use in this publication of trade names, trademarks, service marks, and similar terms, even if they are notidentified as such, is not to be taken as an expression of opinion as to whether or not they are subject toproprietary rights.While the advice and information in this book are believed to be true and accurate at the date of publication,neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors oromissions that may be made. The publisher makes no warranty, express or implied, with respect to thematerial contained hereinPresident and publisher: paul manningLead editor: Tom WelshTechnical reviewers: Brendan horan richard pereira, Wouter thielenEditorial Board: Steve anglin, Ewan buckingham, Gary cornell, louise corrigan, Morgan ertelJonathan gennick, Jonathan Hassell, robert Hutchinson, Michelle Lowman, james MarkhamMatthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-ClarkeDominic Shakeshaft, Gwenan Spearing, Matt Wade, Tom WelshCoordinating Editor: Corbin CollinsCopy Editor: Mary BehrProduction Support: Patrick Cunninghamndexer: SPi globalArtist: SPi globalCover Designer Anna IshchenkoDistributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6thFloor, New York, NY 10013. Phone 1-800-SPRINGER, fax(201)348-4505, e-mail orders-ny@springer-sbm comorvisitwww.springeronline.comForinformationontranslationspleasee-mailrights@apress.comorvisitwww.apress.comApress and friends of ed books may be purchased in bulk for academic, corporate, or promotional use eBookversions and licenses are also available for most titles. For more information, reference our Special Bulk salesebooKlicensingwebpageatwww.apress.com/bulk-salesAny source code or other supplementary materials referenced by the author in this text is available to readersatwww.apress.comFordetailedinformationabouthowtolocateyourbookssourcecodegotowww.Apress.com/source-code/For Professor Keith Chan and Doctor Yuri Demchenko whose unwavering support, guidance, andunderstanding have made so many things possiblePeter embreyFor my son Jesse and the one who will soon be calling him "grote broer.eelco pluggeTo Jacqui for her support, her patience, and most of all her loveDavid howsContents at a glanceAbout the authorsAbout the technical reviewersSpecial Thanks to serverlove a mmmm RRER RRE RRIRERaIEIIEE XixAcknowledgments■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■口■Preface… XXIChapter 1: IntroductionChapter 2: How Web Sites Work.a9Chapter 3: Content Caching: Keeping the Load light aa29Chapter4: DNS Load Balancing…,,,,,,,,…,…,,,,…,,,,,,…53Chapter 5: Content Delivery Networks mammmmmmmmmmmmmmam 71Chapter6: Planning for Performance and Reliability,,,,…,…,…,93Chapter 7: Load Balancing Basics mm mma■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■109Chapter8: Load Balancing Your Web Site…,…,",…,,…,:117Chapter 9: Load Balancing Your Database a mRB amImIIRaIa 135Chapter 10: Network Load Balancing ammmmmmmmmmmmmm RIIm 153Chapter 11: SSL Load Balancing■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■175Chapter 12: Clustering for High Availability aanr■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■193Chapter 13: Load Balancing in the Cloud■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■a■口■■211Chapter 14: IPv6: Implications and concepts.RRBRERIRRIRRIRIIIRIIIm 225Chapter 15: Where to Go Next .m m mmm mnmmmanamam 235Index…243ContentsAbout the authorsAbout the technical reviewersSpecial Thanks to serverlove■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■XXAcknowledgments ummamamammammammamammmamammaaaam XXPreface■■■■■■■■■■■■■■■■■■■■■■■■■■■XXChapter 1: IntroductionThe Problem■■■■■■■■■■■■■ II■■■■■D■■■■■■■ I■■■■■■■■■■■■■ DThe solution2What Is Load Balancing?3Load Balancing Old Style.....3Load Balancing, New Style..........................3Scaling UpScaling outoad Balancing, FinallyWhat makes the web tick?Caching Warp Drive for Your Web site5Load Balancing with DNS面面面日日日面a日日日面自量B面日日面日面日自B自日面B日日面面日自日自日自面面面自n日自日面日日Content Delivery Networks………5Proper Planning Prevents Pretty poor Performance6The essentials∴Http Load Balancing .........cLoad Balancing Your Database.........■ CONTENTSL0 ad Balancing Your Network Connection.…,.,,…7SSLL0 ad Balancing………Clustering for High AvailabilityLoad balancing in the cloudPv6: Implementation and Concepts……Where to go next8Summary■■■■■D■■■■■■■nnnD■■■■■■■■■■■■■ D8Chapter 2: How Web Sites Work■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■9Let the games commence10Coming from a Non-IT Background ...........Kicking off the Process.................Finding the site with DNSConnecting to the Server(Finally!)量面On the server itself12Talking to the database12Quick L0 ok at Caching…13Back to the clientTaking a Closer L0ok…13The network14TCP自a面14DNS16Speed, Bandwidth, and Latency.................Network Summary……,…20HTML and the webHTMIaa面21Why is Text-Based Important? ..21Why is Linking Important?■日自日自自自面日面日自面日日面日日日自自自日日日日22HTML Summary.23The browserCONTENTSWeb content24Static ContentDynamic Content.…,…555Creating Dynamic ContentWeb Content Summary…,Databases: the weakest link27Summary…27Chapter 3: content Caching: Keeping the load light mamamamm 29What is a cache?30Whistle stop Tour■■■■■D■■■■■■■nnnD■■■■■■■■■■■■■ D30Browser-based cachingWeb acceleratorsWeb proxies3323Transparent Web ProxiesEdge- based caching….,,……35Platform Caching…,…,35Application caching…Database CachingJust the beginningCaching Theory: Why Is it so HardHttp 1.0 Caching Support38Http 1.1 enHanced Caching SupportThe solutionCaching Isn' t as easy as|tL0okS…....,…,40Web proxies………40The squid proxy server......................Getting Started.…443Troub| shooting……■ CONTENTSTransparent proxiesWhat's Going On……Getting a Helping HandSquid, the Swiss Army Knife of Proxies......56dge-based Caching: Introducing Varnish46Sane Caching by Default.…..…日面日日面日日面B面47Installing Varnish48Getting Up and Running….……49Customizing varnish自面日面日自日日日日面面日正日面日面日面51Summary…51Chapter 4: DNS Load Balancingu53DNS Details153The ip addressThe problem54The solution面面面Taking a step back…55DNS in Depth■D■■■■■■■■■■■■an■■■■■■■■■■■■■■■■■■■■■■■55Querying Yourself…,56Advanced DNS Queries日日自面日DNS Caching…,58Querying your DNS Cache……DNS Cache in linux,60The real stuffBIND961DNS DB Header62dNS Database entriesLoading your DBChecking the Config,65CONTENTSCommon Issues66Testing your DNS66DNS Load Balancing…………………67Advantages of DNS Load BalancingIssues with DNS Load Balancing68Summary…,9Chapter 5: content Delivery Networks■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■71Choosing a cdn providerGetting Started with Rackspace22■■■■■■D■■■■ D■■■■■■■■■■■■■aaaa■aaaaAdding content to your cDn Account74The rackspace Cloud Files aPl77Integrating the API into PHP……Authenticating with Your API Key…78Connecting and Disconnecting..................……78Working with ContainersWorking with Filesother Useful functionsSummary92Chapter 6: Planning for Performance and Reliability■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■93yoU MAke DInner In TIME■■■■■■■■■■■■nn■■■■■■■■■■■■■94MAke∴D|nner………98TIME面日自日日面面日面正B自日面日面日自日日面面aThe Importance of Planning…,,,,,,,,,…101
用户评论