SlideShare una empresa de Scribd logo
1 de 63
Lecture 13
Session State and Distribution
Strategies
Session State
Reading
 Fowler 6
– Session State

 Fowler 17
– Session State Patterns
Agenda
 Session State
– Business transactions

 Session State Patterns
– Client Session State
– Server Session State
– Database Session State
Business Transactions
 Transactions that expand more than one request
– User is working with data before they are committed
to the database
• Example: User logs in, puts products in a shopping cart,
buys, and logs out

– Where do we keep the state between transactions?
State
 Server with state vs. stateless server
– Stateful server must keep the state between requests

 Problem with stateful servers
– Need more resources, limit scalability
Stateless Servers
 Stateless servers scale much better
 Use fewer resources
 Example:
– View book information
– Each request is separate
Stateful Servers
 Stateful servers are the norm
 Not easy to get rid of them
 Problem: they take resources and cause server
affinity
 Example:
– 100 users make request every 10 second, each
request takes 1 second
– One stateful object per user
– Object are Idle 90% of the time
Session State
 State that is relevant to a session
– State used in business transactions and belong to a
specific client
– Data structure belonging to a client
– May not be consistent until they are persisted

 Session is distinct from record data
– Record data is a long-term persistent data in a
database
– Session state might en up as record data
EXCERISE
Question:
Where do you store the session?
Ways to Store Session State
 We have three players
– The client using a web browser
– The Server running the web application and domain
– The database storing all the data
Ways to Store Session State
 Three basic choices
– Client Session State (456)
– Server Session State (458)
– Database Session State (462)
Client Session State
Store session state on the client
 How It Works
– Desktop applications can store the state in memory
– Web solutions can store state in cookies, hide it in the
web page, or use the URL
– Data Transfer Object can be used
– Session ID is the minimum client state
– Works well with REST
Client Session State
 When to Use It
– Works well if server is stateless
– Maximal clustering and failover resiliency

 Drawbacks
– Does not work well for large amount of data
– Data gets lost if client crashes
– Security issues
Server Session State
Store session state on a server in a
serialized form
 How It Works
– Session Objects – data structures on the server
keyed to session Id

 Format of data
– Can be binary, objects or XML

 Where to store session
– Application server, file or local database
Server Session State
 Specific Implementations
– HttpSession
– Stateful Session Beans – EJB

 When to Use It
– Simplicity, it is easy to store and receive data

 Drawbacks
–
–
–
–

Data can get lost if server goes down
Clustering and session migration becomes difficult
Space complexity (memory of server)
Inactive sessions need to be cleaned up
Database Session State
Store session data as committed data in the database
 How It Works

– Session State stored in the database
– Can be stored as temporary data to distinguish from
committed record data

 Pending session data

– Pending session data might violate integrity rules
– Use of pending field or pending tables

• When pending session data becomes record data it is save in
the real tables
Database Session State
 When to Use It
– Improved scalability – easy to add servers
– Works well in clusters
– Data is persisted, even if data centre goes down

 Drawbacks
– Database becomes a bottleneck
– Need of clean up procedure of pending data that did
not become record data – user just left
What about dead sessions?
 Client session
– No our problem

 Server session
– Web servers will send inactive message upon timeout

 Database session
– Need to be clean up
– Retention routines
Caching
 Caching is temporary data that is kept in
memory between requests for performance
reasons
– Not session data
– Can be thrown away and retrieved any time

 Saves the round-trip to the database
 Can become stale or old and out-dated
– Distributed caching is one way to solve that
Practical Example
 Client session
– For preferences,
user selections

 Server session
– Used for browsing and
caching
– Logged in customer

 Database
– “Legal” session
– Stored, tracked, need to survive between sessions
QUIZ
We are building an application for processing development
grants. The application is complicated and users can login any
time and continue work on their application. What design
pattern would we use for storing the session?
A)
B)
✔ C)
D)

Client Session State
Server Session State
Database Session State
No state required
Distribution Strategies
Reading
 Fowler 7
– Distribution Strategies

 Fowler 15
– Distribution Patterns
– Remote Façade (388)
Agenda
 Distributed Architectures
– Remote and Local Interfaces
– Where You Have to Distribute
– Remote Façade

 Scalablity
 DEMO
Distributed Architecture
 Distribute processing by placing objects different
nodes
Distributed Architecture
 Distribute processing by placing objects on
different nodes
 Benefits
– Load is distributed between different nodes giving
overall better performance
– It is easy to add new nodes
– Middleware products make calls between nodes
transparent

But is this true?
Distributed Architecture
 Distribute processing by placing objects different
nodes
“This design sucks like an inverted hurricane” –
Fowler
Fowler’s First Law of Distributed Object Design:
Don't Distribute your objects!
Remote and Local Interfaces
 Local calls
– Calls between components on the same node are
local

 Remote calls
– Calls between components on different machines are
remote

 Objects Oriented programming
– Promotes fine-grained objects
Remote and Local Interfaces
 Local call within a process is very, very fast
 Remote call between two processes is order-ofmagnitude s l o w e r
– Marshalling and un-marshalling of objects
– Data transfer over the network

 With fine-grained object oriented design, remote
components can kill performance
 Example

– Address object has get and set method for each member,
city, street, and so on
– Will result in many remote calls
Remote and Local Interfaces
 With distributed architectures, interfaces must
be course-grained
– Minimizing remote function calls

 Example
– Instead of having getters and setters for each field,
bulk assessors are used
Example
 Sun Application Model
– “The Canonical Architecture”

 Entity Beans
– Each bean maps to row in the database
– find methods returns
Collection of
Remote interfaces
Example
 Result
– Architecture that does not perform very well

 Suggested solution was
– Use session beans to call entity beans
Distributed Architecture
 Better distribution model
– Load Balancing or Clustering the application involves
putting several copies of the same application on
different nodes
Where You Have to Distribute
 As architect, try to eliminate as many remote call
as possible
– If this cannot be archived choose carefully where the
distribution boundaries lay

 Distribution Boundaries
–
–
–
–
–

Client/Server
Server/Database
Web Server/Application Server
Separation due to vendor differences
There might be some genuine reason
Optimizing Remote Calls
 We know remote calls are expensive
 How can we minimize the cost of remote calls?
 The overhead is
– Marshaling or serializing data
– Network transfer

 Put as much data into the call
– Course grained call

 Remote Façade
Remote Façade
Provides a coarse-grained facade on
fine-grained objects to improve efficiency
over a network
 The façade is a thin wrapper that provides
coarse-grained interface to a system
– In an object-oriented model, you do best with small
objects that have small methods
– Can cause great deal of interaction between objects
and method invocations
Remote Façade
 How It Works
– Allows efficient remote access with coarse-grained
interface
– Façade will use the fine-grained object to build and
return object like Data Transfer Object
– Should not contain any domain logic
Remote Façade
 When to Use It
– Whenever you need remote access to fine grained
object model
– Most common use is between UI and domain model
Remote Façade
 Remote method invocation are expensive
– Performance killer
RMI
Client

JVM
Entity
Entity
Session
Session

Entity
Remote Façade
 Coarse grained interface
JVM
Client

RMI

Local calls

Entity

Remote
Façade

Entity
Session
Session

Entity
Remote Façade
 Benefits
– Net traffic is reduced
– Transactions are closer to the database

 Drawbacks
– Limitations on object oriented programming
– Solution is based on limitations of the network
Interfaces for Distribution
 XML over HTTP is a common interface
– XML is structured and allows for lot of data
– XML is common format, well known
– HTTP is common and esay to use

 XML has overhead
– Parsing and manipulation of strings is expensive
– Overhead if not needed

 Approches like REST are more efficient
– Use HTTP right
Scalability
Scaling the application
 Today’s web sites must handle multiple
simulations users
 Examples:
– All web based apps must handle several users
– mbl.is handles ~180.000 users/day
– Betware must handle up to 100.000 simultaneous
users
The World we Live in
 Average number of tweets per day 58
million
 Total number of minutes spent on
Facebook each month 700 billion
 SnapChat has five million daily active
users who send 200 million photos per
day.
 Instagram has over 150 million users
on the platform and1 billion likes
happening each day
Scalability
 Scalability is the measure of how adding
resource (usually hardware) affects the
performance
– Vertical scalability (up) – increase server power
– Horizontal scalability (out) – increase the servers

 Session migration
– Move the session for one server to another

 Server affinity
– Keep the session on one server and make the client
always use the same server
Scalability Example
Load Distribution
 Use number of machines to handle requests
 Load Balancer directs all
request to particular server
– All requests in one session go
to the same server
– Server affinity

 Benefits

– Load can be increased
– Easy to add new pairs
– Uptime is increased

 Drawbacks

– Database is a bootleneck
Clustering
 Distributing components
– Each node has one
component
– Increased performance
is not guaranteed

 Using cluster
– Have all components
in each node and use
local calls
Clustering
 With clustering, servers
are connected together
as they were a single
computer

– Request can be handled
by any server
– Sessions are stored on
multiple servers
– Servers can be added and
removed any time

 Problem is with state

– State in application servers reduces scalability
– Clients become dependant on particular nodes
Clustering State
 Application functionality
– Handle it yourself, but this is complicated, not worth
the effort

 Shared resources
– Well-known pattern (Database Session State)
– Problem with bottlenecks limits scalablity

 Clustering Middleware
– Several solutions, for example JBoss, Terracotta

 Clustering JVM or network
– Low levels, transparent to applications
Scalability Example
Measuring Scalability
 The only meaningful way to know about
system’s performance is to measure it
 Performance Tools can help this process
– Give indication of scalability
– Identify bottlenecks
Example tool: LoadRunner
Example tool: JMeter
QUIZ
Which is true when you are clustering your application?
A) Make sure all requests goes to the same machine
B) Deploy each component on separate machine to distribute
load
C) You try to minimize network traffic to avoid latency
problems
D) Deploy the whole solution on many machines
Real World Examples:
Betware Iceland Data Center
ISP1

ISP2
Hardware
firewall
Load
balancer

Backup
Software
System
DB

16 port 2Gbps
SAN switch
QLogic

CMS
DB

12 x 300GB
SAS 15K
24 x 300GB
SAS 15K

Pair of each
server on
separate blade

IBM Blade
Chassis
Summary
 Session State
– Business transactions

 Session State Patterns
– Client Session State
– Server Session State
– Database Session State

 Distribution Strategies
– How to distribute

Más contenido relacionado

La actualidad más candente

Patterns of enterprise application architecture
Patterns of enterprise application architecturePatterns of enterprise application architecture
Patterns of enterprise application architectureChinh Ngo Nguyen
 
Designing distributed systems
Designing distributed systemsDesigning distributed systems
Designing distributed systemsMalisa Ncube
 
Bridging the Developer and the Datacenter
Bridging the Developer and the DatacenterBridging the Developer and the Datacenter
Bridging the Developer and the Datacenterlurs83
 
Introduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah HazratIntroduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah HazratAttaullah Hazrat
 
ScalabilityAvailability
ScalabilityAvailabilityScalabilityAvailability
ScalabilityAvailabilitywebuploader
 
Client computing evolution ppt11
Client computing evolution ppt11Client computing evolution ppt11
Client computing evolution ppt11Tech_MX
 
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...Creating a Centralized Consumer Profile Management Service with WebSphere Dat...
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...Prolifics
 
Why Now May Be The Time To Consider A Managed Services Approach to Database A...
Why Now May Be The Time To Consider A Managed Services Approach to Database A...Why Now May Be The Time To Consider A Managed Services Approach to Database A...
Why Now May Be The Time To Consider A Managed Services Approach to Database A...Datavail
 
Using Distributed In-Memory Computing for Fast Data Analysis
Using Distributed In-Memory Computing for Fast Data AnalysisUsing Distributed In-Memory Computing for Fast Data Analysis
Using Distributed In-Memory Computing for Fast Data AnalysisScaleOut Software
 
What is a database server and client ?
What is a database server and client ?What is a database server and client ?
What is a database server and client ?Open E-School
 
Scalable Web Architecture and Distributed Systems
Scalable Web Architecture and Distributed SystemsScalable Web Architecture and Distributed Systems
Scalable Web Architecture and Distributed Systemshyun soomyung
 
Client server architecture
Client server architectureClient server architecture
Client server architectureBhargav Amin
 
Coherence Overview - OFM Canberra July 2014
Coherence Overview - OFM Canberra July 2014Coherence Overview - OFM Canberra July 2014
Coherence Overview - OFM Canberra July 2014Joelith
 

La actualidad más candente (20)

Client Server Architecture1
Client Server Architecture1Client Server Architecture1
Client Server Architecture1
 
