Couchbase .NET SDK Connection Best Practices

What are the recommended best practices for opening connections to the bucket via the SDK using the IBucket interface?

Should connections be opened for only as long as they are required and then closed/disposed? Or is it ok to keep connections open for long periods of time?

Happy signup anniversary! (that’s why you have cake next to your name)

Generally speaking, keep the reference/connection and use it across many threads. The rest is the client’s job. The only exception would be if you’re rarely using it.

@pkramer -

There is some information here regarding connection management. As @ingenthr said, the clients are threadsafe and the best practice is to create/initialize the client when the application starts up and dispose/close the client when the application shuts down. In ASP.NET applications this means tapping into the Application_Start and Application_End event handlers or if you are using OWIN server, you can do this in Startup.cs.


Perfect, thanks for the info!

What protocol does the SDK use to communicate with the cluster?

It uses a mix of memcached binary protocol (which we helped create many years ago) and HTTP.