Skip to content

Instantly share code, notes, and snippets.

@chexov
Forked from jedi4ever/gist:903751
Last active August 29, 2015 14:28

Revisions

  1. @jedi4ever jedi4ever created this gist Apr 5, 2011.
    93 changes: 93 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,93 @@
    # /etc/security/limits.conf
    * soft nofile 999999
    * hard nofile 999999
    root soft nofile 999999
    root hard nofile 999999

    ===========================================================
    # /etc/sysctl.conf
    # sysctl for maximum tuning

    # https://klaver.it/linux/sysctl.conf
    # http://www.kegel.com/c10k.html
    # http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1/
    # https://gist.github.com/243632 - vmsappiness
    # http://blog.urbanairship.com/blog/2010/09/29/linux-kernel-tuning-for-c500k/
    # https://groups.google.com/forum/#!topic/nodejs/0Z34PH_R88o/discussion
    # http://serverfault.com/questions/10852/what-limits-the-maximum-number-of-connections-on-a-linux-server
    # http://fasterdata.es.net/fasterdata/host-tuning/linux/
    # http://ubuntuforums.org/showthread.php?t=1198281

    # Increase size of file handles and inode cache
    fs.file-max = 999999


    # Allowed local port range
    net.ipv4.ip_local_port_range = 1024 65535

    ###
    ### TUNING NETWORK PERFORMANCE ###
    ###

    # Do a 'modprobe tcp_cubic' first
    net.ipv4.tcp_congestion_control = cubic

    # Turn on the tcp_window_scaling
    net.ipv4.tcp_window_scaling = 1

    # Increase the maximum total buffer-space allocatable
    # This is measured in units of pages (4096 bytes)
    net.ipv4.tcp_mem = 65536 131072 262144
    net.ipv4.udp_mem = 65536 131072 262144

    # Increase the read-buffer space allocatable
    net.ipv4.tcp_rmem = 8192 87380 16777216
    net.ipv4.udp_rmem_min = 16384
    net.core.rmem_default = 87380
    net.core.rmem_max = 16777216

    # Increase the write-buffer-space allocatable
    net.ipv4.tcp_wmem = 8192 65536 16777216
    net.ipv4.udp_wmem_min = 16384
    net.core.wmem_default = 65536
    net.core.wmem_max = 16777216

    #############################
    # General gigabit tuning:
    #net.core.rmem_max = 16777216
    #net.core.wmem_max = 16777216
    #net.ipv4.tcp_rmem = 4096 87380 16777216
    #net.ipv4.tcp_wmem = 4096 65536 16777216

    #setting this to 1 -> possible SYN flooding on port 8080. Sending cookies.
    net.ipv4.tcp_syncookies = 0

    # this gives the kernel more memory for tcp
    # which you need with many (100k+) open socket connections
    net.ipv4.tcp_mem = 50576 64768 98152
    net.core.netdev_max_backlog = 30000
    # I was also masquerading the port comet was on, you might not need this
    # net.ipv4.netfilter.ip_conntrack_max = 1048576

    ###############################
    #
    net.ipv4.tcp_max_tw_buckets = 360000
    net.core.netdev_max_backlog = 2500
    vm.min_free_kbytes = 65536
    vm.swappiness = 0

    net.ipv4.tcp_tw_recycle = 0
    net.ipv4.tcp_tw_reuse = 0
    net.ipv4.tcp_orphan_retries = 1
    net.ipv4.tcp_fin_timeout = 25
    #raise this high
    net.ipv4.tcp_max_orphans = 819200

    # http://simonhf.wordpress.com/2010/10/01/node-js-versus-sxe-hello-world-complexity-speed-and-memory-usage/
    net.core.somaxconn = 65535


    net.ipv4.tcp_no_metrics_save = 1

    net.ipv4.tcp_max_syn_backlog = 20480