IPVS的负载均衡机制有三种:
Virtual Server via NAT
Virtual Server via IP Tunneling
Virtual Server via Direct Routing
1、 NAT
http://www.linuxvirtualserver.org/VS-NAT.html
NAT(网络地址转换):直接篡改数据包的源/目的地址。
Packet rewriting works as follows.
The incoming packet for web service would has source and destination addresses as:
SOURCE 202.100.1.2:3456 DEST 202.103.106.5:80
The load balancer will choose a real server, e.g. 172.16.0.3:8000. The packet would be rewritten and forwarded to the server as:
SOURCE 202.100.1.2:3456 DEST 172.16.0.3:8000
Replies get back to the load balancer as:
SOURCE 172.16.0.3:8000 DEST 202.100.1.2:3456
The packets would be written back to the virtual server address and returned to the client as:
SOURCE 202.103.106.5:80 DEST 202.100.1.2:3456
2、 IP Tunneling
http://www.linuxvirtualserver.org/VS-IPTunneling.html
IP Tunneling(IP隧道):在原数据包上封装一层IP地址,让私有网络的数据可以在公网上传输。(VPN就是这么实现的)
3、 Direct Routing
http://www.linuxvirtualserver.org/VS-DRouting.html
Direct Route(直接路由):通过Mac地址广播。
LoadBalance服务器和所有后端服务器必须在同一网段,要能够进行Mac广播。