Load Balance HTTP Requests and chunking
May 10, 2022 03:29AM
Hello,

I was reading about HTTP streaming and am struggling to find the answer to my question. I'm hoping someone here can clarify and help me understand. Note that I am a beginner and have very limited knowledge on NGINX.

First let me provide the background.
- Client is sending HTTPS requests (streaming, transfer-encoding: chunked).
- Requests are going via the NGINX load balancer (SSL termination/offloading here).
- NGINX is load balancing requests across 2 backend servers.

If the requests are load balanced based on TCP connections, I believe it works like this:
- NGINX is configured to load balance requests based on TCP connections.
- Client sends HTTPS request (streaming, chunked data) to the NGINX LB. This creates a TCP connection (session).
- NGINX receives the request and decides to send the request to backend-server-1 and creates another TCP connection to backend-server-1.
- All HTTPS requests (chunks) are sent through the same TCP connection and goes to the same backend server.

Now what I'm struggling to understand is, what if NGINX was configured to load balance based on HTTPS requests (assuming this is possible? I'm new to NGINX) instead of TCP connections:
- Client sends HTTPS request to NGINX. A TCP connection (session) is created.
- Client sends multiple HTTP requests (chunked) via the same TCP connection.
- NGINX receives the requests and does what? Since it is load balancing based on HTTPS requests and not TCP connection, does this mean it will load balance the HTTPS requests across backend-server-1 and backend-server-2?
- This would also mean the overall connection will fail, because the different chunks are sent to different backend servers.
- In order for this to work, you would need to use HTTP request load balancing in combination with sticky sessions (e.g. the client would need to send a cookie along with the HTTP request).

I've made an assumption here.
I'm assuming NGINX has a mode/capability of load balancing based on HTTP requests. I see there is a separate page for HTTP Load Balancing and TCP Load Balancing, but I don't actually know if that means it will load balance based on HTTP requests, or if it meant something else.
https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/

If anyone can enlighten me, that would be much appreciated.

Thankyou.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 123
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready