Use a connection pool
This should both fix cases where the connection closes for various reasons, by having the pool reconnect; and also should be a second way of solving some of the blocking issues we were having with large queries, by letting faster queries use parallel connections. Idk what a reasonable number is, 10 seems to be what various guides are saying? Might tune it down if it ends up pushing various connection limits? (We could also constrain it on dev specifically, if that matters.)
This commit is contained in:
parent
ca812784a6
commit
4ed6344b3d
1 changed files with 2 additions and 1 deletions
|
@ -35,12 +35,13 @@ async function connectToDb({
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = mysql
|
const db = mysql
|
||||||
.createConnection({
|
.createPool({
|
||||||
host,
|
host,
|
||||||
user,
|
user,
|
||||||
password,
|
password,
|
||||||
database,
|
database,
|
||||||
multipleStatements: true,
|
multipleStatements: true,
|
||||||
|
connectionLimit: 10,
|
||||||
})
|
})
|
||||||
// We upgrade to promises here, instead of using the mysql2/promise import,
|
// We upgrade to promises here, instead of using the mysql2/promise import,
|
||||||
// for compatibility with Honeycomb's automatic tracing.
|
// for compatibility with Honeycomb's automatic tracing.
|
||||||
|
|
Loading…
Reference in a new issue