2

We have a load balanced cluster of 2 servers for our Coldfusion applications. I'm encountering some weird behavior, and would like to find out which of the two servers a user is currently on when they are running the web application. Is there a way to find out which server is being used for specific requests?

The cgi.server variable only provides info like cfprod.domain.com and what I need is, cfprod1.domain.com or cfprod2.domain.com

4 Answers 4

1

You can get the CF Instance name using this: #GetMetricData("PERF_MONITOR").InstanceName#

The problem is that you probably don't have the metrics service enabled, since it is disabled by default on the Enterprise editions. I wouldn't be surprised if there is another way to get the instance name as well.

0

If you have a standard header include, perhaps output the server name as an HTML comment. This would mean a slightly different file on each server, but may help you track down the issue for troubleshooting. If the header file must be the same, add code to include or read from some other file that can be different, perhaps outside your webroot if the two servers have the webroot synchronized regularly.

2
  • That's a good idea. I suppose I could tell the sysadmin to put a small xml file on each server, and have a single element in it say the full name of the server. On each request, I could have it look up the file, parse the text, and attach the value to my error report emails. Do you think that would do the job? Aug 27, 2009 at 12:46
  • It very likely would, yes. Aug 30, 2009 at 6:04
0

If you want to do it without adding extra content to manage on the servers, you could programatically get the host names of the server ColdFusion is running on. This will be unique ot each node of the cluster.

<cfset hostName=CreateObject("java", "java.net.InetAddress").localhost.getHostName()/>

This is discussed over on StackOverflow: https://stackoverflow.com/questions/830782/in-coldfusion-is-there-a-way-to-determine-what-server-the-code-is-running-on

0

I have a simple application I used to test session stability, failover, and replication in ColdFusion clusters. You can download session_test.zip from my blog here: http://www.talkingtree.com/blog/downloads.cfm

This test reports which instance your request is on, and if the server instance or session token has changed such as during failover. And if the session recovers after failover back to the originating server then it will indicate that too.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .