dongzhang5006
dongzhang5006
2011-02-14 14:21

http:keep-alive保持php资源打开还是释放所有资源?

已采纳

I am using http keep-alive on a apache server,
Lets say I ask it to keep the connections open upto 2 minutes...
Now, if the connection is created and idle for a minute, will the resources held by php,
like mysql connections, file handles, etc., will be freed or will they survive too ?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • douchuo0730 douchuo0730 10年前

    Confirmed. Keep-Alive is a mechanism to prevent costly TCP connection negotiation. Your PHP process/thread starts as normal and needs to allocate all resources as usual.

    Regarding a high load situation, it might be wise to even keep the keep-alive period not too high: All connection requests compete for free connection slots of your server. If all slots are in-use by keep-alive connections, other users might not connect.

    But, as usual, the optimal amount of slots and good keep-alive period depends on your specific load situation.

    点赞 评论 复制链接分享
  • doufei7516 doufei7516 10年前

    no , http keep-alive save resources of tcp connection . php and mysql will not even aware of that connection is open , when you will make next request it would be fast because time spend resolving ip address , and opening new tcp connection will be saved all this things remain with apache.

    点赞 评论 复制链接分享