1
votes

I have written a Lambda function using athena-express that queries AWS Athena with S3 Parquet files as destination. Also using AWS Glue for ETL processes to S3. I am receiving: "Task timed out after 6.01 seconds". 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. Code should work. I think something is missing in AWS configurations.

I have followed the instructions and using lambda settings: https://www.npmjs.com/package/athena-express. I have added AmazonAthenaFullAccess and AmazonS3FullAccess policies to the Execution role for the Lambda function.

1
Is your lambda in a vpc? - Marcin
what is the timeout set for the lambda function ? Also check the outbound connection of the security group in which lambda is deployed i.e port 443 is added for outbound or not ? If already added and inside vpc then refer docs.aws.amazon.com/athena/latest/ug/… - error404
Yes, lambda is in VPC and timeout is set to 6 seconds. I changed it to 60 seconds and it showed same error e.g. "Task timed out after 60.06 seconds". "All TCP" and 0 - 65535 is added to outbound. I will check that article. Let me check and come back! Thanks! - karvex
That's what I had suspected the issue is with the way aws is trying to connect to athena services it would wait for timeout to reach in such cases..6 sec is too short..keep it for 1 min for time being...I would suggest you to check the route tables for this as all the ports are opened. Also the easy way would be to create an ec2 with the same settings and then hit the request to athena using aws cli - error404
We will try another solution than Athena. Feels that we have chosen wrong service for our purpose if it is > a couple of seconds. We are gonna do queries directly on S3 bucket with parquetjs-lite. Hope we won't have the same problem. We will try to create ec2 as you suggested if we get the same error. Thanks a lot so far! - karvex

1 Answers

1
votes

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.

Your Lambda function must have a timeout that is longer than the longest run time of the queries you run with it. 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. 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.