104 points · by Napsty · 4y ago · 45 comments
The ease with which you can make real-time reactions to threats and conditions is really second to none, and with the ability to truly "hitless" reload (reload without affecting in-flight requests and connections) it makes those have immediate impact and no customer impact.
Sometimes the capabilities make the config a bit inscrutable, but other than that, I can't recommend it enough.
We ended up using HAPRoxy as front for pretty much everything (even if techncially slapping just Nginx would be simpler at first), just because it often happens that this and that needs to be added (stuff like adding proper headers when devs don't want to figure out how to make their '00s CMS emi the '20s security headers).
It can also talk directly via unix socket to the backends so you don't even need to have a bunch of ports open if you want to front something.
The general answer here, is no, I don't think you can do much in HAProxy that you can't do with OpenResty, but with HAProxy you generally don't have to pay the overhead of Lua (and HAProxy tends to be very well optimized, so the difference can be significant at high throughput of requests / bytes).
I think you'll find they're using ARR and not HAProxy for the "batteries included" load balancer. You can tell this from the cookie names "ARRAffinity" and "ARRAffinitySameSite".
Can also be done remotely https://github.com/Wirehive/haproxy-remote
hatop -s /var/run/haproxy/example.sock
Use the arrows to select a backend server and press: F9 - Enable a backend server (Status: UP)
F10 - Disable a backend server (Status: MAINTENANCE)
For Apple keyboards it is fn+F9 and fn+F10.https://www.haproxy.com/documentation/dataplaneapi/community...
as such we try to avoid reloading haproxy as much as possible. you can even renew a cert on-the-fly uploading the new cert via the admin socket.
Assuming you initialize every service you depend on at program start and not in the critical path and that health checks only function after this setup work has been done it simplifies operations a bit and decreases the liklhihood of configuration errors (a drained server in a load balancer) from persisting.
stats admin
to the stats backend to enable ability to do that from statistics UI address. Just make sure it is at the very least behind a password```
403 Forbidden
nginx
```
This depends a great deal on the architecture of your application server and traffic load. There are a lot of reasons that it is nicer to use a queue in front of your load balancer, rather than use queues in your application server, or worse, use the operating system queue.
You must have SSL termination, logging, load balancing, and queuing. You probably want to modify headers and interpret cookies as well.
HAProxy is a queue that feeds into a load balancer. Nginx is a buffer that feeds into a load balancer (IIRC).
One useful property that HAProxy can ensure is no more than 1 request going to a server at a time. I believe (but potentially incorrectly) that nginx will fail requests, rather than "queue" them, if it tries to ensure this property. HAProxy also historically had health checks for backend servers, while for nginx it was a paid premium feature.
I could be wrong about nginx not being able to queue. It has been a while.
For my mental model, nginx is the right choice for SSL termination, logging, request mangling, interpretation of cookies and loadbalancing based on request information (for example choosing haproxy instances based on a domain name). HAProxy is the right tool for queuing and load balancing to servers that will actually fulfill the request.
See info below, correct link: https://www.claudiokuenzler.com/blog/1240/haproxy-how-to-dis...