Skip to main content

Load Balancer Routing Algorithms - Draft version

The main purpose of the load balancer is to distribute the traffic evenly across multiple servers. The Load Balancer promises the efficient usage of the back-end servers without overloading and not keeping the server in busy times. Avoiding the server overload will reduce the downtime.


Table of Content:

  1. Different types of LB
  2. Algorithms used by ALB
  3. ALB Features 
  4. Questions
  5. Configuring ALB in AWS 
  6. Creating K8S config files
  7. Factors to consider to ALB design


There are different types of load balancers:

  1. Application Load Balancer (Layer 7)
  2. Network Load Balancer
  3. Global Server Load Balancer
Let's narrow our discussion to Application Load Balancer(ALB). The ALB operates on layer 7 of OSI model.  

Algorithms used by ALB are:

  1. Round Robin  
  2. Least connections
  3. Weighted Round Robin
  4. IP hash
  5. Least Connections Response time

The ALB evaluates incoming requests to ensure efficient and reliable traffic distribution. LB has to ensure.

  1. High availability
  2. Scalability
  3. Performance optimization
The features provided the LB
  1. Health checks: The LB check the status of back servers and not responding servers are removed from pool and input requests are not shared to the failed server. This will provide the continuous availability of the application to the customer.
  2. Traffic distribution: Traffic routing to back servers is done using various algorithms.
  3. Content-based routing: The routing is done based on 
  4. SSL certificate management:
  5. Session persistence/Sticky session: 

Load Balancers are used in various places in the application

  1. Client - Web server
  2. Web server - Application server
  3. Application server - Database

Question: Is the data transfer inside the VPC secured despite the SSL termination at the load balancer?

data transfer within a VPC (Virtual Private Cloud) is generally considered secure even with SSL termination at the load balancer. Here's why:

  1. Isolation: VPCs provide network isolation from other users in the cloud, meaning your traffic is not exposed to external networks.

  2. Security Groups: You can control traffic between resources within your VPC using security groups, which act as virtual firewalls. This allows you to restrict communication to only necessary ports and protocols.

  3. Network ACLs: Network Access Control Lists (ACLs) provide an additional layer of security by filtering traffic at the subnet level.

  4. Private Subnets: You can place backend servers in private subnets, making them inaccessible directly from the internet. Only the load balancer, situated in a public subnet, would have a public IP address.

  5. Sensitive Data & Encryption in Transit: While the traffic within the VPC is isolated, it might still be unencrypted after SSL termination. If you have strict compliance requirements or are dealing with highly sensitive data, you might consider end-to-end encryption (i.e., having SSL/TLS on both the load balancer and backend servers).

  6. Sometimes to follow the same standard across the organization and follow the encryption in all endpoints, do not do SSL termination in load balancer and allow the SSL encryption to continue/pass through. The extra burden is managing the SSL certificates and rotation.


Question: What will happen if ALB itself fails?

Several strategies provide redundancy and automatic failover mechanisms. 

  1. Load Balancer Redundancy
    1. Active-Active configuration
    2. Active-Passive configuration
  2. Health checks and Monitoring
    1. Frequency health check 
  3. Failover mechanism
  4. Use managed Load Balancer service of cloud providers.

Factors to consider to design a load balancing solution to meet the requirements of the application characteristics such as performance, scalability, security and reliability

  1. Do you need L4 or L7 load balancing
  2. What are the out of box features required for your use case (e.g., health checks, stick sessions, SSL termination)
  3. How much traffic need to handle ?
  4. Do you need LB to be scalable based on custom parameters?
  5. High availability and scalability
  6. Performance optimization
  7. Monitoring and logging
  8. Are you using Websockets and gRPC ?
  9. Cost of using on-premises vs managed load balancer & choosing the computation.

Configuring ALB on AWS & The K8S config files https://www.github.com/bonu/

References:




Comments

Popular posts from this blog

React JS Basics

  What are side effects in React? In React, side effects are operations that interact with external systems or cause changes outside the component's rendering process. These can include: Data fetching: Retrieving data from APIs or other sources. Subscriptions: Setting up listeners for events or data changes. Timers: Creating timers for delayed actions or animations. DOM manipulation: Directly modifying the DOM (rarely used in modern React with declarative approach). Why use useEffect ? In class-based components, you would typically use lifecycle methods like componentDidMount , componentDidUpdate , and componentWillUnmount to handle side effects. Functional components don't have these methods directly. The useEffect Hook provides a way to manage side effects in functional components. It allows you to run a function after a component renders (or re-renders) and optionally clean up any resources created by that function before the component unmounts. How does useEffect wor...

Difference between SKU and Tenant in multi-tenant SaaS application

SKUs define what you get.  Tenants define who gets it in a securely isolated way. A SaaS provider benefits from SKUs for tiered pricing and multi-tenancy for efficient resource usage.   SKU (Stock Keeping Unit) Features and Pricing: SKUs in a SaaS application typically dictate the set of features, functionalities, and usage limits (e.g., storage, number of users, API call volumes) available to a customer. Customer Choice: Customers choose an SKU based on their needs and budget. Higher-tier SKUs usually offer more capabilities and resources at a higher cost. Within a Tenant: A single tenant (customer) can only be subscribed to one SKU at a time, but may potentially upgrade or downgrade over time. Tenant Data Isolation: A tenant represents a logically isolated instance of the SaaS application dedicated to a specific customer or organization. A customer's data, configurations, and often customizations are kept completely separate from other tenants. Multi-Te...

protobuff vs json

  Protocol Buffers (protobuf) and JSON (JavaScript Object Notation) are both data interchange formats, but they have some key differences in terms of usage, efficiency, and features. Here are some points of comparison: Serialization Format: JSON: It's a human-readable, text-based format. It's easy to read and write for both humans and machines. Protobuf: It's a binary serialization format. While it's not human-readable, it's more compact and efficient for data interchange. Data Types: JSON: Supports a limited set of basic data types, including objects, arrays, strings, numbers, booleans, and null. Protobuf: Supports a broader range of data types, including scalar types (integers, floats, booleans, strings), maps, nested structures, and more. Schema: JSON: Schema is not explicitly defined, which means there is flexibility but less strict validation. Protobuf: Requires a predefined schema (defined in a .proto file). This schema provides a contract for the data s...