Java Couchbase Client Config for higher throughput

I had the same problem.

The first query takes 100-200ms. So all other does not take so long except when you have in one second no more request. Then again if you execute the query it takes 100-200ms but all other request are fast. It is because you have a idle_http_connection_timeout is default to 1000 (1 second). When you recieve every second requests your queries are fast. You can set the idle_http_connection_timeout to 5000 (5 seconds) then when you make a first query it takes 100-200ms but all other queries in that 5 seconds are fast, when you recieve every second request it is fast too only WHEN YOU RECIEVE NO MORE REQUEST IN THAT 5 seconds then it recreates the connection but only for the first query

https://issues.couchbase.com/projects/JSCBC/issues/JSCBC-1223?filter=allopenissues

Here is a quote:

If I recall correctly, that closing of the HTTP connection after 1 second was a mitigation to the Slowloris attack, which affects any HTTP TLS connection. With Capella, I don’t think you can ‘prevent’ this. It’s not a function of the node SDK, but something the cluster-side does to drop the connection. We drop the SDK connection slightly quicker to avoid lots of noise in the logs.

What you could do is issue a keepalive request of some sort on a periodic basis. A healthcheck ping against the query service would do this.

For a production application, it might not be worth it since you’ll likely have many requests happening.