The upstream module – Nginx

Closely paired with the proxy module is the upstream module. The upstream directive starts a new context in which a group of upstream servers is defined. These servers may be given different weights (the higher the weight, the greater the number of connections NGINX will pass to that particular upstream server), may be of different types (TCP versus UNIX domain), and may even be marked as down for maintenance reasons.

The following table summarizes the directives valid within the upstream context:

The upstream module directives

Explanation

ip_hash

This directive ensures the distribution of connecting clients evenly over all servers by hashing the IP address, keying on its class-C network.

keepalive

This directive specifies the number of connections to the upstream servers that are cached per worker process. When used with the HTTP connections, proxy_http_version should be set to 1.1 and proxy_set_header to Connection "".

least_conn

This directive activates the load-balancing algorithm where the server with the least number of active connections is chosen for the next new connection.

server

This directive defines an address (domain name or IP address with an optional TCP port, or path to a UNIX-domain socket) and optional parameters for an upstream server. The parameters are as follows:

  • weight: This parameter sets the preference for one server over another

  • max_fails: This parameter is the maximum number of unsuccessful communication attempts to a server within fail_timeout before the server is marked as down

  • fail_timeout: This parameter is the length of time a server has to respond to a request and the length of time a server will be marked as down

  • backup: This parameter will only receive requests once the other servers are down

  • down: This parameter marks a server as not able to process requests

Related Articles

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

read more

Lorem ipsum dolor sit amet consectetur

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

13 + fifteen =