Shadowsocks deployment and optimization on debian

This post might be a little bit of nooby, but I am just trying to help out those poor guys in China.
Get a server, AWS or vultr will do the job.
When selecting operating system, my personal suggestion is to install debian even though it is not the best server os.
Firstly you will need to do some optimizations if you want a nice server.
Step 1, adjust the maximum open files limit:
Open /etc/security/limits.conf with your favorite editor such as vim.
Add these two lines

Show code

* soft nofile 51200
* hard nofile 52100


Then, set the ulimit by executing:
Show code

ulimit -n 51200


Step 2, tune the kernel parameters:
Open /etc/sysctl.conf with your favorite editor.
Insert this in to the file:
Show code

fs.file-max = 51200

net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 4096

net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
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 = 8192
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 = hybla


Execute systemctl -p after this.
We should now start the server.
Install shadowsocks:
Show code

sudo apt-get update
sudo apt-get install shadowsocks-libev


Edit the configuration:
Open /etc/shadowsocks-libev/config.json with your favorite editor.
Insert this in to the config:
Show code



Replace server_ip with your server’s ip or domain name, replace passwd with your password.
Now execute sudo /etc/init.d/shadowsocks-libev start and you’re all done.

One thought on “Shadowsocks deployment and optimization on debian

Leave a Reply

Your email address will not be published. Required fields are marked *