【问题标题】:serverless warm up plugin concurrent execution of warmup functions无服务器预热插件并发执行预热功能
【发布时间】:2019-09-04 19:52:17
【问题描述】:

我的 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 次处决,还是我在这里误解了什么?

编辑: 现在使用主分支并发可以工作,但是现在传递给应该被加热的函数的上下文被破坏了:Using Spring Cloud Functions => "Error parsing Client Context as JSON"

查看生成的预热函数的 JS 交付的源看起来不ok =>

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

【问题讨论】:

  • 嘿,看起来他们没有发布版本来获得并发预热,您需要将 package.json 指向 repo 中的 master 分支!似乎文档已自动更新,但 npm 版本尚未发布。
  • 是的,所以从检查结果来看,他们实际上正在安装一个主要贡献者作为维护者,因为原来的小伙子太忙了,它阻止了你正在发布的功能正在寻找,现在只需将您的 package.json 指向 repo,如果您需要帮助,请告诉我。
  • 谢谢,并发现在就像一个魅力! "serverless-plugin-warmup": { "version": "git+github.com/FidelLimited/…", "requires": { "bluebird": "3.5.3", "fs-extra": "7.0.1" } }跨度>

标签: aws-lambda serverless-framework serverless aws-serverless


【解决方案1】:

添加属性 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

【讨论】:

    猜你喜欢
    • 2020-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-01
    • 2016-10-13
    • 1970-01-01
    • 2021-08-17
    • 2020-02-06
    相关资源
    最近更新 更多