How does couchbase key lookup api work

Let’s say I want to read 10,000 keys. That means I need to send 10,000 http requests (one for each key).

I am guessing that the C# Couchbase SDK does not do 10,000 http requests. Could someone please tell me what it does?

Hey @josh,

Could you expand a bit on what you’re trying to achieve?

There’s multiple ways within the C# Couchbase SDK to retrieve more than one document at the time. You can write queries using the Query service:

You can also try to run tasks concurrently or batch up requests:

Let me know if you have any other questions!

@josh

I’m going to work under the assumption that you are referring to the key/value APIs rather than N1QL query APIs. In which case you are correct, it doesn’t not issue 10,000 HTTP requests. The key/value APIs do not use HTTP at all, in fact. They use a binary protocol based upon the original Memcached protocol which is far more efficient for many small requests than HTTP.

It will issue 10,000 individual requests over this protocol, however each request is small and the requests are distributed across multiple TCP connections to multiple servers. They are also sent across always-on connections, so there is no TCP handshake (unless the connection pool decides to scale up).

My only warning is that if you try to make all 10,000 requests at once it can cause some efficiency issues. I would generally recommend limiting your degree of parallelization. The specific number of simultaneous requests which is optimal is hard to say, however, as it depends on both hardware, network, and use case.