Using NEST (.NET client) with Elastic Cloud

I'm connecting to an Elastic Cloud deployment of Elasticsearch with the NEST client for .NET. The deployment is based on the default "I/O Optimized" template. It has a single "instance", but 2 "zones." I am assuming that this means one "node", and therefore out of the various NEST connection pool options, I should use SingleNodeConnectionPool. Is that correct? "Zones" are a lower-level failover concern and I only ever need to connect to 1 endpoint?

You should use the SingleNodeConnectionPool with Elastic Cloud; the cluster is behind a proxy so the other connection pools like StaticConnectionPool and SniffingConnectionPool won't work as expected.

Thanks Russ, you seem to answer my questions wherever I ask them :slightly_smiling_face:. Appreciate the help!

1 Like

Could you please elaborate a bit more why StaticConnectionPool is not working as it should. I have tried it several times and it worked. Did I was lucky somehow?

I understand that StaticConnectionPool runs pings but haven't faced any issues yet with that. Should I worry though?

@Spyros_Giannopoulos I should have been more specific :smile:

  • SniffingConnectionPool will not work as expected, because the client uses the Uris it's seeded with to make a sniff request to the cluster to find all the nodes in the cluster, using the publish_address (or first bound_address when publish_address is not set) returned as the address use to communicate with a node. The addresses returned for nodes are not publicly reachable however, so this pool should not be used.

  • StaticConnectionPool will work, as it does not issue a sniff request to find all nodes in the cluster. Instead, it will use the Uris that it is seeded with to make requests. In using the StaticConnectionPool over SingleNodeConnectionPool however, you pay a small performance cost associated with the internal implementation round-robin'ing over nodes to select one to issue the request against, in addition to logic that marks nodes as dead and resurrects them after a certain period of time.

So, in the case of Elastic Cloud, or any scenario where the cluster is behind a single endpoint, the best connection pool to use is SingleNodeConnectionPool.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.