75
Non-functional benefits of Scaling your Web Tier using Coherence*Web

Coherence sig-nfr-web-tier-scaling-using-coherence-web

Embed Size (px)

DESCRIPTION

Coherence sig-nfr-web-tier-scaling-using-coherence-web

Citation preview

Page 1: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Non-functional benefits of Scaling your Web Tier using Coherence*Web

Page 2: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Mark Addy, Consultant

Fast, Reliable, Manageable & Secure

Page 3: Coherence sig-nfr-web-tier-scaling-using-coherence-web

HTTP Session Management

Page 4: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Life Before Coherence

Page 5: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Non-Clustered

SessionCache

Server

Application

Load-Balancer

SessionCache

Server

Application

SessionCache

Server

Application

Page 6: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Non-Clustered

• Sticky Session Load-Balancer• No Redundancy• Session Cache bloats Application JVM Heap

Page 7: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Clustered - Replicated

SessionCache

Server

Application

Load-Balancer

SessionCache

Server

Application

SessionCache

Server

Application

Page 8: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Clustered – Replicated

• Sticky Session Load-Balancer• Redundancy / Failover• Too much Redundancy?• Session Cache bloats Application JVM Heap• Replication overhead increases proportionally to the number

of nodes• Adding more node != more Session Storage capacity• Tuning and Scaling of the Session Cache is coupled to the

Application

Page 9: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Clustered – Backup / Buddy Replicas

SessionCache

Server

Application

Load-Balancer

SessionCache

Server

Application

SessionCache

Server

Application

Page 10: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Clustered – “Buddy Replicas”

• Sticky Session Load-Balancer• Implementations

– WebLogic Clustering– JBossCache Buddy Replication– Tomcat Backup Manager

• Redundancy / Failover• Redundancy is more realistic• Adding more nodes == Increased session storage• Session Cache bloats Application JVM Heap• Tuning and Scaling of the Session Cache is coupled to

the Application

Page 11: Coherence sig-nfr-web-tier-scaling-using-coherence-web

The Challenges

• Redundancy– Transparent Failover– Rolling upgrades / zero

downtime

• Coupling– Independent Tuning– Independent Scaling

• Latency– High access HttpSession

Metadata / Attributes

Page 12: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Coherence*Web

Page 13: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Coherence*Web

• Http Session Management Module• Built directly on top of Coherence– Scalability– Availability– Reliability– Performance

Page 14: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Coherence*Web Integration

Page 15: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Active Cache

Integration into WebLogic Server & GlassFish• WebLogic 10.3.3+

– Requires installation of active-cache and coherence-web-spi shared libraries

Page 16: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Active Cache

• Management via console or WLST• Process control via Node Manager

– Including auto-restart for failed nodes

• Application Configuration via WebLogic Deployment Descriptors

Page 17: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Other Containers

Page 18: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Supported

• Apache Tomcat 5.5.n, 6.0.n• IBM WebSphere 5, 6, 7• JBoss Application Server• Jetty 5.1.n, 6.1n• Oracle OC4J 10.1.2.n, 10.1.3.n• Oracle WebLogic 9, 10• Sun Application Server• Sun GlassFish 2.n

Page 19: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Stage 1 - Inspection

java -jar webInstaller.jar ${war} -inspect -server:Tomcat/6.0.x

• Generates Coherence*Web parameters for target container (coherence-web.xml)• Amend settings in this file prior to the installation stage

Page 20: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Stage 2 - Installation / Instrumentation

java -jar webInstaller.jar ${war} -install

• Applies Coherence*Web context parameters to Application web.xml using the coherence-web.xml file generated in the inspection step

• Unregisters Application ServletContext, ServletRequest and HttpSession Listeners

• Registers Coherence*Web ServletContext Listeners• Wraps Servlets with Coherence*Web SessionServlet• Wraps JSP’s with Coherence*Web JspServlet

Page 21: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Redundancy, Availability & Scalability

