Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between frontend/backend and listen in haproxy

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

like image 687
Al F Avatar asked Aug 29 '16 15:08

Al F


People also ask

What is frontend and backend in HAProxy?

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.

What is listen in HAProxy?

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.

What is backend in HAProxy?

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.

What is Maxconn in HAProxy?

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.


1 Answers

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.

like image 100
Michael - sqlbot Avatar answered Oct 03 '22 03:10

Michael - sqlbot