id: 6674244cae684726bad46eb2ef5ba1b3
parent_id: 
item_type: 1
item_id: 8038cd8e000f4cfcad7e75dbbc8d5b60
item_updated_time: 1764345583917
title_diff: "[{\"diffs\":[[1,\"shadowsocksshadowsocks\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":22}]"
body_diff: "[{\"diffs\":[[1,\"<html>\\\r\\\n<head>\\\r\\\n  <title>shadowsocks/shadowsocks</title>\\\r\\\n  <basefont face=\\\"微软雅黑\\\" size=\\\"2\\\" />\\\r\\\n  <meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html;charset=utf-8\\\" />\\\r\\\n  <meta name=\\\"exporter-version\\\" content=\\\"YXBJ Windows/608924 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;\\\"/>\\\r\\\n  <style>\\\r\\\n\\tbody, td {\\\r\\\n\\t  font-family: 微软雅黑;\\\r\\\n\\t  font-size: 12pt;\\\r\\\n\\t}\\\r\\\n  </style>\\\r\\\n</head>\\\r\\\n<body>\\\r\\\n<a name=\\\"17227\\\"></a>\\\r\\\n<h1>shadowsocks/shadowsocks</h1>\\\r\\\n\\\r\\\n<div><span><div style=\\\"-evernote-webclip:true\\\"><br/><div><div><div><div><h1>Optimizing Shadowsocks</h1><div><div></div></div></div>\\\n        <div>\\\n          clowwindy edited this page <span>on 10 Feb 2015</span>\\\n          ·\\\n          <a href=\\\"https://github.com/shadowsocks/shadowsocks/wiki/Optimizing-Shadowsocks/_history\\\" target=\\\"_blank\\\">\\\n            23 revisions\\\n          </a>\\\n        </div>\\\n    \\\n  \\\n  \\\n    \\\n\\\n    \\\n\\\n    \\\n        \\\n          <p>If you see a lot of <code>error: too many open files</code> in your log, you should optimize your system.\\\nThis tutorial applies to all shadowsocks servers (Python, libev, etc).</p>\\\n<p>On Debian 7:</p>\\\n<p>Create <code>/etc/sysctl.d/local.conf</code> with the following content:</p>\\\n<pre><code># max open files\\\nfs.file-max = 51200\\\n# max read buffer\\\nnet.core.rmem_max = 67108864\\\n# max write buffer\\\nnet.core.wmem_max = 67108864\\\n# default read buffer\\\nnet.core.rmem_default = 65536\\\n# default write buffer\\\nnet.core.wmem_default = 65536\\\n# max processor input queue\\\nnet.core.netdev_max_backlog = 4096\\\n# max backlog\\\nnet.core.somaxconn = 4096\\\n\\\n# resist SYN flood attacks\\\nnet.ipv4.tcp_syncookies = 1\\\n# reuse timewait sockets when safe\\\nnet.ipv4.tcp_tw_reuse = 1\\\n# turn off fast timewait sockets recycling\\\nnet.ipv4.tcp_tw_recycle = 0\\\n# short FIN timeout\\\nnet.ipv4.tcp_fin_timeout = 30\\\n# short keepalive time\\\nnet.ipv4.tcp_keepalive_time = 1200\\\n# outbound port range\\\nnet.ipv4.ip_local_port_range = 10000 65000\\\n# max SYN backlog\\\nnet.ipv4.tcp_max_syn_backlog = 4096\\\n# max timewait sockets held by system simultaneously\\\nnet.ipv4.tcp_max_tw_buckets = 5000\\\n# turn on TCP Fast Open on both client and server side\\\nnet.ipv4.tcp_fastopen = 3\\\n# TCP receive buffer\\\nnet.ipv4.tcp_rmem = 4096 87380 67108864\\\n# TCP write buffer\\\nnet.ipv4.tcp_wmem = 4096 65536 67108864\\\n# turn on path MTU discovery\\\nnet.ipv4.tcp_mtu_probing = 1\\\n\\\n# for high-latency network\\\nnet.ipv4.tcp_congestion_control = hybla\\\n\\\n# for low-latency network, use cubic instead\\\n# net.ipv4.tcp_congestion_control = cubic\\\n</code></pre>\\\n<p>Then:</p>\\\n<pre><code>sysctl --system\\\n</code></pre>\\\n<p>Older system:</p>\\\n<pre><code>sysctl -p /etc/sysctl.d/local.conf\\\n</code></pre>\\\n<p>Warning: <strong>DO NOT ENABLE <code>net.ipv4.tcp_tw_recycle</code>!!!</strong> See <a href=\\\"http://vincent.bernat.im/en/blog/2014-tcp-time-wait-state-linux.html\\\" target=\\\"_blank\\\">this article</a>.</p>\\\n<p>If you use <a href=\\\"https://github.com/shadowsocks/shadowsocks/wiki/Configure-Shadowsocks-with-Supervisor\\\" target=\\\"_blank\\\">Supervisor</a>, Make sure you have the following line in <code>/etc/default/supervisor</code>. Once you added that line, restart Supervisor (<code>service stop supervisor &amp;&amp; service start supervisor</code>).</p>\\\n<pre><code>ulimit -n 51200\\\n</code></pre>\\\n<p>If you run shadowsocks in the background in other ways, make sure to add <code>ulimit -n 51200</code> in your init script.</p>\\\n<p>After optimizing, a busy Shadowsocks server that handles thousands of connections, takes about 30MB memory and 10% CPU. Notice that at the same time, <strong>Linux kernel usually uses &gt;100MB RAM</strong> to hold buffer and cache for those connections. By using the sysctl config above, you are trading off RAM for speed. If you want to use less RAM,\\\nreduce the size of rmem and wmem.</p>\\\n<p></p><div><img src=\\\":/fed786d245584301aec5510281273d80\\\" type=\\\"image/png\\\" data-filename=\\\"2a18bc5a-fadf-11e3-96c3-473c42f1a3a3.png\\\" alt=\\\"if_eth0-day\\\" height=\\\"280\\\" width=\\\"497\\\"/></div><p></p>\\\n<p></p><div><img src=\\\":/ae38c0bbd53a446ba026cfe7a9af366b\\\" type=\\\"image/png\\\" data-filename=\\\"2bf8662e-fadf-11e3-8039-3d59bf689fe2.png\\\" alt=\\\"fw_conntrack-day\\\" height=\\\"352\\\" width=\\\"497\\\"/></div><p></p>\\\n<p></p><div><img src=\\\":/a1461070a68547d981edc1a970f9db20\\\" type=\\\"image/png\\\" data-filename=\\\"53951d80-fadf-11e3-8e6b-0ceed96950e2.png\\\" alt=\\\"cpu-day\\\" height=\\\"376\\\" width=\\\"497\\\"/></div><p></p>\\\n<p></p><div><img src=\\\":/591df8033d5545768c76d63c64a7684e\\\" type=\\\"image/png\\\" data-filename=\\\"87c98c08-fadf-11e3-9fc9-949f4061d2ca.png\\\" alt=\\\"proc_mem-day\\\" height=\\\"280\\\" width=\\\"497\\\"/></div><p></p>\\\n<p>Before &amp; after:</p>\\\n<p></p><div><img src=\\\":/174606b978ca4e5a9067cf1342d1950b\\\" type=\\\"image/jpeg\\\" data-filename=\\\"10c34b04-f5d9-11e3-95fc-e38f5299c274.jpg\\\" alt=\\\"cc\\\" height=\\\"291\\\" width=\\\"576\\\"/></div><p></p>\\\n\\\n        </div></div></div><br/></div></span>\\\n</div></body></html>\\u0000\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":4742}]"
metadata_diff: {"new":{"id":"8038cd8e000f4cfcad7e75dbbc8d5b60","parent_id":"f67288c3a0be4374b5d532b5dcc3aabc","latitude":"0.00000000","longitude":"0.00000000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin-desktop","source_application":"net.cozic.joplin-desktop","application_data":"","order":1764348827853,"markup_language":2,"is_shared":0,"share_id":"","conflict_original_id":"","master_key_id":"","user_data":"","deleted_time":0},"deleted":[]}
encryption_cipher_text: 
encryption_applied: 0
updated_time: 2025-11-28T21:04:03.395Z
created_time: 2025-11-28T21:04:03.395Z
type_: 13