[文章作者:张宴 本文版本:v1.0 最后修改:2007.07.24 转载请注明出处:http://blog.zyan.cc]

  新增的一组Apache服务器上线以来,我用netstat -an命令发现服务器中有大量状态为TIME-WAIT的TCP连接,于是用/sbin/sysctl -a查看了一下Linux的各项内核参数,并翻阅有关资料,决定修改其中的两项参数,以达到减少TCP连接中TIME-WAIT sockets的目的。

  vi /etc/sysctl.conf
  编辑/etc/sysctl.conf文件,增加三行:
引用
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1

  说明:
  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,表示关闭。

  再执行以下命令,让修改结果立即生效:
  /sbin/sysctl -p

  用以下语句看了一下服务器的TCP状态:
  netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
  返回结果如下:
  ESTABLISHED 1423
  FIN_WAIT1 1
  FIN_WAIT2 262
  SYN_SENT 1
  TIME_WAIT 962

  效果:处于TIME_WAIT状态的sockets从原来的10000多减少到1000左右。处于SYN_RECV等待处理状态的sockets为0,原来的为50~300。

  附:TCP状态变迁图,见我的另一篇文章《查看Apache并发请求数及其TCP连接状态


Tags: ,
技术大类 » Web服务器 | 评论(45) | 引用(0) | 阅读(74243)
xujie777 Email
2012-5-18 15:57
coach outlet has become a popular shopping experience for consumers around the world, and a desirable distribution channel for manufacturer's and retailers.Getting your hands on coach outlet store online can be a hefty investment of hundreds of dollars.But do not despair,the Coach Outlet store could be the answer to your prayers.coach outlet online is your smart choice when you want to get the discount Coach accessory. You can find the exact Coach Bags and other accessory you want at a low price that's right for you. My dear friends, let the coach outlet online pave your way into the world of high fashion with their ultimate fashion factory.
Louis Vuitton UK Email Homepage
2012-5-19 16:06
Louis Vuitton UK are diversified in various kinds, handbags, backpacks, portable bags, purses, wallets and pouches. All kinds are popular among the whole word people.That publication was the only French periodical to mention the book, Louis Vuitton is the country's biggest advertiser in the press. 
Louis Vuitton Email Homepage
2012-5-19 16:16
During World War II, Louis Vuitton collaborated with the Nazis during the German occupation of France.I know someone has already sent you some photo's of the amazing Marc Jacobs/Louis Vuitton UK exhibition at the Musee Des Arts Decoratifs but I just had to share with you the day I had today . 
Coach  Outlet Email Homepage
2012-5-19 16:32
Coach Outlet has distribution, product development, and quality control operations in the United States, France, Italy, Japan, Hong Kong, China, and South Korea.Lewis Frankfort has been involved with Coach for more than 30 years.Metro Rail and ICF engineers are working to address this general problem.  The Coach Outlet Canada provides primarily for the Indian Railways, a number of different coaches - first and second class coaches, pantry and kitchen cars, luggage and brake vans, self propelled coaches. 
Coach  Outlet Email Homepage
2012-5-19 16:42
Cashin worked for Coach Outlet from 1962 until 1974, and revolutionized their product design. Known as an innovator, she instituted the inclusion of side pockets, coin purses, and brighter colors onto the bags.In the Coach Outlet Online shop, a collection of high quality and hottest Coach Shoulder Bags is offered to you. They are all at the best prices you will ever find. 
Coach Outlet Online Email Homepage
2012-5-19 16:50
At the Coach Outlet Online Store, quality products and satisfying service are provided;High safety and prompt delivery is guaranteed.Coach Outlet has always been simple,durable style features to win consumers.The products are more flexible,with easy bleaching,wear characteristics,and simply use a damp cloth. 
Christian Louboutin Email Homepage
2012-5-19 17:34
christian louboutin have own characteristic designs. The beautiful crystals have added the magical finishing touch to countless bridal gowns. Just get some for yourself. The first Men's Boutique, christian louboutin uk Boutique Homme on Rue Jean-Jacques Rousseau in Paris, opened in the summer of 2012.
Louis Vuitton UK Email Homepage
2012-5-19 17:34
Cheap louis vuitton uk wholesale offers a variety of options to satisfy your needs. Some new ones even has fashionable styles fold over flap to disguise the snap closure and a draw string is added for a convenient closure. Louis vuitton outlet online just like a person who want to show himself in front of other people, because he is confident enough, he can attain the respect of other people.
CoachOutlet Email Homepage
2012-5-19 17:34
coach outlet has become a popular shopping experience for consumers around the world, and a desirable distribution channel for manufacturer's and retailers. Coach outlet online develops very quickly because it runs by its own special way and it contents the customers greatly.
Air Jordan Email Homepage
2012-5-19 17:35
Thank you for shopping in our store. We are a reliable online jordan bags seller, specialist in providing numbers of new air jordan bags at amazing price . If you need practical, fashionable and well-known nike dunks, you can consider to choosing on the nike Outlet. Its nice and popular design will make you feel a sense of fresh air.
Nike Air Max Email Homepage
2012-5-19 17:35
This nike air max for sale belongs to the sounding just what are termed as nike air vintage best sellers, many other products and services for the reason that range appearing companies the actual nike air Galliera, plus the nike air outlet monogram selection. nike dunks are made of high leather materials which can be durable and fashionable.They will make you become the focus in the streets or audience.
xujie123
2012-5-21 11:03
Our online store offers you discounted Designer louis vuitton replica wallet at present. You could find them in desirable quality and price. If you don't mind high class louis vuitton uk, have a good time here.louis vuitton Store Online Handbags can also bring great accuracy as well as practical applicability and fashionable.Have you ever dreamed of being as charming as Madonna? Have you ever thought of becoming an envy of all your friends? If so, come to louis vuitton outlet.<br/>
xujie555
2012-5-21 13:25
coach factory outlet uses graceful accessories to match the classical logo of coach, which is the best combination of coach. The handmade coach products?can make you more charming and graceful.coach factory online provides people many coach goods. If you wish to snatch the coach handbag, then this best method is made for that you like for coach discount.coach factory outlet online is a fashion brand to ensure its quality. With designer coach shoulder bags, you will always attract people's attention. The bags will emphasize your personal style and taste.<br/>
xujie333
2012-5-21 14:47
coach outlet online Store guarantee that all the coach handbags offered are own high quality. In addition , all of them are sold at an unexpected low price.If you want to purchase, just visit their website.coach factory outlet is really sizzling kinds of shopping way for you. With the usage of the replica designer coach bags, you can surely be able to change your individual looks in a stunning manner.Coach bags on sale from the coach outlet are cheap or discount prices that you certainly will stand out from the crowd on your next camping trip!<br/>
Coach Outlet Online Email Homepage
2012-6-8 10:47
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:33
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.
FDGFG Email Homepage
2012-9-26 11:11
How to preserve cash on Joan of Arctic Karen Millen sale Sorel BootsWhile your community division shop might preserve you cash on Joan of Arctic Sorel Boots, there are methods you might get them for much less compared to costs you'll see at these shops - even when there are full shop sales. The 1st issue you must do is go to the division shop that carries the boots which means you know what price tag to beat and verify your size. Then, start Karen Millen dresses browsing online. You will discover that countless on line sellers will market these boots for much less since they don't possess the overhead charges that brick and mortar sellers need to offer with. However,you can preserve even much more should you can discover an on line store that provides totally free shipping. a single issue to remember when purchasing these boots is the actuality that they operate large in size, so do attempt them on at a division shop prior to purchasing them online, it discount Karen Millen will aid guarantee you have the good fit!Silk scarf is commonly a versatile accessory that might be used by any girl no issue her size.
Coach Email Homepage
2012-11-3 14:49
"The Coach Outletengines that will likely power the J-31 we do know a bit mor.Coach Outlet  Those engines were actually revealed at the Zhuhai showCoach Outlet in 2008," Fisher said referring to an annual China air show. He beCoach Outletlieves the new J-31 engine is undergoing preliminary
Coach Email Homepage
2012-11-3 14:49
"The Coach Outletengines that will likely power the J-31 we do know a bit mor.Coach Outlet  Those engines were actually revealed at the Zhuhai showCoach Outlet in 2008," Fisher said referring to an annual China air show. He beCoach Outletlieves the new J-31 engine is undergoing preliminary
GHAWE
2013-1-29 17:36
买轴承就到:www.jkzhoucheng.cn
分页: 2/3 第一页 上页 1 2 3 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]