DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • A Complete Guide to AWS File Handling and How It Is Revolutionizing Cloud Storage
  • Front-End: Cache Strategies You Should Know
  • Alpha Testing Tutorial: A Comprehensive Guide With Best Practices
  • A React Frontend With Go/Gin/Gorm Backend in One Project

Trending

  • A Complete Guide to AWS File Handling and How It Is Revolutionizing Cloud Storage
  • Front-End: Cache Strategies You Should Know
  • Alpha Testing Tutorial: A Comprehensive Guide With Best Practices
  • A React Frontend With Go/Gin/Gorm Backend in One Project
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Web Session Clustering: No Session Left Behind

Web Session Clustering: No Session Left Behind

Dmitriy Setrakyan user avatar by
Dmitriy Setrakyan
·
Dec. 12, 13 · Interview
Like (0)
Save
Tweet
Share
7.11K Views

Join the DZone community and get the full member experience.

Join For Free
Clustering and failing-over web sessions is certainly not a new topic, but time proves that this topic never gets old either.  No e-commerce site wants to loose any customers in case of a server crash. The old approach of sticky sessions does not seem to do the trick anymore, as it often causes uneven load distribution across cluster with certain servers being overloaded while others being almost idle.

Web session clustering provides freedom of load balancing user sessions to any app server without losing intermediate user session data. Why? Because underneath it takes advantage of in-memory distributed caching technology which ensures that user sessions are available in memory regardless of which server is hit. With this approach fault tolerance comes automatically - if a server crashes, simply go to another server and your session will still be available. All of this happens transparently to user who simply continues to browse and add items to the shopping cart as if nothing happened.

As an example, diagram below illustrates how web session clustering works in GridGain:


With GridGain In-Memory Database technology (IMDB) web sessions will be either replicated to all servers or partitioned across the cluster, where every cluster node will serve as a primary node for a particular web session. In case of partitioned strategy, it is possible to configure any number of backup copies within the cluster to ensure fault tolerance. All sessions will be eagerly removed from cache whenever they expire in the app server to free up memory space for others.

Configuration is as easy as adding a few lines into your web.xml file, like so:
...
 
<!-- Declare listener for web sessions caching. -->
<listener>
    <listener-class>
        org.gridgain.grid.cache.websession.GridWebSessionServletContextListener
    </listener-class>
</listener>
 
<!-- Specify GridGain configuration (relative to GRIDGAIN_HOME). -->
<context-param>
    <param-name>GridGainConfigurationFilePath</param-name>
    <param-value>/examples/config/spring-cache.xml</param-value>
</context-param>
 
<!-- Specify the name of GridGain cache for web sessions. -->
<context-param>
    <param-name>GridGainWebSessionsCacheName</param-name>
    <param-value>session-cache</param-value>
</context-param>
 
...
Once configured, simply bring up as many instances of your favorite app server and web sessions will be automatically clustered and cached in memory.
Session (web analytics) clustering

Published at DZone with permission of Dmitriy Setrakyan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • A Complete Guide to AWS File Handling and How It Is Revolutionizing Cloud Storage
  • Front-End: Cache Strategies You Should Know
  • Alpha Testing Tutorial: A Comprehensive Guide With Best Practices
  • A React Frontend With Go/Gin/Gorm Backend in One Project

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: