Chapter 4. Architectures: How to use it?

Table of Contents
A connection pool
A load balancing connection pool
Load balancing connection pool with database replication

In this section we'll describe different ways in which DBBalancer could be useful, along with the configurations needed to achieve the desired results.

A connection pool

This is the most easy, and probably most used configuration. A simple connection pool, where several connections to only one host are opened and shared at startup, can be set up with a configuration file like this:

daemon.reader-port=6666
daemon.writer-port=6666
daemon.host=localhost

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.auth-method=password

machine.host=localhost
machine.dbname=dbbalancer
machine.port=5432
machine.dbuser=daniel
machine.dbpassword=daniel



The command to execute the daemon with this configuration is ./DBBalancerDaemon -rf test/config_examples/ConnectionPoolExample.conf. We can use the connections we get from the pool to read or write data, and every PostgreSQL feature is available.