- Mais recentes
- Mais votos
- Mais comentários
Five seconds seems like a long time. Have you tried the same operation from an EC2 instance? That might give you an idea as to where the problem might be.
You might also turn on debugging in whichever libraries you're using or perhaps instrument your code using X-Ray. Either way you're trying to track down where the delay is.
The delay could come from DNS resolution; it could come from establishing the TCP session to RDS; it could come from the database itself.
Which RDS flavor are you using? Have you configured the RDS Proxy - https://aws.amazon.com/rds/proxy/faqs/ and is lambda using the RDS Proxy? - https://aws.amazon.com/blogs/compute/using-amazon-rds-proxy-with-aws-lambda/
Also is your RDS inside a VPC and is your lambda VPC enabled?
To improve the performance of reads, have you implemented Read Replicas on your RDS database - https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ReadRepl.html
Also make sure that the database connection is being opened outside of the Event Handler block in your lambda code, as mentioned in the "Take advantage of execution environment reuse to improve the performance of your function" section of Lambda Best Practices, if you haven't done so already - https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html
Apart from implementing the client on an EC2 machine, as Brett has suggested above, if your database is Postgres, MySQL or MariaDB, you may also want to try out installing the same version of the database in an EC2 machine and try accessing that database from your lambda function, just to eliminate that RDS is not the culprit.
Conteúdo relevante
- AWS OFICIALAtualizada há 6 meses
- AWS OFICIALAtualizada há 2 anos