Sometime we see that the DNS resolution takes a lot of time (around 6-8 seconds) and we want to avoid the DNS lookup while making the n1ql query. We are running our app in docker container and the couchbase database is on a separate network. How should we connect to couchbase cluster in order to avoid DNS lookup for n1ql query. Will couchbase://ip1,ip2,ip3 help in avoiding the DNS lookup or is there a way we can provide a list of node and ip mapping which can avoid DNS lookup?
The SDK will still need to resolve whatever you put in the connection string, and then also resolve the hostnames returned in the cluster map once the initial connection has been made.
If there’s a problem with slow DNS lookups then you’d be better investigating that. If you can’t make any improvements there then perhaps you could look at adding entries to the local hosts file, but then there’s maintenance overhead if any of the hosts change at all.
A DNS lookup occurs whenever a query connection is created. The frequent lookups are necessary for dynamic environments (i.e. cloud) where the addresses might change. Query connections are not created for every query. Idle http connections will be closed after 1 second. That may be extended somewhat with idleHttpConnectionTimeout - but the server will still close the connection (after five seconds?) regardless of the value of idleHttpConnectionTimeout. Using the IP address might help.