Knight Magenta
Knight Magenta

Reputation: 171

Hibernate in AWS Lambdas leads to slow startups

I have some AWS Lambda functions that perform database CRUD operations. I have about 20 persistent classes. My application is Spring-based and uses Hibernate for the ORM.

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.

Since a response time of 16 seconds is far too much, I need ways to speed this up. Is there a way to defer Hibernate's metadata parsing or to do it at compile time?

I've taken a look at the JPA metamodel generator, but that seems to be made for building queries at run-time.

Upvotes: 3

Views: 1198

Answers (2)

jhenya-d
jhenya-d

Reputation: 399

triggering lambda using cloudWatch can be solution, after first cold start it will be "running" about 40 minutes from last execution, just setup trigger event for lambda each 30-40 minutes.

Upvotes: 0

v.ladynev
v.ladynev

Reputation: 19956

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.

It shouldn't take so much time. The reason is other, I think. Probably Hibernate schema validation is enabled.

Upvotes: 1

Related Questions