AWS Application Load Balancer and Network Load Balancer with EC2 Container Service

What is a load balancer?

  • Redundancy (One application server could die, but as long as there is at least one application server left the load balancer can still direct client traffic to the remaining working application server.)
  • Scalability (By running two servers behind a load balancer you can now handle 2x the traffic from clients. Load balancers make it easy to add more and more backend servers as your traffic increases.)

What is the difference between an ALB and an NLB?

  1. A web browser constructs an HTTP request at the application layer, which is a small text document describing what resource the browser wants to fetch from a web server.
  2. To make sure the communication between browser and server is secure the web request is encrypted using SSL/TLS. This process takes a server’s public key and uses it to turn the HTTP payload into an unreadable chunk of encrypted binary data.
  3. A few layers below at the transport layer the encrypted payload is split up into TCP packets. Each packet is a piece of the HTTP payload wrapped in metadata such as the source IP address that the packet originated from and the destination IP address where the packet should go.
  4. The physical layer takes the raw digital 1’s and 0’s that makeup TCP packets and turns them into an analog signal such as an electrical pulse on a copper wire, a light pulse in a fiber optic cable, or a radio wave in the air. On the other end, another device turns that analog signal back into digital 1’s and 0's.
  5. The network traffic starts its trip back up the network stack as the 1’s and 0’s are interpreted into packets, which are then reassembled into the original encrypted data payload.
  6. The server uses its private key to decrypt the SSL/TLS encrypted payload back into the original plaintext HTTP request document.
  7. The server can interpret the plaintext HTTP request and figure out what resource to deliver back over the network.

ALB and NLB Specific Features

SSL/TLS

HTTP Host and Path-Based Routing

Protocols other than HTTP

Dynamic Ports in ALB and NLB

Integrating ALB and NLB with EC2 Container Service

  1. A client application initiates a new connection to the load balancer.
  2. The load balancer receives the traffic and picks a target from the target group attached to the load balancer. The target group has been configured by EC2 Container Service with a list of instances and ports.
  3. The load balancer sends the traffic to the chosen instance and port.
  4. The docker networking layer accepts the traffic and forwards it to the configured port inside the right container.
  5. Your application running inside the container receives the traffic on the port it has bound to.

Conclusion

Thanks !!! 👏🏻

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store