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与存储 | 评论(83) | 引用(0) | 阅读(75608)
Coach Outlet Online Email Homepage
2012-6-8 10:56 Coach Outlet Online Coach Factory Louis Vuitton Handbags Outlet 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
slitherio Email Homepage
2019-7-22 15:29
Ieuan Ventura
2021-10-20 18:03
You have proven to be a reliable data and source for my project and you never disappoint me with your contents.  I cant wait for more of your thoughts. Good luck  สมัครสมาชิกสล็อต
shz Email
2022-7-19 23:24
I want to say thanks to you. I have bookmark your site for future updates.  Scam Risk
shz Email
2022-7-19 23:26
Welcome to the party of my life here you will learn everything about me.  Scam Risk
shzz Email
2022-7-19 23:28
Very useful post. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up.  Scam Risk
shz Email
2022-7-19 23:30
I like viewing web sites which comprehend the price of delivering the excellent useful resource free of charge. I truly adored reading your posting. Thank you!  Scam Risk
shzz Email
2022-7-19 23:30
Thank you so much for ding the impressive job here, everyone will surely like your post.  Scam Risk
shz Email
2022-7-19 23:33
They're produced by the very best degree developers who will be distinguished for your polo dress creating. You'll find polo Ron Lauren inside exclusive array which include particular classes for men, women.  Scam Risk
shzz Email
2022-7-19 23:36
A great website with interesting and unique material what else would you need.  Scam Risk
shz Email
2022-7-19 23:36
You completed certain reliable points there. I did a search on the subject and found nearly all persons will agree with your blog.  Scam Risk
shzz Email
2022-7-19 23:39
Very awesome!!! When I seek for this I found this website at the top of all blogs in search engine.  Scam Risk
shz Email
2022-7-19 23:39
Writing with style and getting good compliments on the article is quite hard, to be honest.But you've done it so calmly and with so cool feeling and you've nailed the job. This article is possessed with style and I am giving good compliment. Best!  Scam Risk
메이저사이트 Email Homepage
2023-1-16 15:24
There is a lot of interesting things here, and I am so happy to share this information with my friends. Some of my friends and I also have some more in our place, 메이저사이트 so please take it so that you will feel much better.
分页: 4/5 第一页 上页 1 2 3 4 5 下页 最后页
昵称   密码   游客无需密码
网址   电邮   [注册]