不要怂,就是干,撸起袖子干!

Commit 5ac10132 by Jeremy Morton Committed by Mick Hansen

Improved documentation on connection pools (#6676)

* Update sequelize.md

Added min/max connections documentation.

* Update getting-started.md

Clarified multiple processes with multiple instances.

* Update sequelize.md

Added default for idle timeout
1 parent 9731d130
......@@ -62,9 +62,9 @@ var sequelize = new Sequelize('mysql://localhost:3306/database', {})
| [options.native=false] | Boolean | A flag that defines if native library shall be used or not. Currently only has an effect for postgres |
| [options.replication=false] | Boolean | Use read / write replication. To enable replication, pass an object, with two properties, read and write. Write should be an object (a single server for handling writes), and read an array of object (several servers to handle reads). Each read/write server can have the following properties: `host`, `port`, `username`, `password`, `database` |
| [options.pool={}] | Object | Should sequelize use a connection pool. Default is true |
| [options.pool.max] | Integer | |
| [options.pool.min] | Integer | |
| [options.pool.idle] | Integer | The maximum time, in milliseconds, that a connection can be idle before being released |
| [options.pool.max] | Integer | Maximum number of connections in pool. Default is 5 |
| [options.pool.min] | Integer | Minimum number of connections in pool. Default is 0 |
| [options.pool.idle] | Integer | The maximum time, in milliseconds, that a connection can be idle before being released. Default is 10000 |
| [options.pool.validateConnection] | Function | A function that validates a connection. Called with client. The default function checks that client is an object, and that its state is not disconnected |
| [options.quoteIdentifiers=true] | Boolean | Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of them. |
| [options.transactionType='DEFERRED'] | String | Set the default transaction type. See `Sequelize.Transaction.TYPES` for possible options. Sqlite only. |
......
......@@ -14,7 +14,7 @@ $ npm install --save tedious // MSSQL
## Setting up a connection
Sequelize will setup a connection pool on initialization so you should ideally only ever create one instance per database.
Sequelize will setup a connection pool on initialization so you should ideally only ever create one instance per database if you're connecting to the DB from a single process. If you're connecting to the DB from multiple processes, you'll have to create one instance per process, but each instance should have a maximum connection pool size of "max connection pool size divided by number of instances". So, if you wanted a max connection pool size of 90 and you had 3 worker processes, each process's instance should have a max connection pool size of 30.
```js
var sequelize = new Sequelize('database', 'username', 'password', {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!