【问题标题】:Cube.js timing out in serverless environmentCube.js 在无服务器环境中超时
【发布时间】:2020-08-22 12:57:49
【问题描述】:

我一直按照https://cube.dev/docs/deployment#express-with-basic-passport-authentication 上的指南将 Cube.js 部署到 Lambda。我让它在 Athena db 上运行,这样/meta 端点就可以成功运行并返回模式。

但是,当尝试在 Lambda 中查询 Athena 数据时,所有请求都会导致 504 网关超时。检查 CloudWatch 日志,我看到一个一致的错误:

/bin/sh: hostname: command not found

知道这可能是什么吗?

这是我的 server.yml:

service: tw-cubejs

provider:
  name: aws
  runtime: nodejs12.x
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "sns:*"
        # Athena permissions
        - "athena:*"
        - "s3:*"
        - "glue:*"
      Resource:
        - "*"
  # When you uncomment vpc please make sure lambda has access to internet: https://medium.com/@philippholly/aws-lambda-enable-outgoing-internet-access-within-vpc-8dd250e11e12
  vpc:
    securityGroupIds:
      # Your DB and Redis security groups here
      - ########
    subnetIds:
      # Put here subnet with access to your DB, Redis and internet. For internet access 0.0.0.0/0 should be routed through NAT only for this subnet!
      - ########
      - ########
      - ########
      - ########
  environment:
    CUBEJS_AWS_KEY: ########
    CUBEJS_AWS_SECRET: ########
    CUBEJS_AWS_REGION: ########
    CUBEJS_DB_TYPE: athena
    CUBEJS_AWS_S3_OUTPUT_LOCATION: ########
    CUBEJS_JDBC_DRIVER: athena
    REDIS_URL: ########
    CUBEJS_API_SECRET: ########
    CUBEJS_APP: "${self:service.name}-${self:provider.stage}"
    NODE_ENV: production
    AWS_ACCOUNT_ID:
      Fn::Join:
        - ""
        - - Ref: "AWS::AccountId"

functions:
  cubejs:
    handler: cube.api
    timeout: 30
    events:
      - http:
          path: /
          method: GET
      - http:
          path: /{proxy+}
          method: ANY
  cubejsProcess:
    handler: cube.process
    timeout: 630
    events:
      - sns: "${self:service.name}-${self:provider.stage}-process"

plugins:
  - serverless-express

【问题讨论】:

    标签: aws-lambda amazon-athena cube.js


    【解决方案1】:

    即使此hostname 错误消息也在日志中,但这不是问题原因。 很可能您遇到了here 描述的问题。

    @cubejs-backend/serverless 使用互联网连接访问消息传递 API 以及 VPC 内部的 Redis 以管理队列和缓存。 其中之一在您的环境中不起作用。

    此类超时通常意味着internet connectionRedis connection 存在问题。如果是 Redis,您通常会在 cubejscubejsProcess 函数中看到 5 分钟左右的超时。如果是 Internet 连接,您将永远不会在 cubejsProcess 函数中看到任何查询处理日志。

    【讨论】:

    • 这是正确的。让 Redis 与 Lambda 一起工作是一件很痛苦的事。
    【解决方案2】:

    根据更新日志this issue should have been fixed in 0.10.59检查你正在使用的cube.js版本。

    这很可能归结为 cube.js 的依赖项,假设运行它的所有环境都能够运行hostname shell 命令(看起来它正在使用node-machine-id

    【讨论】:

    • 我更新了项目的package-json和四个依赖——cubejs-backend/athena-driver, cubejs-backend/server, cubejs-backend/serverless, cubejs-backend/serverless-aws -- 都提升到 0.19.61。我的本地系统使用的是 cubejs v0.19.51。同样的错误。
    猜你喜欢
    • 2019-07-09
    • 1970-01-01
    • 1970-01-01
    • 2012-07-17
    • 2021-12-10
    • 2018-09-09
    • 1970-01-01
    • 1970-01-01
    • 2021-11-17
    相关资源
    最近更新 更多