负载均衡器

网络

定义

将传入网络流量分发到多个后端服务器的设备或服务,以确保没有单个服务器过载。可提升Web应用程序的可用性、可靠性和可扩展性。

How Load Balancers Distribute Traffic

A load balancer sits between clients and a pool of backend servers, forwarding each incoming request to one server according to a scheduling algorithm. Round-robin distributes requests evenly in sequence. Least-connections sends each new request to the server with the fewest active connections. IP-hash uses a hash of the client source IP so that requests from the same address always reach the same backend — useful for stateful applications. Health checks run continuously; if a backend fails to respond, the load balancer removes it from rotation and redistributes its share automatically.

Layer 4 vs. Layer 7

Layer 4 load balancers operate on TCPTransmission Control Protocol. A reliable, connection-oriented transport protocol that guarantees ordered, error-checked delivery of data through three-way handshakes, acknowledgments, and retransmission. The foundation of HTTP, SSH, and most internet services. and UDPUser Datagram Protocol. A connectionless transport protocol that sends datagrams without establishing a connection or guaranteeing delivery. Faster than TCP, it is preferred for real-time applications like DNS queries, VoIP, gaming, and streaming. connections and make forwarding decisions based solely on IP address and port. They are fast but have no visibility into application content. Layer 7 load balancers inspect HTTPHypertext Transfer Protocol. The application-layer protocol for transmitting web pages, APIs, and other resources. HTTP defines methods (GET, POST, PUT, DELETE) and status codes for client-server communication. headers, URLs, and cookies, enabling content-aware routing: send /api/ requests to one server group and static assets to another. This granularity enables CDNContent Delivery Network. A geographically distributed network of servers that caches and serves content from locations close to end users, reducing latency and improving load times. Major providers include Cloudflare, AWS CloudFront, and Akamai. offloading and A/B testing at the infrastructure level.

Relationship to Other Infrastructure

Load balancers are frequently paired with a Reverse ProxyA server that sits in front of backend servers, forwarding client requests and returning responses on their behalf. Used for SSL termination, load balancing, caching, and hiding the origin server's identity. that handles SSL/TLSSecure Sockets Layer / Transport Layer Security. Cryptographic protocols that provide encrypted, authenticated communication over a network. SSL is deprecated; modern implementations use TLS 1.2 or TLS 1.3. termination upstream, so backend servers receive unencrypted HTTP and need no certificate management. In cloud deployments a load balancer's Public IP AddressA globally unique IP address assigned by an ISP that is routable on the public internet. Every device directly accessible from the internet must have a public IP address. address is the single entry point advertised in DNSDomain Name System. The hierarchical, distributed naming system that translates human-readable domain names (e.g., example.com) into IP addresses (e.g., 93.184.216.34). Often called the "phonebook of the internet.", while backend servers remain on Private IP AddressAn IP address from reserved ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) used within local networks. Private addresses are not routable on the public internet and require NAT for external communication. ranges invisible to the internet.

相关术语

网络 的更多内容