Patterns of enterprise application architecture
Patterns of enterprise application architecturePatterns of enterprise application architecture
Patterns of enterprise application architecture
 
Designing distributed systems
Designing distributed systemsDesigning distributed systems
Designing distributed systems
 
saito_porcupine
saito_porcupinesaito_porcupine
saito_porcupine
 
Bridging the Developer and the Datacenter
Bridging the Developer and the DatacenterBridging the Developer and the Datacenter
Bridging the Developer and the Datacenter
 
Introduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah HazratIntroduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah Hazrat
 
pramod
pramodpramod
pramod
 
ScalabilityAvailability
ScalabilityAvailabilityScalabilityAvailability
ScalabilityAvailability
 
Client computing evolution ppt11
Client computing evolution ppt11Client computing evolution ppt11
Client computing evolution ppt11
 
L19 Application Architecture
L19 Application ArchitectureL19 Application Architecture
L19 Application Architecture
 
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...Creating a Centralized Consumer Profile Management Service with WebSphere Dat...
Creating a Centralized Consumer Profile Management Service with WebSphere Dat...
 
Why Now May Be The Time To Consider A Managed Services Approach to Database A...
Why Now May Be The Time To Consider A Managed Services Approach to Database A...Why Now May Be The Time To Consider A Managed Services Approach to Database A...
Why Now May Be The Time To Consider A Managed Services Approach to Database A...
 
DC
DCDC
DC
 
Scalability Design Principles - Internal Session
Scalability Design Principles - Internal SessionScalability Design Principles - Internal Session
Scalability Design Principles - Internal Session
 
Using Distributed In-Memory Computing for Fast Data Analysis
Using Distributed In-Memory Computing for Fast Data AnalysisUsing Distributed In-Memory Computing for Fast Data Analysis
Using Distributed In-Memory Computing for Fast Data Analysis
 
What is a database server and client ?
What is a database server and client ?What is a database server and client ?
What is a database server and client ?
 
Scalable Web Architecture and Distributed Systems
Scalable Web Architecture and Distributed SystemsScalable Web Architecture and Distributed Systems
Scalable Web Architecture and Distributed Systems
 
Mohammed Abdul Faheem
Mohammed Abdul FaheemMohammed Abdul Faheem
Mohammed Abdul Faheem
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
 
Coherence Overview - OFM Canberra July 2014
Coherence Overview - OFM Canberra July 2014Coherence Overview - OFM Canberra July 2014
Coherence Overview - OFM Canberra July 2014
 

Similar a L12 Session State and Distributation Strategies

Caching for Microservices Architectures: Session II - Caching Patterns
Caching for Microservices Architectures: Session II - Caching PatternsCaching for Microservices Architectures: Session II - Caching Patterns
Caching for Microservices Architectures: Session II - Caching PatternsVMware Tanzu
 
Logical Architecture for Protection
Logical Architecture for ProtectionLogical Architecture for Protection
Logical Architecture for ProtectionSunita Shrivastava
 
Handling Data in Mega Scale Systems
Handling Data in Mega Scale SystemsHandling Data in Mega Scale Systems
Handling Data in Mega Scale SystemsDirecti Group
 
Study the past if you would define the future: How Gang of Four patterns are ...
Study the past if you would define the future: How Gang of Four patterns are ...Study the past if you would define the future: How Gang of Four patterns are ...
Study the past if you would define the future: How Gang of Four patterns are ...Thomas Gamble
 
Scalability Considerations
Scalability ConsiderationsScalability Considerations
Scalability ConsiderationsNavid Malek
 
ConnectED 2015 BP302: Future-Proofing Enterprise IT
ConnectED 2015 BP302: Future-Proofing Enterprise ITConnectED 2015 BP302: Future-Proofing Enterprise IT
ConnectED 2015 BP302: Future-Proofing Enterprise ITDaniel Reimann
 
Software Architecture for Cloud Infrastructure
Software Architecture for Cloud InfrastructureSoftware Architecture for Cloud Infrastructure
Software Architecture for Cloud InfrastructureTapio Rautonen
 
HDFS_architecture.ppt
HDFS_architecture.pptHDFS_architecture.ppt
HDFS_architecture.pptvijayapraba1
 
