Prev: Next: Up: Top[Contents][Index]


6 Request balancing

When several backends are defined in a service, incoming requests will be distributed among them. This process is called balancing. By default, requests are distributed equally. This can be changed by assigning them a priority – a positive integer which assigns a relative weight of the given backend in the distribution algorithm. The greater the priority is, the more requests this backend gets from the total flow.

The distribution algorithm is defined by balancing strategy. As of version 4.15, pound supports two strategies: weighted random balancing and interleaved weighted round robin balancing.

Weighted Random Balancing

This is the default strategy. The backend to use for each request is determined at random, taking into account backend priorities, so that backends with numerically greater priorities have proportionally greater chances of being selected than the ones with lesser priorities.

Interleaved Weighted Round Robin Balancing

This strategy cycles over all active backends, considering each one in its turn. An integer ordinal number is assigned to each round, which is incremented (modulo number of backends) each time a new round is started. A backend is assigned a request only if its priority is greater than the round number.

This strategy offers several advantages compared with the previous one. First, it results in a more even distribution of the requests. Secondly, the resulting distribution is predictable.

Overall, the share of requests a given backend receives can be estimated as:

Pi / S(P)

where Pi is the priority of the backend with index i, and S(P) is the sum of all priorities.

Weighted random balancing is used by default. Each backend gets the default priority 5, unless another value is expressly assigned using the Priority statement, e.g.:

Service
    Backend
        Address 192.168.0.1
        Port 80
        Priority 1
    End
    Backend
        Address 192.168.0.2
        Port 80
        Priority 9
    End
End

In this example, backend 192.168.0.2 will receive roughly 9 times more requests than backend 192.168.0.1.

The balancing strategy to use is defined by the Balancer keyword, which can appear either in the global scope or within a Service section. Its argument can be one of:

random

Use weighted random balancing (default).

iwrr

Use interleaved weighted round robin balancing.

The Balancer statement appearing in the global scope defines balancing strategy for all services that don’t have Balancer statement on their own.


Prev: Next: Up: Top[Contents][Index]