Web Performance Optimization: Load Balancing, DNS, Reverse Proxy, and CDN
To improve web performance, the article examines network‑level optimizations such as request flow, load balancing techniques (including DNS‑based and hardware load balancers), reverse proxy mechanisms like Nginx, and the role of CDNs in caching static assets to reduce latency and enhance scalability.
People often wonder why sites like Facebook need thousands of engineers; the answer is that high‑performance web systems must be optimized from many angles, ranging from server layout to tiny code loops that could cause a total collapse.
The article narrows the focus to the network layer as a starting point for performance tuning.
Network request path:
(Client enters URL) → (DNS server resolves to IP) → (Server processes request) → (Response returned to client)
This abstract flow provides a clear basis for further optimization.
1) Load Balancing
A boss assigns many tasks to Xiao Ming, who then forces Xiao Qiang to help under threat; Xiao Qiang reluctantly complies, and the boss completes the work. This story illustrates how load balancing distributes work among multiple parties.
In computing, a single server cannot handle high concurrency, so requests are distributed to multiple servers via a load‑balancing component placed between client and servers.
DNS
DNS is a crucial intermediary that maps a user’s URL to an IP address. While there are 13 root servers worldwide, most lookups are handled by local DNS servers (LDNS) operated by ISPs.
Early load balancing used local DNS servers to assign multiple IPs to the same hostname using round‑robin or random selection.
However, DNS‑based balancing cannot quickly detect a downed server, nor can it consider each server’s current load, leading to possible overload on some servers while others remain idle.
Hardware Devices
A load balancer (hardware) is placed between client and server and offers many balancing strategies (weight, dynamic ratio, fastest mode, least connections, etc.). Its high performance comes at a high price, often costing tens of thousands of dollars.
Reverse Proxy
Nginx is a high‑performance, lightweight HTTP server that also serves as an excellent reverse‑proxy server.
A forward proxy is client‑initiated (e.g., a scientific internet proxy), whereas a reverse proxy sits on the server side; users access the reverse‑proxy, which then forwards the request to the actual server.
Reverse proxies are a mainstream method for implementing load balancing, with Nginx providing numerous distribution strategies to evenly spread load.
Nginx reverse‑proxy diagram:
Hardware load‑balancer (BIGIP) diagram:
2) CDN
Frequent video buffering and image loading failures that were once normal are now unacceptable; the solution is a Content Delivery Network (CDN).
CDN stores static files on one or more servers, replicating and caching them to serve users from locations closer to them.
1. What are static files?
CSS, HTML, images, and media are static files because their content does not change per request; JSP, PHP, etc., are dynamic.
2. How does CDN accelerate?
When the origin server is far from the user, latency increases due to distance, ISP routing, and bandwidth limits. CDN nodes distributed worldwide receive the user’s request and serve the content from the nearest node, reducing latency.
3. Where does CDN data come from?
CDN nodes can cache files after a user request or proactively pull content from the origin server; they replicate and store the data for future requests.
Geographically distributed CDN nodes:
The article concludes with a promotional note inviting readers to join an architecture discussion group and includes copyright information.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.