2
votes

I read this article about the API Gateway pattern. I realize that API Gateways typically serve as reverse proxies, but this forces a bottleneck situation. If all requests to an application's public services go through a single gateway, or even a single load balancer across multiple replicas of a gateway (perhaps a hardware load balancer which can handle large amounts of bandwidth more easily than an API gateway), then that single access point is the bottleneck.

I also understand that it is a wide bottleneck, as it simply has to deliver messages in proxy, as the gateways and load balancers themselves are not responsible for any processing or querying. However, imagining a very large application with many users, one would require extremely powerful hardware to not notice the massive bandwidth traveling over the gateway or load balancer, given that every request to every microservice exposed by the gateway travels through that single access point.

If the API gateway instead simply redirected the client to publicly exposed microservices (sort of like a custom DNS lookup), the hardware requirements would be much lower. This is because the messages traveling to and from the API Gateway would be very small, the requests consisting only of a microservice name, and the responses consisting only of the associated public IP address.

I recognize that this pattern would involve greater latency due to increased external requests. It would also be more difficult to secure, as every microservice is publicly exposed, rather than providing authentication at a single entrypoint. However, it would allow for bandwidth to be distributed much more evenly, and provide a much wider bottleneck, thus making the application much more scalable. Is this a valid strategy?

2

2 Answers

2
votes

A DNS/Public IP based approach not good from a lot of perspectives:

  • Higher attack surface area as you have too many exposed points and each need to be protected
  • No. of public IPs needed is higher
  • You may need more DNS settings with subdomains or domains to be there for these APIs
  • A lot of times your APIs will run on a root path but you may want to expose them on a folder path example.com/service1, which requires you to use some gateway for the same
  • Handling SSL certificates for these public exposures
  • Security on a focussed set of nodes vs securing every publically exposed service becomes a very difficult task
0
votes

While theoretically it is possible to redirect clients directly to the nodes, there are a few pitfalls.

Security, Certificate and DNS management has been covered by @Tarun

Issues with High Availability

DNS's cache the domains vs IP's they serve fairly aggressively because these seldom change. If we use DNS to expose multiple instances of services publicly, and one of the servers goes down, or if we're doing a deployment, DNS's will continue routing the requests to the nodes which are down for a fair amount of time. We have no control over external DNS's and their policies. Using reverse proxies, we avoid hitting those nodes based on health checks.