Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the exact meaning of "session" in haproxy?

When I open the haproxy statistics report page of my http proxy server, I saw something like this:

Cum. connections:   280073
Cum. sessions   :   3802
Cum. HTTP requests: 24245

I'm not using 'appsession' and any other cookie related command in the configuration. So what's 'session' means here?

I guess haproxy identify http session by this order:

  1. Use cookie or query string if it's exists in the configuration.
  2. Use SSL/TLS session.
  3. Use ip address and TCP connection status.

Am I Right?

like image 508
ASBai Avatar asked Oct 16 '15 10:10

ASBai


People also ask

What is sticky session HAProxy?

Implement sticky sessions with a cookie HAProxy can save a cookie in the user's browser to remember which server to send them back to. The cookie, which contains the server's unique ID, offers the most accurate way to implement sticky sessions because a cookie is guaranteed to belong to only one user.

What is mode in HAProxy?

HAProxy supports 4 connection modes : - keep alive : all requests and responses are processed (default) - tunnel : only the first request and response are processed, everything else is forwarded with no analysis (deprecated). - server close : the server-facing connection is closed after the response.

How can I check my HAProxy status?

Use this systemctl command to examine HAProxy's status on any Linux distribution: sudo systemctl status haproxy.

What is default mode in HAProxy?

defaults mode http log global balance roundrobin timeout client 30s frontend public_web_servers bind *:80 default_backend public_web_servers frontend api_servers bind *:8000 default_backend api_servers backend public_web_servers server s1 192.168.1.25:80 server s2 192.168.1.26:80 backend api_servers server s1 192.168. ...


1 Answers

I was asking myself the very same question this morning.

Searching through http://www.haproxy.org/download/1.5/doc/configuration.txt I came accross this very short definition (hidden in a parameter description) :

A session is a connection that was accepted by the layer 4 rules.

In your case, you're obviously using Haproxy as a layer7/HTTP loadbalancer. If a session is a TCP connection, due to client-side / frontend Keep-Alive, it's normal to have more HTTP reqs than sessions.

Then I guess the high connection number shows that a lot of incoming connections were rejected even before being considered by the HTTP layer. For instance via IP-based ACLs.

As a far as I understand, the 'session' word was introduced to make sure two different concepts were not mixed :

  • a (TCP) connection : it's a discrete event
  • a (TCP) session : it's a state which tracks various metadata and has some duration; most importantly Haproxy workload (CPU and memory) should be mostly related to the number of sessions (both arrival rate and concurrent number)
like image 173
zerodeux Avatar answered Oct 26 '22 18:10

zerodeux