TCP is the foundation of modern internet traffic. In this tutorial, I will show you how you can optimize your server for much faster data transfer on the TCP Protocol.
Before
To understand by how far did this improve our TCP connection, we need to have an idea of where we are at currently without the optimization.
For the tutorial today, we are using a VPS in Europe and to simulate the very worst network conditions, we chose a VPS in China.
For testing, we are using a network testing tool called iperf3. To install on Ubuntu / Debian, use:
We are going to do two tests – Single thread, and one with 8 thread.
The command for this is:
Then, the multithread test:
This can be ran with:
The multithreaded test above was performed with 8 threads, hence:
(Of course 114.51.4.109 is not my real ip…)
Alright! Now we have a rough idea of where our baseline speeds are. Let’s get optimizing!
Method
For this, we will be using the English port of the Nekonekocloud optimization script, which you can find on my github here.
wget https://cdn.jsdelivr.net/gh/daycat/tcp-optimization@main/tcp.sh -O tcp.sh && chmod +x tcp.sh && bash tcp.sh
You should see this screen:
Once you get to this step, take a look at your System info.
At the end of the line, in green, is your system kernel version. The 5.10.0 represents that your kernel version is 5.10.0 and the amd64 at the end means that you are using a VPS on a X86_64 platform (you don’t need to worry about this)
If your number is smaller than 5.x : i.e 4.9.x, you need to run step 1, which updates your linux kernel version. Please note that running step 1 can result in data loss and if you have any important data, you should backup your data before you run it (works fine on Hax VPS KVM locations, but I cannot guarantee that it will work fine every time) . After, reboot and run step 2.
The rest of the script’s functionality isn’t necessary for the TCP optimization, but I’d recommend you run 4, Resource tuning.
Lets test again!
After
As you can see, there are some improvements after optimizing the TCP traffic.