转自:http://blog.youkuaiyun.com/educast/article/details/37695803
1、其实你是受到了redis的file descriptor数目限制,这个需要更改redis的源码,在ae.h的36行(2.2.4版本):
<ol class="linenums" style="list-style-position: outside; margin: 0px; padding: 0px 0px 0px 10px; border: none;"><li class="L0" style="list-style: decimal; margin: 0px; padding: 0px 0px 0px 10px; border: none; line-height: 20px; color: rgb(153, 153, 153); background-color: rgb(250, 250, 250);"><span class="com" style="color: gray;">#define</span><span class="pln" style="color: rgb(0, 0, 0);"> AE_SETSIZE </span><span class="pun" style="color: rgb(0, 0, 0);">(</span><span class="lit" style="color: maroon;">1024</span><span class="pun" style="color: rgb(0, 0, 0);">*</span><span class="lit" style="color: maroon;">10</span><span class="pun" style="color: rgb(0, 0, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="com" style="color: gray;">/* Max number of fd supported */</span></li></ol>
2、另外需要注意的是,如果你需要支持更高的连接数,还需要更改系统的相关配置,比如ulimit数目:
<ol class="linenums" style="list-style-position: outside; margin: 0px; padding: 0px 0px 0px 10px; border: none;"><li class="L0" style="list-style: decimal; margin: 0px; padding: 0px 0px 0px 10px; border: none; line-height: 20px; color: rgb(153, 153, 153); background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">ulimit </span><span class="pun" style="color: rgb(0, 0, 0);">-</span><span class="pln" style="color: rgb(0, 0, 0);">n xxx</span><span class="pun" style="color: rgb(0, 0, 0);">(你需要的数目)</span></li></ol>
以及网络的并发连接数等限制:
<ol class="linenums" style="list-style-position: outside; margin: 0px; padding: 0px 0px 0px 10px; border: none;"><li class="L0" style="list-style: decimal; margin: 0px; padding: 0px 0px 0px 10px; border: none; line-height: 20px; color: rgb(153, 153, 153); background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">net</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">ipv4</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">netfilter</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">ip_conntrack_max</span>
</li><li class="L1" style="list-style: decimal; margin: 0px; padding: 0px 0px 0px 10px; border: none; line-height: 20px; color: rgb(153, 153, 153); background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">net</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">nf_conntrack_max</span>
</li><li class="L2" style="list-style: decimal; margin: 0px; padding: 0px 0px 0px 10px; border: none; line-height: 20px; color: rgb(153, 153, 153); background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">net</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">netfilter</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">nf_conntrack_max</span></li></ol>
redis.conf中maxclients 设置为0表示不作限制。