Page 22: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Partitioned / Distributed Clustering

SessionCache

Server

Application

Load-Balancer

SessionCache

Server

Application

SessionCache

Server

Application

Page 23: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Partitioned / Distributed Clustering

• Configurable Number of back-ups• Coherence Grid hides data-location• Dynamic Scaling• Replication overhead does not increase with cluster size• Sticky Sessions might not be routed to the Node owning the

data

Page 24: Coherence sig-nfr-web-tier-scaling-using-coherence-web

The Coupling Challenge

Page 25: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Coherence*Web Topology

Traditional Http Session Caches are embedded

We have a choice to make:• In-process

– Embedded

• Out of process– Storage disabled

• Out of process– Coherence*Extend

Page 26: Coherence sig-nfr-web-tier-scaling-using-coherence-web

In-Process

Page 27: Coherence sig-nfr-web-tier-scaling-using-coherence-web

In-Process

Coherence Node

Server

Application

Coherence Node

Server

Application

Coherence Node

Server

Application

Coherence Node

Server

Application

Page 28: Coherence sig-nfr-web-tier-scaling-using-coherence-web

In Process

• Fast In memory access when replicated• Low session numbers• Good for Development• Application shares same JVM as Cache– Unable to Scale independently– Unable to Tune Application and Cache independently– Restarts of Application Nodes impact the cluster– Increased Heap size and GC pauses

Page 29: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Out of Process Storage Disabled

Page 30: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Out of Process Storage Disabled

Coherence Node

Server

Application

Coherence Node

Cache Server

Coherence Node

Server

Application

Coherence Node

Server

Application

Coherence Node

Server

Application

Coherence Node

Cache Server

Coherence Node

Cache Server

Page 31: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Out of Process Storage Disabled

• Straight forward to configure-Dtangosol.distributed.local.storage=false

• Application and Cache are separated– Independent tuning– Independent scaling– Looser Coupling

• Application and Cache Tiers are Clustered

Page 32: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Out of Process Coherence*Extend

Page 33: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Out of Process Coherence*Extend

Server

Application

Coherence Node

Cache Server

Coherence Node

Cache Server

Coherence Node

Cache Server

Coherence Proxy

Cache Server

Coherence Proxy

Cache Server

Server

Application

Server

Application

Server

Application

Page 34: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Out of Process Coherence*Extend

• Application and Cache are totally separated– Independent tuning

• Throughput Collector for Application?• Low Pause Collector for Cache?

– Independent scaling– De-coupled– Reduced memory requirement for Application JVM– Sharing Session Cache is possible– Increased Latency

Page 35: Coherence sig-nfr-web-tier-scaling-using-coherence-web

The Latency Challenge

Page 36: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Coherence*Extend Latency

Server

Application

Cache Server Cache Server Cache Server

Coherence Proxy

Cache Server

Coherence Proxy

Cache Server

Server

Application

Server

Application

Server

Application

SessionCache SessionCache SessionCache

Page 37: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Reducing Latency

We have control over the Coherence Cache Configuration

<near-scheme> <scheme-name>near-cache-scheme</scheme-name> <front-scheme> <local-scheme> <scheme-ref>limited-local-near-cache</scheme-ref> </local-scheme> </front-scheme> <back-scheme> <remote-cache-scheme> <scheme-ref>unlimited-partitioned-remote-cache</scheme-ref> </remote-cache-scheme> </back-scheme> </near-scheme>

Page 38: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Coherence*Extend Latency

Server

Application

Cache Server Cache Server Cache Server

Coherence Proxy

Cache Server

Coherence Proxy

Cache Server

SessionCache SessionCache SessionCache

Server

Application

Server

Application

Server

Application

Page 39: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Near Cache

• Front scheme is a subset of the Back scheme• Local caching for high access cache entries• Reduced Latency• Brings session state close for Sticky Sessions• Size limited to ensure Application heap is kept

under control

Page 40: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Latency & The Session Model

