负载均衡器的百度解释:
负载均衡(LoadBalance)建立在现有网络结构之上,它提供了一种廉价、有效、透明的方法,来扩展网络设备和服务器的带宽、增加吞吐量、加强网络数据处理能力、提高网络的灵活性和可用性。
有名的硬件:F5 BIG-IP(SNAT,NPATH)(3-7层)
有名的开源软件:LVS(Dr,Tun,NAT)(3-4层),haproxy(NAT)(7层),nginx(NAT)(3-7层)
NAT:
When a user accesses the service provided by the server
cluster, the request packet destined for virtual IP address (the
external IP address for the load balancer) arrives at the load
balancer. The load balancer examines the packet's destination
address and port number. If they are matched for a virtual server
service according to the virtual server rule table, a real server
is chosen from the cluster by a scheduling algorithm, and the
connection is added into the hash table which record the
established connection. Then, the destination address and the
port of the packet are rewritten to those of the chosen server,
and the packet is forwarded to the server. When the incoming
packet belongs to this connection and the chosen server can be
found in the hash table, the packet will be rewritten and
forwarded to the chosen server. When the reply packets come back,
the load balancer rewrites the source address and port of the
packets to those of the virtual service. After the connection
terminates or timeouts, the connection record will be removed in
the hash table.
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
NPATH(DR):
When a user accesses a virtual service provided by the server
cluster, the packet destined for virtual IP address (the IP address
for the virtual server) arrives. The load balancer(LinuxDirector)
examines the packet's destination address and port. If they are
matched for a virtual service, a real server is chosen from the
cluster by a scheduling algorithm, and the connection is added into
the hash table which records connections. Then, the load balancer
directly forwards it to the chosen server. When the incoming packet
belongs to this connection and the chosen server can be found in the
hash table, the packet will be again directly routed to the
server. When the server receives the forwarded packet, the server
finds that the packet is for the address on its alias interface or for
a local socket, so it processes the request and return the result
directly to the user finally. After a connection terminates or
timeouts, the connection record will be removed from the hash
table.
==over==
阅读(1473) | 评论(0) | 转发(0) |