jdbc - Is JDBC the only option to connect to aws hosted rds from aws lambda function
问题描述
Like the title asks, im wondering if the only way of connecting to my aws hosted rds through aws lambda function in java is through a jdbc connection?
Does the aws sdk provide a way of doing this, querying the data and returning results without the need for jdbc?
I've looked through the aws api documentation but nothing is jumping out at me in terms of making a connection through the aws sdk alone, it seems to provide functions on more admin type tasks. .
The reason I ask is in the interest of speed, the jdbc connection takes a few seconds for a connection, but thought if the aws sdk could connect it may be quicker?
解决方案
根据您使用的数据库类型,有不同的选项。如果您想减少连接延迟,您可以考虑使用RDS 代理,它将充当数据库实例的反向代理,并有几个连接可供您使用。它还经过优化,让您可以通过 JDBC 快速建立与它的连接。
如果您使用 Aurora Serverless,您或许可以使用 Data API,它使用 AWS 开发工具包通过 HTTP 向数据库发出请求。您可以在文档中找到更多信息:使用 Data API for Aurora Serverless。
您还可以始终在 lambda 函数中使用连接池,这至少会使暖 lambda 的性能更高,但对冷启动没有帮助。
推荐阅读
- ruby-on-rails - 如何将数组拆分为具有相同值的元素的子数组?(红宝石)
- css - 修改了图形的 css
- javascript - TypeError: Object(...) is not a function in export default createNavigatorFactory
- spring - 如何使用 thymeleaf 和 spring boot 按名称获取特定用户
- python - 将索引分配给矩阵中的真值的有效 numpy 方法
- spring - Spring AOP 代理 - @CacheEvict 在 @Entity 中不起作用(来自 JPA,非 Spring 类)
- google-drive-api - 使用 Google Drive API v3 PHP 按 id 获取文件大小
- c - GDB 在运行时打印不同的值
- qt - QTreeView 和 ScrollArea 大小
- javascript - Javascript 链接