Page 41: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Session Models

Coherence*Web Session Models• Traditional• Monolithic• Split

The Http Session• MetaData

• Last Accessed Time• Created Time• ID

• Attributes• Store what you want!• Not all Attributes are equal...

Page 42: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Traditional

Page 43: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Traditional

HTTP Session

Attribute 1

Coherence Node

Attribute 2

Attribute 3

Attribute 4

...1010011011...

...1010011011...

...1010011011...

...1010011011...

3

CacheKeyHTTP Session ID

1 2

4

Cache Value

Page 44: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Traditional

HTTP Session

Attribute 1

Attribute 2

Attribute 3

Attribute 4

...10101...

...10101...

...10101...

...10111...

Person

HTTP Session

Attribute 1

Attribute 2

Attribute 3

Attribute 4

Person

Person

Page 45: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Traditional

• Good for small Sessions• Each Attribute is Serialized Independently• All Attributes are transferred together• Doesn’t work when attribute values point at the

same Object

Page 46: Coherence sig-nfr-web-tier-scaling-using-coherence-web

mon·o·lith·ic

Page 47: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Monolithic

HTTP Session

Attribute 1

Coherence Node

Attribute 2

Attribute 3

Attribute 4

...101010110101100111010100010100011...

CacheKeyHTTP Session ID

Attributes 1, 2, 3 & 4

Cache Value

Page 48: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Monolithic

HTTP Session

Attribute 1

Attribute 2

Attribute 3

Attribute 4

Person

HTTP Session

Attribute 1

Attribute 2

Attribute 3

Attribute 4

Person

...101111010011...

Page 49: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Monolithic

• Good when your Session attributes require shared Object references to be preserved

• Attributes are Serialized together• All Attributes are transferred together• Expensive – entire Session must be Serialized into a

single Object Stream

Page 50: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Split

Page 51: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Split

HTTP Session

Attribute 1

Coherence Node

Attribute 2

Attribute 3

Attribute 4

...1010011011...

...1010011011...

...1010011011...

...1010011011...

CacheKeySession ID

1 2

Cache Value

4

CacheKeySession ID:4

Cache Value

3

CacheKeySession ID:3

Cache Value

Page 52: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Split

• Default Coherence*Web Session Model• Attributes are Serialized independently• Large Attributes are transferred independently• Reduces network traffic• Separated handling of small and large attributes• Configurable “Large” Attribute Threshold

Page 53: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Split in Action

Cache Server

session-storage

session-overflow

Server

Application

session-storage

Server

Application

session-storage

Server

Application

session-storage

Cache Proxy Cache Proxy

Cache Server

session-storage

session-overflow

Near Local cache “small” session attributes and

Meta DataPartitioned Remote

cache “small” session attributes

and Meta Data

Partitioned Remote cache “large”

session attributes

Page 54: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Split

• Large Session Attributes are off-loaded to a remote cache scheme

• Frequently accessed attributes and MetaData held in near cache for performance

Page 55: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Tracking Attribute Changes

• Initial binary value vs New Binary Value– Object is mutable?– Initial == new (no change)– Initial != new (write to cache)

• Check can be overridden if you never mutate attributes without calling HttpSession.setAttribute– Removing the check improves performance

<context-param> <param-name>coherence-enable-suspect-attributes</param-name> <param-value>false</param-value></context-param>

Page 56: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Cluster Isolation

Page 57: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Cluster Isolation Scope

• Container• Enterprise Archive• Web Archive

Determined by Class-loading Scope

Page 58: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Container Scoping

Application Server

Enterprise Archive

Web Archive

Web Archive

Web Archive

Web Archive

Coherence Node

Application Server

Enterprise Archive

Web Archive

Web Archive

Web Archive

Web Archive

Coherence Node

Page 59: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Container Scoping

• Least Overhead– Libraries deployed on Container Class Path– Number of loaded Classes– Lowest Memory Requirement– One Coherence Cluster Node per Container

