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.

i have two webservers and the next zone

web1.example.org IN A 10.0.0.1
web2.example.org IN A 10.0.0.2

example.org IN CNAME web1.example.org
example.org IN CNAME web2.example.org

The problem its the php session, you go to web1.example.org and later the dns responds web2.example.org.

How can i fix this?

share|improve this question
1  
I'm probably being anal-retentive, and this doesn't have anything to do with your issue, but you can't have a CNAME as the root of a domain. RFC 1034 specifies that a CNAME can't be shared with any RR having the same name, including NS records. –  jgoldschrafe Dec 16 '10 at 3:36
add comment

2 Answers

up vote 5 down vote accepted

You either need a persistent session store that's not on either server's local disk (e.g. a database or a network volume) or you need to ditch the round-robin approach and implement a load balancer intelligent enough to keep sending each client to the same server in the cluster.

Round-robin is a bad idea for availability anyway -- if one server fails, you're redirecting half of your traffic to a dead system.

share|improve this answer
    
Round robin balancing to a pair of load-balancers is slightly less bad, though. –  Tom O'Connor Dec 16 '10 at 10:20
    
That's yet another point of failure -- you want to at least make sure the IPs are either multicast or high-availability vIPs. –  jgoldschrafe Dec 16 '10 at 14:03
add comment

If you do not want the load to be evenly spread across your servers I would suggest configuring the TTL based on your users sessions to ensure that connections will most likely stay pointed at any given web server.

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.