AWS Lambda - Java SDK - Connection behavior

Good morning everyone:

I hope you are doing well.

I really appreciate your help with the following: according to the aws lambda function cold start and warm start behaviors, once the execution environment is stablished by AWS, the connection created by the Couchbase Java SDK will be persisted in that execution environment for the subsequent invocations; or, otherwise, it will be created again in the warm start phase (each time the lambda function is invoked)?

AWS lambda cold start and warm start reference: Operating Lambda: Performance optimization – Part 1 | AWS Compute Blog.

@Martin_Chavez the SDK will transparently recreate any connections that are dropped and also will load a new configuration should the topology have changed in the meantine (i.e. rebalance).

So it should work, although you might see initial reconnects in the logs if needed.

If there is anything in your app that you see that does not correlate with that behavior please let us know so we can try to recreate it.


Absolutely @daschl I will let you know if there is something that does not match with that behavior.
Another question related to the same thread is if the lambda function will use the same connection for multiple lambda calls or will create as much connections as invocations. Or what should be the expected behavior in this case?

Thank you so much in advance for your explanations.

@Martin_Chavez if you are using the AWS


then I would recommend to instantiate the client in the constructor and then reuse it across


calls. If you have multiple handlers, it would even be benefitial to share the cluster instance across them all (like a singleton), but that I’m a little unsure if that is possible with the AWS apis.

1 Like

Thank you so much @daschl

1 Like