Coldfusion 2018 clustering and session replication not working

470 views Asked by At

Setting up a couple new Coldfusion 2018 servers and will be using clustering for the first time and have run into some problems.

I am having trouble with session replication. Basically, session variables appear to be replicated between nodes in a cluster but are killed after a short while at random.

A little setup info:

  • 2 web servers (Windows Server 2012) behind load balancers
  • On each web server sits a Coldfusion cluster consisting of 2 local instances (still unclear if this is useful or not - will ask in separate question) and 2 remote instances (the remotes reference the local instances of each opposite server)
  • For simplicity, currently just testing on a single server with local Coldfusion instances - leaving the remotes out of the equation until I can get things working reliably locally
  • Using J2EE session variables
  • Coldfusion session timeout set to 2 hours
  • In each Coldfusion instance, channelSendOptions is set to "6"

Here is what I did/experienced:

  • We have a web application that requires login and stores user information in the session upon login.
  • I made a small modification to the web app to show me which cluster instance has serviced my current request.
  • After setting up the cluster, I started the web application and logged in, noting the instance which displayed the login page.
  • Upon logging in, I was immediately returned to the login screen (app checks for user info in session and redirects to login if not found)
  • Debugging revealed that I was actually being logged in but after redirecting to some new page after login the user info would be gone from session.
  • Multiple login attempts in a row (same credentials, just tried over and over again and again) revealed that sometimes login would proceed just fine and I would get into the app. However, if I refreshed the page or went to another page, the session would be lost very soon but at random (within a few page refreshes).
  • In an attempt to simplify the problem to try and figure out what is going on, I created a simple .cfm that bypasses all the login stuff and does one thing: adds a simple string value to session and then dumps the session and instance name. ** I ran the script once, noted which instance was being used and that session contained my value. ** I then edited the script so it no longer set the session value. ** I then hit refresh over and over so I could confirm:
    1. That requests were being serviced by both instances in cluster
    2. That as I flip-flopped between instances, the session value was available all the time.
  • Again, the replication would work and for several refreshes I could see my session variable available on each instance...until it wasn't. After a random number of refreshes/seconds (between 2 - 10 refreshes say) the value would disappear.

I am at a loss to explain why this is happening. We considered using Redis as a session store to see if it helped but frankly, our team has no experience with it, it is clunky to get working in Windows and we really don't want any more moving pieces in our infrastructure if we can help it.

Any insight on what is occurring as well as advice for how to peer behind the scenes as it were and see what is going on with session replication would be greatly appreciated.

Thanks

Adding some code and screenshots. The screenshots show the state of session after each page refresh and which instance is currently serving the page. The last two images represent refreshes 11 and 13 - the session variable was lost in 11 and I went to 13 so that we can see that the variable was lost on the other instance as well. Also a couple pictures of cluster/session setup.

Following is the simple test script. The first line is un-commented on first run to create the session variable and commented out for each subsequent run.

<!--- <cfset Session.svar="cake!"> --->

<cfdump var="#Session#" />

<cfscript>
hostaddress = createObject("java", "java.net.InetAddress").localhost.getHostAddress();
</cfscript>

<cfoutput>
<h3>
Instance: #createobject("component","CFIDE.adminapi.runtime").getinstancename()#
</h3>
</cfoutput>

Refresh 1

Refresh 2

Refresh 3

Refresh 4

enter image description here

Refresh 6

Refresh 7

Refresh 8

Refresh 11

Refresh 13

enter image description here

enter image description here

0

There are 0 answers