lcb_make_http_request is opening a new socket for each call



I am doing some tests for the views in Couchbase . To query a view I am using lcb_make_http_request method. The problem I have encountered is that for each call of the lcb_make_http_request a new tcp socked is opened on the client side.
The connection instance is created only once using lcb_create and lcb_connect, which opens only one tcp socket, so it’s really the lcb_make_http_request that is creating the other tcp sockets.
Those tcp sockets are not freed immediately after the callback finish, they are kept in a TIME_WAIT state for around 1 minute before they are closed.

When the number of lcb_make_http_request is very high (in my case a loop of > 40000 iterations) after a while the lcb_make_http_request will return the error “Connection failed” , must probably because it has reached the maximum number of sockets it can open.

Can anyone explain if opening one socket per lcb_make_http_request is the right behavior in Couchbase or is there a way to avoid this? And if it is the normal behavior … what could be the solution to be able to do as many lcb_make_http_requests as needed without being limited by the maximum number of sockets the client can open during one minute ?

On the client side I am using the C API libcouchbase-2.0.1 and on the server side Couchbase 2.0.



can anyone answer this question? looks like this issue would be performance bottleneck if it cannot be resolved.


Update to libcouchbase 2.1.3, we have fix for that there