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?

link|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
feedback

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.

link|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
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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