-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Diagnostics about Elasticsearch client sockets #134362
Comments
Pinging @elastic/kibana-core (Team:Core) |
After experimenting a bit with elasticsearch-js client and with Node's Http Agents, the concepts are much more clear in my head now. Just to make sure we are all in the same page: ATM connections will be reused if they are idle*. The maxSockets parameter determines how many concurrent sockets the agent can have open per origin. The maxTotalSockets is a more global limit that applies to all origins of the connections managed by the agent. When calling Node's http.request(), the corresponding agent first checks the pool matching the desired origin to see if there are any idle sockets available. If there aren't any, it will check Let's say we have an Agent that connects to ES nodes A, B and C, and we define *socket still open thanks to the keepAlive, but no request or response travelling through. |
Currently, we are creating multiple elasticsearch-js Client instances, through Kibana's ClusterClient class. Core elasticsearch service's contract exposes a method to createClient(...) that accepts a Each of the elasticsearch-js's Thus, with the current implementation, each agent is targeting only a single origin, and it will manage a single pool of sockets:
As a result, in our deployments we have a bunch of elasticsearch-js's Client instances, each one using multiple agents (one per ES node). This makes it quite difficult to monitor (let alone limit) the number of open connections. |
With that in mind, we can consider multiple initiatives:
|
Would having all the instantiated client share a common parent to reuse the same I guess not, given the |
@pgayvallet yes, that works. When calling |
Hum, good to know. So in theory, we could have a way for all ES client instances to use the same connection pool (so connection, and therefore agent, if I followed correctly) by having all the client created within We would need to check if all the options we're using (in |
Wait, not so fast. It works in the sense that it allows sharing the Agent + pools across the instances. Plus there is the problem that the |
The Elasticsearch-js client is currently configured to use
maxSockets: Infinity
which means connections aren't being re-used causing every outgoing connection to have to establish a new connection + TLS. We know we need to reduce this value but it's really hard to choose an appropriate number.In order to tune this value we need to expose the number of actual sockets used by the http agent that the Elasticsearch-js client is using. That way we could log a warning when Kibana hits the limit. If at the limit the event loop is still really healthy then performance could be improved by increasing the number of sockets.
In addition to a warning when we're at the limit, it would be useful to expose the number of sockets as part of our monitoring data as well as through the
ops.metrics
logger.Context:
#112756 (comment)
The text was updated successfully, but these errors were encountered: