Azure Functions + Azure SQL + Node.js 和请求之间的连接池



我想知道 - 有没有办法在 Azure Functions (Node.js( 请求之间建立 Azure SQL 连接池?

创建连接是我的请求运行总时间的很大一部分,我想知道如何改进它。

繁琐网站上的所有示例 http://tediousjs.github.io/tedious/getting-started.html 打开一个新连接,而我所看到的乏味的连接池 https://github.com/tediousjs/tedious-connection-pool 是为在单个请求的生命周期内使用单个连接池而设计的,而不是在请求之间。

任何建议不胜感激!

我会选择繁琐的连接池路线 - 它旨在在请求之间使用。

在函数作用域之外创建连接池:

// created only on first invocation
let pool = new ConnectionPool(poolConfig, connectionConfig);
module.exports = function(context, trigger) {
   // runs on every invocation, acquiring a connection from the pool
   pool.acquire((err, connection) => {
      ...
   });
}

最新更新