What is the difference between HAProxy and API gateway?
The main difference is that HAProxy is for load balancing and API gateway is for API's. I was hoping to do some type of middle ware in which we can handle different API call requests based on the users' ip address.
The main idea is that we want to create a service at the router level (HAProxy). We pass incoming HTTP calls through our proxy layer so we can use a policy mechanism to determine which service to go with. So the question really boils down to:
Do you need a separate application to make the decision? or do you need to have HAProxy/LVS make the decision? In this scenario (assuming HAProxy serves up web services too) we would assume that we route the call to the appropriate server based on the request header as opposed to passing the request through the proxy completely. Of course, this depends on what your configuration looks like.
I'm interested because we are looking into using Kubernetes at our company but there is no way we would use Kube in this scenario as there is no way to authenticate requests. Basically, the server needs to know something about the user because it needs to associate their IP address with them.
Hi @EvanHahn. Sorry for my lack of knowledge, it seems you were writing about two different things (middle-ware vs. Load balancing).
The main idea is not the authentication/authorization but the policy. It's like you say yourself: policy-based routing: decide where to send the traffic based on the incoming packet. You don't need load-balancing for that, as you said. It could be done with "LVS" (HAProxy does it internally), but the advantage of a middleware (like nginx or HAProxy) is that you get a more complex routing than by simply forwarding the traffic to different servers. For instance, if you are using nginx as a middleware (which is great) you will be able to change some "route blocks" (ie to change how each route will be processed depending on certain conditions). Also, if you're setting up routing policies you can use rules such as: if the request headers matches X then make the call to Y instead. That way you can do some form of rate-limiting or something more dynamic.
What is difference between API gateway and load balancer?
In short : in my situation, it should be Gateway as its only responsible for managing and exposing resources from my application to internet. So when someone hits to that API gateway, then this API gateway is going to decide who will be accessing what API by assigning the call as request to its assigned servers. This service should do the job for load balancing across my app servers.
For a long term answer : A gateway will load balance (not necessarily) but it won't scale out, so it should probably not be assigned as your main load balancer in your stack. But if you want to use two API gateways (with two different domains in fact), I would do that. What you can do with that is: One gateway exposes /v1 which is very secure (only accessible for your app). The one exposed via /api gateway exposes all the resources of your application One gateway will handle /v1 and the /api gateway will act as proxy / forwarding requests to the real gateway in case the security on /v1 has been bypassed. So, you will basically have two APIs but they will share the load between two servers. The main difference being that one is private and the other is public.
Can we use load balancer and API gateway together?
I have a Spring Boot application which makes JWT-signed requests and these requests are forwarded to Cloud Foundry instances behind API Gateways(using Zuul proxy). So the backend is exposed as API service running on cf instance, and the frontend Spring app has one entry point to the API gateway as Zuul Proxy. Is it okay to use LoadBalancer with API Gateway? Or can we do both in AWS and how? In aws load balancer you do not directly talk to a instance, instead, it talks to API gateway in the cloud that actually talks to instance that listens to incoming request from users. Since API gateway just handles your web traffic and your application runs on another server, there is no reason why you cannot have load balancer for only serving API gateway and expose application (your web app) with ELB and put backend in another server.
Related Answers
How much does HAProxy load balancer cost?
HAProxy is a highly versatile and capable load balancer. It also lack...
What is HAProxy used for?
In a nutshell: If you need a load balancer with stateless backend servers, HAProx...
Can HAProxy run on Windows?
Yes, it can. The latest version of the HAProxy daemon, 1.6.1, has been...