You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><title>Shadowsocks - Advanced</title><metaname="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"><metaname="description" content=""><metaname="author" content=""><linkrel="stylesheet" href="/assets/css/app.css"><!--[if lt IE 9]><script src="/assets/js/html5.js"></script><![endif]--><linkrel="shortcut icon" href="/assets/img/favicon/favicon.ico"><linkrel="apple-touch-icon" href="/assets/img/favicon/apple-touch-icon.png"><linkrel="apple-touch-icon" sizes="72x72" href="/assets/img/favicon/apple-touch-icon-72x72.png"><linkrel="apple-touch-icon" sizes="114x114" href="/assets/img/favicon/apple-touch-icon-114x114.png"></head><body><divid="wrap" class="boxed"><header><divclass="container clearfix"><divclass="four columns"><divclass="logo"><ahref="/en/index.html">shadowsocks</a></div></div><divclass="twelve columns"><navid="menu" class="navigation"><ulid="nav"><li><ahref="javascript:void" class="">download</a><ul><li><ahref="/en/download/clients.html">Clients</a></li><li><ahref="/en/download/servers.html">Servers</a></li></ul></li><li><ahref="javascript:void" class="active">config</a><ul><li><ahref="/en/config/quick-guide.html">Quick Guide</a></li><li><ahref="/en/config/advanced.html">Advanced</a></li></ul></li><li><ahref="javascript:void" class="">spec</a><ul><li><ahref="/en/spec/protocol.html">Protocol</a></li><li><ahref="/en/spec/cipher.html">Cipher</a></li><li><ahref="/en/spec/one-time-auth.html">One Time Auth</a></li><li><ahref="/en/spec/AEAD.html">AEAD</a></li></ul></li><li><ahref="javascript:void" class="">about</a><ul><li><ahref="/en/about/contributors.html">Contributors</a></li></ul></li><li><ahref="javascript:void">en</a><ul><li><ahref="/en/index.html">en</a></li></ul></li></ul></nav></div><divclass="sixteen columns"><hr></div></div></header><divclass="container clearfix"><divclass="sixteen columns"><h1class="page-title">Advanced<ahref="https://github.com/madeye/shadowsocks-org/edit/master/docs/config/02-advanced.md" data-tooltip="Edit this page on GitHub" class="edit"><iclass="icon-edit"></i></a><spanclass="line"></span></h1></div><divclass="page-columns"><divid="markdown" class="sixteen columns bottom"><h2>Optimize the shadowsocks server on Linux</h2><p>First of all, upgrade your Linux kernel to 3.5 or later.</p><h3>Step 1, increase the maximum number of open file descriptors</h3><p>To handle thousands of concurrent TCP connections, we should increase the limit of file descriptors opened.</p><p>Edit the <code>limits.conf</code></p><pre><codeclass="language-bash">vi /etc/security/limits.conf</code></pre><p>Add these two lines</p><pre><code><spanclass="hljs-bullet">* </span>soft nofile 51200
2
-
<spanclass="hljs-bullet">* </span>hard nofile 51200</code></pre><p>Then, before you start the shadowsocks server, set the ulimit first</p><pre><codeclass="language-bash"><spanclass="hljs-built_in">ulimit</span> -n 51200</code></pre><h3>Step 2, Tune the kernel parameters</h3><p>The priciples of tuning parameters for shadowsocks are</p><ol><li>Reuse ports and conections as soon as possible.</li><li>Enlarge the queues and buffers as large as possible.</li><li>Choose the TCP congestion algorithm for large latency and high throughput.</li></ol><p>Here is an example <code>/etc/sysctl.conf</code> of our production servers:</p><pre><code>fs<spanclass="hljs-selector-class">.file-max</span> = <spanclass="hljs-number">51200</span>
1
+
<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><title>Shadowsocks - Advanced</title><metaname="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"><metaname="description" content=""><metaname="author" content=""><linkrel="stylesheet" href="/assets/css/app.css"><!--[if lt IE 9]><script src="/assets/js/html5.js"></script><![endif]--><linkrel="shortcut icon" href="/assets/img/favicon/favicon.ico"><linkrel="apple-touch-icon" href="/assets/img/favicon/apple-touch-icon.png"><linkrel="apple-touch-icon" sizes="72x72" href="/assets/img/favicon/apple-touch-icon-72x72.png"><linkrel="apple-touch-icon" sizes="114x114" href="/assets/img/favicon/apple-touch-icon-114x114.png"></head><body><divid="wrap" class="boxed"><header><divclass="container clearfix"><divclass="four columns"><divclass="logo"><ahref="/en/index.html">shadowsocks</a></div></div><divclass="twelve columns"><navid="menu" class="navigation"><ulid="nav"><li><ahref="javascript:void" class="">download</a><ul><li><ahref="/en/download/clients.html">Clients</a></li><li><ahref="/en/download/servers.html">Servers</a></li></ul></li><li><ahref="javascript:void" class="active">config</a><ul><li><ahref="/en/config/quick-guide.html">Quick Guide</a></li><li><ahref="/en/config/advanced.html">Advanced</a></li></ul></li><li><ahref="javascript:void" class="">spec</a><ul><li><ahref="/en/spec/protocol.html">Protocol</a></li><li><ahref="/en/spec/cipher.html">Cipher</a></li><li><ahref="/en/spec/one-time-auth.html">One Time Auth</a></li><li><ahref="/en/spec/AEAD.html">AEAD</a></li></ul></li><li><ahref="javascript:void" class="">about</a><ul><li><ahref="/en/about/contributors.html">Contributors</a></li></ul></li><li><ahref="javascript:void">en</a><ul><li><ahref="/en/index.html">en</a></li></ul></li></ul></nav></div><divclass="sixteen columns"><hr></div></div></header><divclass="container clearfix"><divclass="sixteen columns"><h1class="page-title">Advanced<ahref="https://github.com/madeye/shadowsocks-org/edit/master/docs/config/02-advanced.md" data-tooltip="Edit this page on GitHub" class="edit"><iclass="icon-edit"></i></a><spanclass="line"></span></h1></div><divclass="page-columns"><divid="markdown" class="sixteen columns bottom"><h2>Optimize the shadowsocks server on Linux</h2><p>First of all, upgrade your Linux kernel to 3.5 or later.</p><h3>Step 1, increase the maximum number of open file descriptors</h3><p>To handle thousands of concurrent TCP connections, we should increase the limit of file descriptors opened.</p><p>Edit the <code>limits.conf</code></p><pre><codeclass="language-bash">vi /etc/security/limits.conf</code></pre><p>Add these two lines</p><pre><code><spanclass="bullet">* </span>soft nofile 51200
2
+
<spanclass="bullet">* </span>hard nofile 51200</code></pre><p>Then, before you start the shadowsocks server, set the ulimit first</p><pre><codeclass="language-bash">ulimit -n <spanclass="number">51200</span></code></pre><h3>Step 2, Tune the kernel parameters</h3><p>The priciples of tuning parameters for shadowsocks are</p><ol><li>Reuse ports and conections as soon as possible.</li><li>Enlarge the queues and buffers as large as possible.</li><li>Choose the TCP congestion algorithm for large latency and high throughput.</li></ol><p>Here is an example <code>/etc/sysctl.conf</code> of our production servers:</p><pre><code>fs<spanclass="preprocessor">.file</span>-max = <spanclass="number">51200</span>
net<spanclass="hljs-selector-class">.ipv4</span><spanclass="hljs-selector-class">.tcp_congestion_control</span> = hybla</code></pre><p>Of course, remember to execute <code>sysctl -p</code> to reload the config at runtime.</p><h3>How to verify your optimizations work</h3><p>Use munin or any server monitor tools to generate the graph of your TCP connections. A well tuned server should look like this</p><p><imgsrc="http://ww4.sinaimg.cn/large/61b416b1gw1e9jmyps9vpj20dt0b4wg7.jpg" alt="one month munin TCP graph" width="" height=""></p></div></div></div><divclass="push"></div></div><footer><divclass="container"><divclass="sisteen columns"><spanclass="copyright"><ahref="https://github.com/shadowsocks">Projects of Shadowsocks</a> are distributed under different licenses, including <ahref="https://github.com/shadowsocks/shadowsocks/blob/master/LICENSE">APL 2.0,</a> <ahref="https://github.com/shadowsocks/shadowsocks-libev/blob/master/LICENSE">GPLv3</a> and <ahref="https://github.com/shadowsocks/libQtShadowsocks/blob/master/LICENSE">LGPLv3</a>. Theme by <ahref="http://karma-runner.github.io">Karma</a>.</span></div></div></footer></body><scriptsrc="/assets/js/app.js"></script><scriptsrc="/assets/js/analytics.js"></script></html>
net<spanclass="preprocessor">.ipv</span>4<spanclass="preprocessor">.tcp</span>_congestion_control = hybla</code></pre><p>Of course, remember to execute <code>sysctl -p</code> to reload the config at runtime.</p><h3>How to verify your optimizations work</h3><p>Use munin or any server monitor tools to generate the graph of your TCP connections. A well tuned server should look like this</p><p><imgsrc="http://ww4.sinaimg.cn/large/61b416b1gw1e9jmyps9vpj20dt0b4wg7.jpg" alt="one month munin TCP graph" width="" height=""></p></div></div></div><divclass="push"></div></div><footer><divclass="container"><divclass="sisteen columns"><spanclass="copyright"><ahref="https://github.com/shadowsocks">Projects of Shadowsocks</a> are distributed under different licenses, including <ahref="https://github.com/shadowsocks/shadowsocks/blob/master/LICENSE">APL 2.0,</a> <ahref="https://github.com/shadowsocks/shadowsocks-libev/blob/master/LICENSE">GPLv3</a> and <ahref="https://github.com/shadowsocks/libQtShadowsocks/blob/master/LICENSE">LGPLv3</a>. Theme by <ahref="http://karma-runner.github.io">Karma</a>.</span></div></div></footer></body><scriptsrc="/assets/js/app.js"></script><scriptsrc="/assets/js/analytics.js"></script></html>
0 commit comments