我有一些执行数据库 CRUD 操作的 AWS Lambda 函数。我有大约 20 个持久类。我的应用程序基于 Spring,并使用 Hibernate 作为 ORM。
分配了 1536MB,我的函数从冷启动运行大约需要 16 秒。根据日志,大部分时间是 Hibernate 解析我的 hbm.xml
文件、构建 LoadPlans
,以及一般处理元数据。
由于 16 秒的响应时间太长了,我需要一些方法来加快响应速度。有没有办法推迟 Hibernate 的元数据解析或在编译时进行?
我查看了 JPA metamodel生成器,但这似乎是为了在运行时构建查询。
最佳答案
With 1536MB allocated, my function takes about 16 seconds to run from cold start. According to the logs, most of this time is Hibernate parsing my hbm.xml files, building LoadPlans, and generally processing metadata.
它不应该花那么多时间。我认为原因是其他的。可能启用了 Hibernate 模式验证。
关于java - AWS Lambdas 中的 hibernate 导致启动缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47480975/