tcpretries.asciidoc 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. [[system-config-tcpretries]]
  2. === TCP retransmission timeout
  3. Each pair of nodes in a cluster communicates via a number of TCP connections
  4. which <<long-lived-connections,remain open>> until one of the nodes shuts down
  5. or communication between the nodes is disrupted by a failure in the underlying
  6. infrastructure.
  7. TCP provides reliable communication over occasionally-unreliable networks by
  8. hiding temporary network disruptions from the communicating applications. Your
  9. operating system will retransmit any lost messages a number of times before
  10. informing the sender of any problem. Most Linux distributions default to
  11. retransmitting any lost packets 15 times. Retransmissions back off
  12. exponentially, so these 15 retransmissions take over 900 seconds to complete.
  13. This means it takes Linux many minutes to detect a network partition or a
  14. failed node with this method. Windows defaults to just 5 retransmissions which
  15. corresponds with a timeout of around 6 seconds.
  16. The Linux default allows for communication over networks that may experience
  17. very long periods of packet loss, but this default is excessive for production
  18. networks within a single data centre as is the case for most {es} clusters.
  19. Highly-available clusters must be able to detect node failures quickly so that
  20. they can react promptly by reallocating lost shards, rerouting searches and
  21. perhaps electing a new master node. Linux users should therefore reduce the
  22. maximum number of TCP retransmissions.
  23. You can decrease the maximum number of TCP retransmissions to `5` by running
  24. the following command as `root`. Five retransmissions corresponds with a
  25. timeout of around six seconds.
  26. [source,sh]
  27. -------------------------------------
  28. sysctl -w net.ipv4.tcp_retries2=5
  29. -------------------------------------
  30. To set this value permanently, update the `net.ipv4.tcp_retries2` setting in
  31. `/etc/sysctl.conf`. To verify after rebooting, run
  32. `sysctl net.ipv4.tcp_retries2`.
  33. IMPORTANT: This setting applies to all TCP connections and will affect the
  34. reliability of communication with systems outside your cluster too. If your
  35. cluster communicates with external systems over an unreliable network then you
  36. may need to select a higher value for `net.ipv4.tcp_retries2`. For this reason,
  37. {es} does not adjust this setting automatically.
  38. ==== Related configuration
  39. {es} also implements its own internal health checks with timeouts that are much
  40. shorter than the default retransmission timeout on Linux. Since these are
  41. application-level health checks their timeouts must allow for application-level
  42. effects such as garbage collection pauses. You should not reduce any timeouts
  43. related to these application-level health checks.
  44. You must also ensure your network infrastructure does not interfere with the
  45. long-lived connections between nodes, <<long-lived-connections,even if those
  46. connections appear to be idle>>. Devices which drop connections when they reach
  47. a certain age are a common source of problems to Elasticsearch clusters, and
  48. must not be used.