seda an architecture for well condi6oned scalable
play

SEDA:AnArchitectureforWell Condi6oned,ScalableInternet Services - PowerPoint PPT Presentation

SEDA:AnArchitectureforWell Condi6oned,ScalableInternet Services Ma>Welsh,DavidCuller,andEricBrewer ComputerScienceDivision UniversityofCalifornia,Berkeley


  1. SEDA:
An
Architecture
for
Well‐ Condi6oned,
Scalable
Internet
 Services
 Ma>
Welsh,
David
Culler,
and
Eric
Brewer
 Computer
Science
Division
 University
of
California,
Berkeley
 Symposium
on
Opera6ng
Systems
Principles
(SOSP),
October
2001
 h>p://www.eecs.harvard.edu/~mdw/proj/seda/
 [All
graphs
and
figures
from
this
url]


  2. Why
Discuss
Web
Server
in
OS
Class?
 • Paper
discusses
design
of
well‐condi6oned
 Web
servers
 • Thread‐based
and
event‐driven
concurrency
 are
central
to
OS
design
 • Task
scheduling
and
resource
management
 issues
also
very
important


  3. Well‐condi6oned
service
(is
the
goal)
 • Should
behave
in
pipeline
fashion:
 – If
underu6lized
 • Latency
(s)
=
N
x
max
stage
delay
 • Throughput
(requests/s)
propor6onal
to
load

 – At
satura6on
and
beyond
 • Latency
propor6onal
to
queue
delay
 • Throughput
=
1
/
max
stage
delay
 • Graceful
degrada6on
 • Not
how
Web
typically
performs
during
 “Slashdot
effect”


  4. Thread‐based
concurrency
 One
thread
per
request
 • Offers
simple,
supported
programming
model
 • I/O
concurrency
handled
by
OS
scheduling
 • Thread
state
captures
FSM
state
 • Synchroniza6on
required
for
shared
resource
access
 • Cache/TLB
misses,
thread
scheduling,
lock
conten6on
overheads
 •

  5. Threaded
server
throughput
versus
load
 Latency
is
unbounded
as
number
of
threads
increases
 • Throughput
decreases
 • Thrashing
–
more
cycles
spent
on
overhead
than
real
work
 • Hard
to
decipher
performance
bo>lenecks 
 •

  6. Bounded
thread
pool
 • Limit
the
number
of
threads
to
prevent
 thrashing
 • Queue
incoming
requests
or
reject
outright
 • Difficult
to
provide
op6mal
performance
 across
differen6ated
services
 • Inflexible
design
during
peak
usage
 • S6ll
difficult
to
profile
and
tune


  7. Event‐driven
concurrency
 Each
FSM
structured
as
network
of
event
handlers
and
represents
a
single
flow
of
 • execu6on
in
the
system
 Single
thread
per
FSM,
typically
one
FSM
per
CPU,
number
of
FSM’s
is
small
 • App
must
schedule
event
execu6on
and
balance
fairness
against
response
6me
 • • App
must
maintain
FSM
state
across
I/O
access
 I/O
must
be
non‐blocking
 • Modularity
difficult
to
achieve
and
maintain
 • A
poorly
designed
stage
can
kill
app
performance
 •

  8. Event‐driven
server
throughput
versus
load
 • Avoids
performance
degrada6on
of
thread‐driven
approach
 • Throughput
is
constant
 • Latency
is
linear


  9. Structured
event
queue
overview
 • Par66on
the
applica6on
into
discrete
stages
 • Then
add
event
queue
before
each
stage
 • Modularizes
design
 • One
stage
may
enqueue
events
onto
another
 stage’s
input
queue
 • Each
stage
may
have
a
local
thread
pool


  10. A
SEDA
stage
 • Stage
consists
of:
 • Event
queue
(likely
finite
size)
 • Thread
pool
(small)
 • Event
handler
(applica6on
specific)
 • Controller
(local
dequeueing
and
thread
alloca6on)


  11. A
SEDA
applica6on
 • SEDA
applica6on
is
composed
of
network
of
SEDA
stages
 • Event
handler
may
enqueue
event
in
another
stage’s
queue
 • Each
stage
controller
may
 • Exert
backpressure
(block
on
full
queue)
 • Event
shed
(drop
on
full
queue)
 • Degrade
service
(in
applica6on
specific
manner)
 • Or
some
other
ac6on
 • Queues
decouple
stages,
providing
 • Modularity
 • Stage‐level
load
management
 • Profile
analysis/monitoring
 • With
increased
latency


  12. SEDA
resource
controllers
 • Controllers
dynamically
tune
resource
usage
to
meet
performance
targets
 • May
use
both
local
stage
and
global

state
 • Paper
introduces
implementa6ons
of
two
controllers
(others
are
possible)
 • Thread
pool
–
create/delete
threads
as
load
requires
 • Batching
–
vary
number
of
events
processed
per
stage
invoca6on


  13. Asynchronous
I/O
 • SEDA
provides
I/O
stages:
 • Asynchronous
socket
I/O
 – Uses
non‐blocking
I/O
provided
by
OS
 • Asynchronous
file
I/O
 – Uses
blocking
I/O
with
a
thread
pool


  14. Asynchronous
socket
I/O
performance
 SEDA
non‐blocking
I/O
vs.
blocking
I/O
and
bounded
thread
pool

 • SEDA
implementa6on
provides
fairly
constant
I/O
bandwidth
 • Thread
pool
implementa6on
exhibits
typical
thread
thrashing


  15. Performance
comparison
 • SEDA
Haboob
vs
Apache
&
Flash
Web
servers
 • Haboob
is
complex,
10
stage
design
in
Java
 • Apache
uses
bounded
process
pools
in
C
 – One
process
per
connec6on,
150
max
 • Flash
uses
event‐driven
design
in
C
 • Note:
authors
claim
crea6on
of
“Haboob”
was
 greatly
simplified
due
to
modularity
of
SEDA
 architecture


  16. I
got
a
Haboob.
 ha∙boob
 
 /h əˈ bub/
[huh‐boob]

 –noun
a
thick
dust
storm
or
sandstorm
that
blows
in
the
deserts
of
North
 Africa
and
Arabia
or
on
the
plains
of
India.

 From
www.dic6onary
.com


  17. Performance
comparison
(cont.)
 • Apache
fairness
declines
quickly
past
64
clients
 • Throughput
constant
at
high
loads
for
all
servers,
Haboob
is
best
 • Apache
and
Flash
exhibit
huge
varia6on
in
response
6mes
(long
tails)
 • Haboob
provides
low
varia6on
in
response
6mes
at
cost
of
longer
average
 response
6mes


  18. Performance
comparison
(cont.)
 • Apache,
Haboob
w/o
controller
process
all
requests,
buggy
Flash
drops
¾
 • Haboob
response
6me
with
controller
be>er
behaved
 • Controller
drops
requests
with
error
no6fica6on
under
heavy
load
 • Here
98%
of
requests
are
shed
by
the
controller
at
bo>leneck
 • S6ll
not
able
to
offer
guarantee
of
service
be>er
than
target
(22
vs.
5)


  19. Conclusion
 • SEDA
provides
a
viable
and
modularized
 model
for
Web
service
design
 • SEDA
represents
a
middle
ground
between
 thread‐
and
event‐based
Web
services
 • SEDA
offers
robust
performance
under
heavy
 load,
op6mizing
fairness
over
quick
response
 • SEDA
allows
novel
dynamic
control
 mechanisms
to
be
elegantly
incorporated


Recommend


More recommend