The configuration file stores the information that the daemon needs to connect to the databases, to accept clients, and more.
This section encloses some general and behavioural information for the daemon. Lets see
daemon.reader-port=6666 daemon.writer-port=6666 daemon.host=localhost daemon.writer-transaction-per-request=false daemon.init-threads=5 daemon.min-threads=5 daemon.max-threads=30 daemon.init-db-connections=5 daemon.min-db-connections=5 daemon.max-db-connections=30 daemon.reaper-delay=1 daemon.user=daniel daemon.password=daniel daemon.dbname=testdb daemon.auth-method=password
reader-port: This element defines the port in which the daemon will listen when configured as reader. The users connecting thru the daemon will have to set their options to use this port ("port=6666" included in the connection options).
writer-port: This element defines the port in which the daemon will listen when configured as writer. The parameters for reader and writer mode are different to keep the possibility of sharing a config file for both daemons.
host: Defines the host name to which the bind is going to be done, while listening. The values "local" or "localhost" will make the daemon to listen on a UNIX socket. Any other value will make it to listen on INET socket, currently to INADDR_ANY.
writer-transaction-per-request: This parameter defines if a new trasaction is going to be created each time a connection is assigned to a client. This transaction protects backends synchronization by rollbacking every backend when any of them fails to get and update. This may or may not be a desirable behaviour so it's disabled by default, but can be enabled by assigning this parameter to true..
min-threads: The minimum number of threads that the thread pool will handle. When the client requests load is inexistent or very low, the number of threads will gradually move to this number.
init-threads: The initial number of threads spawned in the thread pool, just after the daemon startup.
min-threads: The minimum number of threads that the thread pool will handle. When the client requests load is inexistent or very low, the number of threads will gradually move to this number.
max-threads: As a complement to the previous parameter, this one marks the maximum number of threads that the thread pool will keep spawned simultaneously. This number is likely to be reached when the daemon serves a high number of clients or long running client connections.
init-db-connections: This parameter is similar to init-threads, but it controls the initial number of database backend connections that are opened at startup. This number of connections is opened in every backend, so the real connection number initially active is number_of_backends x init-db-connections. The same rule applys to the other two connection parameters.
min-db-connections: This parameters marks the minimum number of connections that will be kept open in every backend in the lowest load case.
max-db-connections: The maximum number of connections that we'll reach in every backend.
reaper-delay: During the normal daemon operation there are two periodic task that should be accomplished:
The first one is to check if the database connections and thread number are enough or too much to handle the current load. For this the daemon checks the request queue size.
The second one is to check the database connection status. There's some posibility that a backend fails and thus all the connections allocated there became faulty. This task checks this and tries to recover those connections previously detected as faulty.
user: The username that will have to be used to connect to the daemon. This is the username that the clients will have to supply when starting the connection.
password: Password that the daemon will require to connect. If the auth method is trust, then this value is not used for anything.
dbname: Database name that the daemon will require to connect. Previosly to defining this parameter the daemon accepted any dbname, always forwarding connections to the only pool. As this could lead to confusions, this parameter will have to be used to stand clear that there is only ONE database in the pool. Maybe in the future will be supported to serve more than one db in the pool.
auth-method: This parameter can take two values (trust|password) defining the method the daemon will require the clients to use.
This are, with the Daemon section, the most important sections of the file. They define the backends data, needed to connect to them. There will be one of these elements for each database backend. All the parameters are read sequentially so they are meant to be related to the machine.host which is located before them. A common machine is like this:
machine.host=localhost machine.dbname=dbbalancer machine.port=5432 machine.dbuser=daniel machine.dbpassword=daniel
host: The hostname this backend resides. The names "local" or "localhost" will mean that the backend is listening thru UNIX sockets.
dbname: The name of the database
port: The port in which the postmaster is listening.
dbuser: The user needed to connect to the database.
dbpassword: The password for this user.