2017-04-05 68 views
0

我想知道 - Azure函数(Node.js)请求之间有Azure SQL连接池吗?Azure函数+ Azure SQL + Node.js和请求之间的连接池?

创建连接是我请求运行总时间的一个重要组成部分,我想知道如何改进它。

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

任何建议表示赞赏!

回答

2

我会去繁琐的连接池路线 - 它被设计为在请求之间使用。

创建连接池的功能范围之外:

// 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) => { 
     ... 
    }); 
} 
0

这可能是澄清的范畴,而是一个重要的考虑因素。

此方法是否适用于在App Service计划中运行的Azure函数以及消费计划(函数调用不保证位于同一主机上)?

+0

您应该将其作为评论发布到OP - 这不是一个答案 – desertnaut

+0

我会想象如果它不存在池将被重新创建... –