BP302: Future Proofing Enterprise IT
BP302: Future Proofing Enterprise IT BP302: Future Proofing Enterprise IT
BP302: Future Proofing Enterprise IT panagenda
 
How To Build A Stable And Robust Base For a “Cloud”
How To Build A Stable And Robust Base For a “Cloud”How To Build A Stable And Robust Base For a “Cloud”
How To Build A Stable And Robust Base For a “Cloud”Hardway Hou
 
Camunda BPM 7.2: Performance and Scalability (English)
Camunda BPM 7.2: Performance and Scalability (English)Camunda BPM 7.2: Performance and Scalability (English)
Camunda BPM 7.2: Performance and Scalability (English)camunda services GmbH
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesIvo Andreev
 
Guide to Application Performance: Planning to Continued Optimization
Guide to Application Performance: Planning to Continued OptimizationGuide to Application Performance: Planning to Continued Optimization
Guide to Application Performance: Planning to Continued OptimizationMuleSoft
 
Caching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session ICaching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session IVMware Tanzu
 
SharePoint Global Deployment with Joel Oleson
SharePoint Global Deployment with Joel OlesonSharePoint Global Deployment with Joel Oleson
SharePoint Global Deployment with Joel OlesonJoel Oleson
 

Similar a L12 Session State and Distributation Strategies (20)

Caching for Microservices Architectures: Session II - Caching Patterns
Caching for Microservices Architectures: Session II - Caching PatternsCaching for Microservices Architectures: Session II - Caching Patterns
Caching for Microservices Architectures: Session II - Caching Patterns
 
L19 Application Architecture
L19 Application ArchitectureL19 Application Architecture
L19 Application Architecture
 
Logical Architecture for Protection
Logical Architecture for ProtectionLogical Architecture for Protection
Logical Architecture for Protection
 
Handling Data in Mega Scale Systems
Handling Data in Mega Scale SystemsHandling Data in Mega Scale Systems
Handling Data in Mega Scale Systems
 
Study the past if you would define the future: How Gang of Four patterns are ...
Study the past if you would define the future: How Gang of Four patterns are ...Study the past if you would define the future: How Gang of Four patterns are ...
Study the past if you would define the future: How Gang of Four patterns are ...
 
Scalability Considerations
Scalability ConsiderationsScalability Considerations
Scalability Considerations
 
Client server
Client serverClient server
Client server
 
ConnectED 2015 BP302: Future-Proofing Enterprise IT
ConnectED 2015 BP302: Future-Proofing Enterprise ITConnectED 2015 BP302: Future-Proofing Enterprise IT
ConnectED 2015 BP302: Future-Proofing Enterprise IT
 
Software Architecture for Cloud Infrastructure
Software Architecture for Cloud InfrastructureSoftware Architecture for Cloud Infrastructure
Software Architecture for Cloud Infrastructure
 
HDFS_architecture.ppt
HDFS_architecture.pptHDFS_architecture.ppt
HDFS_architecture.ppt
 
BP302: Future Proofing Enterprise IT
BP302: Future Proofing Enterprise IT BP302: Future Proofing Enterprise IT
BP302: Future Proofing Enterprise IT
 
How To Build A Stable And Robust Base For a “Cloud”
How To Build A Stable And Robust Base For a “Cloud”How To Build A Stable And Robust Base For a “Cloud”
How To Build A Stable And Robust Base For a “Cloud”
 
DBMS.pptx
DBMS.pptxDBMS.pptx
DBMS.pptx
 
Camunda BPM 7.2: Performance and Scalability (English)
Camunda BPM 7.2: Performance and Scalability (English)Camunda BPM 7.2: Performance and Scalability (English)
Camunda BPM 7.2: Performance and Scalability (English)
 
L11 Application Architecture
L11 Application ArchitectureL11 Application Architecture
L11 Application Architecture
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challenges
 
Guide to Application Performance: Planning to Continued Optimization
Guide to Application Performance: Planning to Continued OptimizationGuide to Application Performance: Planning to Continued Optimization
Guide to Application Performance: Planning to Continued Optimization
 
Caching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session ICaching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session I
 
SharePoint Global Deployment with Joel Oleson
SharePoint Global Deployment with Joel OlesonSharePoint Global Deployment with Joel Oleson
SharePoint Global Deployment with Joel Oleson
 
