30
The Case for a Session State Storage Layer Benjamin Ling and Armando Fox Stanford University Paper available in the back

The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

The Case for a Session State Storage Layer

Benjamin Ling and Armando Fox

Stanford University

Paper available in the back

Page 2: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

2Benjamin Ling

ROC RetreatJanuary 2003

Outline

What is session state?

Existing solutions, and why they are inadequate

Proposed solution: Middle-tier storage layer

Related and Future Work

Page 3: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

3Benjamin Ling

ROC RetreatJanuary 2003

What is Session State?

Users interact with applications for a period of time, called a session

Session state –lifetime is the duration of a user session, relevant only to a single user

User workflow in enterprise software

Shopping cart in ecommerce

Many architectures produce/consume user session state (e.g. J2EE)

Session state is a large class of state – we address a subcategory

Page 4: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

4Benjamin Ling

ROC RetreatJanuary 2003

An example of usage

Example of usage: Alice is using a web-based marketing application, specifying target customers and offers they should receive

1Browser App Server

Page 5: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

5Benjamin Ling

ROC RetreatJanuary 2003

An example of usage

Example of usage: Alice is using a web-based marketing application, specifying target customers and offers they should receive

2

31Browser App Server

Page 6: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

6Benjamin Ling

ROC RetreatJanuary 2003

An example of usage

Example of usage: Alice is using a web-based marketing application, specifying target customers and offers they should receive

2

31Browser App Server

4

5

Page 7: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

7Benjamin Ling

ROC RetreatJanuary 2003

An example of usage

Example of usage: Alice is using a web-based marketing application, specifying target customers and offers they should receive

Important:Session State must be present on each interaction

Retrieval of session state is in critical path of app

2

31Browser App Server

4

5

6

Page 8: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

8Benjamin Ling

ROC RetreatJanuary 2003

Exploiting properties of session state

1. Not shared – user reads her own stateNo concurrency control needed

2. Is semi-persistentTemporal, lease-like guarantee is sufficient

3. Is keyed to a particular user – don’t need general query mechSingle-key lookup sufficient

4. Is updated on every interactionPrevious copies can be discarded

5. Does not need to be ACIDOnly atomic update and consistency necessary

Page 9: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

9Benjamin Ling

ROC RetreatJanuary 2003

Existing solutions

Database

File System

In memory, non-replicated

In memory, replicated

Page 10: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

10Benjamin Ling

ROC RetreatJanuary 2003

Database or File System

“I already have a DB and FS, why don’t I just use one of them to store session state?”

Drawbacks:D1: Contention – Session state requests interfere with requests for persistent objects

D2: Failure and recovery is expensive

Slow -> bad for end users

Fast -> usually very expensive

D3: Session cleanup an afterthought

Someone has to scrub -> degrades performance

D4: Performance hit – not just a round-trip, sometimes disk access

Page 11: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

11Benjamin Ling

ROC RetreatJanuary 2003

In-Memory: Replicated and non-replicated

Try to avoid network roundtrip, usually faster than DB/FS

Affinity: Require a user to “stick” to a particular server

Middle-tier becomes stateful

Affinity limits load balancing options

Replicated -> pay RT cost, but usually not disk access

Non-replicated -> lose data on crash

Page 12: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

12Benjamin Ling

ROC RetreatJanuary 2003

Replicated in-memory solutions: Drawbacks

D5: Contention -> secondary App Servers now face contention from session state updates

D6: Recovery more difficult -> special case code necessary -> system is harder to reason about

D7: Poor failure/recovery performance

D8: Lack of separation of concernsApp Server now does state storage and app processing

D9: Performance coupling

Page 13: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

13Benjamin Ling

ROC RetreatJanuary 2003

Proposed solution: Middle-tier Storage

Design principlesP1: Avoid special case recovery code

Reduces total cost of ownership

P2: Design for separation of concerns

P3: Session cleanup should be easy

P4: Graceful degradation upon node failures

No cache warming effects, uneven failure

P5: Avoid performance coupling

Page 14: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

14Benjamin Ling

ROC RetreatJanuary 2003

Assumptions

Secure and well-administered cluster

System Area Network (high throughput, low latency)

No network partitions

UPS reduces probability of system-wide simultaneous

Fail-stop components

Page 15: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

15Benjamin Ling

ROC RetreatJanuary 2003

Middle-tier storage components

Bricks: Stores objects via Hash table interface, periodic beacons

Stubs: interface with bricks, keeps track of live bricks

AppServerSTUB

Brick 1

Brick 2

Brick NAppServer

STUB

SAN

Page 16: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

16Benjamin Ling

ROC RetreatJanuary 2003

Write Algorithm (Stub -> Brick)

Call W the write set, WQ the write quota, R the read set.

A stub:Calculate checksum for object and expiration time.Create a list of bricks L, initially the empty set.Choose W random bricks, and issue the write of {object, checksum, and expiry} to each brick.Wait for WQ of the bricks to return with success messages, or until t elapsed. When each brick replies, add its identifier to the set L.If t has elapsed and the size of L is less than WQ, repeat step 3. Otherwise, continue.Create a cookie consisting of H, the identifiers of the WQ bricks that acknowledged the write, and the expiry, and calculate a checksum for the cookie.Return the cookie to the caller.

Page 17: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

17Benjamin Ling

ROC RetreatJanuary 2003

Write example

Try to write to W bricks, W = 4Must wait for WQ bricks to reply, WQ = 2

Brick 1

AppServerSTUB

Brick 2Browser

Brick 3

Brick 4

Brick 5

Page 18: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

18Benjamin Ling

ROC RetreatJanuary 2003

Write example

Try to write to W bricks, W = 4Must wait for WQ bricks to reply, WQ = 2

Browser AppServerSTUB

Brick 1

Brick 2

Brick 3

Brick 4

Brick 5

Page 19: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

19Benjamin Ling

ROC RetreatJanuary 2003

Write example

Try to write to W bricks, W = 4Must wait for WQ bricks to reply, WQ = 2

AppServerSTUB

Brick 1

Brick 2Browser

Brick 3

Brick 4

Brick 5

Page 20: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

20Benjamin Ling

ROC RetreatJanuary 2003

Write example

Try to write to W bricks, W = 4Must wait for WQ bricks to reply, WQ = 2

AppServerSTUB

Brick 1

Brick 2Browser

14

Brick 3

Brick 4

Brick 5

Page 21: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

21Benjamin Ling

ROC RetreatJanuary 2003

Read Algorithm (Stub -> Brick)

Verify the checksum on the cookie

Issue the read to R random bricks chosen from the list of WQ bricks contained in the cookie.

Wait for 1 of the bricks to return, or until t elapses.

If the timeout has elapsed and no response has been returned, repeat step 2. Otherwise, continue.

Verify checksum and expiration. If checksum is invalid, repeat step 2. Otherwise continue.

Return the object to the caller.

Page 22: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

22Benjamin Ling

ROC RetreatJanuary 2003

Read example

Ask R bricks for the read, wait for fastest 1 to reply. R = 2

Brick 1

Brick 2

Brick 3

Brick 4

14

AppServerSTUB

Browser

Page 23: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

23Benjamin Ling

ROC RetreatJanuary 2003

Read example

Ask R bricks for the read, wait for fastest 1 to reply. R = 2

AppServerSTUB

Brick 1

Brick 2

Brick 3

Brick 4

14

Browser

Page 24: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

24Benjamin Ling

ROC RetreatJanuary 2003

Read example

Ask R bricks for the read, wait for fastest 1 to reply. R = 2

AppServerSTUB

Brick 1

Brick 2

Brick 3

Brick 4

14

Browser

Page 25: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

25Benjamin Ling

ROC RetreatJanuary 2003

Read example

Ask R bricks for the read, wait for fastest 1 to reply. R = 2

AppServerSTUB

Brick 1

Brick 2

Brick 3

Brick 4

14

Browser

Page 26: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

26Benjamin Ling

ROC RetreatJanuary 2003

What happens on failure?

All components stateless/soft-stateRestart!

App Server Crash Restart and reconstruct list of live bricks

Brick CrashAll state on brick is lost, but…

Copies are in WQ -1 other bricks, so state is not lost

Rejuvenation of state

Easily add new nodes to a running system

Page 27: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

27Benjamin Ling

ROC RetreatJanuary 2003

Interesting properties

Negative feedback loop exampleLet write group for a given write be A, B, C. B is slow.

WQ =2

Since B is slow, will not reply to write of a key X

B won’t be involved in read of X

May help ease load on overloaded nodes

Bricks can say “no”Since more writes are issued than necessary, when overloaded, a brick can drop writes

Page 28: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

28Benjamin Ling

ROC RetreatJanuary 2003

Related Work

Quorums – don’t need to read so many copies, since we know where up-to-date copies live

DDS – performance coupling, persistent, negative cache-warming effects

“Directory oriented available copies” – uses a directory to find available copies

Berkeley DB – emphasized fast restart and failure as a common case

DeStor – focuses on persistent storage

Page 29: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

29Benjamin Ling

ROC RetreatJanuary 2003

Conclusion

Session State Server that:Performs well, without coupling

Fault-tolerant

Recovers instantly

Scalable

Lowers total cost of ownership

Page 30: The Case for a Session State Storage Layerroc.cs.berkeley.edu/retreats/winter_03/slides/bling.pdf · 3 Benjamin Ling ROC Retreat January 2003 What is Session State? Users interact

30Benjamin Ling

ROC RetreatJanuary 2003

Questions?

[email protected]

http://www.stanford.edu/~bling/SessionStore.ps