Elasticsearch http.tcp.keep_count Setting

The http.tcp.keep_count setting in Elasticsearch controls the number of TCP keep-alive probes to send before considering the connection dead. It is part of the TCP keep-alive mechanism used to maintain and verify the status of network connections.

Description

  • Default value: The default value is system-dependent.
  • Possible values: Any positive integer.
  • Recommendations: The optimal value depends on your network environment and requirements. A common range is between 3 and 9.

This setting determines how many unanswered TCP keep-alive probes are sent before Elasticsearch decides that the connection is no longer active. Increasing this value can help in environments with unreliable networks, while decreasing it can lead to faster detection of dead connections.

Version Compatibility

This setting is available in Elasticsearch 7.0 and later versions.

Example

To change the http.tcp.keep_count setting using the cluster settings API:

PUT _cluster/settings
{
  "persistent": {
    "http.tcp.keep_count": 5
  }
}

This change would set the number of TCP keep-alive probes to 5. You might want to increase this value if you're experiencing premature connection closures in a network with occasional packet loss. The effect would be that Elasticsearch becomes more tolerant of temporary network issues before declaring a connection dead.

Common Issues and Misuses

  • Setting the value too low can result in premature termination of valid connections in networks with occasional packet loss.
  • Setting the value too high can lead to unnecessary resource consumption by maintaining dead connections for too long.

Do's and Don'ts

  • Do adjust this setting in conjunction with http.tcp.keep_idle and http.tcp.keep_interval for optimal results.
  • Don't set this value extremely high, as it may delay the detection of truly dead connections.
  • Do consider your network environment and application requirements when adjusting this setting.
  • Don't change this setting without monitoring its effects on your cluster's performance and stability.

Frequently Asked Questions

Q: How does http.tcp.keep_count interact with other TCP keep-alive settings?
A: It works in conjunction with http.tcp.keep_idle (time before sending the first probe) and http.tcp.keep_interval (time between probes). Together, these settings define the behavior of TCP keep-alive mechanism in Elasticsearch.

Q: Can changing http.tcp.keep_count affect Elasticsearch's performance?
A: Yes, it can impact network resource utilization and connection management. A higher value may keep unnecessary connections open longer, while a lower value might cause more frequent connection re-establishments.

Q: Is it necessary to restart Elasticsearch after changing this setting?
A: No, this setting can be changed dynamically using the cluster settings API without requiring a restart.

Q: How can I determine the optimal value for http.tcp.keep_count in my environment?
A: Start with the default value and adjust based on your network conditions. Monitor connection stability and resource usage. If you experience frequent disconnects, consider increasing the value gradually.

Q: Does this setting affect client connections only, or also inter-node communication?
A: This setting primarily affects HTTP client connections to Elasticsearch. For inter-node communication, Elasticsearch uses a separate transport layer with its own configuration settings.

Subscribe to the Pulse Newsletter

Get early access to new Pulse features, insightful blogs & exclusive events , webinars, and workshops.

We use cookies to provide an optimized user experience and understand our traffic. To learn more, read our use of cookies; otherwise, please choose 'Accept Cookies' to continue using our website.