Skip to content

Dynamo DB connection during run time #787

Answered by ran-isenberg
abel-dan asked this question in Q&A
Discussion options

You must be logged in to vote

hey @abel-dan , thanks for asking a question and welcome to the amazing world of serverless :)

As you can see, there's a decorator in line 23 for cache and class itself is a singleton. That means that we create only one client class (until the cache expires) and reuse it as long as the function is warm for new invocations.
It's not set in stone to init that connection as AWS recommends, i did a lazy init here and afterwards its warm for new invocation. I dont think there's a difference in performance. TBH, putting way too things that init during the first run isnt that useful in my view and breaks the architectural layers model i discuss at : https://www.ranthebuilder.cloud/post/learn-how…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ran-isenberg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants