SEDA AnarchitectureforWellCondi6oned, scalableInternetServices - - PowerPoint PPT Presentation

seda an architecture for well condi6oned scalable
SMART_READER_LITE
LIVE PREVIEW

SEDA AnarchitectureforWellCondi6oned, scalableInternetServices - - PowerPoint PPT Presentation

SEDA AnarchitectureforWellCondi6oned, scalableInternetServices Ma=Welsh,DavidCuller,andEricBrewer UniversityofCalifornia,Berkeley Symposium on Operating Systems Principles (SOSP),


slide-1
SLIDE 1

SEDA
 An
architecture
for
Well‐Condi6oned,
 scalable
Internet
Services


Ma=
Welsh,
David
Culler,
and
Eric
Brewer
 University
of
California,
Berkeley
 Symposium on Operating Systems Principles (SOSP), October 2001 http://www.eecs.harvard.edu/~mdw/proj/seda/ Presented by: Disha Gandhi

slide-2
SLIDE 2

Outline


  • Why
SEDA
??

  • What
is
SEDA
??

  • Thread
and
Event‐based
Concurrency

  • SEDA
Architecture

  • Asynchronous
I/O
Primi6ves

  • Applica6ons
and
Performance
Evalua6on


2


slide-3
SLIDE 3

Mo6va6on
for
SEDA


  • Prototypical
applica6on:
web
server


  • Requirements
for
internet
services


– Need
high
level
concurrency.
 – Handle
huge
varia6ons
in
load
(Slashdot
effect)
 – Handle
new
system
designs
to
manage
these
loads
 challenges
–
dynamic
content,
hos6ng
of
services


  • n
general‐purpose
servers.

  • Well‐condi6oned
service:
simple
pipeline


without
degrada6on
beyond
load
satura6on


3


slide-4
SLIDE 4

What
is
SEDA???


  • From
Ma=
Welsh’s
PhD
work
at
Berkeley


(2000‐2002)


  • A
design
for
highly
concurrent
server


applica6ons


  • Combines
elements
of
both
thread
and
event‐

based
programming


  • Dynamic
resource
control
mechanisms
for


automa6c
tuning
and
load
condi6oning

to
 handle
large
fluctua6ons
in
load


4


slide-5
SLIDE 5

Thread
based
concurrency
model



  • Thread
per‐request
model
(commonly
used
design
for


server
applica6ons)


  • Synchroniza6on
protects
shared
resources

  • OS
overlaps
computa6on
and
I/O
by
transparently


switching
among
threads.


  • Cache/TLB
misses,
threads
scheduling,
lock
conten6on

  • verheads.


5


slide-6
SLIDE 6

Thread‐server

 performance
degrada6on


  • High
load
‐
high
context

  • verhead.

  • Throughput
decreases

  • Response
6me
very


high
as
task
queue
 length
increases


  • Not
good
for


concurrency
 requirements
of
 Internet


6


slide-7
SLIDE 7

Bounded
Thread
Pools


  • To
avoid
overuse
of


threads,
bind
the
size
of
 thread
pool.


  • Reject
addi6onal


connec6ons.


  • Common
solu6on


(Apache
etc)


  • Throughput,
overall


performance
be=er
 But
:


  • is
it
fair
to
clients?

  • How
to
determine


upper
limit?


  • Difficult
to
iden6fy


internal
performance
 bo=lenecks.


7


slide-8
SLIDE 8

Pipeline
Model
Of
Computa6on


8


slide-9
SLIDE 9

Event‐driven
concurrency


  • Small
number
of
threads
(typically
one
per
CPU)


that
loop
con6nuously,
processing
events
from
a
 queue.



  • Events‐handlers
should
be
short‐lived.

  • I/O
must
be
non‐blocking.


9


slide-10
SLIDE 10

Performance


  • Robust
to
load

  • Throughput
constant

  • Latency
linear.


10


slide-11
SLIDE 11

Problems
with
Event‐driven


  • Scheduling
and
overhead
of
events

  • Choice
of
scheduling
algorithm
is
tailored
to


applica6on.


  • No
principled
framework,
so
solu6ons
are


typically
ad‐hoc,
lacking
modularity


  • “Structured
Event
queues”
to
improve
code


modularity
and
simplify
applica6on
design.


11


slide-12
SLIDE 12

Staged
Event‐Driven
Architecture


  • Applica6on
decomposed
into
independent
stages
separated
by
queues.

  • Supports
massive
concurrency:

each
stage
has
own
thread
pool

  • Self‐contained
applica6on
components–
event
handler,
incoming
event
queue


and
thread
pool
–
clean
boundary
for
modularity/security
and
introspec6on.
(at
 cost
of
increased
latency)


  • Finite
event
queues
can
provide:



 
backpressure:
blocking
on
a
full
queue
 
 
load
shedding:
dropping
events
 
 
errors
to
user,
etc.


12


slide-13
SLIDE 13

Anatomy
of
a
Stage


  • Self‐contained


applica6on
 components.


  • Applica6on‐supplied


event
handler


  • Controller
dynamically


adjusts
resource
 alloca6on.


  • Small
number
of


threads
per
stage


13


slide-14
SLIDE 14

Dynamic
Resource
Controller


  • Adjusts

batching
factor
to
increase


throughput
while
maintaining
cache


  • p6miza6on
and
task
aggrega6on


14


  • Automa6cally
adapt
the
resource
usage
of
a
stage

  • based
on
observed
performance
and
demand


Adjust
number
of
threads
allocated
 to
stage
based
on
actual
measured
 usage


slide-15
SLIDE 15

Using
Asynchronous
I/O
Primi6ves


Asynchronous
socket
I/O


  • Uses
non‐blocking
I/O


provided
by
OS
for
 services.
 Asynchronous
file
I/O


  • Uses
blocking
I/O
and
a


bounded
threaded
pool.


15


slide-16
SLIDE 16

Comparison


  • SEDA
based
layer:
non‐

blocking
I/O
by
OS
and
/ dev/poll
event‐driven
 mechanism
:
~constant
 I/O
bandwidth


  • Compa6bility
layer
that


uses
blocking
sockets
 and
a
thread
pool:
 thread
thrashing


16


slide-17
SLIDE 17

Sandstorm:
A
SEDA
Prototype


  • En6rely
in
java

  • Na6ve
libraries
for
non‐blocking
socket
I/O

  • Automated
memory
management
to
garbage‐collec6ng


expired
events.


  • Each
applica6on
module
implements
a
simple
event


handler
interface
with
a
single
method
call
which
processes
 a
batch
of
events
pulled
from
stages’s
incoming
event
 queue.


  • Run‐6me
system
and
associated
controllers
create
threads.

  • API’s
for
naming,
crea6ng
and
destroying
stages,
and
other


func6ons.


  • Socket
and
file
I/O
mechanisms
as
standard
interfaces.


17


slide-18
SLIDE 18

Haboob
:
SEDA
Web
server


  • More
complicated
web
server:
10
stages,
4
for
asynchronous
socket
and
disk
I/

O.


  • H=pParse
stage:
accept
new
client
connec6ons.

  • H=pRecv
stage:
accept
HTTP
connec6on
and
request
events
and
pass
to


PageCache
stage
or
generate
response
directly


  • PageCache:
in‐memory
Web
page
cache
using
hashtable
indexed
by
URL

  • Cachemiss:
handle
page
cache
misses,
using
asynchronus
file
I/O
to
read
from


disk


  • H=pSend:
send
response
to
client,
sta6s6cs
gathering

  • High
modularity


18


slide-19
SLIDE 19

Performance
Comparison


  • Throughput
stable
at
high
loads
for
all,
though
Haboob
is
the
best.

  • Apache
and
Flash
have
huge
varia6on
in
response
6me
(long
tails)

  • Haboob
has
low
varia6on
in
response
6me,
but
has
longer
average


response
6me


  • Haboob
has
graceful
degrada6on,
apache
fairness
decline
quickly


aker
its
limit
of
number
of
connec6ons.


19


slide-20
SLIDE 20

Results:
Resource
Thro=ling


20


  • 1024
clients
repeatedly
request
dynamic
pages
with
I/O
and
computa6on

  • Apache
and
Haboob
(with
no
control)
process
all
requests,
Flash
rejects
some
due
to


a
bug
in
its
code.


  • Haboob
controller
drops
(with
error)
if
average
response
6me
>
5
sec

slide-21
SLIDE 21

Gnutella
packet
router


  • Use
of
SEDA
for
non‐tradi6onal
Internet


services.


  • Rou6ng
packets
in

a
peer
to
peer
file
sharing


network


  • 3
stages
in
SEDA
implementa6on:


GnutellaServer,
GneutellaRouter
and
 Gneutellacatcher


21


slide-22
SLIDE 22

Summary


  • SEDA
provides
a
framework
for
web
services


(
handle
massive
concurrency
and
huge
 varia6ons
in
load).


  • Combined
approach
tries
to
achieve


performance,
with
flexibility
and
ease
of
 programming.


  • SEDA
uses
dynamic
controllers
for
resource


usage
and
scheduling
at
each
stage.



  • Robust
performance
as
per
published
results.


22


slide-23
SLIDE 23

Current
state
of
SEDA


  • “a
number
of
recent
research
papers
have
demonstrated
that
the


SEDA
prototype
(in
Java)
performs
poorly
compared
to
threaded
or
 event‐based
systems
implemented
in
C”


  • “The
most
fundamental
aspect
of
the
SEDA
architecture
is
the


programming
model
that
supports
stage‐level
backpressure
and
 load
management.
Our
goal
was
never
to
show
that
SEDA


  • utperforms
other
server
designs,
but
rather
that
acceptable


performance
can
be
achieved
while
providing
a
disciplined
 apporach
to
overload
management.
Clearly
more
work
is
needed
to
 show
that
this
goal
can
be
met
in
a
range
of
applica6on
and
server
 environments.”


  • h=p://www.eecs.harvard.edu/~mdw/proj/seda/


23


slide-24
SLIDE 24

Acknowledgement


  • h=p://www.eecs.harvard.edu/~mdw/proj/

seda/.


  • Previous
class
presenta6ons.


24