Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

4 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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? –  David Csonka Aug 27 '09 at 12:46
    
It very likely would, yes. –  Justin Scott Aug 30 '09 at 6:04
add comment

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: http://stackoverflow.com/questions/830782/in-coldfusion-is-there-a-way-to-determine-what-server-the-code-is-running-on

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.