1Perlbal::Manual::LoadBaUlsaenrceCro(n3t)ributed Perl DocPuemrelnbtaalt:i:oMnanual::LoadBalancer(3)
2
3
4

NAME

6       Perlbal::Manual::LoadBalancer - Using Perlbal as a Load Balancer
7
8   VERSION
9       Perlbal 1.78.
10
11   DESCRIPTION
12       How to configure a Perlbal Load Balancing service.
13
14   READ ME FIRST
15       Please read Perlbal::Manual::Configuration first for a better
16       explanation on how to configure Perlbal. This document will make much
17       more sense after reading that.
18
19   Using Perlbal as a Load Balancer
20       For a better understanding of how to set up Perbal as a Load Balancer,
21       it should be noted that a Load Balancer and a Reverse Proxy can often
22       be the same thing; not always, but often.
23
24       A Load Balancer is a server (or device) that balances requests across a
25       number of servers to spread the load. A Reverse Proxy can still do this
26       but also have a number of other features.
27
28       Perlbal as a Reverse Proxy provides features such as buffering content,
29       preserving connections to the backend servers, starting connections
30       ahead of time and a high priority queue, among others.
31
32       You could almost say that a Load Balancer is a subset of a Reverse
33       Proxy (it's not, but you could).
34
35       When it comes to Perlbal, the Load Balancer is implemented as a Reverse
36       Proxy without all the extra options, and that's why you set the role of
37       a Load Balancer to "reverse_proxy":
38
39           SET role            = reverse_proxy
40
41       Simple load balancing
42
43       Let's assume you want to configure two machines to serve your website
44       and you want to let Perlbal decide how to balance the requests. For the
45       sake of this exercise let's assume you have two servers at:
46
47           10.0.0.1:80
48           10.0.0.2:80
49
50       And now you want to use these two machines to serve your website at:
51
52           10.0.0.3:80
53
54       Here's a sample configuration to make this happen:
55
56           CREATE POOL mywebsite
57               POOL mywebsite ADD 10.0.0.1:80
58               POOL mywebsite ADD 10.0.0.2:80
59
60           CREATE SERVICE service_mywebsite
61               SET role            = reverse_proxy
62               SET pool            = mywebsite
63               SET listen          = 10.0.0.3:80
64           ENABLE service_mywebsite
65
66       The first line defines a pool of machines called "mywebsite". The
67       second and third lines add your two machines to that pool (note that
68       the indentation is not mandatory).
69
70       After that you define a service called "service_mywebsite" with the
71       role "reverse_proxy" set to listen on "10.0.0.3:80" and using the pool
72       "mywebsite" to serve the requests.
73
74       The last line is what allows you have several services configured in a
75       file even if they are not currently active (a common scenario is to
76       configure everything on the file and then enable/disable services on-
77       the-fly as required; see Perlbal::Manual::Management for more
78       information on this process).
79
80       The Load Balancing algorithm
81
82       Perlbal uses a highly efficient load balancing algorithm. It is very
83       effective for distributing dynamic web requests among potentially
84       heterogeneous hardware.
85
86       First, backend servers must have their MaxClients (for apache, or
87       equivalent) setting tuned to a reasonable limit. If your hardware can
88       run 20 requests in parallel before running out of CPU, set MaxClients
89       to 20.
90
91       Next, by default Perlbal will distribute requests randomly. Opening a
92       new connection to any available backend, and issuing the request.
93
94       The proper algorithm is able to be used if "verify_backend",
95       "backend_persist", "backend_persist_cache", and "connect_ahead" are
96       enabled.
97
98           SET persist_backend       = on
99           SET verify_backend        = on
100           SET backend_persist_cache = 5
101           SET connect_ahead         = 2
102
103       In this configuration, Perlbal will only route client requests to
104       backends that it knows are real processes, instead of the OS listen
105       queue. It will attempt to reuse pre-verified backends, and will attempt
106       to create slightly more idle connections than it needs in preparation
107       of future requests.
108
109       When you put all this together, it becomes less likely that a client
110       will wait for Perlbal to find an available backend. By setting your
111       MaxClients properly, backends are able to serve traffic without getting
112       overwhelmed. If no backends are available, Perlbal will queue them
113       internally, rather than overload backends.
114
115       You would want to disable "verify_backend" if you are balancing across
116       image servers, or other extremely lightweight requests.
117
118   SEE ALSO
119       Perlbal::Manual::Configuration, Perlbal::Manual::FailOver,
120       Perlbal::Manual::Management, Perlbal::Manual::ReverseProxy.
121
122
123
124perl v5.38.0                      2023-07-19  Perlbal::Manual::LoadBalancer(3)
Impressum