• Least Separation– Multiple Applications share the same Cluster– Can be problematic...

Page 60: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Enterprise Archive ScopingApplication Server

Enterprise Archive

Web Archive

Web Archive

Coherence Node

Enterprise Archive

Web Archive

Web Archive

Coherence Node

Application Server

Enterprise Archive

Web Archive

Web Archive

Coherence Node

Enterprise Archive

Web Archive

Web Archive

Coherence Node

Page 61: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Enterprise Archive Scoping• Overhead– Libraries scoped to EAR– One Coherence Cluster Node per Application

• Separation– Applications within the EAR share the same Cluster

<weblogic-application>... <library-ref> <library-name>coherence</library-name> </library-ref> ... <library-ref> <library-name>active-cache</library-name> </library-ref>...</weblogic-application>

Page 62: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Web Archive Scoping

Application Server

Web Archive

Coherence Node

Web Archive

Coherence Node

Web Archive

Coherence Node

Application Server

Web Archive

Coherence Node

Web Archive

Coherence Node

Web Archive

Coherence Node

Page 63: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Web Archive Scoping

• Overhead– Libraries scoped to WAR– One Coherence Cluster Node per Web Archive

• Separation– Each Web Archive participates in its own cluster– Total Independence from negative external factors

Reference via MANIFEST.MF

Manifest-Version: 1.0Extension-List: coherence active-cachecoherence-Extension-Name: coherenceactive-cache-Extension-Name: active-cache

...or package in WEB-INF/lib

Page 64: Coherence sig-nfr-web-tier-scaling-using-coherence-web

So what can we do?

Page 65: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Application Tier Shutdown

Page 66: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Application Tier Shutdown

Coherence Near Cache

Server

Application

Coherence Node

Cache Server

Coherence Node

Cache Server

Coherence Node

Cache Server

Coherence Near Cache

Server

Application

Coherence Near Cache

Server

Application

Coherence Near Cache

Server

Application

Cache Proxy Cache Proxy

Page 67: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Application Tier Shutdown

• Application and Cache are totally separated– Session State is retained by the Cache Tier

Page 68: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Sharing Sessions

Page 69: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Sharing Session State Across Applications & Containers

WLS Server

Application A

WLS Server

Application B

Apache Tomcat

Application C

Cache Proxy Cache Proxy

...

Cache Server Cache Server Cache Server

SessionCache SessionCache SessionCache

Page 70: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Session & Attribute Scoping

Page 71: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Session Scoping• For Applications running under separate domains without a load-

balancer:– http://consulting.c2b2.com– http://marketing.c2b2.com

<context-param> <param-name>coherence-session-cookie-domain</param-name> <param-value>.c2b2.com</param-value></context-param>

• For Applications with different context paths:– http://www.acme.com/shared/portal– http://www.acme.com/shared/trading

<context-param> <param-name>coherence-session-cookie-path</param-name> <param-value>/shared</param-value></context-param>

Page 72: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Session Attribute Scoping<context-param> <param-name>coherence-scopecontroller-class</param-name> <param-value>...</param-value></context-param>

• Global Scoping– AbstractHttpSessionCollection$GlobalScopeController

• Application Scoping– AbstractHttpSessionCollection$ApplicationScopeController – Allows different applications sharing HttpSessions to use identically named

attributes in isolation– Default implementation applies a configurable prefix– Pluggable control over whether attributes are shared or isolated

<context-param> <param-name>coherence-application-name</param-name> <param-value>session-attribute-prefix</param-value></context-param>

Page 73: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Demo

Page 74: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Summary

• Independent Scaling• Independent Tuning• Near Cache Optimization offsets remote Latency• Split Session Model Attribute separation• Redundancy• Scalability• Availability• Performance

Page 75: Coherence sig-nfr-web-tier-scaling-using-coherence-web

Thanks for ListeningAny Questions?

http://www.c2b2.co.ukhttp://blog.c2b2.co.uk

@c2b2consulting