Hazelcast Web Session Replication
About me
E M R A H K O C A M A N
@emrahkocaman
emrah@hazelcast.com
What Is Hazelcast?
Hazelcast is a distributed, 

highly available and scalable
Open Source In-Memory Data Grid
In Memory Data Grid
01001
10101
01010
In Memory 

Data Computing
In Memory 

Data Messaging
++In Memory 

Data Storage
IM Data Store (Caching) Use Case

Database Caching Use-Case
Business Systems
A B C
RDBMS Mainframe
MongoDB

NoSQL
REST
Scale
Hazelcast
HD 

Cache
Dist.
Compute
Dist.
Message
Hazelcast Servers
Hazelcast Server

JVM [Memory]
IM Distributed Computing Use Case
A B C
Business Logic
Data Data Data
CE = Compute Engine
Result
Business / Processing Logic
Result
TCP / IP
Client Client
HD 

Cache
Dist.
Compute
Dist.
Message
IM Distributed Messaging Use Case
Hazelcast Distributed 

Topic Bus
Hazelcast

Topic
Hazelcast

Node 1
Hazelcast

Node 2
Hazelcast

Node 3
MSG
Subscribes
Delivers
Subscribes
Delivers
HD 

Cache
Dist.
Compute
Dist.
Message
Why Hazelcast?
Scale-out Computing enables cluster capacity to be
increased or decreased on-demand
Resilience with automatic recovery from member failures
without losing data while minimizing performance impact on
running applications
Programming Model provides a way for developers to easily
program a cluster application as if it is a single process
Fast Application Performance enables very large data sets
to be held in main memory for real-time performance
World-Class Customers
TELECOMMUNICATIONS
BANKING & 

FINANCIAL SERVICES
HIGH-TECH
LOGISTICS
INSURANCE
GAMING & ENTERTAINMENT
CONSUMER &
ECOMMERCE
Ecosystem Traction

Dozens of Commercial and Open Source Projects Embed Hazelcast
Feature Overview
Map Set Queue Lock/

Sem. Atomics Topic User
DefinedMultiMap Ring

Buffer
Hazelcast In-memory Computing Platform
Java
C++ .NET
Portable Serialization / 

Pluggable Serialization
Memcached REST Internal Client

Network Protocol
java.util.concurrent.*javax.cache.*Hibernate 2nd Level
Cache
Executor ServiceSQL Query Map / Reduce Aggregation
Low-level Services API
Node Engine

(Threads, Instances, Eventing, Wait/Notify, Invocation)
Partition Management

(Master Partition, Data Affinity, Replicas, Migrations, Partition Groups)
Cluster Management

(Multicast, IP List, AWS/OpenStack)
Networking

(IPv4, IPv6)
On-heap Storage
ManagementCenter

(API,JMX)
Security

(Connection,Encryption,Authentication,Authorization)
WAN

(TopologyAwarePartitionManagement,WANReplication)
Hazelcast Open Source Hazelcast Enterprise
Hazelcast Architecture
Predicate Entry Processor
High-Density (HD) Memory Store
Continuous
Query
HD Near Cache
Open Client 

Network Protocol
Hot Restart Store*
* Coming in 3.6
Web Sessions
Web Session Replication
Web Session Replication
• Web Session Replication is replicating web session
to other members of the cluster each time there is a
change in the session data.
Use Case
Use Case
Use Case
Deployment Options
Great for early stages of rapid
application development and iteration
Necessary for scale up or scale out
deployments – decouples
upgrading of clients and cluster for
long term TCO
Embedded Hazelcast
Hazelcast Node
1
Applications
Java API
Client-Server Mode
Hazelcast
Node 3
Java API
Applications
Java API
Applications
Java API
Applications
Hazelcast
Node 2
Hazelcast
Node 1
Hazelcast Node
2
Applications
Java API
Hazelcast Node
3
Applications
Java API
Generic Web Session Replication
• Filter Based
• Servlet Container Agnostic
• Runs on any container that supports Servlet 3.0
• Configured in “web.xml”
• Spring Security Support
• Client/P2P Mode
• Deferred write
• Sticky/Non-Sticky session support
Configuration
<filter>
<filter-name>hazelcast-filter</filter-name>
<filter-class>com.hazelcast.web.WebFilter</filter-class>
<init-param>
<param-name>map-name</param-name>
<param-value>my-sessions</param-value>
</init-param>
<init-param>
<param-name>sticky-session</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>hazelcast-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<listener>
<listener-class>com.hazelcast.web.SessionListener</listener-class>
</listener>
Tomcat Session Replication
• Tomcat 6, 7 & 8
• Easy to set up
• No need to modify applications
• Put a <Listener> element into the file $CATALINA_HOME$/conf/
server.xml
• Put a <Manager> element into the file $CATALINA_HOME$/conf/
context.xml
Jetty Session Replication
• Jetty 7,8 & 9
Demo
Thank you

Web session replication with Hazelcast