举个例子,假设一个Azure Functions App包含一个共享模块,它为某些资源提供了一个全局连接池:
// connection-pool.js
const pool = /* initialize pool ... */
exports.getPool = () => pool以及FunctionsApp中使用共享连接池模块的两个函数:
// fn1/index.js
const pool = require('../connection-pool').getPool()
module.exports = async function (ctx, req) {
// Do something...
}// fn2/index.js
const pool = require('../connection-pool').getPool()
module.exports = async function (ctx, req) {
// Do something...
}在运行时,在Functions App的单个实例中是否会存在1个或2个池?
发布于 2019-10-21 14:28:22
在每个实例中,语言的worker与宿主一起启动,并且在同一实例中,加载的模块位于相同的内存空间中。
请注意,随着函数的扩展,每个实例都会有自己的内存空间。因此,这不适用于您想要存储任何状态的情况。
https://stackoverflow.com/questions/58415324
复制相似问题