{"id":2927,"date":"2011-09-06T13:55:58","date_gmt":"2011-09-06T05:55:58","guid":{"rendered":"https:\/\/www.icocean.com\/wp\/?p=2927"},"modified":"2011-09-06T13:56:02","modified_gmt":"2011-09-06T05:56:02","slug":"varnishxcache%e6%9e%84%e5%bb%ba%e9%ab%98%e6%80%a7%e8%83%bdweb%e6%9e%84%e6%9e%b6%e5%88%9d%e6%8e%a2","status":"publish","type":"post","link":"https:\/\/www.icocean.com\/blog\/?p=2927","title":{"rendered":"Varnish+Xcache\u6784\u5efa\u9ad8\u6027\u80fdWEB\u6784\u67b6\u521d\u63a2"},"content":{"rendered":"<p>\u672c\u6587\u4e3b\u8981\u8bb2\u8ff0web\u4f18\u5316\u65b9\u6848\u548c\u7f13\u5b58\u5de5\u5177\u7684\u8c03\u7814\u53ca\u4f7f\u7528\u3002\u6839\u636e\u76ee\u524d\u7684\u6d4b\u8bd5\u7ed3\u679c\u6765\u770b\uff0c\u91c7\u7528varnish+xcache\u4f5c\u4e3a apache\u548cphp\u7f13\u5b58\u8fd9\u79cd\u67b6\u6784\u5177\u6709\u9ad8\u5e76\u53d1\u3001\u9ad8\u7a33\u5b9a\u6027\uff0c\u6613\u6269\u5c55\u7b49\u4f18\u70b9\uff0c\u670d\u52a1\u5668\u7684\u52a8\u6001\u8bf7\u6c42\u5904\u7406\u80fd\u529b\u662f\u4e4b\u524d\u76847\u500d\u4e4b\u591a\u3002\u901a\u8fc7\u5206\u6790\u53d1\u73b0\uff0c\u76ee\u524d\u5bf9\u670d\u52a1\u5668\u7684\u8d1f\u8f7d\u4e3b\u8981\u662f\u5728cpu\u4f7f\u7528\u65b9\u9762\uff0c\u968f\u7740\u6d41\u91cf\u7684\u589e\u52a0\u74f6\u9888\u4e5f\u5c06\u51fa\u73b0\u5728cpu\u65b9\u9762\uff0c\u800c\u5185\u5b58\u548cIO\u65b9\u9762\u90fd\u4e0d\u662f\u95ee\u9898\u3002<\/p>\n<p>\u9488\u5bf9\u8fd9\u6837\u7684\u60c5\u51b5\uff0c\u6211\u4eec\u5c31\u8981\u7814\u7a76\u600e\u4e48\u53bb\u964d\u4f4ecpu\u7684\u8d1f\u8f7d\uff0c\u6d88\u9664\u6216\u964d\u4f4e\u7cfb\u7edf\u7684\u74f6\u9888\u3002<\/p>\n<p><strong>\u4e1a\u52a1\u7279\u70b9\u5206\u6790<\/strong><br \/>\nU \u670d\u52a1\u91c7\u7528\u7684\u662fLAMP(Linux Apache mysql php)\u67b6\u6784\uff0c\u800c\u670d\u52a1\u672c\u8eab\u7684\u903b\u8f91\u6bd4\u8f83\u7b80\u5355\uff0c\u5c31\u662f\u6839\u636e\u4e0d\u540c\u7684url\u8fd4\u56de\u7279\u5b9a\u7684\u9875\u9762\u5185\u5bb9\uff0c\u800c\u8fd9\u4e9b\u9875\u9762\u5185\u5bb9\u57fa\u672c\u662f\u4e0d\u4f1a\u53d8\u7684\u3002\u6574\u4e2a\u8fc7\u7a0b\u662f\u7531php\u52a8\u6001\u5b8c\u6210\u7684\uff0c\u4e0d\u9700\u8981\u548c\u5176\u4ed6\u670d\u52a1\u5668\u4ea4\u4e92\u3002\u5728\u4e00\u4e2a\u8bf7\u6c42\u7684\u54cd\u5e94\u8fc7\u7a0b\u4e2d\uff0c\u7cfb\u7edfcpu\u7684\u6d88\u8017\u57fa\u672c\u90fd\u5728php\u5904\u7406\u4e0a\u9762\u3002\u6211\u4eec\u8981\u505a\u7684\u5c31\u662f\u5c3d\u91cf\u51cf\u5c11php\u7684\u52a8\u6001\u5904\u7406\u3002<!--more--><\/p>\n<p><strong>\u4f18\u5316\u65b9\u6848\u8c03\u7814<\/strong><br \/>\n\u6027\u80fd\u4f18\u5316\u901a\u5e38\u7684\u65b9\u6cd5\u662f\u91c7\u7528\u7f13\u5b58\u7b56\u7565\u3002\u6839\u636eU\u670d\u52a1\u7684\u4e1a\u52a1\u7279\u70b9\uff0c\u4f18\u5316\u4e3b\u8981\u4ece\u4e24\u4e2a\u65b9\u9762\u8fdb\u884c\uff0cphp\u7f13\u5b58\u548c\u524d\u7aef\u7f13\u5b58\uff0c\u539f\u7406\u56fe\u5982\u4e0b\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2011\/09\/055559QGN.jpg\" alt=\"\" width=\"693\" height=\"311\" \/><\/p>\n<p><strong>Php\u7f13\u5b58\u8c03\u7814<br \/>\n<\/strong>\u6bcf \u6b21HTTP\u8bf7\u6c42PHP\u9875\u9762\u65f6\uff0cPHP\u4ee3\u7801\u90fd\u4f1a\u88ab\u89e3\u6790\u548c\u7ffb\u8bd1\u4e3a\u64cd\u4f5c\u7801\uff08PHP \u5f15\u64ce\u76f4\u63a5\u6267\u884c\u7684\u539f\u8bed\u6307\u4ee4&#8211;\u7c7b\u4f3c\u4e8e\u6c47\u7f16\u8bed\u8a00\uff09\u518d\u6267\u884c\u3002\u5728\u8981\u6c42\u5f88\u4f4e\u6216\u53ef\u5ffd\u7565\u7684\u60c5\u51b5\u4e0b\uff0c\u670d\u52a1\u5668\u770b\u4e0a\u53bb\u80fd\u7acb\u5373\u6267\u884c\u8fd9\u4e2a\u590d\u6742\u7684\u89e3\u91ca\u8fc7\u7a0b\u3002\u4f46\u662f\u4e00\u65e6\u5904\u7406\u7684\u9875\u9762\u589e\u52a0\uff0c \u91cd\u590d\u5de5\u4f5c\u5c31\u4f1a\u5bf9\u670d\u52a1\u5668\u9020\u6210\u5f88\u5927\u7684\u8d1f\u62c5\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u201c\u7f16\u8bd1\u201dPHP\u4ee3\u7801\u7684\u65f6\u95f4\u4f1a\u8fdc\u8fdc\u8d85\u8fc7\u6267\u884c\u8be5\u4ee3\u7801\u6240\u9700\u7684\u65f6\u95f4\uff0c\u5e76\u4e14\u4f1a\u5bf9\u670d\u52a1\u5668\u8d1f\u8f7d\u9020\u6210\u5f88\u5927\u538b\u529b\u3002Php \u7f13\u5b58\u4e3b\u8981\u662f\u7f13\u5b58opcode\uff0c\u907f\u514d\u91cd\u590d\u7f16\u8bd1PHP\u4ee3\u7801\u3002\u76ee\u524d\u9488\u5bf9php\u7684\u5185\u5b58\u7f13\u5b58\u7b56\u7565\u4e3b\u8981\u6709 memcache \u3001 eAccelerator \u3001 xcache \u548c APC \u3002Memcache\u662f\u4e00\u79cd\u57fa\u4e8e\u7f51\u7edc\u7684\u7f13\u5b58\u7b56\u7565\uff0c\u662f \u4e00\u4e2a\u9ad8\u6027\u80fd\u7684\u5206\u5e03\u5f0f\u7684\u5185\u5b58\u5bf9\u8c61\u7f13\u5b58\u7cfb\u7edf\uff0c\u901a\u8fc7\u5728\u5185\u5b58\u91cc\u7ef4\u62a4\u4e00\u4e2a\u7edf\u4e00\u7684\u5de8\u5927\u7684hash\u8868\uff0c\u5b83\u80fd\u591f\u7528\u6765\u5b58\u50a8\u5404\u79cd\u683c\u5f0f\u7684\u6570\u636e\uff0c\u5305\u62ec\u56fe\u50cf\u3001\u89c6\u9891\u3001\u6587\u4ef6\u4ee5\u53ca\u6570\u636e\u5e93\u68c0 \u7d22\u7684\u7ed3\u679c\u7b49\u3002\u4ecememcache\u7684\u7279\u70b9\u6765\u770b\uff0c\u66f4\u9002\u5408\u7528\u4e8e\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u548c\u5206\u5e03\u5f0f\u8ba1\u7b97\u9886\u57df\u3002\u5149\u4ece\u9875\u9762\u7f13\u5b58\u548c\u52a0\u901f\u89d2\u5ea6\u6765\u8bf4\u8fdc\u4e0d\u53caeAccelerator\u3001 xcache\u548cAPC\u3002eAccelerator\u3001 xcache \u548c APC \u5dee \u4e0d\u591a\uff0c\u90fd\u662f\u81ea\u7531\u5f00\u653e\u6e90\u7801php\u52a0\u901f\u5668\uff0c\u4f18\u5316\u548c\u52a8\u6001\u5185\u5bb9\u7f13\u5b58\uff0c\u80fd\u591f\u5927\u5927\u63d0\u9ad8php\u811a\u672c\u6027\u80fd\u3002\u5b83\u4f7f\u5f97PHP\u811a\u672c\u5728\u7f16\u8bd1\u7684\u72b6\u6001\u4e0b\uff0c\u5bf9\u670d\u52a1\u5668\u7684\u5f00\u9500\u51e0\u4e4e\u5b8c\u5168\u6d88\u9664\u3002 \u5176\u4e2dxcache\u662f\u4e00\u79cd\u6bd4\u8f83\u65b0\u7684\u52a0\u901f\u5668\uff0c\u662feAccelerator\u7684\u66ff\u4ee3\u4ea7\u54c1\uff0c\u66f4\u52a0\u7a33\u5b9a\u548c\u9ad8\u6548\uff0c\u76ee\u524dshifen\u524d\u7aef\u5df2\u5728\u4f7f\u7528\u3002<\/p>\n<p><strong>Http\u524d\u7aef\u7f13\u5b58\u8c03\u7814<br \/>\n<\/strong>\u9488 \u5bf9HTTP\u7684\u5185\u5b58\u7f13\u5b58\u7b56\u7565\u4f7f\u7528\u5f97\u6bd4\u8f83\u591a\u5c31\u662f squid \u548c varnish \u3002Squid \u662f\u4e00\u79cd\u5728Linux\u4e0b\u4f7f\u7528\u5f97\u6bd4\u8f83 \u591a\u7684\u4f18\u79c0\u7684\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u9488\u5bf9web\u7528\u6237\u6765\u8bf4\uff0c\u5b83\u8fd8\u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684\u4ee3\u7406\u7f13\u5b58\u670d\u52a1\u5668\uff0c\u5b83\u5c06\u6570\u636e\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u540c\u65f6\u4e5f\u7f13\u5b58DNS\u7684\u67e5\u8be2\u7ed3\u679c\uff0c\u53ef\u4ee5\u52a0\u5feb\u7f51\u7edc\u6d4f\u89c8\u7684 \u901f\u5ea6\uff0c\u63d0\u9ad8\u5ba2\u6237\u673a\u7684\u8bbf\u95ee\u547d\u4e2d\u7387\u3002Squid\u662f\u76ee\u524d\u4f7f\u7528\u7684\u6700\u5e7f\u7684HTTP\u52a0\u901f\u5668\u4e4b\u4e00\uff0c\u76ee\u524d\u5728\u767e\u5ea6\u4f7f\u7528\u5f97\u8fd8\u5f88\u5c11\u3002Varnish \u662f\u53e6\u4e00\u79cd\u9ad8\u6027\u80fd\u7684\u5f00\u6e90 HTTP\u52a0\u901f\u5668\u3002Varnish \u7684\u4f5c\u8005Poul-Henning Kamp\u662fFreeBSD\u7684\u5185\u6838\u5f00\u53d1\u8005\u4e4b\u4e00\uff0c\u4ed6\u8ba4\u4e3a\u73b0\u5728\u7684\u8ba1\u7b97\u673a\u6bd4\u8d771975\u5e74\u5df2\u7ecf\u590d\u6742\u8bb8\u591a\u3002\u57281975\u5e74\u65f6\uff0c\u50a8\u5b58\u5a92\u4ecb\u53ea\u6709\u4e24\u79cd\uff1a\u5185\u5b58\u4e0e\u786c\u76d8\u3002\u4f46\u73b0\u5728\u8ba1\u7b97 \u673a\u7cfb\u7edf\u7684\u5185\u5b58\u9664\u4e86\u4e3b\u5b58\u5916\uff0c\u8fd8\u5305\u62ec\u4e86CPU\u5185\u7684L1\u3001L2\uff0c\u751a\u81f3\u6709L3\u5feb\u53d6\u3002\u786c\u76d8\u4e0a\u4e5f\u6709\u81ea\u5df1\u7684\u5feb\u53d6\u88c5\u7f6e\uff0c\u56e0\u6b64Squid Cache\u81ea\u884c\u5904\u7406\u7269\u4ef6\u66ff\u6362\u7684\u67b6\u6784\u4e0d\u53ef\u80fd\u5f97\u77e5\u8fd9\u4e9b\u60c5\u51b5\u800c\u505a\u5230\u6700\u4f73\u5316\uff0c\u4f46\u64cd\u4f5c\u7cfb\u7edf\u53ef\u4ee5\u5f97\u77e5\u8fd9\u4e9b\u60c5\u51b5\uff0c\u6240\u4ee5\u8fd9\u90e8\u4efd\u7684\u5de5\u4f5c\u5e94\u8be5\u4ea4\u7ed9\u64cd\u4f5c\u7cfb\u7edf\u5904\u7406\uff0c\u8fd9\u5c31\u662f Varnish cache\u8bbe\u8ba1\u67b6\u6784\u3002\u76ee\u524d\u56fd\u5185\u6709\u4e9b\u95e8\u6237\u7f51\u7ad9\u5982\u65b0\u6d6a\uff0c\u817e\u8baf\u6b63\u5728\u4f7f\u7528\u3002<\/p>\n<p><strong>\u7f13\u5b58\u5de5\u5177\u6027\u80fd\u5bf9\u6bd4\u53ca\u9009\u62e9<br \/>\n<\/strong><strong>\u6d4b\u8bd5\u5e73\u53f0<\/strong>\uff1a HOST\uff1atc-un-ct00.tc OS\uff1a Linux 2.6.9_5-4-0-2 #1 SMP CPU: Intel(R) Xeon(R) CPU 5150 @ 2.66GHz \u00d7 4 MEM: 8GB \u6d4b\u8bd5\u6570\u636e \uff1a jx-rcv00 20081028\u65e518:00 \u2013 19:00 \u95f4\u7684\u6570\u636e \u538b\u529b\u5de5\u5177 \uff1a pfmtest<br \/>\n<strong>Php\u7f13\u5b58\u5de5\u5177\u5bf9\u6bd4\u6d4b\u8bd5<br \/>\n<\/strong>\u51e0\u4e2a\u4e3b\u6d41php\u7f13\u5b58\u5de5\u5177\u6027\u80fd\u5bf9\u6bd4\u6d4b\u8bd5\u5982\u4e0b\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2011\/09\/055600Yb9.jpg\" alt=\"\" width=\"817\" height=\"378\" \/><\/p>\n<p><strong>\u524d\u7aef\u7f13\u5b58\u5de5\u5177\u5bf9\u6bd4\u6d4b\u8bd5<br \/>\n<\/strong>apache\uff0csquid+apache\uff0cvarnish+apache \u6027\u80fd\u5bf9\u6bd4\u5982\u4e0b\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2011\/09\/0556022G5.jpg\" alt=\"\" width=\"818\" height=\"581\" \/><\/p>\n<p><strong>\u6d4b\u8bd5\u7ed3\u8bba<br \/>\n<\/strong>Php\u7f13\u5b58\u5de5\u5177\u6d4b\u8bd5\u4e2d\uff0cxcache\u5728\u54cd\u5e94\u65f6\u95f4\uff0ccpu\u5360\u7528\u7684\u65b9\u9762\u5747\u6709\u6700\u4f73\u7684\u8868\u73b0\uff1b\u53e6\u4e00\u65b9\u9762\uff0c\u4ece\u524d\u7aef\u7f13\u5b58\u6d4b\u8bd5\u7ed3\u679c\u6765\u770b\uff0cvarnish\u66f4\u9002\u5408U\u670d\u52a1\u7684\u5168\u52a8\u6001\u670d\u52a1\u3002<br \/>\n<strong>Varnish\u53caxcache\u7684\u4f7f\u7528<br \/>\n<\/strong><\/p>\n<p>Varnish\u7684\u4f7f\u7528<br \/>\nvarnish \u5de5\u5177\u7684\u4ecb\u7ecd\u53ca\u8be6\u7ec6\u4f7f\u7528\u65b9\u6cd5\u53c2\u89c1<a href=\"http:\/\/varnish.projects.linpro.no\/\">http:\/\/varnish.projects.linpro.no\/<\/a><\/p>\n<p>Xcache\u7684\u4f7f\u7528<br \/>\nXcache\u7684\u4ecb\u7ecd\u53ca\u8be6\u7ec6\u4f7f\u7528\u65b9\u6cd5\u53c2\u52a0<a href=\"http:\/\/xcache.lighttpd.net\/\">http:\/\/xcache.lighttpd.net\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u4e3b\u8981\u8bb2\u8ff0web\u4f18\u5316\u65b9\u6848\u548c\u7f13\u5b58\u5de5\u5177\u7684\u8c03\u7814\u53ca\u4f7f\u7528\u3002\u6839\u636e\u76ee\u524d\u7684\u6d4b\u8bd5\u7ed3\u679c\u6765\u770b\uff0c\u91c7\u7528varnish+xcache\u4f5c\u4e3a <a href='https:\/\/www.icocean.com\/blog\/?p=2927' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[4114,3469,3062,3470],"class_list":["post-2927","post","type-post","status-publish","format-standard","hentry","category-lamp","tag-lamp","tag-varnish","tag-xcache","tag-3470","category-24-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2927"}],"version-history":[{"count":1,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2927\/revisions"}],"predecessor-version":[{"id":2931,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2927\/revisions\/2931"}],"wp:attachment":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}