I have two multihomed, web-balanced webservers running Lucee and I'm having issues getting the session to replicate across EHCache instances. I'm not even sure if auto discovery works
Here is my setup and config:
OS setup
- Multicast setup for both servers on eth0 with address 224.0.0.0 (I know this works because when I ping 224.0.0.1 I get responses from both webserver IPs)
- /etc/sysctl.conf:
net.ipv4.icmp_echo_ignore_broadcasts = 0
andnet.ipv4.ip_forward =1
Lucee SessionCache object setup for each instance
- Auto Peer Discover
- Multicast User Group Address:
224.0.0.1
- Multicast User Group Port:
4446
Host:
xx.xx.xx.xx
(this is the IP address of each of the server's eth0 interface that I'm using and I did confirm that they respond when pinging the multicast user group)Synchronization has everything checked
All other settings (RMI, Listener) are left as default (blank in some cases)
When I run my application which uses this sessionCache object as sessionstorage and attempt to login, I only login on one instance then get redirected(load balancer) to the next instance where I have to login again because the session does not get replicated.
Update #1
In order to enable the session replication in a distributed cluster, you need this.sessionCluster = true
and J2EE
session types (this.sessionType = "j2ee"
) in the Application.cfc
pseudo-constructor
Update #2
Distributed cache for session storage seems to be very prone to race conditions even with synchronous replication. Asynchronous replication
is definitely not recommended, especially when your load balancer does Round Robin.
Which brings me to load balancer Round Robin
. Lucee creates a brand new session every time you jump an instance, so my replication is useless because I'm not hitting the same sessionid
Update #3
Storing the sessions in a database through the sessionStorage
property seems to mitigate all my issues. I can even do Round Robin in the load balancer. Instructions on setting that up can be found here.
CFML
sessions are recommended instead of J2EE