Skip to content

Instantly share code, notes, and snippets.

@lukebakken
Last active January 29, 2024 10:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save lukebakken/e9392fc96d4e493fcea045e095f96f30 to your computer and use it in GitHub Desktop.
Save lukebakken/e9392fc96d4e493fcea045e095f96f30 to your computer and use it in GitHub Desktop.
RabbitMQ / MQTT TCP Tuning

rabbitmq.config

[
    {rabbit, [
        {background_gc_enabled, true},
        {background_gc_target_interval, 60000},
        {tcp_listeners, [5672]},
        {num_tcp_acceptors, 10},
        {connection_max, infinity},
        {tcp_listen_options, [{backlog, 4096}, {buffer, 1024},
                              {sndbuf, 1024}, {recbuf, 1024}]},
        {ssl_options, [
            {hibernate_after, 5000}
        ]},
    ]},
    {rabbitmq_mqtt, [
        {tcp_listeners, [1883]},
        {num_tcp_acceptors, 10},
        {connection_max, infinity},
        {tcp_listen_options, [{backlog, 4096}, {buffer, 1024},
                              {sndbuf, 1024}, {recbuf, 1024}]},
        {ssl_options, [
            {hibernate_after, 5000}
        ]},
    ]}
].

sysctl values

net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 131072
net.core.somaxconn = 4096
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_mem = 262144 524288 4194304
# NB: default is 30
net.ipv4.tcp_keepalive_intvl = 10
# NB: default is 9
net.ipv4.tcp_keepalive_probes = 4
# NB: default is 60
net.ipv4.tcp_keepalive_time = 60

# https://mrotaru.wordpress.com/2013/10/10/scaling-to-12-million-concurrent-connections-how-migratorydata-did-it/
net.core.wmem_default = 1024
net.core.rmem_default = 1024
net.core.rmem_max = 8192
net.core.wmem_max = 8192
net.ipv4.tcp_rmem = 1024 2048 8192
net.ipv4.tcp_wmem = 1024 2048 8192
net.ipv4.tcp_moderate_rcvbuf = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment