Hi @ingenthr,
Thanks for the reply. I will try turning up the log level today and providing some debug with timings.
When you say “turn up the log level” do you mean as per the instructions under “Changing log levels” on this page? I assume the “cluster” component is most relevant? Looking in the static_config file, loglevel_cluster is already set to debug (the default) so I think it’s already at the correct level.
Assuming the log level is at the correct level, which is the most relevant log file? I have looked at all the logs /opt/couchbase/var/lib/couchbase/logs when running my test but none of them seem to be particularly relevant to this. In fact, a grep for “couchbase:” is empty.
I’ve written a simple test app that just opens the couchbase cluster with one of the two protocols, connects to a bucket, runs a simple ViewQuery (limited to one result, rather than 0, to prove it’s actually connected) and closes the bucket. I have used console.time to time how long it takes between “new couchbase.Cluster” and “bucket.on(‘connect’)”. I can attach the test app if required. The results are as follows:
$ node cbTest.js http
Connecting to couchbase with url http://localhost:8091
cbtest: 2.991ms
Bucket open
Query returned 1 IDs
$ node cbTest.js
Connecting to couchbase with url couchbase://localhost
cbtest: 5841.208ms
Bucket open
Query returned 1 IDs
As you can see, using http it takes around 3ms, whereas using couchbase: takes around 6 seconds. Quite a difference!
This test is repeatable and the results are always similar.
If you can let me know which log file to check I can upload it.
Thanks,
Giles
p.s. As an aside, I have run this test code on three other machines, one Macbook Pro, and two Linux servers, both nodes hosted by Linode. None of these servers shows the same huge difference (I agree with the initial assessment that there’s something strange with the DNS lookup on the first machine, which is also a Linux server) but on all three machines, connecting via http is quicker than connecting via couchbase.
Macbook Pro: http 5.493ms, couchbase 24.734ms
Linux server 1: http: 6.466ms, couchbase 10.857ms
Linux server 2: http: 7.065ms, couchbase 13.638ms
The difference in timing with these is negligible and I’m not going to lose sleep over them, but I wanted to post them as it goes against @ingenthr’s initial assessment that the couchbase method should be quicker in the majority of cases.