| Apache Cayenne > Index > Cayenne FAQ > Connection Pools |
In Cayenne Modeler, you can specify a maximum number of database connections for Cayenne to use when configuring the DataNode. Extra connections are created - up to the maximum number specified - when all currently open connections are busy. This allows Cayenne-based applications to run multiple simultaneous queries to the database and to stay more responsive (especially important in web applications). Also, since the maximum connections is defined at the DataNode level, if you have multiple DataNodes, each DataNode will have a separate connection pool.
Cayenne will also periodically close unused database connections if it determines there are too many that are open and idle. Because of this you may see in your logs that Cayenne is opening more connections than the "maximum" allowed, but this just means that it has closed some along the way. The maximum number is for concurrent connections and not the total number of connections allowed during the life-span of the application. If you are curious on the algorithm used to close idle connections, look at the PoolManager.PoolMaintenanceThread inner class.