Request Schedulers

Request Schedulers

Request Schedulers

Defining Schedulers

Enfold Proxy can filter incoming connections and use different schedulers. In order to make use of this functionality, first, you must define a scheduler in the eep.ini file:

[scheduler sched1]
vh_host = localhost:8080 localhost:8081
scheduler = leastconns
rules = HEADER1|regexp1
        HEADER2|regexp2

The various options alter the scheduler's configuration as follows:

vh_host
Defines which back-ends to schedule to respond to incoming requests. For a typical Plone setup, these back-ends correspond to ZEO clients.
scheduler

Defines your scheduling algorithm of choice. The different algorithm options are:

leastconns
Route each request to the back-end (from the pool of back-ends enumerated in the vh_host section) with the least number of connections.
roundrobin
Route the first request to the first back-end (enumerated in the vh_host section). Route the second request to the second back-end, route the third request to the third back-end, etc., then cycle back to the first back-end.
random
Route each request to a random back-end (enumerated in the vh_host section).
rules

Defines a list of filtering rules. Enfold Proxy uses the specified scheduler only if all of the rules are matched. The Python code corresponding to this logic is as follows:

regexp1.match(environ[HEADER1]) and regexp2.match(environ[HEADER2]

HEADER1 and HEADER2 are keys in the environment dictionary logged to the proxy.log file at the debug log level.

Associating Schedulers with Hosts

After defining one or more schedulers, you can also define which schedulers to use for a particular host in the eep.ini file like so:

[host website]
vh_host = localhost:8080 localhost:8081
...
schedulers = sched1 sched2

In this example, you must have previously defined schedulers sched1 and sched2 (per the previous section of this document).

If Enfold Proxy's log level is set to debug, it will log the request environment as well as additional scheduling information to the proxy.log file:

SCHEDULER 'sched1' DOES NOT MATCH on criteria 'REMOTE_ADDR|127.0.0.1' for '/content.html'

or:

SCHEDULER 'sched1' MATCH on criteria 'REMOTE_ADDR|127.0.0.1' for '/news.html'

Example

Here's an example configuration that uses ZEO clients localhost:8081 and localhost:8082 for requests originating from our local network 192.168.1.xx, and ZEO clients localhost:8083 for GoogleBot:

[scheduler local]
vh_host = localhost:8081 localhost:8082
scheduler = leastconns
rules = REMOTE_ADDR|^192.168.1.

[scheduler googlebot]
vh_host = localhost:8083
scheduler = leastconns
rules = HTTP_USER_AGENT|Googlebot

[host site]
vh_host=localhost:8080
schedulers = local googlebot

Handling 500 Errors

A proxy definition can also specify some default actions to take when handling 500 errors from the Plone Server. You configure these directly in the eep.ini file. To add an option, just add one of these lines to your proxy definition in the eep.ini file and specify a value.

scheduler_dead_500_ratio
When this percentage of a back-end host's responses are 500 errors, Enfold Proxy marks the host as dead. The minumum value is 5 (%), the maximum is 50 (%), and the default is 20 (%).
scheduler_dead_500_period
How long to wait before zeroing out the scheduler_dead_500_ratio statistics. The default value is 600 (seconds).
scheduler_dead_500_count
When the back-end host returns this many 500 errors in a row, Enfold Proxy marks the host as dead. The default value is 5.