Hopefully a simple question. I apologize if this has been covered before. I'm learning haproxy and overall seems very straightforward and simple. However I am curious what the difference is between using frontend/backend and listen config blocks? My assumption is that listen is just simpler, for basic configurations, while frontend/backend is more advanced, allowing you to dynamically switch backends or share backends, etc. Is that it in a nutshell?
Thanks,
Al
When HAProxy Enterprise is used as a reverse proxy in front of your backend servers, a frontend section defines the IP addresses and ports that clients can connect to. You may add as many frontend sections as needed to expose various websites or applications to the internet.
A listen section can be used to define a complete proxy with the functions of a frontend and backend combined. The listen section is well suited whenever you need to route traffic to a specific set of servers or for non-HTTP-related configurations such as TCP gateways.
HAProxy Enterprise frontend sections accept incoming connections that can then be forwarded to a pool of servers. The backend section is where those pools of servers that will service requests are defined.
maxconn. The maxconn setting limits the maximum number of connections that HAProxy will accept. Its purpose is to protect your load balancer from running out of memory. You can determine the best value for your environment by consulting the sizing guide for memory requirements.
All three are called "proxies."
A listen
is a combined frontend
and backend
. A listen
has an implicit default_backend
of itself, but the frontend logic of a listen
can use other backends and its backend section can be used by other frontends. Fundamentally it just keep configuration more compact for simple rules, but otherwise it's almost the same as declaring a separate frontend and backend of the same name, while keeping the config together.
A "listen" section defines a complete proxy with its frontend and backend parts combined in one section. It is generally useful for TCP-only traffic.
http://cbonte.github.io/haproxy-dconv/1.6/configuration.html#4
It's paricularly useful for TCP because such configurations are usually simpler than HTTP. But a listen
proxy can be used for either application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With