Using libloadbal

You can use the load balancing plugin libloadbal to allow your server
to execute a program when certain thread load conditions are met, so a load
distribution product on the front-end can redistribute the load.

There are two methods that you can use to trigger the load balancer
to increase or decrease load:

Standard

Base
load decisions on the number of queued requests. This is a passive approach.
By letting the queue fill up you are already delaying some requests. In this
case, you want the HighThreshold to be a low value and LowThreshold to be a high value.

Aggressive

Base
load decisions on the number of active threads in the pool. This is designed
to more tightly control the requests so that you would reduce the load before
requests get queued.

Library configuration

To enable the plugin, you must modify magnus.conf manually. This should look something
like this:

Testing

To test the load balancer, you can create an NSAPI plugin that prints
an HTML page and then calls sleep() for a period to simulate
execution time. This way you can build up a simulated load on the server and
ensure that the load balancer commands are working properly.

To configure the sample program

Add a new mime.type so
this isn't run for every request by modifying config/mime.types and adding:

type=magnus-internal/sleep exts=sleep

Create a file in your document root directory with the extension
of .sleep.

It does
not matter if anything is in this file; it is used only as a placeholder.

The argument duration tells the server how long to
sleep for each request in seconds.

Restart your server.

You should now be ready to test
the load balancer plugin. The NSAPI plugin will keep the threads busy long
enough to simulate your desired load. The load balancing plugin is tested
by retrieving the .sleep file you created earlier.