No history yet

High Availability Strategies

Beyond Basic Load Balancing

When scaling a system, a single server can't handle all the traffic. The obvious solution is to add more servers and use a load balancer to distribute requests among them. But this introduces a new problem: what if the load balancer itself fails? Or what if one of the servers it's directing traffic to goes offline?

This is the core challenge of high availability. We need to design systems that can withstand failures without interrupting service. The goal is to eliminate any single point of failure (SPOF), which is any component whose failure would cause the entire system to stop working. The key strategy to eliminate SPOFs is redundancy, which means having duplicate components ready to take over.

High availability (HA) designs mandate distributing resources across multiple availability zones or regions to eradicate single points of failure.

Different Layers of Logic

Not all load balancers work the same way. They operate at different layers of the network stack, which gives them different capabilities. The two most common types are Layer 4 and Layer 7.

Layer 4 (L4) load balancers operate at the transport layer. They make routing decisions based on information like the source and destination IP addresses and ports from the first few packets of a network connection. They don't inspect the actual content of the traffic. This makes them extremely fast and simple, acting like a high-speed traffic cop that only looks at the vehicle's origin and destination, not what's inside.

In contrast, Layer 7 (L7) load balancers operate at the application layer. This means they can inspect the content of the traffic, such as , URLs, and cookies. This deep insight allows for much more intelligent routing decisions. For example, an L7 load balancer can route requests for video content to servers optimized for streaming, while requests for a user's account page go to servers that handle database transactions. It's a much smarter traffic director that understands the purpose of each request.

FeatureLayer 4 Load BalancerLayer 7 Load Balancer
Decision BasisIP Address & PortHTTP Headers, URL, Cookies
SpeedVery FastSlower (due to inspection)
IntelligenceLow (Content-agnostic)High (Content-aware)
FlexibilityLimitedHigh (e.g., path-based routing)
Common Use CaseSimple, high-speed traffic distributionComplex applications, microservices

Going Global

When your user base spans the globe, having all your servers in one data center isn't good enough. The physical distance creates latency, slowing down the experience for users far away. The solution is to have multiple data centers in different geographic regions.

This is where Global Server Load Balancing (GSLB) comes in. GSLB is a method for distributing traffic among servers located in different geographical locations. It typically works at the DNS level. When a user tries to access your service, the GSLB system determines the best data center to send them to based on factors like geographic proximity, data center health, and server load. This ensures users get the fastest response times while also providing resilience; if one entire data center goes down, GSLB can redirect all traffic to the healthy ones.

A load balancer is only effective if it knows which servers are healthy enough to receive traffic. This is managed through health checks. A health check is a periodic request sent by the load balancer to a server to ensure it's running correctly. If a server fails a health check, the load balancer automatically stops sending traffic to it until it becomes healthy again.

Health checks are the eyes and ears of your load balancer. Without them, you're just blindly hoping your servers are online.

These checks can be simple, like a to see if a port is open, or more complex, like an HTTP request that expects a specific 200 OK status code from a /health endpoint. A sophisticated health check might even query the application to ensure that its dependencies, like a database connection, are also healthy. This prevents traffic from being sent to a server that is running but unable to actually serve requests properly.

Planning for Failure

With redundancy and health checks in place, the final piece is a clear strategy for what happens when a component fails. This is called a failover mechanism. The two most common models are active-passive and active-active.

Lesson image

In an active-passive setup, you have a primary server (or group of servers) that handles all traffic, and an identical, redundant passive server that is on standby. The standby server does not receive live traffic but is kept up-to-date, often through data replication. If health checks detect that the primary server has failed, traffic is automatically rerouted to the passive server, which then becomes active. This is like having an understudy for a play who is always ready to go on stage at a moment's notice.

An active-active configuration is different. Here, all servers are handling traffic simultaneously, usually spread across multiple availability zones. A load balancer distributes requests among all of them. If one server or even an entire zone fails, the load balancer simply redirects its traffic to the remaining active servers. This model offers better resource utilization since you aren't paying for idle standby hardware. However, it requires careful architecture to ensure the application can handle state and data consistency across all active nodes.

Let's check your understanding of these high availability concepts.

Quiz Questions 1/6

What is the primary purpose of redundancy in designing a highly available system?

Quiz Questions 2/6

An e-commerce site wants to direct users browsing for clothing to one set of servers and users browsing for electronics to another. Which type of load balancer is necessary to accomplish this?

By combining multi-layered load balancing, global distribution, automated health checks, and robust failover strategies, you can build a system that remains available and performant for millions of users, even when individual components inevitably fail.