• No results found

Practical Load Balancing

N/A
N/A
Protected

Academic year: 2021

Share "Practical Load Balancing"

Copied!
13
0
0

Loading.... (view fulltext now)

Full text

(1)

Practical Load

Balancing

Ride the Performance

Tiger

Illtil

Peter

Membrey

David Hows

Eelco

Plugge

(2)

Contents

About the Authors xvii

About the Technical Reviewers xviii

Special

Thanks to serverlove xix

Acknowledgments

xx

Preface xxi

Chapter

1: Introduction 1

The Problem 1

The Solution 2

What Is Load

Balancing?

3

Load Balancing,OldStyle 3

Load Balancing,NewStyle 3

Scaling Up 3

ScalingOut 4

Load

Balancing,

Finally

4

What Makes the Web Tick? 4

Caching: WarpDrive for Your Web Site 5

Load Balancingwith DNS 5

ContentDeliveryNetworks 5

Proper PlanningPreventsPrettyPoor Performance 6

The Essentials 6

HTTP LoadBalancing 6 LoadBalancing YourDatabase 6

(3)

CONTENTS

LoadBalancingYour Network Connection 7

SSL LoadBalancing 7

ClusteringforHigh Availability 7

LoadBalancingin the Cloud 7

IPv6:Implementation andConcepts 7

Where To Go Next 8

Summary

8

Chapter

2: How Web Sites Work 9

Let the Games Commence! 10

ComingfromaNon-ITBackground 10

KickingOff the Process 10

Finding theSite with DNS 11

Connectingto the Server(Finally!) 11

On the Server itself 12 Talkingto the Database 12

QuickLook atCaching 13 Backto theClient 13

Taking

a Closer Look 13

The Network 14

TCP 14

DNS 16

Speed, Bandwidth,and Latency 17

NetworkSummary 20

HTML and the Web 20

HTML 21

Whyis Text-BasedImportant? 21

Why isLinkingImportant? 22

HTMLSummary 23

(4)

«CONTENTS

Web Content 24

StaticContent 25

DynamicContent 25

CreatingDynamicContent 25

WebContent Summary 27

Databases: The Weakest Link 27

Summary

27

Chapter

3: Content

Caching:

Keeping

the Load

Light

29

What IsaCache? 30

Whistle

Stop

Tour 30

Browser-basedCaching 31 Web Accelerators 31

Web Proxies 32

TransparentWeb Proxies 33

Edge-based Caching 35

PlatformCaching 35

Application Caching 36

DatabaseCaching 37

JusttheBeginning 37

Caching

Theory:

Why

Is ItsoHard? 37

HTTP1.0CachingSupport 38

HTTP1.1 EnhancedCachingSupport 38

The Solution 39

Caching Isn'tasEasyasItLooks 40

Web Proxies 40

TheSquidProxyServer 41

GettingStarted 41

Troubleshooting 43

(5)

mCONTENTS

TransparentProxies 43

What's Going On 44

GettingaHelpingHand 45

Squid,the SwissArmyKnife ofProxies 46

Edge-based Caching: Introducing

Varnish 46

Sane CachingbyDefault 47

InstallingVarnish 48

Getting UpandRunning 49

CustomizingVarnish 51

Summary

51

Chapter

4: DNS Load Balancing 53

DNS Details 53

The IPAddress 53

TheProblem 54

The Solution 54

Taking aStepBack 55

DNS in

Depth

55

QueryingYourself 56

Advanced DNS Queries 57

DNS

Caching

58

QueryingyourDNS Cache 59

DNSCache in Linux 60

The RealStuff 60

BIND9 61

DNS DB Header 62

DNSDatabase Entries 63

LoadingyourDB 65

CheckingtheConfig 65

(6)

CONTENTS

Common Issues 66

TestingyourDNS 66

DNS Load

Balancing

67

Advantagesof DNSLoadBalancing 67

Issues with DNSLoadBalancing 68

Summary

69

Chapter

5: Content

Delivery

Networks 71

Choosing

aCDN Provider 72

Getting

Started with

Rackspace

72

Adding

Content to Your CDN Account 74

The

Rackspace

Cloud Files API 77

Integratingthe API into PHP 77

Authenticating with YourAPI Key 78

Connecting and Disconnecting 78

Workingwith Containers 79

Workingwith Files 85

OtherUseful Functions 91

Summary

92

Chapter

6:

Planning

for Performance and

Reliability...

...93

yoU

MAke Dinner In TiME 94

yoU 94

MAke 97

Dinner 97

In 98

TiME 100

TheImportanceofPlanning 101

(7)

SCONTENTS

Backups

103

WhyBackupsAresoImportant 103

There MayBe Trouble Ahead 103

Automation isaMust 104

Tactical Backups 105

StrategicBackups 105

Incrementalvs. Full 106

Please, PleasePerform Test Restores! 106

Summary

106

Chapter

7: Load

Balancing

Basics 109

What Is Load

Balancing?

109

What

Computing

Resources AreAvailable? 110

Processor(CPU) 110

Memory(RAM) 111

CheckingPerformance ofCPUand RAM with top 111

Network 113

Storage (Disk) 114

Load

Balancing

in Practice 114

Guiding

Principles

115

UnderstandYourSystem 115

Planning 116

MonitoringandTesting 116

Summary

116

Chapter

8: Load

Balancing

Your Web Site 117

Measuring

Web Server Performance 117

Accelerating Apache

HTTP 120

Disabling UnneededModules 120

(8)

aCONTENTS

UsingCompression 121

FollowSymLinksandSymLinkslfOwnerMatch 123

Accelerating

nginx

123

worker_processesandworker_cpu_affinity 124

Gzip Compression 125

Load

Balancing

Your Web Server 126

TheSetup 127

Preparingthe Server 128

Preparingthe Workers 130

TestingtheLoad Balancer 131

Best of Both Worlds 132

Summary

134

Chapter

9: Load

Balancing

Your Database 135

Setting

up the

MySQL

Cluster 135

InstallingtheManagementSoftware 137

Configuringthe ManagementSoftware 138

Preparingthe Cluster'sDataNodes 140

Installingthe MySQLServer and NOB Daemon 141

Configuringthe NDB Daemon 142

StartingtheCluster Node's Services 143

Updating MySQL'sRoot User 144

TestingtheInstallation 145

Applying

Load

Balancing

147

TheSetup 148

Settingupthe Load Balancer 148

Preparingthe Workers 150

Testingthe Load Balancer 150

Summary

151

(9)

CONTENTS

Chapter

10: Network Load

Balancing

153

Sharing

the Workload 153

TCP/IP 154

TCP 154

IP 155

Routing

155

The Load Balancer 157

IPVS 160

IPVSScheduling 160

IPVS Installation onUbuntu 162

IPVSInstallationonCentos 163

IPVSADM 164

Expanding

IPVS 166

Advanced IPVS 167

Changing Scheduling Algorithm 167

Assigning WeightValues 168

Protocol andMultipleVirtual Servers 170 Another IP Address 171

Making

It Stick 173

Summary

174

Chapter

11: SSL Load

Balancing

175

Whatare SSLandTLS? 175

Public-Key

Cryptography

176

Trust and Certificate Authorities 177

TLS

Encryption

178

TLS Load

Balancing

178

(10)

CONTENTS

Configuring

SSL onYour WebServer 179

Apache 181

Nginx 182

SSLAcceleration 182

Apache 183

Nginx

183

SSL Termination 183

Configuring Nginx

184

Testing

the SSL 185

Further

Configurations

187

Engine 187

Caching 188

Protocols 189

SpecificCiphers 189

LVS and Your SSL Terminator 191

Integrated

Load Balancer/SSL Terminator 192

Summary

192

Chapter

12:

Clustering

for

High Availability

193

High

Availability

194

Single

Point of Failure 195

Clustering

197

IPVS Failover 198

Install with Ubuntu 199

Install with Centos 200

Configure 200

CommonConfigProblems 203

ConfirmingYourSystem 204

(11)

ilCONTENTS

Testing

206

Web Server

Specifics

207

Ubuntu 207

Centos 207

Advanced

Config Options

208

ha.cf 208

Idirectord.cf 208

Web Server 209

Summary

209

Chapter

13: Load

Balancing

in the Cloud 211

Cloud

Computing

211

Virilization 212

Hypervisor 212

Virtualized Resources 215

Managing

Virtual Resources 216

Balancing 217

Overprovisioning 219

Planning 219

Cloud

Elasticity

220

Working

withaCloud Server 221

Summary

224

Chapter

14: IPv6:

Implications

and

Concepts

225

IPv6 225

Hexadecimal Notation 225

(12)

mCONTENTS

IPv4 Exhaustion 226

Approach

to IPv6 227

Advantages

of IPv6 227

Implementation

228

Internet Connection 229

DNS 230

Operating

System

230

Networking

230

Single GatewayNetwork 231

Dual Network 231

Application Support

231

Apache 231

Nginx 232

Varnish Cache 232

Memcached 233

IPVS 233

Ldirectord 234

Heartbeat 234

Summary

234

Chapter

15: Where to Go Next 235

Recap 236

Monitoring

236

Security

237

AccessControl 238

Views 238

CommonExploitPrevention 239

(13)

*CONTENTS

Operating

System

Performance 240

CompileYourself 240

CutDown 240

High-PerformanceOS 241

Planning 241

Summary

241

Index.. ....243

References

Related documents

ORTHOPAEDIC SURGERY FOR THE LOWER LIMBS IN CHILDREN WITH CEREBRAL

Most of the schools (about 85%) apply a test for this purpose called the Eindtoets Basisonderwijs (Cito, 2012; Van der Lubbe, 2007), whereas the remainder apply other tests

In this paper, we propose a method for simultaneously reducing the dimensionality of very high-dimensional input and output spaces in Gaussian process emulators for stochastic

Service (RAS): North Simcoe – Muskoka Access and Accountability: Improving Acute Mental Health and Addiction Service Rideau Valley Diabetes Services Primary Health Partnership

MGC2SD-1 UPFLOW / HORIZONTAL - COMPONENT LOCATION Heat Exchanger Main Air Limit Switch Pressure Switches (Condensate) Transformer Door Switch Outlet Header Box Inducer Orifice

The results show that fatal road accidents have a negative long-run effect on economic growth while on the other hand labour productivity, unemployment, real

On the other hand, in the absence of a forfeiture rule, if there is substantial factual uncertainty, the insurer may benefit from refusing to defend and thus lowering defense

As a constitutional matter, prescriptive jurisdiction issues come in two main flavors: power and rights. Power issues relate to the power of the state or sovereign