TryGhost / Ghost

Independent technology for modern publishing, memberships, subscriptions and newsletters.
https://ghost.org
MIT License
46.27k stars 10.11k forks source link

How to restrict connection pool size for mysql and/or postgresql? #2709

Closed drnic closed 10 years ago

drnic commented 10 years ago

Could someone please help me with some example configuration for telling mysql or postgresql adapters to use a constrained connection pool size?

It may fix https://github.com/TryGhost/Ghost/issues/863#issuecomment-42486676

I tried the following for mysql within my config.js:

config = {
    production: {
...
        database: {
            client: 'mysql',
            connection: {
                // https://github.com/felixge/node-mysql#connection-options
                database: sql.credentials.name,
                host:     sql.credentials.hostname,
                port:     sql.credentials.port,
                user:     sql.credentials.username,
                password: sql.credentials.password,
                charset  : 'utf8',
                connectionLimit: 3 // limit of the free cleardb spark plan
            }
        },
joshuatalb commented 10 years ago

A quick Google search returned this. The Engine returned by the _createengine() function in most cases has a QueuePool integrated, so this should work.

engine = create_engine('postgresql://me@localhost/mydb', pool_size=20, max_overflow=0)

halfdan commented 10 years ago

@drnic This isn't an issue with Ghost and should either be asked in the Forums or taken from the documentation of knex.js or node-mysql.

drnic commented 10 years ago

Thanks for pointing me to the forums. I'll do Q&A there.

drnic commented 10 years ago

A quick google - doh - showed me the project does document how to manage pool sizes - http://docs.ghost.org/usage/configuration/

I swear I tried to google for this before :)