<Insert Picture Here>
©2011 Oracle Corporation ‹#›
<Insert Picture Here>
©2011 Oracle Corporation
In memory session replication with WebLogic, GlassFish and Coherence
Presenter
Title
©2011 Oracle Corporation 3
Agenda
• ActiveCache - Coherence*Web• Deployment Models• Session Models• Locking Modes• Cluster Node Isolation• Session and Session Attribute Sharing• ActiveCache - WebLogic Server 10.3 • ActiveCache - Oracle GlassFish Server 3.1
<Insert Picture Here>
©2011 Oracle Corporation
Coherence*Web
©2011 Oracle Corporation 5
Coherence*Web
What: Distributed HTTP Session Management
Span Applications: Seamlessly share sessions between applications
Span Heterogeneous Environments: Share sessions between WebLogic, OAS, WebSphere, JBoss
Handle Large Sessions: Store more information within the session
©2011 Oracle Corporation 6
Coherence*Web
Why:
Decouple session management from web container
Handle more users without adding more application servers
Restart/maintain applications/containers without loosing sessions
Handle very large sessions efficiently
Keep session data coherent under heavy load
<Insert Picture Here>
©2011 Oracle Corporation
Deployment Models
©2011 Oracle Corporation 8
Deployment Models:In-Process
• Session state maintained within app server process
• Default model for ease of demonstration
DO NOT USE IN PRODUCTION
©2011 Oracle Corporation 9
Deployment Models:Out-of-Process
• Two tiers – app server and cache server
• Session data storage is offloaded from the app server tier
• Each tier can be scaled independently
Default recommendation due to flexibility
©2011 Oracle Corporation 10
Deployment Models:Out-of-Process-Extend
• Similar to the Out-of-Process deployment model
• Communication between tiers is over Coherence*Extend (i.e. TCP/IP)
• Ideal in environments where network does not support UDP
<Insert Picture Here>
©2011 Oracle Corporation
Session Models
©2011 Oracle Corporation 12
Session Models: Traditional
• Manages each session in a single Coherence cache entry…
• … But manages each session attribute’s serialization/deserialization separately
©2011 Oracle Corporation 13
Session Models: Monolithic
• Similar to the Traditional Model…
• … But serializes and deserializes all session attributes together in a single object stream.
• Solves the shared object issue
©2011 Oracle Corporation 14
Session Models:Split
• Session meta-data and “small” attributes stored in one cache
• “Large” attributes stored in a separate cache
• Easily supports very large session objects
• Leverages near caching for “small” attributes
HIGHLY RECOMMENDED
<Insert Picture Here>
©2011 Oracle Corporation
Locking Modes
©2011 Oracle Corporation 16
Locking Mode
Optimistic Locking (default)Allows multiple nodes in a cluster to access an HTTP session
simultaneously. Concurrent updates are detected and rejected using an optimistic approach.
Member LockingDoes not allow more than one node in the cluster to access
an HTTP session.
Thread LockingDoes not allow more than one thread in the cluster to access
an HTTP session.
<Insert Picture Here>
©2011 Oracle Corporation
Cluster Node Isolation
©2011 Oracle Corporation 18
Cluster Node Isolation:App Server Scoped
• All deployed applications in each app server instance will be part of one Coherence node.
• Will result in the smallest number of Coherence nodes (one per web container JVM).
• Minimizes resource utilization (only one copy of the Coherence classes loaded per JVM)
©2011 Oracle Corporation 19
Cluster Node Isolation:EAR Scoped
• All deployed applications within each EAR will be part of one Coherence node.
• Will result in the next smallest number of Coherence nodes (one per deployed EAR that uses Coherence*Web).
• Reduces the deployment effort as no changes to the application server classpath are required.
©2011 Oracle Corporation 20
Cluster Node Isolation:WAR Scoped
• Each deployed web applications will be its own Coherence node.
• Will result in the largest number of Coherence nodes (one per deployed WAR that uses Coherence*Web).
• Results in the largest resource utilization out of the three options (one copy of the Coherence classes loaded per deployed WAR).
<Insert Picture Here>
©2011 Oracle Corporation
Session and Session Attribute Scoping
©2011 Oracle Corporation 22
Session and Session Attribute Scoping
Session Scoping• Coherence*Web allows session data to be shared by
different Web applications deployed in the same or different Web containers.
Session Attribute Scoping• Extension of Session Scoping allowing for scoping of
individual session attributes so that they are either globally visible or scoped to an individual web application.
• Behavior is controllable via the AttributeScopeController interface. Two out of the box implementations:
ApplicationScopeController and GlobalScopeController
©2011 Oracle Corporation 23©2008 Oracle Corporation 23
ActiveCache and WebLogic
©2011 Oracle Corporation 24
ActiveCache and WebLogic
• Integration of Coherence and WebLogic Server– Incremental progress since
launch of 11g
• The whole is greater than sum of its parts!– Coherence*Web SPI Support
for HTTP Sessions– Dependency Injection– Configuration, Lifecycle and
and Monitoring of Coherence Clusters and Servers
+
©2011 Oracle Corporation 25
WebLogic Server Installers with Coherence
• PS2 installer includes Coherence 3.5.3p2• $MW_HOME\coherence_3.5
• PS3 installer includes Coherence 3.6.0.4• $MW_HOME\coherence_3.6
©2011 Oracle Corporation 26
active-cache-1.0.jar
• Shipped with WebLogic Server distribution• Required for advanced WebLogic Server and Coherence
integration• Manage Coherence configuration with WLS MBeans and WLS
Console• Dependency Injection in JEE modules• Manages Coherence Lifecycle in JEE modules• How to reference from applications:
– EAR scope - Import into the JEE application as a shared library jar in weblogic-application.xml
– WAR scope - Import as an optional package via META-INF/manfiest.mf– Server scope – reference this jar from the system classpath
©2011 Oracle Corporation 27
active-cache-1.0.jar (continued)
Manifest-Version: 1.0Ant-Version: Apache Ant 1.7.1Created-By: R28.0.2-3-133398-1.6.0_20-20100512-1453-windows-ia32 (Orac le Corporation)Specification-Title: active-cacheSpecification-Version: 1.0Implementation-Title: active-cacheImplementation-Version: 1.0Extension-Name: active-cacheClass-Path: @BEA_HOME@/modules/features/weblogic.server.modules.cohere nce.integration_10.3.4.0.jar ../../../modules/features/weblogic.serve r.modules.coherence.integration_10.3.4.0.jar
• META-INF/manifest.mf file uses relative paths to refer to other WLS libraries, so refer to this jar in the location: $WLS_HOME/common/deployable-libraries
• If you copy it out of that location it will not work
©2011 Oracle Corporation 28
coherence.jar
• Shipped with Coherence distribution in $COHERENCE_HOME/lib
• Contains core Coherence classes• How to reference from applications:
– EAR scoped - reference as a shared library in weblogic-application.xml (recommended) or embed in APP-INF/lib
– WAR scoped - embed in an application in WEB-INF/lib– Server scoped - can be put on the system classpath
©2011 Oracle Corporation 29
coherence-web-spi.war
• Shipped with Coherence distribution in $COHERENCE_HOME/lib
• Contains WebLogic Server SPI implementation for HTTP Session storage in Coherence
• Reference as a shared library in web module WEB-INF/weblogic.xml
• Contains default cache configuration for session storage WEB-INF/classes/session-cache-config.xml (can be overridden via classpath)
• Local storage defaults to false by default
©2011 Oracle Corporation 30
Node Manager and Coherence Servers
• Coherence Servers need classpath to include $MW_HOME/modules/features/weblogic.server.modules.coherence.server_10.3.4.0.jar
• META-INF/manfist.mf contains relative references to other WebLogic Server libraries, so refer to it in the default location and do not copy it
• If no classpath entries are specified in Startup tab, this jar and coherence.jar are added by default implicitly by Node Manager
©2011 Oracle Corporation 31©2008 Oracle Corporation 31
ActiveCache and GlassFish
©2011 Oracle Corporation 32
ActiveCache and Oracle GlassFish Server
• Integration of Coherence and GlassFish– For commercial
distribution, not open source edition
• Coherence*Web support for HTTP Sessions
+
©2011 Oracle Corporation 33
Getting Started
• Configure your session to use Coherence*Web– Edit glassfish-web.xml
<glassfish-web-app error-url=“”>
<Session-config>
<session-manager persistence-type=“coherence-web” />
</session-config>
…
</glassfish-web-app>
• Advanced configuration options available in glassfish-web.xml– Defaults will handle most web applications– Additional <context-params> elements will override or add
new configuration
©2011 Oracle Corporation 34
Preparing your GlassFish application(s)
• Configuration changes do require restart of Web App• Extract coherence-web.jar and session-cache-
config.xml from coherence\lib\webInstaller.jar/web-install
• Copy session-cache-config.xml to WEB-INF\classes• If clustered, copy coherence.jar to appropriate location
©2011 Oracle Corporation 35
Example: preparing your GlassFish Server
• Example: clustered, in-process deployment model• Create/configure domain
– Use asadmin at command line to create and start– Use GF console to add appropriate JVM options
• coherence –D JVM arguments
• Example JVM options• Well known addresses (as opposed to multicast)• If multi-homed system that has multiple IPs, which IP to bind to
• Tell glassfish to use cache servers for storage, not the in the GlassFish JVM, e.g.
•Session.localstorage=false (ensuring use of coherence cache server, not GF)
©2011 Oracle Corporation 36
Example continued
• Example: clustered, in-process deployment model• Configure load balancer (ex. Apache)
– Configure JVM for cluster or standalone servers to use– Configure / Enable mod_jk.conf load balancer plug-in
• Mount paths defined in workers.properties– Edit workers.properties list to accommodate cluster members– Enable mod_jk for GlassFish
• –Djvmroute option for routing to LB• JVM -D option for location of workers.properties &• In GF console, enable JK network listener for Apache
– for AJP protocol
©2011 Oracle Corporation 37
Links
Coherence User Guidehttp://coherence.oracle.com/display/COH35UG
Coherence*Web Session Management
http://coherence.oracle.com/display/COH35UG/Coherence*Web+Session+Management+Module
Coherence*Web and WebLogic Server
http://coherence.oracle.com/display/COH35UG/Coherence*Web+and+WebLogic+Server
Coherence*Web and WebLogic Portal
http://coherence.oracle.com/display/COH35UG/Coherence*Web+and+WebLogic+Portal
<Insert Picture Here>
©2011 Oracle Corporation