无服务器预热插件并发执行预热功能
serverless warm up plugin concurrent execution of warmup functions
我得到了 serverless-plugin-warmup 4.2.0-rc.1,可以在无服务器版本 1.36.2 上正常工作
但它只执行一次预热调用而不是配置的五个。
我的 serverless.yml 配置有问题吗?
也很奇怪,我必须在功能部分添加'warmup: true'才能让功能预热。根据 https://github.com/FidelLimited/serverless-plugin-warmup 上的文档,自定义部分的配置应该足够了。
plugins:
- serverless-prune-plugin
- serverless-plugin-warmup
custom:
warmup:
enabled: true
concurrency: 5
prewarm: true
schedule: rate(2 minutes)
source: { "type": "keepLambdaWarm" }
timeout: 60
functions:
myFunction:
name: ${self:service}-${opt:stage}-${opt:version}
handler: myHandler
environment:
FUNCTION_NAME: myFunction
warmup: true
在 AWS Cloud Watch 中,我每 2 分钟只看到一次执行。我希望每 2 分钟看到 5 次处决,还是我误解了什么?
编辑:
现在使用 master 分支并发可以工作,但是现在传递给应该预热的函数的上下文被破坏了:使用 Spring Cloud Functions => "Error parsing Client Context as JSON"
查看生成的预热函数的 JS,交付的源代码看起来不正常 =>
const functions = [{"name":"myFunction","config":{"enabled":true,"source":"\"\\"{\\\\"source\\\\":\\\\"serverless-plugin-warmup\\\\"}\\"\"","concurrency":3}}];
配置为:
custom:
warmup:
enabled: true
concurrency: 3
prewarm: true
schedule: rate(5 minutes)
timeout: 60
添加了 属性 sourceRaw: true 到预热配置,它在 Function JS 中生成一个干净的源。
const functions = [{"name":"myFunctionName","config":{"enabled":true,"source":"{\"type\":\"keepLambdaWarm\"}","concurrency":3}}];
配置:
custom:
warmup:
enabled: true
concurrency: 3
prewarm: true
schedule: rate(5 minutes)
source: { "type": "keepLambdaWarm" }
sourceRaw: true
timeout: 60
我得到了 serverless-plugin-warmup 4.2.0-rc.1,可以在无服务器版本 1.36.2 上正常工作
但它只执行一次预热调用而不是配置的五个。
我的 serverless.yml 配置有问题吗?
也很奇怪,我必须在功能部分添加'warmup: true'才能让功能预热。根据 https://github.com/FidelLimited/serverless-plugin-warmup 上的文档,自定义部分的配置应该足够了。
plugins:
- serverless-prune-plugin
- serverless-plugin-warmup
custom:
warmup:
enabled: true
concurrency: 5
prewarm: true
schedule: rate(2 minutes)
source: { "type": "keepLambdaWarm" }
timeout: 60
functions:
myFunction:
name: ${self:service}-${opt:stage}-${opt:version}
handler: myHandler
environment:
FUNCTION_NAME: myFunction
warmup: true
在 AWS Cloud Watch 中,我每 2 分钟只看到一次执行。我希望每 2 分钟看到 5 次处决,还是我误解了什么?
编辑: 现在使用 master 分支并发可以工作,但是现在传递给应该预热的函数的上下文被破坏了:使用 Spring Cloud Functions => "Error parsing Client Context as JSON"
查看生成的预热函数的 JS,交付的源代码看起来不正常 =>
const functions = [{"name":"myFunction","config":{"enabled":true,"source":"\"\\"{\\\\"source\\\\":\\\\"serverless-plugin-warmup\\\\"}\\"\"","concurrency":3}}];
配置为:
custom:
warmup:
enabled: true
concurrency: 3
prewarm: true
schedule: rate(5 minutes)
timeout: 60
添加了 属性 sourceRaw: true 到预热配置,它在 Function JS 中生成一个干净的源。
const functions = [{"name":"myFunctionName","config":{"enabled":true,"source":"{\"type\":\"keepLambdaWarm\"}","concurrency":3}}];
配置:
custom:
warmup:
enabled: true
concurrency: 3
prewarm: true
schedule: rate(5 minutes)
source: { "type": "keepLambdaWarm" }
sourceRaw: true
timeout: 60