Azure Function:QueueTrigger运行时HttpTrigger API变慢/不可用问题
Azure Function队列触发器运行时HTTP触发器响应缓慢问题排查
我有一个包含HttpTrigger类型API函数和QueueTrigger类型函数的Azure Function项目。当QueueTrigger处理任务时,HttpTrigger API会变得缓慢甚至不可用,推测可能是函数只能同时处理一个任务,但不确定原因,怀疑是某处配置问题。
相关配置
hosts.json
{ "version": "2.0", "extensions": { "queues": { "batchSize": 1, "maxDequeueCount": 2, "newBatchThreshold": 0, "visibilityTimeout" : "00:01:00" } }, "logging": ... "extensionBundle": ... "functionTimeout": "00:10:00" }
其中batchSize设为1,我仅希望QueueTrigger同时处理一个任务,但该配置应该仅作用于队列触发器,不应影响HttpTrigger API?
API的functions.json
{ "bindings": [ { "authLevel": "function", "type": "httpTrigger", "direction": "in", "name": "req", "route": "trpc/{*segments}" }, { "type": "http", "direction": "out", "name": "$return" } ], "scriptFile": "../dist/api/index.js" }
QueueTrigger的functions.json
{ "bindings": [ { "name": "import", "type": "queueTrigger", "direction": "in", "queueName": "process-job", "connection": "AZURE_STORAGE_CONNECTION_STRING" }, { "type": "queue", "direction": "out", "name": "$return", "queueName": "process-job", "connection": "AZURE_STORAGE_CONNECTION_STRING" } ], "scriptFile": "../dist/process-job.js" }
Azure其他相关设置
FUNCTIONS_WORKER_PROCESS_COUNT = 4- Azure横向扩展选项(界面为瑞典语):当前为手动缩放模式,实例数量设置为1,最大突发数为8
更新
- 尝试将最大突发数调整为8,也尝试切换为dynamicConcurrency,但均未解决问题
- 推测是任务占用100%CPU导致API变慢或超时,不受并发设置等影响
内容的提问来源于stack exchange,提问作者Joe
相关产品推荐
相关产品推荐

