简体   繁体   English

Cube.js 在无服务器环境中超时

[英]Cube.js timing out in serverless environment

I've been following the guide on https://cube.dev/docs/deployment#express-with-basic-passport-authentication to deploy Cube.js to Lambda.我一直在按照https://cube.dev/docs/deployment#express-with-basic-passport-authentication上的指南将 Cube.js 部署到 Lambda。 I got it working against an Athena db such that the /meta endpoint works successfully and returns schemas.我让它针对 Athena 数据库工作,以便/meta端点成功工作并返回模式。

When trying to query Athena data in Lambda however, all requests are resulting in 504 Gateway Timeouts.然而,当尝试查询 Lambda 中的 Athena 数据时,所有请求都会导致 504 网关超时。 Checking the CloudWatch logs I see one consistent error:检查 CloudWatch 日志,我看到一个一致的错误:

/bin/sh: hostname: command not found

Any idea what this could be?知道这可能是什么吗?

Here's my server.yml:这是我的 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

Even this hostname error message is in logs however it isn't an issue cause.即使此hostname错误消息也在日志中,但这不是问题原因。 Most probably you experiencing issue described here .很可能您遇到了此处描述的问题。

@cubejs-backend/serverless uses internet connection to access messaging API as well as Redis inside VPC for managing queue and cache. @cubejs-backend/serverless使用 Internet 连接来访问消息传递 API 以及 VPC 内部的 Redis 用于管理队列和缓存。 One of those doesn't work in your environment.其中之一在您的环境中不起作用。

Such timeouts usually mean that there's a problem with internet connection or with Redis connection .此类超时通常意味着Internet 连接Redis 连接存在问题。 If it's Redis you'll usually see timeouts after 5 minutes or so in both cubejs and cubejsProcess functions.如果是 Redis,您通常会在cubejscubejsProcess函数中看到 5 分钟左右的超时。 If it's internet connection you will never see any logs of query processing in cubejsProcess function.如果是 Internet 连接,您将永远不会在cubejsProcess function 中看到任何查询处理日志。

Check the version of cube.js you are using, according to the changelog this issue should have been fixed in 0.10.59 .检查您正在使用的 cube.js 版本,根据更新日志, 这个问题应该已经在 0.10.59 中修复

It's most likely down to a dependency of cube.js assuming that all environments where it will run will be able to run the hostname shell command (looks like it's using node-machine-id .假设它运行的所有环境都能够运行hostname shell 命令(看起来它正在使用node-machine-id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM