httpnginxhttprequesthttpconnection

What is the relationship between HTTP connection and a request?


While I am configuring my nginx, I found two modules: ngx_http_limit_conn_module and ngx_http_limit_req_module one is for limiting connection per defined key, and one for limiting request.

My question is what is the relationship (and difference) between a HTTP connection and a request. It seems that multiple HTTP requests can use one common HTTP connection, what is the principle under this?


Solution

  • Basically connections are established to make requests using it. So for instance endpoint for given key may accept 5 connections per hour from given IP address. But it doesn't mean only 5 requests can be made but much more - if the connection is not closed after a request (from HTTP 1.1 it's by default kept alive).

    E.g. an endpoint accepts 5 connections and 10 requests from given IP address. If connection is established for every request only 5 requests overall can be made. If connection is kept alive single client may make all the requests. If there are 5 clients, every establishes a connection and keeps it alive there are 2 request approx. that can be made by each client - however one can make all the request if it's fast enough.