简体   繁体   中英

Do I need to have HAProxy TCP/HTTP Load Balancer when I already have AWS ELB?

Let's say I have 20 servers at Amazon AWS and I also have AWS ELB setup for these servers. I heard that HAProxy is reliable and fast TCP/HTTP Load Balancer, so question is:

  1. do I need to have HAProxy installed in each EC2 instances while I have AWS ELB?
  2. What is the benefit of having both ELB and Haproxy at the same time?

Thanks

There are a few scenarios where people chose their own load balancing solution like HAProxy than ELB:

Financial transactions: ELB is an opaque service. Logs are not provided. So if you are missing transactions, you won't know if ELB dropped them or not.

Doesn't work well with traffic spikes: ELBs scaling takes at least 5 minutes. If your application traffic is doubling every 5-10 minutes, it will do well. But if it is at a constant rate and you will get a spike all of a sudden, then you will have problems with ELB.

ELBs can be slower than running your own Loadbalancing: In my environment, I got 15% performance boost by using HAProxy/Nginx (for SSL termination) instead. It was roughly 30ms per call, but keep in mind I was using SSL so I use CPU power.

ELBs only do round-robin load balancing and HAProxy has a lot more.

HAProxy also has ton more configurations that ELB does not support. It depends if one needs them for their application.

In one suite of applications, I have both running. ELB->haproxy->A suite of apps. In my case the following occurs:

  • ELB translates HTTPS to http
  • HAproxy targets to the app servers based on path
  • The app servers run in plain old http

The upside to this is that I can move around the apps without changing their URLs The downside is that ELB isn't a fixed IP address so if you need to point to it from an IP adress instead of a cname you can't do it.

Short answer: No you don't need HAProxy. Go with an ELB.

tldr;

Yes HAProxy is powerful and tested.

First of all, you would need to have a separate EC2 HAProxy instance (as opposed to having HAProxy installed on every EC2 instance you need to balance). In essence an ELB is equivalent to an EC2 instance loaded with some kind of load balancing software.

Second, having both ELBs and HAProxy balancing instances in your environment is a rare use case. You might come to a point that you need more fine grained access and the ability to configure more on your load balancers. It purely depends on what you're doing and what problems an ELB might be giving you. Google to read through possible use cases.

I'm using an ELB and Haproxy behind.

When a customer uses my webservices from a unique IP, ELB redirects all his requests to the same hosts. It doesn't scale. (I supposed it's a hash from the src ip or something like that).

The haproxy has another balancer algorithm.

I keep the ELB for HA (1 haproxy / availability zone). And each haproxy instance redispatchs to region zone backend servers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM