What are the differences between a load balancer and an API gateways?

What are the differences between a load balancer and an API gateways?

·

1 min read

first, let's clarify some concepts before discussing the differences.

NLB(Network Load Balancer) is usually deployed before the API gateway, handling traffic routing based on IP. It does not parse the HTTP requests.

ALB( Application Load Balancer) routes requests based on HTTP header or URL and thus can provide richer routing rules. We can choose the load balancer based on routing requirements .For simple services with a smaller scale, one load balancer is enough.

The API gateway performs tasks more on the application level. So it has different responsibilities from the load balancer.

there are two option used to provide a scalable and secure architecture for modern web apps.

option a: ALB is used to distribute requests among different services. Due to the fact that the services implement their own rating limitation , authentication, etc., this approach is more flexible but requires more work at the service level.

option b: An API gateway takes care of authentication, rate limiting, caching, etc., so there is less work at the service level. However, this option is less flexible compared with the ALB approach.