In this post we will review the AWS load balancers types, and investigate the tasks each load balancer is suitable to perform. We will review this as a load balancer serving clients that access services in a kubernetes cluster.
ALB: AWS Application Load Balancer
An ALB is a communication layer 7 creature.
An ALB distributes traffic among multiple kubernetes cluster services' pods. A single ALB can serve multiple services, and by traffic metadata such as host name and path the ALB selects the target service. Once a service is located, the ALB can route the HTTP request directly to the related pod, while distributing the requests between all the pods that are READY for service. Notice that the ALB's health check differs from the health and ready check configured by the pod, and in case it is not the default access to the slash, special ALB configuration should be made.
ALB handles both HTTP 1.x and HTTP 2.x requests, which means that it can also handle gRPC protocol.
ALB can also supply additional layer 7 functions such as authentication and WAF.
NLB: AWS Network Load Balancer
Which Should I use?
Let's start with the price: ALB cost is 0.008$ per LCU, while NLB cost is 0.006$ per LCU.
So ALB costs more, but it has a major advantage: It distributes per request, and not per TCP connection. This is critical in case we have multiple pods, and long lasting client connection.
ALB IP address must be resolved through DNS, while NLB uses a static IP address, hence if we cannot use DNS, we must use NLB.
Hence to choose the appropriate load balancer type:
- If we must use static IP address - use NLB
- If we use non HTTP protocol - use NLB
- If we have single service with single pod - use NLB
- If we have single service with short lasting client sockets - use NLB
- For other cases - use ALB
No comments:
Post a Comment