L13 Oranizing Domain Logic
L13 Oranizing Domain LogicL13 Oranizing Domain Logic
L13 Oranizing Domain Logic
 

Más de Ólafur Andri Ragnarsson

New Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course IntroductionNew Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course IntroductionÓlafur Andri Ragnarsson
 
New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine Ólafur Andri Ragnarsson
 

Más de Ólafur Andri Ragnarsson (20)

Nýsköpun - Leiðin til framfara
Nýsköpun - Leiðin til framfaraNýsköpun - Leiðin til framfara
Nýsköpun - Leiðin til framfara
 
Nýjast tækni og framtíðin
Nýjast tækni og framtíðinNýjast tækni og framtíðin
Nýjast tækni og framtíðin
 
New Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course IntroductionNew Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course Introduction
 
L01 Introduction
L01 IntroductionL01 Introduction
L01 Introduction
 
L23 Robotics and Drones
L23 Robotics and Drones L23 Robotics and Drones
L23 Robotics and Drones
 
L22 Augmented and Virtual Reality
L22 Augmented and Virtual RealityL22 Augmented and Virtual Reality
L22 Augmented and Virtual Reality
 
L20 Personalised World
L20 Personalised WorldL20 Personalised World
L20 Personalised World
 
L19 Network Platforms
L19 Network PlatformsL19 Network Platforms
L19 Network Platforms
 
L18 Big Data and Analytics
L18 Big Data and AnalyticsL18 Big Data and Analytics
L18 Big Data and Analytics
 
L17 Algorithms and AI
L17 Algorithms and AIL17 Algorithms and AI
L17 Algorithms and AI
 
L16 Internet of Things
L16 Internet of ThingsL16 Internet of Things
L16 Internet of Things
 
L14 From the Internet to Blockchain
L14 From the Internet to BlockchainL14 From the Internet to Blockchain
L14 From the Internet to Blockchain
 
L14 The Mobile Revolution
L14 The Mobile RevolutionL14 The Mobile Revolution
L14 The Mobile Revolution
 
New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine
 
L12 digital transformation
L12 digital transformationL12 digital transformation
L12 digital transformation
 
L10 The Innovator's Dilemma
L10 The Innovator's DilemmaL10 The Innovator's Dilemma
L10 The Innovator's Dilemma
 
L09 Disruptive Technology
L09 Disruptive TechnologyL09 Disruptive Technology
L09 Disruptive Technology
 
L09 Technological Revolutions
L09 Technological RevolutionsL09 Technological Revolutions
L09 Technological Revolutions
 
L07 Becoming Invisible
L07 Becoming InvisibleL07 Becoming Invisible
L07 Becoming Invisible
 
L06 Diffusion of Innovation
L06 Diffusion of InnovationL06 Diffusion of Innovation
L06 Diffusion of Innovation
 

