# 2382421 - Optimizing the Network Configuration on HANA- and OS-Level

[version]
VERSION=47
DATE=12.03.2024
DESCRIPTION=Optimizing the Network Configuration on HANA- and OS-Level
REFERENCES=https://me.sap.com/notes/2382421

[sysctl]
# This is the size of the SYN backlog.
# To prevent the kernel from using SYN cookies in a situation where lots of
# connection requests are sent in a short timeframe and to prevent a
# corresponding warning about a potential SYN flooding attack in the system
# log, the size of the SYN backlog should be set to a reasonably high value.
# net.ipv4.tcp_max_syn_backlog >= 8192
net.ipv4.tcp_max_syn_backlog = 8192

# net.ipv4.ip_local_port_range
# As HANA uses a considerable number of connections for the internal
# communication, it makes sense to have as many client ports available as
# possible for this purpose.
# At the same time, you need to ensure that you explicitly exclude the ports
# used by processes and applications which bind to specific ports by adjusting
# parameter net.ipv4.ip_local_reserved_ports accordingly.
# If configured correctly, the SAP Host Agent takes care of adjusting this
# parameter and setting it manually is neither recommended nor required.
#
# The SAP Host Agent typically increases the port range to 9000-65499.
# If your port range is significantly different, for example when your lower
# port range starts with port 40000, please check the SAP Host Agent section
net.ipv4.ip_local_port_range =

# net.ipv4.ip_local_reserved_ports
# This parameter specifies the ports which are reserved for known applications.
# You especially also have to specify the standard ports that are used by the
# SAP HANA. To find out which standard ports are used by your SAP HANA please
# refer to SAP Note 2477204.
# Ports listed in this parameter will not be used by automatic port assignment,
# while explicit port allocation behavior is unchanged. 
# If configured correctly, the SAP Host Agent takes care of the standard ports
# used by SAP HANA if the instance numbers are provided accordingly. Setting
# this configuration manually is neither recommended nor required.
net.ipv4.ip_local_reserved_ports =

# net.ipv4.tcp_slow_start_after_idle
# If enabled (=1), provide RFC 2861 behavior and time out the congestion
# window after an idle period. An idle period is defined as the current
# RTO (retransmission timeout). If disabled (=0), the congestion window will
# not be timed out after an idle period.
#
# This setting disables the need to scale-up incrementally the TCP window size
# for TCP connections which were idle for some time. Using this parameter it is
# ensured that the maximum speed is used from beginning also for previously
# idle TCP connections.
#
# This value is important for large ScaleOut HANA clusters and HANA2 in general.
# So disable TCP slow start on idle connections
# set net.ipv4.tcp_slow_start_after_idle=0
#
net.ipv4.tcp_slow_start_after_idle = 0

# net.ipv4.tcp_wmem and net.ipv4.tcp_rmem
# These parameters specify the minimum, default and maximum size of the TCP
# send and receive buffer.
# They are mostly relevant for system replication scenarios with a latency
# higher than usual.
# The maximum value should be equal to at least the bandwidth delay product of
# the relevant connection.
# Both, tcp_wmem and tcp_rmem, are specified as three values separated by
# blanks: minimum, default and maximum buffer size.
# Preconditions for these settings to take effect are:
# * net.core.wmem_max and net.core.rmem_max must not be lower than the
#   respective maximum value.
# * TCP window scaling has been enabled by setting net.ipv4.tcp_window_scaling=1
#
#   Example:
#   net.ipv4.tcp_wmem = 4096 16384 4194304
#
#   In this example, the current maximum is 4 MB. Given a 10 GBit/s connection
#   with a latency of 1 ms, the required maximum would be
#   10 GBit/s * 1ms = 1.25 Mbytes, therefore the current setting is fine.
#   If you want to saturate a 1 Gbit/s connection with a latency of 100 ms, the
#   required maximum is 1 GBit/s * 100 ms = 12.5 Mbyte, so in this case the
#   setting should be adjusted to at least 12.5 MByte.
#   The minimum and the default buffer size do not need to be adjusted.
net.ipv4.tcp_wmem =
net.ipv4.tcp_rmem =

# net.core.wmem_max and net.core.rmem_max
# These settings define the maximum socket send and receive buffer size.
# To ensure complete functionality it must be ensured that the wmem_max and
# rmem_max values are at least the same as the respective maximum value of the
# parameters net.ipv4.tcp_wmem and net.ipv4.tcp_rmem.
net.core.wmem_max =
net.core.rmem_max =

# net.ipv4.tcp_window_scaling
# This setting enables the TCP window scaling.
# On most systems it already should be active. Moreover, it is a prerequisite
# for net.ipv4.tcp_wmem and net.ipv4.tcp_rmem.
#
net.ipv4.tcp_window_scaling = 1

# In landscapes where TCP timestamps are enabled please carefully evaluate if
# the following OS settings can be applied:
#
# net.ipv4.tcp_timestamps
# This setting adds the timestamp field to the TCP header.
# It should already be active on most systems and is a prerequisite for
# net.ipv4.tcp_tw_reuse and net.ipv4.tcp_tw_recycle.
# If you are running on Microsoft Azure depending on your scenario the setting
# of this OS parameter might not be supported. Please refer to the documentation
# provided by Microsoft for details. In this case please adjust the OS
# parameters as recommended by Microsoft. Moreover, please keep in mind that
# parameters net.ipv4.tcp_tw_reuse and net.ipv4.tcp_tw_recycle must also not be
# enabled in such a case.
net.ipv4.tcp_timestamps = 1

# net.ipv4.tcp_tw_reuse
# This setting allows HANA to reuse a client port immediately after the
# connection has been closed, even though the connection is still in TIME_WAIT
# state. A precondition for it to take effect is that TCP timestamps are
# enabled, i.e. net.ipv4.tcp_timestamps = 1, which is the default on most
# modern systems. This setting must not be applied if the HANA node needs to
# communicate with hosts using Network Address Translation (NAT).
# Moreover, it must  not be applied if not all hosts that use a TCP connection
# to communicate with the HANA node have TCP timestamps enabled. Otherwise you
# might encounter TCP connection issues after applying this configuration
# parameter.
# As of SLES 15 SP2 the new option "2" is available which is also the default
# one. In single node systems this new default value is sufficient. If you are
# therefore running on a high enough OS version you should only consider setting
# net.ipv4.tcp_tw_reuse = 1 in case you are running SAP HANA in a scale-out
# setup.
#net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_reuse =

# On SAP HANA 1 Revisions <= 122.14 and on all SAP HANA 2 Revisions
# of SPS00 you additionally need to set the following parameter:
# net.ipv4.tcp_syn_retries
# The default value for this parameter is 5, which translates to a timeout of
# about 24 seconds.
# If the system is under load, a timeout of 24 seconds can be too short and
# lead to avoidable errors.
# It also prevents processes to set a longer timeout. The recommended value is
# 8, which translates into a timeout of 190 seconds.
net.ipv4.tcp_syn_retries = 8

# This parameter limits the size of the accept backlog of a listening socket.
# The Linux default of 128 on systems <= 15SP3 is not sufficient. You need to
# set the parameter to 4096 in order that the HANA system can use higher values.
# There is an interdependency between this parameter and HANA configuration
# parameter tcp_backlog. If net.core.somaxconn is set to a lower value than
# tcp_backlog, tcp_backlog will be silently truncated to the value set for
# net.core.somaxconn. Therefore, you need to ensure that net.core.somaxconn
# is always set to a value equal to or greater than tcp_backlog.
# net.core.somaxconn >= 4096
# On systems >= 15SP4 the default value is sufficient.
net.core.somaxconn =

[sysctl:os=15-SP3]
net.core.somaxconn = 4096
[sysctl:os=15-SP2]
net.core.somaxconn = 4096
[sysctl:os=15-SP1]
net.core.somaxconn = 4096
[sysctl:os=12-SP5]
net.core.somaxconn = 4096

[sysctl:os=12-SP3]
# net.ipv4.tcp_tw_recycle
# This parameter reduces the time a connection spends in the TIME_WAIT state.
# It is not necessary to set it to 1.
#
# It has been removed without substitution as of Linux kernel version 4.12.
# You can therefore not set it anymore when using kernel versions >= 4.12,
# which applies as of SUSE Linux Enterprise Server (SLES) 12 SP4,
# SLES 15 GA and RHEL 8.0.
#
# If you need to enable it for individual reasons, you need to ensure that all
# preconditions are fulfilled, otherwise you might face TCP connection issues:
#  * HANA node must not communicate with hosts using Network Address Translation (NAT)
#  * TCP timestamps must be enabled on the HANA node and all nodes communicating
#    with HANA
#      * for Linux: parameter net.ipv4.tcp_timestamps = 1
#      * for Windows: see SAP Note 2789262
#net.ipv4.tcp_tw_recycle
net.ipv4.tcp_tw_recycle =

[sysctl:os=12-SP2]
# net.ipv4.tcp_tw_recycle
# This parameter reduces the time a connection spends in the TIME_WAIT state.
# It is not necessary to set it to 1.
#
# It has been removed without substitution as of Linux kernel version 4.12.
# You can therefore not set it anymore when using kernel versions >= 4.12,
# which applies as of SUSE Linux Enterprise Server (SLES) 12 SP4,
# SLES 15 GA and RHEL 8.0.
#
# If you need to enable it for individual reasons, you need to ensure that all
# preconditions are fulfilled, otherwise you might face TCP connection issues:
#  * HANA node must not communicate with hosts using Network Address Translation (NAT)
#  * TCP timestamps must be enabled on the HANA node and all nodes communicating
#    with HANA
#      * for Linux: parameter net.ipv4.tcp_timestamps = 1
#      * for Windows: see SAP Note 2789262
#net.ipv4.tcp_tw_recycle
net.ipv4.tcp_tw_recycle =

# net.ipv4.tcp_timestamps for Azure
# This setting adds the timestamp field to the TCP header.
# It should already be active on most systems and is a prerequisite for
# net.ipv4.tcp_tw_reuse and net.ipv4.tcp_tw_recycle.
# If you are running on Microsoft Azure depending on your scenario the setting
# of this OS parameter might not be supported. Please refer to the documentation
# provided by Microsoft for details. In this case please adjust the OS
# parameters as recommended by Microsoft.
[sysctl:csp=azure]
net.ipv4.tcp_timestamps =

[reminder]
# SAP HANA Parameters - all '.ini' file changes - not handled by saptune
# WARNING - on systems with iSCSI devices the setting of 'net.ipv4.tcp_syn_retries = 8'
# may result in deferred faulty message of iSCSI paths.
