带有轮循机制的 dns 一个两个 Web 服务器

lea*_*one 0 domain-name-system web-server

我有两个网络服务器和下一个区域

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
Run Code Online (Sandbox Code Playgroud)

问题出在 php 会话上,您转到 web1.example.org,然后 dns 响应 web2.example.org。

我怎样才能解决这个问题?

jgo*_*afe 5

您要么需要一个不在任一服务器的本地磁盘(例如数据库或网络卷)上的持久会话存储,要么您需要放弃循环方法并实现一个足够智能的负载平衡器,以保持将每个客户端发送到同一服务器集群。

无论如何,循环对于可用性来说是一个坏主意——如果一台服务器出现故障,您会将一半的流量重定向到一个死系统。