Database Layer

Kimura is primarily designed for MySQL 5.x, however the database layer is built on top of PDO so just about every database server is supported.

Database Pools

You can define one or more database pools.  Each database pool contains one or more servers and has the following structure:

  • Name - The name of the pool.
  • Table Prefix - The prefix of each table so you can use a single database for multiple sites and functions.
  • Dead Timeout - When load balancing, this is the number of seconds to wait before retrying a database server that has failed.
  • Load Balance - The load balancing scheme to use which can be "sticky", "round robin", or "random".  When a request is processed, a database connection is retrieved using the type of load balancing.
  • Servers - An array of server definitions
    • Datasource - The connection string to the database in PDO format (protocol:host=?;dbname=?).
    • Username - The username.
    • Password - The password.
    • Persistent - Flag for whether or not to make the connection persistent
    • Connection Timeout - The number of seconds to wait while connecting before the connection is aborted.

Once you've defined your pools, you can associate the pool to a specific type of function.

Databases

The heart of the database layer has two pools: the master and the slave pools. The master pool is used for write operations (insert, update, and delete). If you have a slave pool defined, Kimura will use it for read-only operations otherwise the master pool is used.  With this system, it is easy to set up a master-master replication for the master databases, then have those replicated to a series of slaves for performance.

Load Balancing

If there is more than one server in a particular pool, they can be load balanced by the database layer via round robin, sticky session, or randomly.