Bulk get per node

As far as I understand there does not seem to be any batching per node to get documents by key, only running tasks in parallel per document?

If I want to get 2000 documents, I most likely do not want to do 2000 requests. It would probably be better to batch the number of requests per node.

When looking into the code, the CouchbaseRequestExecuter seems to execute each operation separately where each get operation has a one-to-one relationship to a document. What am I missing?

Hi @Fresa

The .NET SDK’s multiplexing connection implementation opens a TCP socket in full duplex mode which allows concurrent writing and reading. This means we do not block a socket until we receive a response per request and can effectively pipeline multiple operations per connection. Each connection has a dedicated reader thread that processes and coordinates responses back to the originator as they are received.

Creating multiple GetAsync operation tasks and combining with Task.WhenAll is the most efficient way to batch Get requests.

I hope this helps.

Thanks for your reply!

However, doesn’t that still cause a lot of package size overhead and thread delegations/exhaustion compared to grouping the requests per node and using a batching format on protocol level?

I’ve done some tracing comparing getting ~300 documents of ~2kb each by using their keys vs querying with a secondary index, and the querying is equally fast or even faster than fetching the documents by keys, which is a bit surprising. When looking at the traces it seems I get capped by the number of threads/requests I can concurrently execute, which I would expect.