tcpretries.asciidoc 2.5 KB

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