Professional Documents
Culture Documents
High Availability: Scalability
High Availability: Scalability
com
Scalability &
CONTENTS INCLUDE:
n
Overview
n
Implementing Scalable Systems
High Availability
n
Caching Strategies
n
Clustering
n
Redundancy and Fault Tolerance
n
Hot Tips and more...
By Eugene Ciurana
Scalability, continued
Overview
the amount of main memory to host more virtual servers in the
Scalability, High Availability, and Performance same hardware.
The terms scalability, high availability, performance, and
mission-critical can mean different things to different Virtual Node 3
organizations, or to different departments within an Virtual Node 2
CONTENTS INCLUDE:
Cheat Sheets.
Chain of Responsibility
Design Patterns
n
n
Command Inspired
n
Interpreter by the
n
Iterator GoF
Bestseller
n
Mediator
n
Observer By Jason McDonald
n
Template Method and more...
Load Balancer
Choose your
Chain of Responsibility, continued
ABOUT DESIGN PATTERNS
Use n Multiple objects may handle a request and the handler doesnt have to
When be a specific object.
This Design Patterns refcard provides a quick reference to the n A set of objects should be able to handle a request with the handler
original 23 Gang of Four (GoF) design patterns, as listed in determined at runtime.
n A request not being handled is an acceptable potential outcome.
the book Design Patterns: Elements of Reusable Object-
Oriented Software. Each pattern includes class diagrams, Example Exception handling in some languages implements this pattern. When an
exception is thrown in a method the runtime checks to see if the method
explanation, usage information, and a real world example.
favorite topics.
has a mechanism to handle the exception or if it should be passed up the
call stack. When passed up the call stack the process repeats until code to
Creational Patterns: Used to construct objects such handle the exception is encountered or until there are no more parent
that they can be decoupled from their implementing objects to hand the request to.
system.
Spring Configuration
w w w.dzone.com
be changed at runtime.
Node Node Node Node Class Scope: Deals with class relationships that can be
changed at compile time.
Receiver
Command
+execute ( )
jQuery Selectors
the request to be handled in traditionally object based relationships such
C Abstract Factory S Decorator C Prototype as queuing and callbacks.
Windows Powershell
C S Flyweight C Singleton
Builder
Example Job queues are widely used to facilitate the asynchronous processing
B B Interpreter B State of algorithms. By utilizing the command pattern the functionality to be
Chain of
Figure 1: Clustering
executed can be given to a job queue for processing without any need
Responsibility B Iterator B Strategy for the queue to have knowledge of the actual implementation it is
invoking. The command object that is enqueued implements its particular
Figure 1 - Clustering
B Command
EJB 3
B Mediator B Template Method algorithm within the confines of the interface the queue is expecting.
S Composite B Memento B Visitor
successor
<<interface>>
Client Handler
Purpose Gives more than one object an opportunity to handle a request by linking
receiving objects together.
High availability depends on the expected uptime defined for Figure 3: Load BalancerFigure 3 - Load Balancer
system requirements; dont be misled by vendor figures. The
Scheduling rules are algorithms for determining which server
meaning of having a highly available system and its measurable must service a request. Web applications and services are
uptime are a direct function of a Service Level Agreement. balanced by following round robin scheduling rules. Caching
Availability goes up when factoring planned downtime, such as pools are balanced by applying frequency rules and expiration
a monthly 8-hour maintenance window. algorithms. Applications where stateless requests arrive with
The cost of each additional nine of availability can grow a uniform probability for any number of servers may use a
exponentially. Availability is a function of scaling the systems pseudo-random scheduler. Applications like music stores,
up or out and implementing system, network, and storage where some content is statistically more popular, may use
redundancy. asymmetric load balancers to shift the larger number popular
Service Level Agreement (SLA) requests to higher performance systems, serving the rest of the
SLAs are the negotiated terms that outline the obligations of requests from less powerful systems or clusters.
the two parties involved in delivering and using a system, like: Persistent Load Balancers
System type (virtual or dedicated servers, shared hosting) Stateful applications require persistent or sticky load
Levels of availability balancing, where a consumer is guaranteed to maintain a
Minimum session with a specific server from the pool. Figure 4 shows a
Target sticky balancer that maintains sessions from multiple clients.
Uptime Figure 5 shows how the cluster maintains sessions by sharing
Network data using a database.
Power
Maintenance windows Consumer Consumer Consumer
Serviceability
Performance and metrics
Billing
Sticky Load
SLAs can bind obligations between two internal organizations Balancer
74.0.125.28
(e.g. the IT and e-commerce departments), or between the
organization and an outsourced services provider. The SLA
establishes the metrics for evaluating the system performance, Node Node
192.168.202.55 192.168.202.69
and provides the definitions for availability and the scalability Node
192.168.202.66
Node
192.168.202.67
targets. It makes no sense to talk about any of these topics
unless an SLA is being drawn or one already exists. Figure 4: Sticky Load Balancer
Figure 4 - Sticky Load Balancer
Common Features of a Load Balancer
Implementing Scalable Systems Asymmetric load distribution assigns some servers to handle
a bigger load than others
SLAs determine whether systems must scale up or out. They Content filtering inbound or outbound
also drive the growth timeline. A stock trading system must Distributed Denial of Service (DDoS) attack protection
scale in real-time within minimum and maximum availability Firewalling
levels. An e-commerce system, in contrast, may scale in during Payload switching send requests to different servers
the slow months of the year, and scale out during the retail based on URI, port, and/or protocol
holiday season to satisfy much larger demand. Priority activation adds standing by servers to the pool
Node
192.168.202.55
Node
192.168.202.66
Node
192.168.202.67
Node
192.168.202.69 In general, implicit caching systems are specific to a platform
or language. Terracotta, for example, only works with Java and
JVM-hosted languages like Groovy. Explicit caching systems
may be used with many programming languages and across
Session
Data
multiple platforms at the same time. memcached works with
every major programming language, and Coherence works with
Figure 5: Database Sessions
Figure 5 - Database Sessions Java, .Net, and native C++ applications.
Web Caching
Caching Strategies
Web caching is used for storing documents or portions of
documents (particles) to reduce server load, bandwidth usage
Stateful load balancing techniques require data sharing among
and lag for web applications. Web caching can exist on the
the service providers. Caching is a technique for sharing
browser (user cache) or on the server, the topic of this section.
data among multiple consumers or servers that are expensive
Web caches are invisible to the client may be classified in any
to either compute or fetch. Data are stored and retrieved
of these categories:
in a subsystem that provides quick access to a copy of the
frequently accessed data. Web accelerators: they operate on behalf of the
Caches are implemented as an indexed table where a unique server of origin. Used for expediting access
key is used for referencing some datum. to heavy resources, like media files. Content
Consumers access data by checking distribution networks (CDNs) are an
(hitting) the cache first and retrieving example of web acceleration caches;
the datum from it. If its not there Akamai, Amazon S3, Nirvanix are
(cache miss), then the costlier retrieval Begin examples of this technology.
operation takes place and the consumer
Proxy caches: they serve requests to a
or a subsystem inserts the datum to the query update
Query? group of clients that may all have
cache.
Fetch
access to the same resources. They
Write Policy datum from
cache
can be used for content filtering and
The cache may become stale if the Update for reducing bandwidth usage. Squid,
datum in
backing store changes without updating database Apache, ISA server are examples
datum is no
the cache. A write policy for the cache None of this technology.
defines how cached data are refreshed. yes Invalidate cache
Some common write policies include: Query Distributed Caching
Write-through: every write to the datum from
database Caching techniques can be implemented
cache follows a synchronous write to Add or update across multiple systems that serve
datum to cache
the backing store Add datum to
requests for multiple consumers and
Write-behind: updated entries are cache from multiple resources. These are
marked in the cache table as dirty known as distributed caches, like the
and its updated only when a dirty setup in Figure 7. Akamai is an example
datum is requested. Use datum of a distributed web cache. memcached
in app
No-write allocation: only read is an example of a distributed application
requests are cached under the cache.
End
assumption that the data wont
change over time but its expensive
Figure 6: Caching Usage
Figure Pattern
6 - Caching Usage Pattern
to retrieve
DZone, Inc. | www.dzone.com
4
Scalability & High Availability
Load Balancer
Database
Consumer
Master
Load Balancer
74.0.125.28
Fault isolation problem detection must pinpoint the PNG PNG PNG PNG Node Node Node Node
stateless application.
Node Node Node Node
Consumer
Legacy Back-end
Load Balancer
74.0.125.28
Enterprise
Database
Replacement
Node Node Node Node
Node
192.168.202.55 192.168.202.66 192.168.202.67 192.168.202.69 Figure 15 - Cloud Computing Conguration
192.168.202.53
Figure 14: Cloud Computing Configuration
Figure 12: A/A Full Tolerance andFault
Figure 12 - A/A Recovery
Tolerance and Recovery
Cloud Services Types
Some stateful applications may only scale up; the A/P cluster Web services Salesforce
in Figure 13 provides uninterrupted service and disaster com, USPS, Google Maps
recovery for such an application. A/A configurations provide Service platforms Google App Engine, Amazon Web
failure transparency. A/P configurations may provide failure Services (EC2, S3, Cloud Front), Nirvanix, Akamai,
transparency at a much higher cost because automatic failure MuleSource
detection and reconfiguration are implemented through a
feedback control system, which is more expensive and trickier
Fault Detection Methods
Fault detection methods must provide enough information
to implement.
to isolate the fault and execute automatic or assisted failover
action. Some of the most common fault detection methods
include:
Built-in Diagnostics
Protocol Sniffers
Sanity Checks
Watchdog Checks
AB O U T T HE A U T H O R RE C O MME N D E D B O O K
Eugene Ciurana Developing with Google App Engine
Eugene Ciurana is an open-source evangelist who introduces Google App Engine, a platform
specializes in the design and implementation of mission- that provides developers and users with
critical, high-availability large scale systems. As Director the infrastructure that Google itself uses for
of Systems Infrastructure, he and his team designed and developing and deploying massively scalable
built a 100% SOA and cloud system that enables millions applications. Using Python as the primary
of Internet-ready educational and handheld products and services. As chief programming tool, Developing with Google
liaison between Walmart.com Global and the ISD Technology Council, he led App Engine makes it easy to implement
the official adoption of Linux and other open-source technologies at Walmart scalability and high performance features like
Stores Information Systems Division. Hes also designed high performance distributed databases, clustering, stateless
systems for major financial institutions and many Fortune 100 companies in applications, and sophisticated data caching.
the United States and Europe.
Publications Web site
n Developing with the Google App Engine http://eugeneciurana.com BUY NOW
n Best Of Breed: Building High Quality Systems, books.dzone.com/books/google-app-engine
Within Budget, On Time, and Without Nonsense
n The Tesla Testament: A Thriller
Bro
ugh
t to
you
by...
Professional Cheat Sheets You Can Trust
tt erns Exactly what busy developers need:
n Pa
ld
ona
sig son
McD
simple, short, and to the point.
De
Ja
By
#8
ired
Insp e
by th
GoF ller con
tinu
ed
ndle
r doe
snt
have
to
in tab
Cha d ultip ecific o should cep pat
this if the m up the
man
n M
an ac
z.co
n
sp s ents
be a ject ime. d is see passed
Download Now
Com reter of ob at runt handle plem ks to de to
...
n
uest som tion proces e no m
Itera tor ore req
n A g in metho
d
cep
dm ndlin
e e ar
tho e to ptio th
Exce ion is sm to ha up th tered or
e ca
n
Ob
se Me S renc ral
Refcardz.com
plate RN refe listed in mp
le ce pt ni
echa n pa ssed co un avio
Beh
TTE
n
ex
is en
ick
BIRT Windows Powershell
am
Tem Exa he .
A s has ack. W tion uest to ject
NP a qu s, a ct- cep Ob
it
n
st q
IG e s e rn b je call e ex e re
vid patt able O le th nd th
DES
! V is
pro s, hand s to ha
UT ard ign us ram .
des diag
JSF 2.0 Dependency Injection with EJB 3
ct
ABO refc oF) f Re le obje
erns ts o lass exa
mp oke
r
Patt ur (G lemen es c Inv
arz
n F o d rl d h
Des
ig go
f s: E inclu al w
o suc
Th is G a n
l 23 sign Pa
tt e rn e rn
patt , and a
re je ts
t ob mentin
c g AN
D
Adobe AIR Netbeans IDE JavaEditor
c
a h c M M
ef
in c u
orig kD
e
re.
Ea tion ons
tr ple CO ma
nd
boo Softwa rma to c their im om
BPM&BPMN Getting Started with Eclipse
re R
( low
e x p o n la rg cute is al ch
ati an b rm ts. +exe . Th
bject nship
s su
Cre y c fo je c an o
t th
e
ed
to ob ms, d as ed rela
tio
Get
nsh
ips
that
can psu
Enca quest
the
re
late
sa
and
e ha
to b llbacks
ca
.
nalit
y.
riant
times
or in
varia
ling
the
invo
catio
ing
n.
DZone, Inc. ISBN-13: 978-1-934238-46-2
ra o pose uing nctio led at va hand
io n ti ct cess be
av ,a la P ur
as q
ue
ack
fu je pro
Beh nships t re
1251 NW Maynard
e nd ob
rela
tio
with
ob je c
s th
at c
a n b ed
You ne s need
st
callb
to
que
b e ha eded.
ne
sts is couple n
d fro m the
e th
ynch
e as the fu
ro nous nality
nctio
itho
to
y ne
ut an is
ed
ISBN-10: 1-934238-46-5
eals
it
ship Reque y of re de ar
ld be litat pattern ssing w tation articul
e: D tion faci
50795
or
e. Use
n
A hist shou d ce en p
ed to mman for pro implem ents its ting.
cop runtim rela type
ker
Cary, NC 27513
n
S s Whe invo y us
n
s co al m pec
jec t at cla Pro
to Th e
w id el th e ue ue
ac tu
d im
p le ex
are utilizing a job q of the ue is
Ob ged with
n
C ues ueue e que
han eals me.
y dge enq
que s. B en to th
e c : D P roxy Job orithm be giv knowle that is terface
b e ti
cop
g n ct
pile r S in
rato er mp
le of al ed ca to have d obje of the
ss S at com serv
888.678.0399
Exa ut
Deco nes
an
.com
919.678.0300
one
Abst tory
C C
Fac
B
State
t
pte
r eigh y
teg
Ada Flyw Stra od
z
Meth
more than 2 million software developers, architects and decision
S S r B
w. d
e rp rete plate
ridg
Refcardz Feedback Welcome
B B
Inte Tem
S B
er tor or
ww
C B r B
NSIB
ILIT
S
Com
po si te
P O succ
ess
or Sponsorship Opportunities
RES
DZone is a developers dream, says PC Magazine.
F
CH
AIN
O
ace
>> sales@dzone.com
terf r
<<in andle
H st ( )
re
ndle
+ha
ern
1 ki ng
ler by lin .c o
m
and uest one
teH req z
cre () le a w.d
Con uest hand | ww