Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Helpful script to speed up vps network connectivity
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Helpful script to speed up vps network connectivity

Hi all,

most of you are probably way more technical than me however i thought i'd share what i enable immediately after i setup a vps to optimize the network speed and in my tests it does work so i created a script and thought i'd share what i enable and my settings, if anyone else has suggestions to add to this happy to hear.

#!/bin/bash
echo 'net.core.wmem_max=12582912' >> /etc/sysctl.conf
echo 'net.core.rmem_max=12582912' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_rmem= 10240 87380 12582912' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_wmem= 10240 87380 12582912' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_window_scaling = 1' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_timestamps = 1' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_sack = 1' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_no_metrics_save = 1' >> /etc/sysctl.conf
echo 'net.core.netdev_max_backlog = 5000' >> /etc/sysctl.conf
echo 'net.ipv4.icmp_echo_ignore_all=1' >> /etc/sysctl.conf
echo 'net.core.default_qdisc=fq' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=bbr' >> /etc/sysctl.conf
sysctl -p
echo 'Done'
Thanked by 1JasonM

Comments

  • yoursunnyyoursunny Member, IPv6 Advocate

    You shouldn't modify /etc/sysctl.conf directly.
    Instead, create a new file in /etc/sysctl.conf.d directory.

  • LisoLiso Member
    edited December 2022

    @yoursunny said:
    You shouldn't modify /etc/sysctl.conf directly.
    Instead, create a new file in /etc/sysctl.conf.d directory.

    Yes each file store single configuration, easier to manage.

    [EDIT] To op, did you know what those command do ?

  • @Liso said:

    @yoursunny said:
    You shouldn't modify /etc/sysctl.conf directly.
    Instead, create a new file in /etc/sysctl.conf.d directory.

    Yes each file store single configuration, easier to manage.

    [EDIT] To op, did you know what those command do ?

    as far as i know enhance tcp packets?

  • I once used this kind of so called Linux optm parameter into sysctl.conf , then my page static resources loading time increases from like 0.3 second to 3 seconds :D

  • happy to hear suggestions or you optimized settings

  • yoursunnyyoursunny Member, IPv6 Advocate

    My setup procedure only enables BBR congestion control.
    I don't fiddle with buffer sizes.

    tee /etc/sysctl.d/80-tcp-bbr.conf <<EOT
    net.core.default_qdisc=fq
    net.ipv4.tcp_congestion_control=bbr
    EOT
    

    net.ipv4.icmp_echo_ignore_all=1

    I keep ICMP echo enabled at all times.
    It's a valuable debugging tool.

    Thanked by 1pbx
  • @yoursunny said:
    My setup procedure only enables BBR congestion control.
    I don't fiddle with buffer sizes.

    tee /etc/sysctl.d/80-tcp-bbr.conf <<EOT
    net.core.default_qdisc=fq
    net.ipv4.tcp_congestion_control=bbr
    EOT
    

    net.ipv4.icmp_echo_ignore_all=1

    I keep ICMP echo enabled at all times.
    It's a valuable debugging tool.

    i drop those and only enable when needed

  • @socialzzz said: optimize the network speed and in my tests it does work so i created a script and thought i'd share what i enable and my settings

    thanks. will give it a try!

    Thanked by 1socialzzz
  • ####BBR
    #sysctl
    sudo cat >> /etc/sysctl.conf <<EOF
    vm.swappiness = 10
    vm.overcommit_memory=1
    fs.file-max = 65536
    net.core.rmem_max = 67108864
    net.core.wmem_max = 67108864
    net.core.rmem_default = 65536
    net.core.wmem_default = 65536
    net.core.netdev_max_backlog = 4096
    net.core.somaxconn = 4096
    net.ipv4.tcp_syncookies = 1
    net.ipv4.tcp_tw_reuse = 1
    net.ipv4.tcp_fin_timeout = 30
    net.ipv4.tcp_keepalive_time = 1200
    net.ipv4.ip_local_port_range = 10000 65000
    net.ipv4.tcp_max_syn_backlog = 4096
    net.ipv4.tcp_max_tw_buckets = 5000
    net.ipv4.tcp_fastopen = 3
    net.ipv4.tcp_mem = 25600 51200 102400
    net.ipv4.tcp_rmem = 4096 87380 67108864
    net.ipv4.tcp_wmem = 4096 65536 67108864
    net.ipv4.tcp_mtu_probing = 1
    net.ipv4.tcp_congestion_control = bbr
    net.core.default_qdisc = cake
    net.ipv4.tcp_ecn = 1
    net.ipv4.tcp_ecn_fallback = 1
    EOF
    
    sudo sysctl -p
    
    
    #limits
    sudo cat >> /etc/security/limits.conf <<EOF
    * soft nproc 65536
    * hard nproc 65536
    * soft nofile 65536
    * hard nofile 65536
    EOF
    
    
  • rm_rm_ IPv6 Advocate, Veteran
    edited December 2022

    @yoursunny said: Instead, create a new file in /etc/sysctl.conf.d directory.

    That's a good advice, but it's /etc/sysctl.d/, at least on Debian. Thanks!

    Thanked by 1yoursunny
  • @rm_ said:

    @yoursunny said: Instead, create a new file in /etc/sysctl.conf.d directory.

    That's a good advice, but it's /etc/sysctl.d/, at least on Debian. Thanks!

    Should I create a file like /etc/sysctl.d/sysctl.conf and put new parameters there?

  • stonedstoned Member
    edited December 2022

    Take a look at this, and try to understand what each setting does before you modify it, otherwise it may cause undesired effects:

    https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
    https://www.kernel.org/doc/Documentation/networking/ip-sysctl.rst

    https://www.kernel.org/doc/Documentation/networking/ <- look for files containing sysctl and look through the relevant files for the settings.

Sign In or Register to comment.