Take the 2-minute tour ×

i have two webservers and the next zone

web1.example.org IN A
web2.example.org IN A

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

2 Answers 2

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

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

Your Answer