Último

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Último (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

L12 Session State and Distributation Strategies

  • 1. Lecture 13 Session State and Distribution Strategies
  • 3. Reading  Fowler 6 – Session State  Fowler 17 – Session State Patterns
  • 4. Agenda  Session State – Business transactions  Session State Patterns – Client Session State – Server Session State – Database Session State
  • 5. Business Transactions  Transactions that expand more than one request – User is working with data before they are committed to the database • Example: User logs in, puts products in a shopping cart, buys, and logs out – Where do we keep the state between transactions?
  • 6. State  Server with state vs. stateless server – Stateful server must keep the state between requests  Problem with stateful servers – Need more resources, limit scalability
  • 7. Stateless Servers  Stateless servers scale much better  Use fewer resources  Example: – View book information – Each request is separate
  • 8. Stateful Servers  Stateful servers are the norm  Not easy to get rid of them  Problem: they take resources and cause server affinity  Example: – 100 users make request every 10 second, each request takes 1 second – One stateful object per user – Object are Idle 90% of the time
  • 9. Session State  State that is relevant to a session – State used in business transactions and belong to a specific client – Data structure belonging to a client – May not be consistent until they are persisted  Session is distinct from record data – Record data is a long-term persistent data in a database – Session state might en up as record data
  • 10. EXCERISE Question: Where do you store the session?
  • 11. Ways to Store Session State  We have three players – The client using a web browser – The Server running the web application and domain – The database storing all the data
  • 12. Ways to Store Session State  Three basic choices – Client Session State (456) – Server Session State (458) – Database Session State (462)
  • 13. Client Session State Store session state on the client  How It Works – Desktop applications can store the state in memory – Web solutions can store state in cookies, hide it in the web page, or use the URL – Data Transfer Object can be used – Session ID is the minimum client state – Works well with REST
  • 14. Client Session State  When to Use It – Works well if server is stateless – Maximal clustering and failover resiliency  Drawbacks – Does not work well for large amount of data – Data gets lost if client crashes – Security issues
  • 15. Server Session State Store session state on a server in a serialized form  How It Works – Session Objects – data structures on the server keyed to session Id  Format of data – Can be binary, objects or XML  Where to store session – Application server, file or local database
  • 16. Server Session State  Specific Implementations – HttpSession – Stateful Session Beans – EJB  When to Use It – Simplicity, it is easy to store and receive data  Drawbacks – – – – Data can get lost if server goes down Clustering and session migration becomes difficult Space complexity (memory of server) Inactive sessions need to be cleaned up
  • 17. Database Session State Store session data as committed data in the database  How It Works – Session State stored in the database – Can be stored as temporary data to distinguish from committed record data  Pending session data – Pending session data might violate integrity rules – Use of pending field or pending tables • When pending session data becomes record data it is save in the real tables
  • 18. Database Session State  When to Use It – Improved scalability – easy to add servers – Works well in clusters – Data is persisted, even if data centre goes down  Drawbacks – Database becomes a bottleneck – Need of clean up procedure of pending data that did not become record data – user just left
  • 19. What about dead sessions?  Client session – No our problem  Server session – Web servers will send inactive message upon timeout  Database session – Need to be clean up – Retention routines
  • 20. Caching  Caching is temporary data that is kept in memory between requests for performance reasons – Not session data – Can be thrown away and retrieved any time  Saves the round-trip to the database  Can become stale or old and out-dated – Distributed caching is one way to solve that
  • 21. Practical Example  Client session – For preferences, user selections  Server session – Used for browsing and caching – Logged in customer  Database – “Legal” session – Stored, tracked, need to survive between sessions
  • 22. QUIZ We are building an application for processing development grants. The application is complicated and users can login any time and continue work on their application. What design pattern would we use for storing the session? A) B) ✔ C) D) Client Session State Server Session State Database Session State No state required
  • 24. Reading  Fowler 7 – Distribution Strategies  Fowler 15 – Distribution Patterns – Remote Façade (388)
  • 25. Agenda  Distributed Architectures – Remote and Local Interfaces – Where You Have to Distribute – Remote Façade  Scalablity  DEMO
  • 26. Distributed Architecture  Distribute processing by placing objects different nodes
  • 27. Distributed Architecture  Distribute processing by placing objects on different nodes  Benefits – Load is distributed between different nodes giving overall better performance – It is easy to add new nodes – Middleware products make calls between nodes transparent But is this true?
  • 28. Distributed Architecture  Distribute processing by placing objects different nodes “This design sucks like an inverted hurricane” – Fowler Fowler’s First Law of Distributed Object Design: Don't Distribute your objects!
  • 29. Remote and Local Interfaces  Local calls – Calls between components on the same node are local  Remote calls – Calls between components on different machines are remote  Objects Oriented programming – Promotes fine-grained objects
  • 30. Remote and Local Interfaces  Local call within a process is very, very fast  Remote call between two processes is order-ofmagnitude s l o w e r – Marshalling and un-marshalling of objects – Data transfer over the network  With fine-grained object oriented design, remote components can kill performance  Example – Address object has get and set method for each member, city, street, and so on – Will result in many remote calls
  • 31. Remote and Local Interfaces  With distributed architectures, interfaces must be course-grained – Minimizing remote function calls  Example – Instead of having getters and setters for each field, bulk assessors are used
  • 32. Example  Sun Application Model – “The Canonical Architecture”  Entity Beans – Each bean maps to row in the database – find methods returns Collection of Remote interfaces
  • 33. Example  Result – Architecture that does not perform very well  Suggested solution was – Use session beans to call entity beans
  • 34. Distributed Architecture  Better distribution model – Load Balancing or Clustering the application involves putting several copies of the same application on different nodes
  • 35. Where You Have to Distribute  As architect, try to eliminate as many remote call as possible – If this cannot be archived choose carefully where the distribution boundaries lay  Distribution Boundaries – – – – – Client/Server Server/Database Web Server/Application Server Separation due to vendor differences There might be some genuine reason
  • 36. Optimizing Remote Calls  We know remote calls are expensive  How can we minimize the cost of remote calls?  The overhead is – Marshaling or serializing data – Network transfer  Put as much data into the call – Course grained call  Remote Façade
  • 37. Remote Façade Provides a coarse-grained facade on fine-grained objects to improve efficiency over a network  The façade is a thin wrapper that provides coarse-grained interface to a system – In an object-oriented model, you do best with small objects that have small methods – Can cause great deal of interaction between objects and method invocations
  • 38. Remote Façade  How It Works – Allows efficient remote access with coarse-grained interface – Façade will use the fine-grained object to build and return object like Data Transfer Object – Should not contain any domain logic
  • 39. Remote Façade  When to Use It – Whenever you need remote access to fine grained object model – Most common use is between UI and domain model
  • 40. Remote Façade  Remote method invocation are expensive – Performance killer RMI Client JVM Entity Entity Session Session Entity
  • 41. Remote Façade  Coarse grained interface JVM Client RMI Local calls Entity Remote Façade Entity Session Session Entity
  • 42. Remote Façade  Benefits – Net traffic is reduced – Transactions are closer to the database  Drawbacks – Limitations on object oriented programming – Solution is based on limitations of the network
  • 43. Interfaces for Distribution  XML over HTTP is a common interface – XML is structured and allows for lot of data – XML is common format, well known – HTTP is common and esay to use  XML has overhead – Parsing and manipulation of strings is expensive – Overhead if not needed  Approches like REST are more efficient – Use HTTP right
  • 45. Scaling the application  Today’s web sites must handle multiple simulations users  Examples: – All web based apps must handle several users – mbl.is handles ~180.000 users/day – Betware must handle up to 100.000 simultaneous users
  • 46. The World we Live in  Average number of tweets per day 58 million  Total number of minutes spent on Facebook each month 700 billion  SnapChat has five million daily active users who send 200 million photos per day.  Instagram has over 150 million users on the platform and1 billion likes happening each day
  • 47. Scalability  Scalability is the measure of how adding resource (usually hardware) affects the performance – Vertical scalability (up) – increase server power – Horizontal scalability (out) – increase the servers  Session migration – Move the session for one server to another  Server affinity – Keep the session on one server and make the client always use the same server
  • 49. Load Distribution  Use number of machines to handle requests  Load Balancer directs all request to particular server – All requests in one session go to the same server – Server affinity  Benefits – Load can be increased – Easy to add new pairs – Uptime is increased  Drawbacks – Database is a bootleneck
  • 50. Clustering  Distributing components – Each node has one component – Increased performance is not guaranteed  Using cluster – Have all components in each node and use local calls
  • 51. Clustering  With clustering, servers are connected together as they were a single computer – Request can be handled by any server – Sessions are stored on multiple servers – Servers can be added and removed any time  Problem is with state – State in application servers reduces scalability – Clients become dependant on particular nodes
  • 52. Clustering State  Application functionality – Handle it yourself, but this is complicated, not worth the effort  Shared resources – Well-known pattern (Database Session State) – Problem with bottlenecks limits scalablity  Clustering Middleware – Several solutions, for example JBoss, Terracotta  Clustering JVM or network – Low levels, transparent to applications
  • 54. Measuring Scalability  The only meaningful way to know about system’s performance is to measure it  Performance Tools can help this process – Give indication of scalability – Identify bottlenecks
  • 57. QUIZ Which is true when you are clustering your application? A) Make sure all requests goes to the same machine B) Deploy each component on separate machine to distribute load C) You try to minimize network traffic to avoid latency problems D) Deploy the whole solution on many machines
  • 58. Real World Examples: Betware Iceland Data Center
  • 59. ISP1 ISP2 Hardware firewall Load balancer Backup Software System DB 16 port 2Gbps SAN switch QLogic CMS DB 12 x 300GB SAS 15K 24 x 300GB SAS 15K Pair of each server on separate blade IBM Blade Chassis
  • 60.
  • 61.
  • 62.
  • 63. Summary  Session State – Business transactions  Session State Patterns – Client Session State – Server Session State – Database Session State  Distribution Strategies – How to distribute