Overview

The scaling of any web application depends on how user sessions are handled. One way to address scaling is to implement sticky sessions and session replication through node clusters.

But sticky sessions have their own bottlenecks. In such situations, you can implement an external cache server to handle various sessions across multiple nodes.

All ColdFusion sessions are stored in memory. But the sessions cannot be shared across ColdFusion nodes. You can replicate sessions, but as the number of nodes increase in a cluster, the configuration and management of sessions become increasingly difficult and resource-intensive.

One way to solve this problem is to use an external session storage like Redis.

Redis support

You can now store ColdFusion sessions in external cache servers like Redis, instead of in-memory storage in ColdFusion servers.

Session Persistence

To set up session storage in Redis:

  1. In ColdFusion administrator, click Server Settings > Memory Variables.

    Session Storage Settings
  2. Select Redis from the Session Storage drop-down list.

    Redis Option
  3. Enter the Redis server details and the port number.

    Redis Details

    Note:

    If you select Use J2EE session variables, you cannot store ColdFusion sessions in Redis.

Session object serialization

Once a session object is received from Redis, there can be changes to the object within the timespan of a given request. The session is persisted (if modified) back to external storage on request end. The changes made by the current request on one node are available to all other nodes.

Note:

If the nodes in a cluster use Redis, disable sticky sessions at the load balancer. In addition, clear the Sticky Sessions and Session Replication check-boxes in Cluster Manager.

Cluster Manager

Session invalidation

After a specified timeout period, sessions in both in-memory and Redis are invalidated and removed.

Backing up Redis

You can take a backup of Redis using rdb files. For example, you can create backups of rdb files every hour and save the snapshots to a different location.

The Redis server creates dump.rdb and you can copy this file to another location.

To retrieve Redis data, delete the file appendonly.aof and also delete the latest instance of dump.rdb. Copy the older dump.rdb file to the location. 

Note: Before deleting the files, stop the Redis server. After copying the rdb file, restart Redis.

To modify the duration of snapshots of Redis, edit the redis.windows.conf.properties file and modify the snapshot properties.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy