简体   繁体   English

Lambda function 查询 AWS Athena 给出超时

[英]Lambda function to query AWS Athena gives timeout

I have written a Lambda function using athena-express that queries AWS Athena with S3 Parquet files as destination.我使用athena-express编写了一个 Lambda function ,它使用 S3 Parquet 文件作为目标查询 AWS Athena。 Also using AWS Glue for ETL processes to S3.还将 AWS Glue 用于 S3 的 ETL 流程。 I am receiving: " Task timed out after 6.01 seconds ".我收到:“任务在 6.01 秒后超时”。 Increasing the timeout gives me the same message but with higher amount of timeout seconds.增加超时会给我相同的消息,但超时秒数更高。 The strange thing is that it works locally, but not when it's deployed to AWS.奇怪的是它可以在本地工作,但在部署到 AWS 时就不行。 Code should work.代码应该可以工作。 I think something is missing in AWS configurations.我认为 AWS 配置中缺少一些东西。

I have followed the instructions and using lambda settings: https://www.npmjs.com/package/athena-express .我已按照说明使用 lambda 设置: https://www.npmjs.com/package/athena-express I have added AmazonAthenaFullAccess and AmazonS3FullAccess policies to the Execution role for the Lambda function.我已将 AmazonAthenaFullAccess 和 AmazonS3FullAccess 策略添加到 Lambda function 的执行角色

When you say it works locally I assume that when you run it locally you have no timeout on the code.当您说它在本地工作时,我假设当您在本地运行它时,您的代码没有超时。 Athena is not a low latency database, and queries very rarely run in less than a few seconds, and often in minutes – it all depends on how much data they scan and other factors. Athena 不是一个低延迟的数据库,查询很少会在几秒钟内运行,通常在几分钟内运行——这完全取决于它们扫描的数据量和其他因素。

Your Lambda function must have a timeout that is longer than the longest run time of the queries you run with it.您的 Lambda function 的超时时间必须长于您使用它运行的查询的最长运行时间。 If those queries run for more than a minute, the timeout must be more than a minute, if they run for more than ten minutes, your timeout must be more than ten minutes, and so on.如果这些查询运行超过一分钟,则超时必须超过一分钟,如果它们运行超过十分钟,您的超时必须超过十分钟,依此类推。

In general, long running queries is not a great fit for Lambda and API Gateway that are made for more low latency situations.通常,长时间运行的查询不太适合为更低延迟情况而设计的 Lambda 和 API 网关。 Since your queries seem to run for minutes I suggest that you look other ways of solving your problem.由于您的查询似乎运行了几分钟,我建议您寻找其他解决问题的方法。 If you provide more context about what you are trying to do, we may be able to help you with that.如果您提供有关您正在尝试做的事情的更多背景信息,我们可能会为您提供帮助。

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

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