Linux下高并发的Squid服务器,TCP TIME_WAIT套接字数量经常达到两、三万,服务器很容易被拖死。通过修改Linux内核参数,可以减少Squid服务器的TIME_WAIT套接字数量。
  
vi /etc/sysctl.conf

  增加以下几行:
引用
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 1024    65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000

  说明:
  net.ipv4.tcp_syncookies = 1 表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭;
  net.ipv4.tcp_tw_reuse = 1 表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭;
  net.ipv4.tcp_tw_recycle = 1 表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭。
  net.ipv4.tcp_fin_timeout = 30 表示如果套接字由本端要求关闭,这个参数决定了它保持在FIN-WAIT-2状态的时间。
  net.ipv4.tcp_keepalive_time = 1200 表示当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时,改为20分钟。
  net.ipv4.ip_local_port_range = 1024    65000 表示用于向外连接的端口范围。缺省情况下很小:32768到61000,改为1024到65000。
  net.ipv4.tcp_max_syn_backlog = 8192 表示SYN队列的长度,默认为1024,加大队列长度为8192,可以容纳更多等待连接的网络连接数。
  net.ipv4.tcp_max_tw_buckets = 5000 表示系统同时保持TIME_WAIT套接字的最大数量,如果超过这个数字,TIME_WAIT套接字将立刻被清除并打印警告信息。默认为180000,改为5000。对于Apache、Nginx等服务器,上几行的参数可以很好地减少TIME_WAIT套接字数量,但是对于Squid,效果却不大。此项参数可以控制TIME_WAIT套接字的最大数量,避免Squid服务器被大量的TIME_WAIT套接字拖死。

  执行以下命令使配置生效:
/sbin/sysctl -p


Tags: , , ,
技术大类 » Cache与存储 | 评论(68) | 引用(0) | 阅读(58827)
Coach Outlet Online Email Homepage
2012-6-8 10:56
http://www.atcoachoutletsonline.net/ Coach Outlet Online
http://www.getcoachfactoryoutlet.org/ Coach Factory
http://www.louisvuittonhandbagsoutlet.org/ Louis Vuitton Handbags Outlet
http://www.saleincoachoutlets.com/ Coach Outlet
coach88888888 Email
2012-8-13 17:47
If you desire to go to Coach Factory Outlet, but have no idea in which to go, you can research online. It is no doubt that there is drastically information and details about it for the reference.Coach Factory Online are loved by many people, when you walk in the street, you could see many people take coach styles.hat experts claim Coach Outlet Online shopping is in the changes they are available in.Coach Outlet will send you a coupon in the post to use in their upon only after you type a achieve. The Coach bags are customarily somewhat many than the ones in the stores.
FGFHG Email Homepage
2012-9-27 08:58
When buying, confirm the stores have an Karen Millen dresses effortless protection of purchasing. guarantee the payment ways will be also extremely effortless and specifically effortless. You'll frequently uncover an right jacket for the do it yourself out of your assortment of Barbour overcoats accessible in extra on the web. You might even avail reductions anytime you are buying in the web. These reductions will ensure that you're inside of a location Karen Millen dress to produce your buys at an inexpensive cost.In the occasion you desire to seem superb and stay comfy too then get a few attractive and comfy Barbour coats.should you are searching for some funky and fashionable pair Karen Millen Ireland of peep toe shoes, then dark peep toe will possibly be the perfect one. frequently footwear are within the best record in relation to fashion. This sort of shoes arrives in many colours and styles thus letting the clients to select the a single they prefer.
Hadassa Email Homepage
2012-12-1 09:42
beats by dre pas cher d'Un mauvais sucri-s, que C'est une affaire fâcheuse; C% parlant d'Une entreprise, que C'est une affaire aisée ou malaisée. Vous me contez là
外贸 Homepage
2013-8-23 16:57
这个很好了,顶
高仿包 Homepage
2015-4-29 09:57
分页: 4/4 第一页 上页 1 2 3 4 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]