Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1 | ----------------------- |
| 2 | HAProxy Starter Guide |
| 3 | ----------------------- |
Willy Tarreau | 29698e3 | 2022-05-31 17:05:27 +0200 | [diff] [blame] | 4 | version 2.7 |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 5 | |
| 6 | |
| 7 | This document is an introduction to HAProxy for all those who don't know it, as |
| 8 | well as for those who want to re-discover it when they know older versions. Its |
| 9 | primary focus is to provide users with all the elements to decide if HAProxy is |
| 10 | the product they're looking for or not. Advanced users may find here some parts |
| 11 | of solutions to some ideas they had just because they were not aware of a given |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 12 | new feature. Some sizing information is also provided, the product's lifecycle |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 13 | is explained, and comparisons with partially overlapping products are provided. |
| 14 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 15 | This document doesn't provide any configuration help or hints, but it explains |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 16 | where to find the relevant documents. The summary below is meant to help you |
| 17 | search sections by name and navigate through the document. |
| 18 | |
| 19 | Note to documentation contributors : |
| 20 | This document is formatted with 80 columns per line, with even number of |
| 21 | spaces for indentation and without tabs. Please follow these rules strictly |
| 22 | so that it remains easily printable everywhere. If you add sections, please |
| 23 | update the summary below for easier searching. |
| 24 | |
| 25 | |
| 26 | Summary |
| 27 | ------- |
| 28 | |
| 29 | 1. Available documentation |
| 30 | |
| 31 | 2. Quick introduction to load balancing and load balancers |
| 32 | |
| 33 | 3. Introduction to HAProxy |
| 34 | 3.1. What HAProxy is and is not |
| 35 | 3.2. How HAProxy works |
| 36 | 3.3. Basic features |
| 37 | 3.3.1. Proxying |
| 38 | 3.3.2. SSL |
| 39 | 3.3.3. Monitoring |
| 40 | 3.3.4. High availability |
| 41 | 3.3.5. Load balancing |
| 42 | 3.3.6. Stickiness |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 43 | 3.3.7. Logging |
Mathias Weiersmueller | 243c2d1 | 2022-09-10 19:45:51 +0200 | [diff] [blame] | 44 | 3.3.8. Statistics |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 45 | 3.4. Standard features |
| 46 | 3.4.1. Sampling and converting information |
| 47 | 3.4.2. Maps |
| 48 | 3.4.3. ACLs and conditions |
| 49 | 3.4.4. Content switching |
| 50 | 3.4.5. Stick-tables |
| 51 | 3.4.6. Formatted strings |
| 52 | 3.4.7. HTTP rewriting and redirection |
| 53 | 3.4.8. Server protection |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 54 | 3.5. Advanced features |
| 55 | 3.5.1. Management |
| 56 | 3.5.2. System-specific capabilities |
| 57 | 3.5.3. Scripting |
| 58 | 3.6. Sizing |
| 59 | 3.7. How to get HAProxy |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 60 | |
| 61 | 4. Companion products and alternatives |
| 62 | 4.1. Apache HTTP server |
| 63 | 4.2. NGINX |
| 64 | 4.3. Varnish |
| 65 | 4.4. Alternatives |
| 66 | |
Willy Tarreau | 6562623 | 2020-05-05 18:08:07 +0200 | [diff] [blame] | 67 | 5. Contacts |
| 68 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 69 | |
| 70 | 1. Available documentation |
| 71 | -------------------------- |
| 72 | |
| 73 | The complete HAProxy documentation is contained in the following documents. |
| 74 | Please ensure to consult the relevant documentation to save time and to get the |
| 75 | most accurate response to your needs. Also please refrain from sending questions |
| 76 | to the mailing list whose responses are present in these documents. |
| 77 | |
| 78 | - intro.txt (this document) : it presents the basics of load balancing, |
| 79 | HAProxy as a product, what it does, what it doesn't do, some known traps to |
| 80 | avoid, some OS-specific limitations, how to get it, how it evolves, how to |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 81 | ensure you're running with all known fixes, how to update it, complements |
| 82 | and alternatives. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 83 | |
Willy Tarreau | 373933d | 2015-10-13 16:32:20 +0200 | [diff] [blame] | 84 | - management.txt : it explains how to start haproxy, how to manage it at |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 85 | runtime, how to manage it on multiple nodes, and how to proceed with |
| 86 | seamless upgrades. |
Willy Tarreau | 373933d | 2015-10-13 16:32:20 +0200 | [diff] [blame] | 87 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 88 | - configuration.txt : the reference manual details all configuration keywords |
| 89 | and their options. It is used when a configuration change is needed. |
| 90 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 91 | - coding-style.txt : this is for developers who want to propose some code to |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 92 | the project. It explains the style to adopt for the code. It is not very |
| 93 | strict and not all the code base completely respects it, but contributions |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 94 | which diverge too much from it will be rejected. |
| 95 | |
| 96 | - proxy-protocol.txt : this is the de-facto specification of the PROXY |
| 97 | protocol which is implemented by HAProxy and a number of third party |
| 98 | products. |
| 99 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 100 | - README : how to build HAProxy from sources |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 101 | |
| 102 | |
| 103 | 2. Quick introduction to load balancing and load balancers |
| 104 | ---------------------------------------------------------- |
| 105 | |
| 106 | Load balancing consists in aggregating multiple components in order to achieve |
| 107 | a total processing capacity above each component's individual capacity, without |
| 108 | any intervention from the end user and in a scalable way. This results in more |
Willy Tarreau | eff04f4 | 2015-08-27 14:44:43 +0200 | [diff] [blame] | 109 | operations being performed simultaneously by the time it takes a component to |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 110 | perform only one. A single operation however will still be performed on a single |
| 111 | component at a time and will not get faster than without load balancing. It |
| 112 | always requires at least as many operations as available components and an |
| 113 | efficient load balancing mechanism to make use of all components and to fully |
| 114 | benefit from the load balancing. A good example of this is the number of lanes |
| 115 | on a highway which allows as many cars to pass during the same time frame |
| 116 | without increasing their individual speed. |
| 117 | |
| 118 | Examples of load balancing : |
| 119 | |
| 120 | - Process scheduling in multi-processor systems |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 121 | - Link load balancing (e.g. EtherChannel, Bonding) |
| 122 | - IP address load balancing (e.g. ECMP, DNS round-robin) |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 123 | - Server load balancing (via load balancers) |
| 124 | |
| 125 | The mechanism or component which performs the load balancing operation is |
| 126 | called a load balancer. In web environments these components are called a |
| 127 | "network load balancer", and more commonly a "load balancer" given that this |
| 128 | activity is by far the best known case of load balancing. |
| 129 | |
| 130 | A load balancer may act : |
| 131 | |
| 132 | - at the link level : this is called link load balancing, and it consists in |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 133 | choosing what network link to send a packet to; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 134 | |
| 135 | - at the network level : this is called network load balancing, and it |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 136 | consists in choosing what route a series of packets will follow; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 137 | |
| 138 | - at the server level : this is called server load balancing and it consists |
| 139 | in deciding what server will process a connection or request. |
| 140 | |
| 141 | Two distinct technologies exist and address different needs, though with some |
Willy Tarreau | eff04f4 | 2015-08-27 14:44:43 +0200 | [diff] [blame] | 142 | overlapping. In each case it is important to keep in mind that load balancing |
| 143 | consists in diverting the traffic from its natural flow and that doing so always |
| 144 | requires a minimum of care to maintain the required level of consistency between |
| 145 | all routing decisions. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 146 | |
| 147 | The first one acts at the packet level and processes packets more or less |
| 148 | individually. There is a 1-to-1 relation between input and output packets, so |
| 149 | it is possible to follow the traffic on both sides of the load balancer using a |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 150 | regular network sniffer. This technology can be very cheap and extremely fast. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 151 | It is usually implemented in hardware (ASICs) allowing to reach line rate, such |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 152 | as switches doing ECMP. Usually stateless, it can also be stateful (consider |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 153 | the session a packet belongs to and called layer4-LB or L4), may support DSR |
| 154 | (direct server return, without passing through the LB again) if the packets |
| 155 | were not modified, but provides almost no content awareness. This technology is |
| 156 | very well suited to network-level load balancing, though it is sometimes used |
| 157 | for very basic server load balancing at high speed. |
| 158 | |
| 159 | The second one acts on session contents. It requires that the input streams is |
| 160 | reassembled and processed as a whole. The contents may be modified, and the |
| 161 | output stream is segmented into new packets. For this reason it is generally |
| 162 | performed by proxies and they're often called layer 7 load balancers or L7. |
| 163 | This implies that there are two distinct connections on each side, and that |
| 164 | there is no relation between input and output packets sizes nor counts. Clients |
| 165 | and servers are not required to use the same protocol (for example IPv4 vs |
| 166 | IPv6, clear vs SSL). The operations are always stateful, and the return traffic |
| 167 | must pass through the load balancer. The extra processing comes with a cost so |
| 168 | it's not always possible to achieve line rate, especially with small packets. |
| 169 | On the other hand, it offers wide possibilities and is generally achieved by |
| 170 | pure software, even if embedded into hardware appliances. This technology is |
| 171 | very well suited for server load balancing. |
| 172 | |
| 173 | Packet-based load balancers are generally deployed in cut-through mode, so they |
| 174 | are installed on the normal path of the traffic and divert it according to the |
| 175 | configuration. The return traffic doesn't necessarily pass through the load |
| 176 | balancer. Some modifications may be applied to the network destination address |
| 177 | in order to direct the traffic to the proper destination. In this case, it is |
| 178 | mandatory that the return traffic passes through the load balancer. If the |
| 179 | routes doesn't make this possible, the load balancer may also replace the |
| 180 | packets' source address with its own in order to force the return traffic to |
| 181 | pass through it. |
| 182 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 183 | Proxy-based load balancers are deployed as a server with their own IP addresses |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 184 | and ports, without architecture changes. Sometimes this requires to perform some |
| 185 | adaptations to the applications so that clients are properly directed to the |
| 186 | load balancer's IP address and not directly to the server's. Some load balancers |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 187 | may have to adjust some servers' responses to make this possible (e.g. the HTTP |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 188 | Location header field used in HTTP redirects). Some proxy-based load balancers |
| 189 | may intercept traffic for an address they don't own, and spoof the client's |
| 190 | address when connecting to the server. This allows them to be deployed as if |
| 191 | they were a regular router or firewall, in a cut-through mode very similar to |
| 192 | the packet based load balancers. This is particularly appreciated for products |
| 193 | which combine both packet mode and proxy mode. In this case DSR is obviously |
| 194 | still not possible and the return traffic still has to be routed back to the |
| 195 | load balancer. |
| 196 | |
| 197 | A very scalable layered approach would consist in having a front router which |
| 198 | receives traffic from multiple load balanced links, and uses ECMP to distribute |
| 199 | this traffic to a first layer of multiple stateful packet-based load balancers |
| 200 | (L4). These L4 load balancers in turn pass the traffic to an even larger number |
| 201 | of proxy-based load balancers (L7), which have to parse the contents to decide |
| 202 | what server will ultimately receive the traffic. |
| 203 | |
| 204 | The number of components and possible paths for the traffic increases the risk |
| 205 | of failure; in very large environments, it is even normal to permanently have |
| 206 | a few faulty components being fixed or replaced. Load balancing done without |
| 207 | awareness of the whole stack's health significantly degrades availability. For |
| 208 | this reason, any sane load balancer will verify that the components it intends |
| 209 | to deliver the traffic to are still alive and reachable, and it will stop |
| 210 | delivering traffic to faulty ones. This can be achieved using various methods. |
| 211 | |
| 212 | The most common one consists in periodically sending probes to ensure the |
| 213 | component is still operational. These probes are called "health checks". They |
| 214 | must be representative of the type of failure to address. For example a ping- |
| 215 | based check will not detect that a web server has crashed and doesn't listen to |
| 216 | a port anymore, while a connection to the port will verify this, and a more |
| 217 | advanced request may even validate that the server still works and that the |
| 218 | database it relies on is still accessible. Health checks often involve a few |
| 219 | retries to cover for occasional measuring errors. The period between checks |
| 220 | must be small enough to ensure the faulty component is not used for too long |
| 221 | after an error occurs. |
| 222 | |
| 223 | Other methods consist in sampling the production traffic sent to a destination |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 224 | to observe if it is processed correctly or not, and to evict the components |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 225 | which return inappropriate responses. However this requires to sacrifice a part |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 226 | of the production traffic and this is not always acceptable. A combination of |
| 227 | these two mechanisms provides the best of both worlds, with both of them being |
| 228 | used to detect a fault, and only health checks to detect the end of the fault. |
| 229 | A last method involves centralized reporting : a central monitoring agent |
| 230 | periodically updates all load balancers about all components' state. This gives |
| 231 | a global view of the infrastructure to all components, though sometimes with |
| 232 | less accuracy or responsiveness. It's best suited for environments with many |
| 233 | load balancers and many servers. |
| 234 | |
| 235 | Layer 7 load balancers also face another challenge known as stickiness or |
| 236 | persistence. The principle is that they generally have to direct multiple |
| 237 | subsequent requests or connections from a same origin (such as an end user) to |
| 238 | the same target. The best known example is the shopping cart on an online |
| 239 | store. If each click leads to a new connection, the user must always be sent |
| 240 | to the server which holds his shopping cart. Content-awareness makes it easier |
| 241 | to spot some elements in the request to identify the server to deliver it to, |
| 242 | but that's not always enough. For example if the source address is used as a |
| 243 | key to pick a server, it can be decided that a hash-based algorithm will be |
| 244 | used and that a given IP address will always be sent to the same server based |
| 245 | on a divide of the address by the number of available servers. But if one |
| 246 | server fails, the result changes and all users are suddenly sent to a different |
| 247 | server and lose their shopping cart. The solution against this issue consists |
| 248 | in memorizing the chosen target so that each time the same visitor is seen, |
| 249 | he's directed to the same server regardless of the number of available servers. |
| 250 | The information may be stored in the load balancer's memory, in which case it |
| 251 | may have to be replicated to other load balancers if it's not alone, or it may |
| 252 | be stored in the client's memory using various methods provided that the client |
| 253 | is able to present this information back with every request (cookie insertion, |
| 254 | redirection to a sub-domain, etc). This mechanism provides the extra benefit of |
| 255 | not having to rely on unstable or unevenly distributed information (such as the |
| 256 | source IP address). This is in fact the strongest reason to adopt a layer 7 |
| 257 | load balancer instead of a layer 4 one. |
| 258 | |
| 259 | In order to extract information such as a cookie, a host header field, a URL |
| 260 | or whatever, a load balancer may need to decrypt SSL/TLS traffic and even |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 261 | possibly to re-encrypt it when passing it to the server. This expensive task |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 262 | explains why in some high-traffic infrastructures, sometimes there may be a |
| 263 | lot of load balancers. |
| 264 | |
| 265 | Since a layer 7 load balancer may perform a number of complex operations on the |
| 266 | traffic (decrypt, parse, modify, match cookies, decide what server to send to, |
| 267 | etc), it can definitely cause some trouble and will very commonly be accused of |
| 268 | being responsible for a lot of trouble that it only revealed. Often it will be |
| 269 | discovered that servers are unstable and periodically go up and down, or for |
| 270 | web servers, that they deliver pages with some hard-coded links forcing the |
| 271 | clients to connect directly to one specific server without passing via the load |
| 272 | balancer, or that they take ages to respond under high load causing timeouts. |
| 273 | That's why logging is an extremely important aspect of layer 7 load balancing. |
| 274 | Once a trouble is reported, it is important to figure if the load balancer took |
| 275 | a wrong decision and if so why so that it doesn't happen anymore. |
| 276 | |
| 277 | |
| 278 | 3. Introduction to HAProxy |
| 279 | -------------------------- |
| 280 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 281 | HAProxy is written as "HAProxy" to designate the product, and as "haproxy" to |
| 282 | designate the executable program, software package or a process. However, both |
| 283 | are commonly used for both purposes, and are pronounced H-A-Proxy. Very early, |
| 284 | "haproxy" used to stand for "high availability proxy" and the name was written |
| 285 | in two separate words, though by now it means nothing else than "HAProxy". |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 286 | |
| 287 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 288 | 3.1. What HAProxy is and isn't |
| 289 | ------------------------------ |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 290 | |
| 291 | HAProxy is : |
| 292 | |
| 293 | - a TCP proxy : it can accept a TCP connection from a listening socket, |
| 294 | connect to a server and attach these sockets together allowing traffic to |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 295 | flow in both directions; IPv4, IPv6 and even UNIX sockets are supported on |
| 296 | either side, so this can provide an easy way to translate addresses between |
| 297 | different families. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 298 | |
| 299 | - an HTTP reverse-proxy (called a "gateway" in HTTP terminology) : it presents |
| 300 | itself as a server, receives HTTP requests over connections accepted on a |
| 301 | listening TCP socket, and passes the requests from these connections to |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 302 | servers using different connections. It may use any combination of HTTP/1.x |
| 303 | or HTTP/2 on any side and will even automatically detect the protocol |
| 304 | spoken on each side when ALPN is used over TLS. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 305 | |
| 306 | - an SSL terminator / initiator / offloader : SSL/TLS may be used on the |
| 307 | connection coming from the client, on the connection going to the server, |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 308 | or even on both connections. A lot of settings can be applied per name |
| 309 | (SNI), and may be updated at runtime without restarting. Such setups are |
| 310 | extremely scalable and deployments involving tens to hundreds of thousands |
| 311 | of certificates were reported. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 312 | |
| 313 | - a TCP normalizer : since connections are locally terminated by the operating |
| 314 | system, there is no relation between both sides, so abnormal traffic such as |
| 315 | invalid packets, flag combinations, window advertisements, sequence numbers, |
| 316 | incomplete connections (SYN floods), or so will not be passed to the other |
| 317 | side. This protects fragile TCP stacks from protocol attacks, and also |
| 318 | allows to optimize the connection parameters with the client without having |
| 319 | to modify the servers' TCP stack settings. |
| 320 | |
| 321 | - an HTTP normalizer : when configured to process HTTP traffic, only valid |
| 322 | complete requests are passed. This protects against a lot of protocol-based |
| 323 | attacks. Additionally, protocol deviations for which there is a tolerance |
| 324 | in the specification are fixed so that they don't cause problem on the |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 325 | servers (e.g. multiple-line headers). |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 326 | |
| 327 | - an HTTP fixing tool : it can modify / fix / add / remove / rewrite the URL |
| 328 | or any request or response header. This helps fixing interoperability issues |
| 329 | in complex environments. |
| 330 | |
| 331 | - a content-based switch : it can consider any element from the request to |
| 332 | decide what server to pass the request or connection to. Thus it is possible |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 333 | to handle multiple protocols over a same port (e.g. HTTP, HTTPS, SSH). |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 334 | |
| 335 | - a server load balancer : it can load balance TCP connections and HTTP |
| 336 | requests. In TCP mode, load balancing decisions are taken for the whole |
| 337 | connection. In HTTP mode, decisions are taken per request. |
| 338 | |
| 339 | - a traffic regulator : it can apply some rate limiting at various points, |
| 340 | protect the servers against overloading, adjust traffic priorities based on |
| 341 | the contents, and even pass such information to lower layers and outer |
| 342 | network components by marking packets. |
| 343 | |
| 344 | - a protection against DDoS and service abuse : it can maintain a wide number |
| 345 | of statistics per IP address, URL, cookie, etc and detect when an abuse is |
| 346 | happening, then take action (slow down the offenders, block them, send them |
| 347 | to outdated contents, etc). |
| 348 | |
| 349 | - an observation point for network troubleshooting : due to the precision of |
| 350 | the information reported in logs, it is often used to narrow down some |
| 351 | network-related issues. |
| 352 | |
| 353 | - an HTTP compression offloader : it can compress responses which were not |
| 354 | compressed by the server, thus reducing the page load time for clients with |
| 355 | poor connectivity or using high-latency, mobile networks. |
| 356 | |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 357 | - a caching proxy : it may cache responses in RAM so that subsequent requests |
| 358 | for the same object avoid the cost of another network transfer from the |
| 359 | server as long as the object remains present and valid. It will however not |
| 360 | store objects to any persistent storage. Please note that this caching |
| 361 | feature is designed to be maintenance free and focuses solely on saving |
| 362 | haproxy's precious resources and not on save the server's resources. Caches |
| 363 | designed to optimize servers require much more tuning and flexibility. If |
| 364 | you instead need such an advanced cache, please use Varnish Cache, which |
| 365 | integrates perfectly with haproxy, especially when SSL/TLS is needed on any |
| 366 | side. |
| 367 | |
| 368 | - a FastCGI gateway : FastCGI can be seen as a different representation of |
| 369 | HTTP, and as such, HAProxy can directly load-balance a farm comprising any |
| 370 | combination of FastCGI application servers without requiring to insert |
| 371 | another level of gateway between them. This results in resource savings and |
| 372 | a reduction of maintenance costs. |
| 373 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 374 | HAProxy is not : |
| 375 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 376 | - an explicit HTTP proxy, i.e. the proxy that browsers use to reach the |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 377 | internet. There are excellent open-source software dedicated for this task, |
| 378 | such as Squid. However HAProxy can be installed in front of such a proxy to |
| 379 | provide load balancing and high availability. |
| 380 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 381 | - a data scrubber : it will not modify the body of requests nor responses. |
| 382 | |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 383 | - a static web server : during startup, it isolates itself inside a chroot |
| 384 | jail and drops its privileges, so that it will not perform any single file- |
| 385 | system access once started. As such it cannot be turned into a static web |
| 386 | server (dynamic servers are supported through FastCGI however). There are |
| 387 | excellent open-source software for this such as Apache or Nginx, and |
| 388 | HAProxy can be easily installed in front of them to provide load balancing, |
| 389 | high availability and acceleration. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 390 | |
| 391 | - a packet-based load balancer : it will not see IP packets nor UDP datagrams, |
| 392 | will not perform NAT or even less DSR. These are tasks for lower layers. |
| 393 | Some kernel-based components such as IPVS (Linux Virtual Server) already do |
| 394 | this pretty well and complement perfectly with HAProxy. |
| 395 | |
| 396 | |
| 397 | 3.2. How HAProxy works |
| 398 | ---------------------- |
| 399 | |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 400 | HAProxy is an event-driven, non-blocking engine combining a very fast I/O layer |
| 401 | with a priority-based, multi-threaded scheduler. As it is designed with a data |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 402 | forwarding goal in mind, its architecture is optimized to move data as fast as |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 403 | possible with the least possible operations. It focuses on optimizing the CPU |
| 404 | cache's efficiency by sticking connections to the same CPU as long as possible. |
| 405 | As such it implements a layered model offering bypass mechanisms at each level |
| 406 | ensuring data doesn't reach higher levels unless needed. Most of the processing |
| 407 | is performed in the kernel, and HAProxy does its best to help the kernel do the |
| 408 | work as fast as possible by giving some hints or by avoiding certain operation |
| 409 | when it guesses they could be grouped later. As a result, typical figures show |
| 410 | 15% of the processing time spent in HAProxy versus 85% in the kernel in TCP or |
| 411 | HTTP close mode, and about 30% for HAProxy versus 70% for the kernel in HTTP |
| 412 | keep-alive mode. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 413 | |
| 414 | A single process can run many proxy instances; configurations as large as |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 415 | 300000 distinct proxies in a single process were reported to run fine. A single |
| 416 | core, single CPU setup is far more than enough for more than 99% users, and as |
| 417 | such, users of containers and virtual machines are encouraged to use the |
| 418 | absolute smallest images they can get to save on operational costs and simplify |
| 419 | troubleshooting. However the machine HAProxy runs on must never ever swap, and |
| 420 | its CPU must not be artificially throttled (sub-CPU allocation in hypervisors) |
| 421 | nor be shared with compute-intensive processes which would induce a very high |
| 422 | context-switch latency. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 423 | |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 424 | Threading allows to exploit all available processing capacity by using one |
| 425 | thread per CPU core. This is mostly useful for SSL or when data forwarding |
| 426 | rates above 40 Gbps are needed. In such cases it is critically important to |
| 427 | avoid communications between multiple physical CPUs, which can cause strong |
| 428 | bottlenecks in the network stack and in HAProxy itself. While counter-intuitive |
| 429 | to some, the first thing to do when facing some performance issues is often to |
| 430 | reduce the number of CPUs HAProxy runs on. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 431 | |
| 432 | HAProxy only requires the haproxy executable and a configuration file to run. |
| 433 | For logging it is highly recommended to have a properly configured syslog daemon |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 434 | and log rotations in place. Logs may also be sent to stdout/stderr, which can be |
| 435 | useful inside containers. The configuration files are parsed before starting, |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 436 | then HAProxy tries to bind all listening sockets, and refuses to start if |
| 437 | anything fails. Past this point it cannot fail anymore. This means that there |
| 438 | are no runtime failures and that if it accepts to start, it will work until it |
| 439 | is stopped. |
| 440 | |
| 441 | Once HAProxy is started, it does exactly 3 things : |
| 442 | |
| 443 | - process incoming connections; |
| 444 | |
| 445 | - periodically check the servers' status (known as health checks); |
| 446 | |
| 447 | - exchange information with other haproxy nodes. |
| 448 | |
| 449 | Processing incoming connections is by far the most complex task as it depends |
| 450 | on a lot of configuration possibilities, but it can be summarized as the 9 steps |
| 451 | below : |
| 452 | |
| 453 | - accept incoming connections from listening sockets that belong to a |
| 454 | configuration entity known as a "frontend", which references one or multiple |
| 455 | listening addresses; |
| 456 | |
| 457 | - apply the frontend-specific processing rules to these connections that may |
| 458 | result in blocking them, modifying some headers, or intercepting them to |
| 459 | execute some internal applets such as the statistics page or the CLI; |
| 460 | |
| 461 | - pass these incoming connections to another configuration entity representing |
| 462 | a server farm known as a "backend", which contains the list of servers and |
| 463 | the load balancing strategy for this server farm; |
| 464 | |
| 465 | - apply the backend-specific processing rules to these connections; |
| 466 | |
| 467 | - decide which server to forward the connection to according to the load |
| 468 | balancing strategy; |
| 469 | |
| 470 | - apply the backend-specific processing rules to the response data; |
| 471 | |
| 472 | - apply the frontend-specific processing rules to the response data; |
| 473 | |
| 474 | - emit a log to report what happened in fine details; |
| 475 | |
| 476 | - in HTTP, loop back to the second step to wait for a new request, otherwise |
| 477 | close the connection. |
| 478 | |
| 479 | Frontends and backends are sometimes considered as half-proxies, since they only |
| 480 | look at one side of an end-to-end connection; the frontend only cares about the |
| 481 | clients while the backend only cares about the servers. HAProxy also supports |
| 482 | full proxies which are exactly the union of a frontend and a backend. When HTTP |
| 483 | processing is desired, the configuration will generally be split into frontends |
| 484 | and backends as they open a lot of possibilities since any frontend may pass a |
| 485 | connection to any backend. With TCP-only proxies, using frontends and backends |
| 486 | rarely provides a benefit and the configuration can be more readable with full |
| 487 | proxies. |
| 488 | |
| 489 | |
| 490 | 3.3. Basic features |
| 491 | ------------------- |
| 492 | |
| 493 | This section will enumerate a number of features that HAProxy implements, some |
| 494 | of which are generally expected from any modern load balancer, and some of |
| 495 | which are a direct benefit of HAProxy's architecture. More advanced features |
| 496 | will be detailed in the next section. |
| 497 | |
| 498 | |
| 499 | 3.3.1. Basic features : Proxying |
| 500 | -------------------------------- |
| 501 | |
| 502 | Proxying is the action of transferring data between a client and a server over |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 503 | two independent connections. The following basic features are supported by |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 504 | HAProxy regarding proxying and connection management : |
| 505 | |
| 506 | - Provide the server with a clean connection to protect them against any |
| 507 | client-side defect or attack; |
| 508 | |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 509 | - Listen to multiple IP addresses and/or ports, even port ranges; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 510 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 511 | - Transparent accept : intercept traffic targeting any arbitrary IP address |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 512 | that doesn't even belong to the local system; |
| 513 | |
| 514 | - Server port doesn't need to be related to listening port, and may even be |
| 515 | translated by a fixed offset (useful with ranges); |
| 516 | |
| 517 | - Transparent connect : spoof the client's (or any) IP address if needed |
| 518 | when connecting to the server; |
| 519 | |
| 520 | - Provide a reliable return IP address to the servers in multi-site LBs; |
| 521 | |
| 522 | - Offload the server thanks to buffers and possibly short-lived connections |
| 523 | to reduce their concurrent connection count and their memory footprint; |
| 524 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 525 | - Optimize TCP stacks (e.g. SACK), congestion control, and reduce RTT impacts; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 526 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 527 | - Support different protocol families on both sides (e.g. IPv4/IPv6/Unix); |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 528 | |
| 529 | - Timeout enforcement : HAProxy supports multiple levels of timeouts depending |
| 530 | on the stage the connection is, so that a dead client or server, or an |
| 531 | attacker cannot be granted resources for too long; |
| 532 | |
| 533 | - Protocol validation: HTTP, SSL, or payload are inspected and invalid |
| 534 | protocol elements are rejected, unless instructed to accept them anyway; |
| 535 | |
| 536 | - Policy enforcement : ensure that only what is allowed may be forwarded; |
| 537 | |
| 538 | - Both incoming and outgoing connections may be limited to certain network |
| 539 | namespaces (Linux only), making it easy to build a cross-container, |
| 540 | multi-tenant load balancer; |
| 541 | |
| 542 | - PROXY protocol presents the client's IP address to the server even for |
| 543 | non-HTTP traffic. This is an HAProxy extension that was adopted by a number |
| 544 | of third-party products by now, at least these ones at the time of writing : |
| 545 | - client : haproxy, stud, stunnel, exaproxy, ELB, squid |
| 546 | - server : haproxy, stud, postfix, exim, nginx, squid, node.js, varnish |
| 547 | |
| 548 | |
| 549 | 3.3.2. Basic features : SSL |
| 550 | --------------------------- |
| 551 | |
| 552 | HAProxy's SSL stack is recognized as one of the most featureful according to |
| 553 | Google's engineers (http://istlsfastyet.com/). The most commonly used features |
| 554 | making it quite complete are : |
| 555 | |
| 556 | - SNI-based multi-hosting with no limit on sites count and focus on |
| 557 | performance. At least one deployment is known for running 50000 domains |
| 558 | with their respective certificates; |
| 559 | |
| 560 | - support for wildcard certificates reduces the need for many certificates ; |
| 561 | |
| 562 | - certificate-based client authentication with configurable policies on |
| 563 | failure to present a valid certificate. This allows to present a different |
| 564 | server farm to regenerate the client certificate for example; |
| 565 | |
| 566 | - authentication of the backend server ensures the backend server is the real |
| 567 | one and not a man in the middle; |
| 568 | |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 569 | - authentication with the backend server lets the backend server know it's |
| 570 | really the expected haproxy node that is connecting to it; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 571 | |
| 572 | - TLS NPN and ALPN extensions make it possible to reliably offload SPDY/HTTP2 |
| 573 | connections and pass them in clear text to backend servers; |
| 574 | |
| 575 | - OCSP stapling further reduces first page load time by delivering inline an |
| 576 | OCSP response when the client requests a Certificate Status Request; |
| 577 | |
| 578 | - Dynamic record sizing provides both high performance and low latency, and |
| 579 | significantly reduces page load time by letting the browser start to fetch |
| 580 | new objects while packets are still in flight; |
| 581 | |
| 582 | - permanent access to all relevant SSL/TLS layer information for logging, |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 583 | access control, reporting etc. These elements can be embedded into HTTP |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 584 | header or even as a PROXY protocol extension so that the offloaded server |
| 585 | gets all the information it would have had if it performed the SSL |
| 586 | termination itself. |
| 587 | |
| 588 | - Detect, log and block certain known attacks even on vulnerable SSL libs, |
| 589 | such as the Heartbleed attack affecting certain versions of OpenSSL. |
| 590 | |
Pavlos Parissis | ba56d9c | 2015-08-24 13:14:32 +0200 | [diff] [blame] | 591 | - support for stateless session resumption (RFC 5077 TLS Ticket extension). |
| 592 | TLS tickets can be updated from CLI which provides them means to implement |
| 593 | Perfect Forward Secrecy by frequently rotating the tickets. |
| 594 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 595 | |
| 596 | 3.3.3. Basic features : Monitoring |
| 597 | ---------------------------------- |
| 598 | |
| 599 | HAProxy focuses a lot on availability. As such it cares about servers state, |
| 600 | and about reporting its own state to other network components : |
| 601 | |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 602 | - Servers' state is continuously monitored using per-server parameters. This |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 603 | ensures the path to the server is operational for regular traffic; |
| 604 | |
| 605 | - Health checks support two hysteresis for up and down transitions in order |
| 606 | to protect against state flapping; |
| 607 | |
| 608 | - Checks can be sent to a different address/port/protocol : this makes it |
| 609 | easy to check a single service that is considered representative of multiple |
| 610 | ones, for example the HTTPS port for an HTTP+HTTPS server. |
| 611 | |
| 612 | - Servers can track other servers and go down simultaneously : this ensures |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 613 | that servers hosting multiple services can fail atomically and that no one |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 614 | will be sent to a partially failed server; |
| 615 | |
| 616 | - Agents may be deployed on the server to monitor load and health : a server |
| 617 | may be interested in reporting its load, operational status, administrative |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 618 | status independently from what health checks can see. By running a simple |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 619 | agent on the server, it's possible to consider the server's view of its own |
| 620 | health in addition to the health checks validating the whole path; |
| 621 | |
| 622 | - Various check methods are available : TCP connect, HTTP request, SMTP hello, |
| 623 | SSL hello, LDAP, SQL, Redis, send/expect scripts, all with/without SSL; |
| 624 | |
| 625 | - State change is notified in the logs and stats page with the failure reason |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 626 | (e.g. the HTTP response received at the moment the failure was detected). An |
Willy Tarreau | eff04f4 | 2015-08-27 14:44:43 +0200 | [diff] [blame] | 627 | e-mail can also be sent to a configurable address upon such a change ; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 628 | |
| 629 | - Server state is also reported on the stats interface and can be used to take |
| 630 | routing decisions so that traffic may be sent to different farms depending |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 631 | on their sizes and/or health (e.g. loss of an inter-DC link); |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 632 | |
| 633 | - HAProxy can use health check requests to pass information to the servers, |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 634 | such as their names, weight, the number of other servers in the farm etc. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 635 | so that servers can adjust their response and decisions based on this |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 636 | knowledge (e.g. postpone backups to keep more CPU available); |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 637 | |
| 638 | - Servers can use health checks to report more detailed state than just on/off |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 639 | (e.g. I would like to stop, please stop sending new visitors); |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 640 | |
| 641 | - HAProxy itself can report its state to external components such as routers |
| 642 | or other load balancers, allowing to build very complete multi-path and |
| 643 | multi-layer infrastructures. |
| 644 | |
| 645 | |
| 646 | 3.3.4. Basic features : High availability |
| 647 | ----------------------------------------- |
| 648 | |
| 649 | Just like any serious load balancer, HAProxy cares a lot about availability to |
| 650 | ensure the best global service continuity : |
| 651 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 652 | - Only valid servers are used ; the other ones are automatically evicted from |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 653 | load balancing farms ; under certain conditions it is still possible to |
| 654 | force to use them though; |
| 655 | |
| 656 | - Support for a graceful shutdown so that it is possible to take servers out |
| 657 | of a farm without affecting any connection; |
| 658 | |
| 659 | - Backup servers are automatically used when active servers are down and |
| 660 | replace them so that sessions are not lost when possible. This also allows |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 661 | to build multiple paths to reach the same server (e.g. multiple interfaces); |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 662 | |
| 663 | - Ability to return a global failed status for a farm when too many servers |
| 664 | are down. This, combined with the monitoring capabilities makes it possible |
| 665 | for an upstream component to choose a different LB node for a given service; |
| 666 | |
| 667 | - Stateless design makes it easy to build clusters : by design, HAProxy does |
| 668 | its best to ensure the highest service continuity without having to store |
| 669 | information that could be lost in the event of a failure. This ensures that |
| 670 | a takeover is the most seamless possible; |
| 671 | |
| 672 | - Integrates well with standard VRRP daemon keepalived : HAProxy easily tells |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 673 | keepalived about its state and copes very well with floating virtual IP |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 674 | addresses. Note: only use IP redundancy protocols (VRRP/CARP) over cluster- |
| 675 | based solutions (Heartbeat, ...) as they're the ones offering the fastest, |
| 676 | most seamless, and most reliable switchover. |
| 677 | |
| 678 | |
| 679 | 3.3.5. Basic features : Load balancing |
| 680 | -------------------------------------- |
| 681 | |
| 682 | HAProxy offers a fairly complete set of load balancing features, most of which |
| 683 | are unfortunately not available in a number of other load balancing products : |
| 684 | |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 685 | - no less than 10 load balancing algorithms are supported, some of which apply |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 686 | to input data to offer an infinite list of possibilities. The most common |
| 687 | ones are round-robin (for short connections, pick each server in turn), |
| 688 | leastconn (for long connections, pick the least recently used of the servers |
| 689 | with the lowest connection count), source (for SSL farms or terminal server |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 690 | farms, the server directly depends on the client's source address), URI (for |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 691 | HTTP caches, the server directly depends on the HTTP URI), hdr (the server |
| 692 | directly depends on the contents of a specific HTTP header field), first |
| 693 | (for short-lived virtual machines, all connections are packed on the |
| 694 | smallest possible subset of servers so that unused ones can be powered |
| 695 | down); |
| 696 | |
| 697 | - all algorithms above support per-server weights so that it is possible to |
| 698 | accommodate from different server generations in a farm, or direct a small |
| 699 | fraction of the traffic to specific servers (debug mode, running the next |
| 700 | version of the software, etc); |
| 701 | |
| 702 | - dynamic weights are supported for round-robin, leastconn and consistent |
| 703 | hashing ; this allows server weights to be modified on the fly from the CLI |
| 704 | or even by an agent running on the server; |
| 705 | |
| 706 | - slow-start is supported whenever a dynamic weight is supported; this allows |
| 707 | a server to progressively take the traffic. This is an important feature |
| 708 | for fragile application servers which require to compile classes at runtime |
| 709 | as well as cold caches which need to fill up before being run at full |
| 710 | throttle; |
| 711 | |
| 712 | - hashing can apply to various elements such as client's source address, URL |
| 713 | components, query string element, header field values, POST parameter, RDP |
| 714 | cookie; |
| 715 | |
| 716 | - consistent hashing protects server farms against massive redistribution when |
| 717 | adding or removing servers in a farm. That's very important in large cache |
| 718 | farms and it allows slow-start to be used to refill cold caches; |
| 719 | |
| 720 | - a number of internal metrics such as the number of connections per server, |
| 721 | per backend, the amount of available connection slots in a backend etc makes |
| 722 | it possible to build very advanced load balancing strategies. |
| 723 | |
| 724 | |
| 725 | 3.3.6. Basic features : Stickiness |
| 726 | ---------------------------------- |
| 727 | |
| 728 | Application load balancing would be useless without stickiness. HAProxy provides |
| 729 | a fairly comprehensive set of possibilities to maintain a visitor on the same |
| 730 | server even across various events such as server addition/removal, down/up |
| 731 | cycles, and some methods are designed to be resistant to the distance between |
| 732 | multiple load balancing nodes in that they don't require any replication : |
| 733 | |
| 734 | - stickiness information can be individually matched and learned from |
| 735 | different places if desired. For example a JSESSIONID cookie may be matched |
| 736 | both in a cookie and in the URL. Up to 8 parallel sources can be learned at |
| 737 | the same time and each of them may point to a different stick-table; |
| 738 | |
| 739 | - stickiness information can come from anything that can be seen within a |
| 740 | request or response, including source address, TCP payload offset and |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 741 | length, HTTP query string elements, header field values, cookies, and so |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 742 | on. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 743 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 744 | - stick-tables are replicated between all nodes in a multi-master fashion; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 745 | |
| 746 | - commonly used elements such as SSL-ID or RDP cookies (for TSE farms) are |
| 747 | directly accessible to ease manipulation; |
| 748 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 749 | - all sticking rules may be dynamically conditioned by ACLs; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 750 | |
| 751 | - it is possible to decide not to stick to certain servers, such as backup |
| 752 | servers, so that when the nominal server comes back, it automatically takes |
| 753 | the load back. This is often used in multi-path environments; |
| 754 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 755 | - in HTTP it is often preferred not to learn anything and instead manipulate |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 756 | a cookie dedicated to stickiness. For this, it's possible to detect, |
| 757 | rewrite, insert or prefix such a cookie to let the client remember what |
| 758 | server was assigned; |
| 759 | |
| 760 | - the server may decide to change or clean the stickiness cookie on logout, |
| 761 | so that leaving visitors are automatically unbound from the server; |
| 762 | |
| 763 | - using ACL-based rules it is also possible to selectively ignore or enforce |
| 764 | stickiness regardless of the server's state; combined with advanced health |
| 765 | checks, that helps admins verify that the server they're installing is up |
| 766 | and running before presenting it to the whole world; |
| 767 | |
| 768 | - an innovative mechanism to set a maximum idle time and duration on cookies |
| 769 | ensures that stickiness can be smoothly stopped on devices which are never |
| 770 | closed (smartphones, TVs, home appliances) without having to store them on |
| 771 | persistent storage; |
| 772 | |
| 773 | - multiple server entries may share the same stickiness keys so that |
| 774 | stickiness is not lost in multi-path environments when one path goes down; |
| 775 | |
| 776 | - soft-stop ensures that only users with stickiness information will continue |
| 777 | to reach the server they've been assigned to but no new users will go there. |
| 778 | |
| 779 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 780 | 3.3.7. Basic features : Logging |
| 781 | ------------------------------- |
| 782 | |
| 783 | Logging is an extremely important feature for a load balancer, first because a |
| 784 | load balancer is often wrongly accused of causing the problems it reveals, and |
| 785 | second because it is placed at a critical point in an infrastructure where all |
| 786 | normal and abnormal activity needs to be analyzed and correlated with other |
| 787 | components. |
| 788 | |
| 789 | HAProxy provides very detailed logs, with millisecond accuracy and the exact |
| 790 | connection accept time that can be searched in firewalls logs (e.g. for NAT |
| 791 | correlation). By default, TCP and HTTP logs are quite detailed and contain |
| 792 | everything needed for troubleshooting, such as source IP address and port, |
| 793 | frontend, backend, server, timers (request receipt duration, queue duration, |
| 794 | connection setup time, response headers time, data transfer time), global |
| 795 | process state, connection counts, queue status, retries count, detailed |
| 796 | stickiness actions and disconnect reasons, header captures with a safe output |
| 797 | encoding. It is then possible to extend or replace this format to include any |
| 798 | sampled data, variables, captures, resulting in very detailed information. For |
| 799 | example it is possible to log the number of cumulative requests or number of |
| 800 | different URLs visited by a client. |
| 801 | |
| 802 | The log level may be adjusted per request using standard ACLs, so it is possible |
| 803 | to automatically silent some logs considered as pollution and instead raise |
| 804 | warnings when some abnormal behavior happen for a small part of the traffic |
| 805 | (e.g. too many URLs or HTTP errors for a source address). Administrative logs |
| 806 | are also emitted with their own levels to inform about the loss or recovery of a |
| 807 | server for example. |
| 808 | |
| 809 | Each frontend and backend may use multiple independent log outputs, which eases |
| 810 | multi-tenancy. Logs are preferably sent over UDP, maybe JSON-encoded, and are |
| 811 | truncated after a configurable line length in order to guarantee delivery. But |
| 812 | it is also possible to send them to stdout/stderr or any file descriptor, as |
| 813 | well as to a ring buffer that a client can subscribe to in order to retrieve |
| 814 | them. |
| 815 | |
| 816 | |
| 817 | 3.3.8. Basic features : Statistics |
| 818 | ---------------------------------- |
| 819 | |
| 820 | HAProxy provides a web-based statistics reporting interface with authentication, |
| 821 | security levels and scopes. It is thus possible to provide each hosted customer |
| 822 | with his own page showing only his own instances. This page can be located in a |
| 823 | hidden URL part of the regular web site so that no new port needs to be opened. |
| 824 | This page may also report the availability of other HAProxy nodes so that it is |
| 825 | easy to spot if everything works as expected at a glance. The view is synthetic |
| 826 | with a lot of details accessible (such as error causes, last access and last |
| 827 | change duration, etc), which are also accessible as a CSV table that other tools |
| 828 | may import to draw graphs. The page may self-refresh to be used as a monitoring |
| 829 | page on a large display. In administration mode, the page also allows to change |
| 830 | server state to ease maintenance operations. |
| 831 | |
| 832 | A Prometheus exporter is also provided so that the statistics can be consumed |
| 833 | in a different format depending on the deployment. |
| 834 | |
| 835 | |
| 836 | 3.4. Standard features |
| 837 | ---------------------- |
| 838 | |
| 839 | In this section, some features that are very commonly used in HAProxy but are |
| 840 | not necessarily present on other load balancers are enumerated. |
| 841 | |
| 842 | |
| 843 | 3.4.1. Standard features : Sampling and converting information |
| 844 | -------------------------------------------------------------- |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 845 | |
| 846 | HAProxy supports information sampling using a wide set of "sample fetch |
| 847 | functions". The principle is to extract pieces of information known as samples, |
| 848 | for immediate use. This is used for stickiness, to build conditions, to produce |
| 849 | information in logs or to enrich HTTP headers. |
| 850 | |
| 851 | Samples can be fetched from various sources : |
| 852 | |
| 853 | - constants : integers, strings, IP addresses, binary blocks; |
| 854 | |
| 855 | - the process : date, environment variables, server/frontend/backend/process |
| 856 | state, byte/connection counts/rates, queue length, random generator, ... |
| 857 | |
| 858 | - variables : per-session, per-request, per-response variables; |
| 859 | |
| 860 | - the client connection : source and destination addresses and ports, and all |
| 861 | related statistics counters; |
| 862 | |
| 863 | - the SSL client session : protocol, version, algorithm, cipher, key size, |
| 864 | session ID, all client and server certificate fields, certificate serial, |
| 865 | SNI, ALPN, NPN, client support for certain extensions; |
| 866 | |
| 867 | - request and response buffers contents : arbitrary payload at offset/length, |
| 868 | data length, RDP cookie, decoding of SSL hello type, decoding of TLS SNI; |
| 869 | |
| 870 | - HTTP (request and response) : method, URI, path, query string arguments, |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 871 | status code, headers values, positional header value, cookies, captures, |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 872 | authentication, body elements; |
| 873 | |
| 874 | A sample may then pass through a number of operators known as "converters" to |
| 875 | experience some transformation. A converter consumes a sample and produces a |
| 876 | new one, possibly of a completely different type. For example, a converter may |
| 877 | be used to return only the integer length of the input string, or could turn a |
| 878 | string to upper case. Any arbitrary number of converters may be applied in |
| 879 | series to a sample before final use. Among all available sample converters, the |
| 880 | following ones are the most commonly used : |
| 881 | |
| 882 | - arithmetic and logic operators : they make it possible to perform advanced |
| 883 | computation on input data, such as computing ratios, percentages or simply |
| 884 | converting from one unit to another one; |
| 885 | |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 886 | - IP address masks are useful when some addresses need to be grouped by larger |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 887 | networks; |
| 888 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 889 | - data representation : URL-decode, base64, hex, JSON strings, hashing; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 890 | |
| 891 | - string conversion : extract substrings at fixed positions, fixed length, |
| 892 | extract specific fields around certain delimiters, extract certain words, |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 893 | change case, apply regex-based substitution; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 894 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 895 | - date conversion : convert to HTTP date format, convert local to UTC and |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 896 | conversely, add or remove offset; |
| 897 | |
| 898 | - lookup an entry in a stick table to find statistics or assigned server; |
| 899 | |
| 900 | - map-based key-to-value conversion from a file (mostly used for geolocation). |
| 901 | |
| 902 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 903 | 3.4.2. Standard features : Maps |
| 904 | ------------------------------- |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 905 | |
| 906 | Maps are a powerful type of converter consisting in loading a two-columns file |
| 907 | into memory at boot time, then looking up each input sample from the first |
| 908 | column and either returning the corresponding pattern on the second column if |
| 909 | the entry was found, or returning a default value. The output information also |
| 910 | being a sample, it can in turn experience other transformations including other |
| 911 | map lookups. Maps are most commonly used to translate the client's IP address |
| 912 | to an AS number or country code since they support a longest match for network |
| 913 | addresses but they can be used for various other purposes. |
| 914 | |
| 915 | Part of their strength comes from being updatable on the fly either from the CLI |
| 916 | or from certain actions using other samples, making them capable of storing and |
| 917 | retrieving information between subsequent accesses. Another strength comes from |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 918 | the binary tree based indexation which makes them extremely fast even when they |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 919 | contain hundreds of thousands of entries, making geolocation very cheap and easy |
| 920 | to set up. |
| 921 | |
| 922 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 923 | 3.4.3. Standard features : ACLs and conditions |
| 924 | ---------------------------------------------- |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 925 | |
| 926 | Most operations in HAProxy can be made conditional. Conditions are built by |
| 927 | combining multiple ACLs using logic operators (AND, OR, NOT). Each ACL is a |
| 928 | series of tests based on the following elements : |
| 929 | |
| 930 | - a sample fetch method to retrieve the element to test ; |
| 931 | |
| 932 | - an optional series of converters to transform the element ; |
| 933 | |
| 934 | - a list of patterns to match against ; |
| 935 | |
| 936 | - a matching method to indicate how to compare the patterns with the sample |
| 937 | |
| 938 | For example, the sample may be taken from the HTTP "Host" header, it could then |
| 939 | be converted to lower case, then matched against a number of regex patterns |
| 940 | using the regex matching method. |
| 941 | |
| 942 | Technically, ACLs are built on the same core as the maps, they share the exact |
| 943 | same internal structure, pattern matching methods and performance. The only real |
| 944 | difference is that instead of returning a sample, they only return "found" or |
| 945 | or "not found". In terms of usage, ACL patterns may be declared inline in the |
| 946 | configuration file and do not require their own file. ACLs may be named for ease |
| 947 | of use or to make configurations understandable. A named ACL may be declared |
| 948 | multiple times and it will evaluate all definitions in turn until one matches. |
| 949 | |
| 950 | About 13 different pattern matching methods are provided, among which IP address |
| 951 | mask, integer ranges, substrings, regex. They work like functions, and just like |
| 952 | with any programming language, only what is needed is evaluated, so when a |
| 953 | condition involving an OR is already true, next ones are not evaluated, and |
| 954 | similarly when a condition involving an AND is already false, the rest of the |
| 955 | condition is not evaluated. |
| 956 | |
| 957 | There is no practical limit to the number of declared ACLs, and a handful of |
| 958 | commonly used ones are provided. However experience has shown that setups using |
| 959 | a lot of named ACLs are quite hard to troubleshoot and that sometimes using |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 960 | anonymous ACLs inline is easier as it requires less references out of the scope |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 961 | being analyzed. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 962 | |
| 963 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 964 | 3.4.4. Standard features : Content switching |
| 965 | -------------------------------------------- |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 966 | |
| 967 | HAProxy implements a mechanism known as content-based switching. The principle |
| 968 | is that a connection or request arrives on a frontend, then the information |
| 969 | carried with this request or connection are processed, and at this point it is |
| 970 | possible to write ACLs-based conditions making use of these information to |
| 971 | decide what backend will process the request. Thus the traffic is directed to |
| 972 | one backend or another based on the request's contents. The most common example |
| 973 | consists in using the Host header and/or elements from the path (sub-directories |
| 974 | or file-name extensions) to decide whether an HTTP request targets a static |
| 975 | object or the application, and to route static objects traffic to a backend made |
| 976 | of fast and light servers, and all the remaining traffic to a more complex |
| 977 | application server, thus constituting a fine-grained virtual hosting solution. |
| 978 | This is quite convenient to make multiple technologies coexist as a more global |
| 979 | solution. |
| 980 | |
| 981 | Another use case of content-switching consists in using different load balancing |
| 982 | algorithms depending on various criteria. A cache may use a URI hash while an |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 983 | application would use round-robin. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 984 | |
| 985 | Last but not least, it allows multiple customers to use a small share of a |
| 986 | common resource by enforcing per-backend (thus per-customer connection limits). |
| 987 | |
| 988 | Content switching rules scale very well, though their performance may depend on |
| 989 | the number and complexity of the ACLs in use. But it is also possible to write |
| 990 | dynamic content switching rules where a sample value directly turns into a |
| 991 | backend name and without making use of ACLs at all. Such configurations have |
| 992 | been reported to work fine at least with 300000 backends in production. |
| 993 | |
| 994 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 995 | 3.4.5. Standard features : Stick-tables |
| 996 | --------------------------------------- |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 997 | |
| 998 | Stick-tables are commonly used to store stickiness information, that is, to keep |
| 999 | a reference to the server a certain visitor was directed to. The key is then the |
| 1000 | identifier associated with the visitor (its source address, the SSL ID of the |
| 1001 | connection, an HTTP or RDP cookie, the customer number extracted from the URL or |
| 1002 | from the payload, ...) and the stored value is then the server's identifier. |
| 1003 | |
| 1004 | Stick tables may use 3 different types of samples for their keys : integers, |
| 1005 | strings and addresses. Only one stick-table may be referenced in a proxy, and it |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1006 | is designated everywhere with the proxy name. Up to 8 keys may be tracked in |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1007 | parallel. The server identifier is committed during request or response |
| 1008 | processing once both the key and the server are known. |
| 1009 | |
| 1010 | Stick-table contents may be replicated in active-active mode with other HAProxy |
| 1011 | nodes known as "peers" as well as with the new process during a reload operation |
| 1012 | so that all load balancing nodes share the same information and take the same |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1013 | routing decision if client's requests are spread over multiple nodes. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1014 | |
| 1015 | Since stick-tables are indexed on what allows to recognize a client, they are |
| 1016 | often also used to store extra information such as per-client statistics. The |
| 1017 | extra statistics take some extra space and need to be explicitly declared. The |
| 1018 | type of statistics that may be stored includes the input and output bandwidth, |
| 1019 | the number of concurrent connections, the connection rate and count over a |
| 1020 | period, the amount and frequency of errors, some specific tags and counters, |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1021 | etc. In order to support keeping such information without being forced to |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1022 | stick to a given server, a special "tracking" feature is implemented and allows |
| 1023 | to track up to 3 simultaneous keys from different tables at the same time |
| 1024 | regardless of stickiness rules. Each stored statistics may be searched, dumped |
| 1025 | and cleared from the CLI and adds to the live troubleshooting capabilities. |
| 1026 | |
| 1027 | While this mechanism can be used to surclass a returning visitor or to adjust |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1028 | the delivered quality of service depending on good or bad behavior, it is |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1029 | mostly used to fight against service abuse and more generally DDoS as it allows |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1030 | to build complex models to detect certain bad behaviors at a high processing |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1031 | speed. |
| 1032 | |
| 1033 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1034 | 3.4.6. Standard features : Formatted strings |
| 1035 | -------------------------------------------- |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1036 | |
| 1037 | There are many places where HAProxy needs to manipulate character strings, such |
| 1038 | as logs, redirects, header additions, and so on. In order to provide the |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1039 | greatest flexibility, the notion of Formatted strings was introduced, initially |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1040 | for logging purposes, which explains why it's still called "log-format". These |
| 1041 | strings contain escape characters allowing to introduce various dynamic data |
| 1042 | including variables and sample fetch expressions into strings, and even to |
| 1043 | adjust the encoding while the result is being turned into a string (for example, |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 1044 | adding quotes). This provides a powerful way to build header contents, to build |
| 1045 | response data or even response templates, or to customize log lines. |
| 1046 | Additionally, in order to remain simple to build most common strings, about 50 |
| 1047 | special tags are provided as shortcuts for information commonly used in logs. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1048 | |
| 1049 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1050 | 3.4.7. Standard features : HTTP rewriting and redirection |
| 1051 | --------------------------------------------------------- |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1052 | |
| 1053 | Installing a load balancer in front of an application that was never designed |
| 1054 | for this can be a challenging task without the proper tools. One of the most |
| 1055 | commonly requested operation in this case is to adjust requests and response |
| 1056 | headers to make the load balancer appear as the origin server and to fix hard |
| 1057 | coded information. This comes with changing the path in requests (which is |
| 1058 | strongly advised against), modifying Host header field, modifying the Location |
| 1059 | response header field for redirects, modifying the path and domain attribute |
| 1060 | for cookies, and so on. It also happens that a number of servers are somewhat |
| 1061 | verbose and tend to leak too much information in the response, making them more |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1062 | vulnerable to targeted attacks. While it's theoretically not the role of a load |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1063 | balancer to clean this up, in practice it's located at the best place in the |
| 1064 | infrastructure to guarantee that everything is cleaned up. |
| 1065 | |
| 1066 | Similarly, sometimes the load balancer will have to intercept some requests and |
| 1067 | respond with a redirect to a new target URL. While some people tend to confuse |
| 1068 | redirects and rewriting, these are two completely different concepts, since the |
| 1069 | rewriting makes the client and the server see different things (and disagree on |
| 1070 | the location of the page being visited) while redirects ask the client to visit |
| 1071 | the new URL so that it sees the same location as the server. |
| 1072 | |
| 1073 | In order to do this, HAProxy supports various possibilities for rewriting and |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1074 | redirects, among which : |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1075 | |
| 1076 | - regex-based URL and header rewriting in requests and responses. Regex are |
| 1077 | the most commonly used tool to modify header values since they're easy to |
| 1078 | manipulate and well understood; |
| 1079 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1080 | - headers may also be appended, deleted or replaced based on formatted strings |
| 1081 | so that it is possible to pass information there (e.g. client side TLS |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1082 | algorithm and cipher); |
| 1083 | |
| 1084 | - HTTP redirects can use any 3xx code to a relative, absolute, or completely |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1085 | dynamic (formatted string) URI; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1086 | |
| 1087 | - HTTP redirects also support some extra options such as setting or clearing |
| 1088 | a specific cookie, dropping the query string, appending a slash if missing, |
| 1089 | and so on; |
| 1090 | |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 1091 | - a powerful "return" directive allows to customize every part of a response |
| 1092 | like status, headers, body using dynamic contents or even template files. |
| 1093 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1094 | - all operations support ACL-based conditions; |
| 1095 | |
| 1096 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1097 | 3.4.8. Standard features : Server protection |
| 1098 | -------------------------------------------- |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1099 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1100 | HAProxy does a lot to maximize service availability, and for this it takes |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1101 | large efforts to protect servers against overloading and attacks. The first |
| 1102 | and most important point is that only complete and valid requests are forwarded |
| 1103 | to the servers. The initial reason is that HAProxy needs to find the protocol |
| 1104 | elements it needs to stay synchronized with the byte stream, and the second |
| 1105 | reason is that until the request is complete, there is no way to know if some |
| 1106 | elements will change its semantics. The direct benefit from this is that servers |
| 1107 | are not exposed to invalid or incomplete requests. This is a very effective |
| 1108 | protection against slowloris attacks, which have almost no impact on HAProxy. |
| 1109 | |
| 1110 | Another important point is that HAProxy contains buffers to store requests and |
| 1111 | responses, and that by only sending a request to a server when it's complete and |
| 1112 | by reading the whole response very quickly from the local network, the server |
| 1113 | side connection is used for a very short time and this preserves server |
| 1114 | resources as much as possible. |
| 1115 | |
| 1116 | A direct extension to this is that HAProxy can artificially limit the number of |
| 1117 | concurrent connections or outstanding requests to a server, which guarantees |
| 1118 | that the server will never be overloaded even if it continuously runs at 100% of |
| 1119 | its capacity during traffic spikes. All excess requests will simply be queued to |
| 1120 | be processed when one slot is released. In the end, this huge resource savings |
| 1121 | most often ensures so much better server response times that it ends up actually |
| 1122 | being faster than by overloading the server. Queued requests may be redispatched |
| 1123 | to other servers, or even aborted in queue when the client aborts, which also |
| 1124 | protects the servers against the "reload effect", where each click on "reload" |
| 1125 | by a visitor on a slow-loading page usually induces a new request and maintains |
| 1126 | the server in an overloaded state. |
| 1127 | |
| 1128 | The slow-start mechanism also protects restarting servers against high traffic |
| 1129 | levels while they're still finalizing their startup or compiling some classes. |
| 1130 | |
| 1131 | Regarding the protocol-level protection, it is possible to relax the HTTP parser |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1132 | to accept non standard-compliant but harmless requests or responses and even to |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1133 | fix them. This allows bogus applications to be accessible while a fix is being |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 1134 | developed. In parallel, offending messages are completely captured with a |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1135 | detailed report that help developers spot the issue in the application. The most |
| 1136 | dangerous protocol violations are properly detected and dealt with and fixed. |
| 1137 | For example malformed requests or responses with two Content-length headers are |
| 1138 | either fixed if the values are exactly the same, or rejected if they differ, |
| 1139 | since it becomes a security problem. Protocol inspection is not limited to HTTP, |
| 1140 | it is also available for other protocols like TLS or RDP. |
| 1141 | |
| 1142 | When a protocol violation or attack is detected, there are various options to |
| 1143 | respond to the user, such as returning the common "HTTP 400 bad request", |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1144 | closing the connection with a TCP reset, or faking an error after a long delay |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1145 | ("tarpit") to confuse the attacker. All of these contribute to protecting the |
| 1146 | servers by discouraging the offending client from pursuing an attack that |
| 1147 | becomes very expensive to maintain. |
| 1148 | |
| 1149 | HAProxy also proposes some more advanced options to protect against accidental |
| 1150 | data leaks and session crossing. Not only it can log suspicious server responses |
| 1151 | but it will also log and optionally block a response which might affect a given |
| 1152 | visitors' confidentiality. One such example is a cacheable cookie appearing in a |
| 1153 | cacheable response and which may result in an intermediary cache to deliver it |
| 1154 | to another visitor, causing an accidental session sharing. |
| 1155 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1156 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1157 | 3.5. Advanced features |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1158 | ---------------------- |
| 1159 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1160 | 3.5.1. Advanced features : Management |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1161 | ------------------------------------- |
| 1162 | |
| 1163 | HAProxy is designed to remain extremely stable and safe to manage in a regular |
| 1164 | production environment. It is provided as a single executable file which doesn't |
| 1165 | require any installation process. Multiple versions can easily coexist, meaning |
| 1166 | that it's possible (and recommended) to upgrade instances progressively by |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1167 | order of importance instead of migrating all of them at once. Configuration |
| 1168 | files are easily versioned. Configuration checking is done off-line so it |
| 1169 | doesn't require to restart a service that will possibly fail. During |
| 1170 | configuration checks, a number of advanced mistakes may be detected (e.g. a rule |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1171 | hiding another one, or stickiness that will not work) and detailed warnings and |
| 1172 | configuration hints are proposed to fix them. Backwards configuration file |
| 1173 | compatibility goes very far away in time, with version 1.5 still fully |
| 1174 | supporting configurations for versions 1.1 written 13 years before, and 1.6 |
| 1175 | only dropping support for almost unused, obsolete keywords that can be done |
| 1176 | differently. The configuration and software upgrade mechanism is smooth and non |
| 1177 | disruptive in that it allows old and new processes to coexist on the system, |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1178 | each handling its own connections. System status, build options, and library |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1179 | compatibility are reported on startup. |
| 1180 | |
| 1181 | Some advanced features allow an application administrator to smoothly stop a |
| 1182 | server, detect when there's no activity on it anymore, then take it off-line, |
| 1183 | stop it, upgrade it and ensure it doesn't take any traffic while being upgraded, |
| 1184 | then test it again through the normal path without opening it to the public, and |
| 1185 | all of this without touching HAProxy at all. This ensures that even complicated |
| 1186 | production operations may be done during opening hours with all technical |
| 1187 | resources available. |
| 1188 | |
| 1189 | The process tries to save resources as much as possible, uses memory pools to |
| 1190 | save on allocation time and limit memory fragmentation, releases payload buffers |
| 1191 | as soon as their contents are sent, and supports enforcing strong memory limits |
| 1192 | above which connections have to wait for a buffer to become available instead of |
| 1193 | allocating more memory. This system helps guarantee memory usage in certain |
| 1194 | strict environments. |
| 1195 | |
| 1196 | A command line interface (CLI) is available as a UNIX or TCP socket, to perform |
| 1197 | a number of operations and to retrieve troubleshooting information. Everything |
| 1198 | done on this socket doesn't require a configuration change, so it is mostly used |
| 1199 | for temporary changes. Using this interface it is possible to change a server's |
| 1200 | address, weight and status, to consult statistics and clear counters, dump and |
| 1201 | clear stickiness tables, possibly selectively by key criteria, dump and kill |
| 1202 | client-side and server-side connections, dump captured errors with a detailed |
| 1203 | analysis of the exact cause and location of the error, dump, add and remove |
| 1204 | entries from ACLs and maps, update TLS shared secrets, apply connection limits |
| 1205 | and rate limits on the fly to arbitrary frontends (useful in shared hosting |
| 1206 | environments), and disable a specific frontend to release a listening port |
| 1207 | (useful when daytime operations are forbidden and a fix is needed nonetheless). |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 1208 | Updating certificates and their configuration on the fly is permitted, as well |
| 1209 | as enabling and consulting traces of every processing step of the traffic. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1210 | |
| 1211 | For environments where SNMP is mandatory, at least two agents exist, one is |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1212 | provided with the HAProxy sources and relies on the Net-SNMP Perl module. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1213 | Another one is provided with the commercial packages and doesn't require Perl. |
| 1214 | Both are roughly equivalent in terms of coverage. |
| 1215 | |
| 1216 | It is often recommended to install 4 utilities on the machine where HAProxy is |
| 1217 | deployed : |
| 1218 | |
| 1219 | - socat (in order to connect to the CLI, though certain forks of netcat can |
| 1220 | also do it to some extents); |
| 1221 | |
| 1222 | - halog from the latest HAProxy version : this is the log analysis tool, it |
| 1223 | parses native TCP and HTTP logs extremely fast (1 to 2 GB per second) and |
| 1224 | extracts useful information and statistics such as requests per URL, per |
| 1225 | source address, URLs sorted by response time or error rate, termination |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1226 | codes etc. It was designed to be deployed on the production servers to |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1227 | help troubleshoot live issues so it has to be there ready to be used; |
| 1228 | |
| 1229 | - tcpdump : this is highly recommended to take the network traces needed to |
| 1230 | troubleshoot an issue that was made visible in the logs. There is a moment |
| 1231 | where application and haproxy's analysis will diverge and the network traces |
| 1232 | are the only way to say who's right and who's wrong. It's also fairly common |
| 1233 | to detect bugs in network stacks and hypervisors thanks to tcpdump; |
| 1234 | |
| 1235 | - strace : it is tcpdump's companion. It will report what HAProxy really sees |
| 1236 | and will help sort out the issues the operating system is responsible for |
| 1237 | from the ones HAProxy is responsible for. Strace is often requested when a |
| 1238 | bug in HAProxy is suspected; |
| 1239 | |
| 1240 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1241 | 3.5.2. Advanced features : System-specific capabilities |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1242 | ------------------------------------------------------- |
| 1243 | |
| 1244 | Depending on the operating system HAProxy is deployed on, certain extra features |
| 1245 | may be available or needed. While it is supported on a number of platforms, |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 1246 | HAProxy is primarily developed on Linux, which explains why some features are |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1247 | only available on this platform. |
| 1248 | |
| 1249 | The transparent bind and connect features, the support for binding connections |
| 1250 | to a specific network interface, as well as the ability to bind multiple |
| 1251 | processes to the same IP address and ports are only available on Linux and BSD |
| 1252 | systems, though only Linux performs a kernel-side load balancing of the incoming |
| 1253 | requests between the available processes. |
| 1254 | |
| 1255 | On Linux, there are also a number of extra features and optimizations including |
| 1256 | support for network namespaces (also known as "containers") allowing HAProxy to |
| 1257 | be a gateway between all containers, the ability to set the MSS, Netfilter marks |
| 1258 | and IP TOS field on the client side connection, support for TCP FastOpen on the |
| 1259 | listening side, TCP user timeouts to let the kernel quickly kill connections |
| 1260 | when it detects the client has disappeared before the configured timeouts, TCP |
| 1261 | splicing to let the kernel forward data between the two sides of a connections |
| 1262 | thus avoiding multiple memory copies, the ability to enable the "defer-accept" |
| 1263 | bind option to only get notified of an incoming connection once data become |
| 1264 | available in the kernel buffers, and the ability to send the request with the |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1265 | ACK confirming a connect (sometimes called "piggy-back") which is enabled with |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1266 | the "tcp-smart-connect" option. On Linux, HAProxy also takes great care of |
| 1267 | manipulating the TCP delayed ACKs to save as many packets as possible on the |
| 1268 | network. |
| 1269 | |
| 1270 | Some systems have an unreliable clock which jumps back and forth in the past |
| 1271 | and in the future. This used to happen with some NUMA systems where multiple |
| 1272 | processors didn't see the exact same time of day, and recently it became more |
| 1273 | common in virtualized environments where the virtual clock has no relation with |
| 1274 | the real clock, resulting in huge time jumps (sometimes up to 30 seconds have |
| 1275 | been observed). This causes a lot of trouble with respect to timeout enforcement |
| 1276 | in general. Due to this flaw of these systems, HAProxy maintains its own |
| 1277 | monotonic clock which is based on the system's clock but where drift is measured |
| 1278 | and compensated for. This ensures that even with a very bad system clock, timers |
| 1279 | remain reasonably accurate and timeouts continue to work. Note that this problem |
| 1280 | affects all the software running on such systems and is not specific to HAProxy. |
| 1281 | The common effects are spurious timeouts or application freezes. Thus if this |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1282 | behavior is detected on a system, it must be fixed, regardless of the fact that |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1283 | HAProxy protects itself against it. |
| 1284 | |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 1285 | On Linux, a new starting process may communicate with the previous one to reuse |
| 1286 | its listening file descriptors so that the listening sockets are never |
Thayne McCombs | cdbcca9 | 2021-01-07 21:24:41 -0700 | [diff] [blame] | 1287 | interrupted during the process's replacement. |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 1288 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1289 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1290 | 3.5.3. Advanced features : Scripting |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1291 | ------------------------------------ |
| 1292 | |
| 1293 | HAProxy can be built with support for the Lua embedded language, which opens a |
| 1294 | wide area of new possibilities related to complex manipulation of requests or |
| 1295 | responses, routing decisions, statistics processing and so on. Using Lua it is |
| 1296 | even possible to establish parallel connections to other servers to exchange |
| 1297 | information. This way it becomes possible (though complex) to develop an |
| 1298 | authentication system for example. Please refer to the documentation in the file |
| 1299 | "doc/lua-api/index.rst" for more information on how to use Lua. |
| 1300 | |
| 1301 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1302 | 3.5.4. Advanced features: Tracing |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 1303 | --------------------------------- |
| 1304 | |
| 1305 | At any moment an administrator may connect over the CLI and enable tracing in |
| 1306 | various internal subsystems. Various levels of details are provided by default |
| 1307 | so that in practice anything between one line per request to 500 lines per |
| 1308 | request can be retrieved. Filters as well as an automatic capture on/off/pause |
| 1309 | mechanism are available so that it really is possible to wait for a certain |
| 1310 | event and watch it in detail. This is extremely convenient to diagnose protocol |
| 1311 | violations from faulty servers and clients, or denial of service attacks. |
| 1312 | |
| 1313 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1314 | 3.6. Sizing |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1315 | ----------- |
| 1316 | |
| 1317 | Typical CPU usage figures show 15% of the processing time spent in HAProxy |
| 1318 | versus 85% in the kernel in TCP or HTTP close mode, and about 30% for HAProxy |
| 1319 | versus 70% for the kernel in HTTP keep-alive mode. This means that the operating |
| 1320 | system and its tuning have a strong impact on the global performance. |
| 1321 | |
| 1322 | Usages vary a lot between users, some focus on bandwidth, other ones on request |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1323 | rate, others on connection concurrency, others on SSL performance. This section |
| 1324 | aims at providing a few elements to help with this task. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1325 | |
| 1326 | It is important to keep in mind that every operation comes with a cost, so each |
| 1327 | individual operation adds its overhead on top of the other ones, which may be |
| 1328 | negligible in certain circumstances, and which may dominate in other cases. |
| 1329 | |
| 1330 | When processing the requests from a connection, we can say that : |
| 1331 | |
| 1332 | - forwarding data costs less than parsing request or response headers; |
| 1333 | |
| 1334 | - parsing request or response headers cost less than establishing then closing |
| 1335 | a connection to a server; |
| 1336 | |
| 1337 | - establishing an closing a connection costs less than a TLS resume operation; |
| 1338 | |
| 1339 | - a TLS resume operation costs less than a full TLS handshake with a key |
| 1340 | computation; |
| 1341 | |
| 1342 | - an idle connection costs less CPU than a connection whose buffers hold data; |
| 1343 | |
| 1344 | - a TLS context costs even more memory than a connection with data; |
| 1345 | |
| 1346 | So in practice, it is cheaper to process payload bytes than header bytes, thus |
| 1347 | it is easier to achieve high network bandwidth with large objects (few requests |
| 1348 | per volume unit) than with small objects (many requests per volume unit). This |
| 1349 | explains why maximum bandwidth is always measured with large objects, while |
| 1350 | request rate or connection rates are measured with small objects. |
| 1351 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1352 | Some operations scale well on multiple processes spread over multiple CPUs, |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1353 | and others don't scale as well. Network bandwidth doesn't scale very far because |
| 1354 | the CPU is rarely the bottleneck for large objects, it's mostly the network |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1355 | bandwidth and data buses to reach the network interfaces. The connection rate |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1356 | doesn't scale well over multiple processors due to a few locks in the system |
| 1357 | when dealing with the local ports table. The request rate over persistent |
| 1358 | connections scales very well as it doesn't involve much memory nor network |
| 1359 | bandwidth and doesn't require to access locked structures. TLS key computation |
| 1360 | scales very well as it's totally CPU-bound. TLS resume scales moderately well, |
| 1361 | but reaches its limits around 4 processes where the overhead of accessing the |
| 1362 | shared table offsets the small gains expected from more power. |
| 1363 | |
| 1364 | The performance numbers one can expect from a very well tuned system are in the |
| 1365 | following range. It is important to take them as orders of magnitude and to |
| 1366 | expect significant variations in any direction based on the processor, IRQ |
| 1367 | setting, memory type, network interface type, operating system tuning and so on. |
| 1368 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1369 | The following numbers were found on a Core i7 running at 3.7 GHz equipped with |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1370 | a dual-port 10 Gbps NICs running Linux kernel 3.10, HAProxy 1.6 and OpenSSL |
| 1371 | 1.0.2. HAProxy was running as a single process on a single dedicated CPU core, |
| 1372 | and two extra cores were dedicated to network interrupts : |
| 1373 | |
| 1374 | - 20 Gbps of maximum network bandwidth in clear text for objects 256 kB or |
| 1375 | higher, 10 Gbps for 41kB or higher; |
| 1376 | |
| 1377 | - 4.6 Gbps of TLS traffic using AES256-GCM cipher with large objects; |
| 1378 | |
| 1379 | - 83000 TCP connections per second from client to server; |
| 1380 | |
| 1381 | - 82000 HTTP connections per second from client to server; |
| 1382 | |
| 1383 | - 97000 HTTP requests per second in server-close mode (keep-alive with the |
| 1384 | client, close with the server); |
| 1385 | |
| 1386 | - 243000 HTTP requests per second in end-to-end keep-alive mode; |
| 1387 | |
| 1388 | - 300000 filtered TCP connections per second (anti-DDoS) |
| 1389 | |
| 1390 | - 160000 HTTPS requests per second in keep-alive mode over persistent TLS |
| 1391 | connections; |
| 1392 | |
| 1393 | - 13100 HTTPS requests per second using TLS resumed connections; |
| 1394 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1395 | - 1300 HTTPS connections per second using TLS connections renegotiated with |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1396 | RSA2048; |
| 1397 | |
| 1398 | - 20000 concurrent saturated connections per GB of RAM, including the memory |
| 1399 | required for system buffers; it is possible to do better with careful tuning |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1400 | but this result it easy to achieve. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1401 | |
| 1402 | - about 8000 concurrent TLS connections (client-side only) per GB of RAM, |
| 1403 | including the memory required for system buffers; |
| 1404 | |
| 1405 | - about 5000 concurrent end-to-end TLS connections (both sides) per GB of |
| 1406 | RAM including the memory required for system buffers; |
| 1407 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1408 | A more recent benchmark featuring the multi-thread enabled HAProxy 2.4 on a |
| 1409 | 64-core ARM Graviton2 processor in AWS reached 2 million HTTPS requests per |
| 1410 | second at sub-millisecond response time, and 100 Gbps of traffic: |
| 1411 | |
| 1412 | https://www.haproxy.com/blog/haproxy-forwards-over-2-million-http-requests-per-second-on-a-single-aws-arm-instance/ |
| 1413 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1414 | Thus a good rule of thumb to keep in mind is that the request rate is divided |
| 1415 | by 10 between TLS keep-alive and TLS resume, and between TLS resume and TLS |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1416 | renegotiation, while it's only divided by 3 between HTTP keep-alive and HTTP |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1417 | close. Another good rule of thumb is to remember that a high frequency core |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1418 | with AES instructions can do around 20 Gbps of AES-GCM per core. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1419 | |
| 1420 | Another good rule of thumb is to consider that on the same server, HAProxy will |
| 1421 | be able to saturate : |
| 1422 | |
| 1423 | - about 5-10 static file servers or caching proxies; |
| 1424 | |
| 1425 | - about 100 anti-virus proxies; |
| 1426 | |
Willy Tarreau | 16af23c | 2015-08-27 16:30:53 +0200 | [diff] [blame] | 1427 | - and about 100-1000 application servers depending on the technology in use. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1428 | |
| 1429 | |
Willy Tarreau | e68e7e8 | 2022-05-31 16:23:06 +0200 | [diff] [blame] | 1430 | 3.7. How to get HAProxy |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1431 | ----------------------- |
| 1432 | |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1433 | HAProxy is an open source project covered by the GPLv2 license, meaning that |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1434 | everyone is allowed to redistribute it provided that access to the sources is |
| 1435 | also provided upon request, especially if any modifications were made. |
| 1436 | |
| 1437 | HAProxy evolves as a main development branch called "master" or "mainline", from |
| 1438 | which new branches are derived once the code is considered stable. A lot of web |
| 1439 | sites run some development branches in production on a voluntarily basis, either |
| 1440 | to participate to the project or because they need a bleeding edge feature, and |
| 1441 | their feedback is highly valuable to fix bugs and judge the overall quality and |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 1442 | stability of the version being developed. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1443 | |
| 1444 | The new branches that are created when the code is stable enough constitute a |
| 1445 | stable version and are generally maintained for several years, so that there is |
| 1446 | no emergency to migrate to a newer branch even when you're not on the latest. |
| 1447 | Once a stable branch is issued, it may only receive bug fixes, and very rarely |
| 1448 | minor feature updates when that makes users' life easier. All fixes that go into |
| 1449 | a stable branch necessarily come from the master branch. This guarantees that no |
| 1450 | fix will be lost after an upgrade. For this reason, if you fix a bug, please |
| 1451 | make the patch against the master branch, not the stable branch. You may even |
| 1452 | discover it was already fixed. This process also ensures that regressions in a |
| 1453 | stable branch are extremely rare, so there is never any excuse for not upgrading |
| 1454 | to the latest version in your current branch. |
| 1455 | |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 1456 | Branches are numbered with two digits delimited with a dot, such as "1.6". |
| 1457 | Since 1.9, branches with an odd second digit are mostly focused on sensitive |
| 1458 | technical updates and more aimed at advanced users because they are likely to |
| 1459 | trigger more bugs than the other ones. They are maintained for about a year |
| 1460 | only and must not be deployed where they cannot be rolled back in emergency. A |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1461 | complete version includes one or two sub-version numbers indicating the level of |
| 1462 | fix. For example, version 1.5.14 is the 14th fix release in branch 1.5 after |
| 1463 | version 1.5.0 was issued. It contains 126 fixes for individual bugs, 24 updates |
| 1464 | on the documentation, and 75 other backported patches, most of which were needed |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 1465 | to fix the aforementioned 126 bugs. An existing feature may never be modified |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1466 | nor removed in a stable branch, in order to guarantee that upgrades within the |
| 1467 | same branch will always be harmless. |
| 1468 | |
| 1469 | HAProxy is available from multiple sources, at different release rhythms : |
| 1470 | |
| 1471 | - The official community web site : http://www.haproxy.org/ : this site |
| 1472 | provides the sources of the latest development release, all stable releases, |
| 1473 | as well as nightly snapshots for each branch. The release cycle is not fast, |
| 1474 | several months between stable releases, or between development snapshots. |
| 1475 | Very old versions are still supported there. Everything is provided as |
| 1476 | sources only, so whatever comes from there needs to be rebuilt and/or |
| 1477 | repackaged; |
| 1478 | |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 1479 | - GitHub : https://github.com/haproxy/haproxy/ : this is the mirror for the |
| 1480 | development branch only, which provides integration with the issue tracker, |
| 1481 | continuous integration and code coverage tools. This is exclusively for |
| 1482 | contributors; |
| 1483 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1484 | - A number of operating systems such as Linux distributions and BSD ports. |
| 1485 | These systems generally provide long-term maintained versions which do not |
| 1486 | always contain all the fixes from the official ones, but which at least |
| 1487 | contain the critical fixes. It often is a good option for most users who do |
| 1488 | not seek advanced configurations and just want to keep updates easy; |
| 1489 | |
| 1490 | - Commercial versions from http://www.haproxy.com/ : these are supported |
| 1491 | professional packages built for various operating systems or provided as |
| 1492 | appliances, based on the latest stable versions and including a number of |
| 1493 | features backported from the next release for which there is a strong |
| 1494 | demand. It is the best option for users seeking the latest features with |
| 1495 | the reliability of a stable branch, the fastest response time to fix bugs, |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1496 | or simply support contracts on top of an open source product; |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1497 | |
| 1498 | |
| 1499 | In order to ensure that the version you're using is the latest one in your |
| 1500 | branch, you need to proceed this way : |
| 1501 | |
| 1502 | - verify which HAProxy executable you're running : some systems ship it by |
| 1503 | default and administrators install their versions somewhere else on the |
| 1504 | system, so it is important to verify in the startup scripts which one is |
| 1505 | used; |
| 1506 | |
| 1507 | - determine which source your HAProxy version comes from. For this, it's |
| 1508 | generally sufficient to type "haproxy -v". A development version will |
| 1509 | appear like this, with the "dev" word after the branch number : |
| 1510 | |
Willy Tarreau | 58000fe | 2021-05-09 06:25:16 +0200 | [diff] [blame] | 1511 | HAProxy version 2.4-dev18-a5357c-137 2021/05/09 - https://haproxy.org/ |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1512 | |
| 1513 | A stable version will appear like this, as well as unmodified stable |
| 1514 | versions provided by operating system vendors : |
| 1515 | |
Willy Tarreau | 58000fe | 2021-05-09 06:25:16 +0200 | [diff] [blame] | 1516 | HAProxy version 1.5.14 2015/07/02 |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1517 | |
| 1518 | And a nightly snapshot of a stable version will appear like this with an |
| 1519 | hexadecimal sequence after the version, and with the date of the snapshot |
| 1520 | instead of the date of the release : |
| 1521 | |
Willy Tarreau | 58000fe | 2021-05-09 06:25:16 +0200 | [diff] [blame] | 1522 | HAProxy version 1.5.14-e4766ba 2015/07/29 |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1523 | |
| 1524 | Any other format may indicate a system-specific package with its own |
| 1525 | patch set. For example HAProxy Enterprise versions will appear with the |
| 1526 | following format (<branch>-<latest commit>-<revision>) : |
| 1527 | |
Willy Tarreau | 58000fe | 2021-05-09 06:25:16 +0200 | [diff] [blame] | 1528 | HAProxy version 1.5.0-994126-357 2015/07/02 |
| 1529 | |
| 1530 | Please note that historically versions prior to 2.4 used to report the |
| 1531 | process name with a hyphen between "HA" and "Proxy", including those above |
| 1532 | which were adjusted to show the correct format only, so better ignore this |
| 1533 | word or use a relaxed match in scripts. Additionally, modern versions add |
| 1534 | a URL linking to the project's home. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1535 | |
Willy Tarreau | 58000fe | 2021-05-09 06:25:16 +0200 | [diff] [blame] | 1536 | Finally, versions 2.1 and above will include a "Status" line indicating |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 1537 | whether the version is safe for production or not, and if so, till when, as |
| 1538 | well as a link to the list of known bugs affecting this version. |
| 1539 | |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1540 | - for system-specific packages, you have to check with your vendor's package |
| 1541 | repository or update system to ensure that your system is still supported, |
| 1542 | and that fixes are still provided for your branch. For community versions |
| 1543 | coming from haproxy.org, just visit the site, verify the status of your |
| 1544 | branch and compare the latest version with yours to see if you're on the |
| 1545 | latest one. If not you can upgrade. If your branch is not maintained |
| 1546 | anymore, you're definitely very late and will have to consider an upgrade |
| 1547 | to a more recent branch (carefully read the README when doing so). |
| 1548 | |
| 1549 | HAProxy will have to be updated according to the source it came from. Usually it |
| 1550 | follows the system vendor's way of upgrading a package. If it was taken from |
| 1551 | sources, please read the README file in the sources directory after extracting |
| 1552 | the sources and follow the instructions for your operating system. |
| 1553 | |
| 1554 | |
| 1555 | 4. Companion products and alternatives |
| 1556 | -------------------------------------- |
| 1557 | |
| 1558 | HAProxy integrates fairly well with certain products listed below, which is why |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1559 | they are mentioned here even if not directly related to HAProxy. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1560 | |
| 1561 | |
| 1562 | 4.1. Apache HTTP server |
| 1563 | ----------------------- |
| 1564 | |
| 1565 | Apache is the de-facto standard HTTP server. It's a very complete and modular |
| 1566 | project supporting both file serving and dynamic contents. It can serve as a |
Michael Prokop | 4438c60 | 2019-05-24 10:25:45 +0200 | [diff] [blame] | 1567 | frontend for some application servers. It can even proxy requests and cache |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1568 | responses. In all of these use cases, a front load balancer is commonly needed. |
Patrick Starr | dce734e | 2017-10-09 13:17:12 +0700 | [diff] [blame] | 1569 | Apache can work in various modes, some being heavier than others. Certain |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1570 | modules still require the heavier pre-forked model and will prevent Apache from |
| 1571 | scaling well with a high number of connections. In this case HAProxy can provide |
| 1572 | a tremendous help by enforcing the per-server connection limits to a safe value |
| 1573 | and will significantly speed up the server and preserve its resources that will |
| 1574 | be better used by the application. |
| 1575 | |
| 1576 | Apache can extract the client's address from the X-Forwarded-For header by using |
| 1577 | the "mod_rpaf" extension. HAProxy will automatically feed this header when |
| 1578 | "option forwardfor" is specified in its configuration. HAProxy may also offer a |
| 1579 | nice protection to Apache when exposed to the internet, where it will better |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1580 | resist a wide number of types of DoS attacks. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1581 | |
| 1582 | |
| 1583 | 4.2. NGINX |
| 1584 | ---------- |
| 1585 | |
| 1586 | NGINX is the second de-facto standard HTTP server. Just like Apache, it covers a |
| 1587 | wide range of features. NGINX is built on a similar model as HAProxy so it has |
| 1588 | no problem dealing with tens of thousands of concurrent connections. When used |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1589 | as a gateway to some applications (e.g. using the included PHP FPM) it can often |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1590 | be beneficial to set up some frontend connection limiting to reduce the load |
| 1591 | on the PHP application. HAProxy will clearly be useful there both as a regular |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1592 | load balancer and as the traffic regulator to speed up PHP by decongesting |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1593 | it. Also since both products use very little CPU thanks to their event-driven |
| 1594 | architecture, it's often easy to install both of them on the same system. NGINX |
| 1595 | implements HAProxy's PROXY protocol, thus it is easy for HAProxy to pass the |
| 1596 | client's connection information to NGINX so that the application gets all the |
| 1597 | relevant information. Some benchmarks have also shown that for large static |
| 1598 | file serving, implementing consistent hash on HAProxy in front of NGINX can be |
| 1599 | beneficial by optimizing the OS' cache hit ratio, which is basically multiplied |
| 1600 | by the number of server nodes. |
| 1601 | |
| 1602 | |
| 1603 | 4.3. Varnish |
| 1604 | ------------ |
| 1605 | |
| 1606 | Varnish is a smart caching reverse-proxy, probably best described as a web |
| 1607 | application accelerator. Varnish doesn't implement SSL/TLS and wants to dedicate |
| 1608 | all of its CPU cycles to what it does best. Varnish also implements HAProxy's |
| 1609 | PROXY protocol so that HAProxy can very easily be deployed in front of Varnish |
| 1610 | as an SSL offloader as well as a load balancer and pass it all relevant client |
| 1611 | information. Also, Varnish naturally supports decompression from the cache when |
| 1612 | a server has provided a compressed object, but doesn't compress however. HAProxy |
| 1613 | can then be used to compress outgoing data when backend servers do not implement |
| 1614 | compression, though it's rarely a good idea to compress on the load balancer |
| 1615 | unless the traffic is low. |
| 1616 | |
| 1617 | When building large caching farms across multiple nodes, HAProxy can make use of |
| 1618 | consistent URL hashing to intelligently distribute the load to the caching nodes |
| 1619 | and avoid cache duplication, resulting in a total cache size which is the sum of |
Willy Tarreau | ec8962c | 2020-05-05 17:39:16 +0200 | [diff] [blame] | 1620 | all caching nodes. In addition, caching of very small dumb objects for a short |
| 1621 | duration on HAProxy can sometimes save network round trips and reduce the CPU |
| 1622 | load on both the HAProxy and the Varnish nodes. This is only possible is no |
| 1623 | processing is done on these objects on Varnish (this is often referred to as |
| 1624 | the notion of "favicon cache", by which a sizeable percentage of useless |
| 1625 | downstream requests can sometimes be avoided). However do not enable HAProxy |
| 1626 | caching for a long time (more than a few seconds) in front of any other cache, |
| 1627 | that would significantly complicate troubleshooting without providing really |
| 1628 | significant savings. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1629 | |
| 1630 | |
| 1631 | 4.4. Alternatives |
| 1632 | ----------------- |
| 1633 | |
| 1634 | Linux Virtual Server (LVS or IPVS) is the layer 4 load balancer included within |
| 1635 | the Linux kernel. It works at the packet level and handles TCP and UDP. In most |
| 1636 | cases it's more a complement than an alternative since it doesn't have layer 7 |
| 1637 | knowledge at all. |
| 1638 | |
| 1639 | Pound is another well-known load balancer. It's much simpler and has much less |
| 1640 | features than HAProxy but for many very basic setups both can be used. Its |
| 1641 | author has always focused on code auditability first and wants to maintain the |
| 1642 | set of features low. Its thread-based architecture scales less well with high |
| 1643 | connection counts, but it's a good product. |
| 1644 | |
| 1645 | Pen is a quite light load balancer. It supports SSL, maintains persistence using |
| 1646 | a fixed-size table of its clients' IP addresses. It supports a packet-oriented |
| 1647 | mode allowing it to support direct server return and UDP to some extents. It is |
| 1648 | meant for small loads (the persistence table only has 2048 entries). |
| 1649 | |
| 1650 | NGINX can do some load balancing to some extents, though it's clearly not its |
| 1651 | primary function. Production traffic is used to detect server failures, the |
| 1652 | load balancing algorithms are more limited, and the stickiness is very limited. |
| 1653 | But it can make sense in some simple deployment scenarios where it is already |
| 1654 | present. The good thing is that since it integrates very well with HAProxy, |
Davor Ocelic | 4094ce1 | 2017-12-19 23:30:39 +0100 | [diff] [blame] | 1655 | there's nothing wrong with adding HAProxy later when its limits have been |
| 1656 | reached. |
Willy Tarreau | d8e42b6 | 2015-08-18 21:51:36 +0200 | [diff] [blame] | 1657 | |
| 1658 | Varnish also does some load balancing of its backend servers and does support |
| 1659 | real health checks. It doesn't implement stickiness however, so just like with |
| 1660 | NGINX, as long as stickiness is not needed that can be enough to start with. |
| 1661 | And similarly, since HAProxy and Varnish integrate so well together, it's easy |
| 1662 | to add it later into the mix to complement the feature set. |
| 1663 | |
Willy Tarreau | 6562623 | 2020-05-05 18:08:07 +0200 | [diff] [blame] | 1664 | |
| 1665 | 5. Contacts |
| 1666 | ----------- |
| 1667 | |
| 1668 | If you want to contact the developers or any community member about anything, |
| 1669 | the best way to do it usually is via the mailing list by sending your message |
| 1670 | to haproxy@formilux.org. Please note that this list is public and its archives |
| 1671 | are public as well so you should avoid disclosing sensitive information. A |
| 1672 | thousand of users of various experience levels are present there and even the |
| 1673 | most complex questions usually find an optimal response relatively quickly. |
| 1674 | Suggestions are welcome too. For users having difficulties with e-mail, a |
| 1675 | Discourse platform is available at http://discourse.haproxy.org/ . However |
| 1676 | please keep in mind that there are less people reading questions there and that |
| 1677 | most are handled by a really tiny team. In any case, please be patient and |
| 1678 | respectful with those who devote their spare time helping others. |
| 1679 | |
| 1680 | I you believe you've found a bug but are not sure, it's best reported on the |
| 1681 | mailing list. If you're quite convinced you've found a bug, that your version |
| 1682 | is up-to-date in its branch, and you already have a GitHub account, feel free |
| 1683 | to go directly to https://github.com/haproxy/haproxy/ and file an issue with |
| 1684 | all possibly available details. Again, this is public so be careful not to post |
| 1685 | information you might later regret. Since the issue tracker presents itself as |
| 1686 | a very long thread, please avoid pasting very long dumps (a few hundreds lines |
| 1687 | or more) and attach them instead. |
| 1688 | |
| 1689 | If you've found what you're absolutely certain can be considered a critical |
| 1690 | security issue that would put many users in serious trouble if discussed in a |
| 1691 | public place, then you can send it with the reproducer to security@haproxy.org. |
| 1692 | A small team of trusted developers will receive it and will be able to propose |
| 1693 | a fix. We usually don't use embargoes and once a fix is available it gets |
| 1694 | merged. In some rare circumstances it can happen that a release is coordinated |
| 1695 | with software vendors. Please note that this process usually messes up with |
| 1696 | eveyone's work, and that rushed up releases can sometimes introduce new bugs, |
| 1697 | so it's best avoided unless strictly necessary; as such, there is often little |
| 1698 | consideration for reports that needlessly cause such extra burden, and the best |
| 1699 | way to see your work credited usually is to provide a working fix, which will |
| 1700 | appear in changelogs. |