¡¡¡¡Õâ´ÎÊÇFotologµÄ¾Ñ飬´«ËµÖбÈFlickr¸ü´óµÄÍøÕ¾£¬FotologÔÚ21̨·þÎñÆ÷Éϲ¿ÊðÁË51¸ömemcachedʵÀý£¬×ܼÆÓÐ254G»º´æ¿Õ¼ä¿ÉÓ㬻º´æÁ˶à´ï175GµÄÄÚÈÝ£¬Õâ¸öÊýÁ¿±ÈºÜ¶àÍøÕ¾µÄÊý¾Ý¿â¶¼Òª´óµÄ¶à£¬ÔÎÄÊÇA Bunch of Great Strategies for Using Memcached and MySQL Better Together£¬ÎÒÕâÀﻹÊÇÑ¡ÔñÐԵķÒëÒÔ¼°°´ÕÕÎÒµÄÀí½â²¹³ä£¬¸ÐлTodd Hoff£¬×ÜÄܸøÎÒÃÇһЩѧϰµÄ°¸Àý£¬´ÓÕâÀïÒ²ÄÜ¿´³ö¹úÍâ¼¼ÊõµÄ¿ª·Å̬¶È£¬²»ËÆÎÒÃÇ£¬Æäʵ¾ÍÄÇôµãС¾Å¾Å»¹²Ø×ÅÒ´×Å£¬ºÃÁË£¬½øÈëÕýÌâ¡£Ò»¡¢¹ØÓÚmemcached¡¡¡¡»¹²»ÖªµÀÕâ¸ö£¿ÄÇÄãÈ¥ÃæÊÔµÄʱºòÒª³Ô¿÷ÁË£¬¸Ï½ôÈ¥¹Ù·½ÍøÕ¾¿´Ò»ÏÂhttp://www.danga.com/memcached/£¬ÁíÍâgoogleÒ»ÏÂÓ÷¨£¬Ó²ÅÌ×ÜÊÇÌ«Âý£¬°ÑÊý¾Ý´æÔÚÄÚ´æÀïÃæ°É£¬Èç¹ûÄãÖ»ÓÐһ̨·þÎñÆ÷£¬ÍƼöÓÃÒ»ÏÂAPC(FacebookÔÚÓÃ)»òÕßeaccelerator»òÕßXcache(¹úÈË¿ª·¢µÄ)£¬ÕâЩ²úÆ·µ¥»úЧ¹û¸üºÃ£¬Èç¹ûÄãÐèÒª·Ö²¼Ê½µÄ»º´æ·½°¸£¬ÄÇôÓÃmemcached°É¡£¶þ¡¢memcachedÈçºÎÓëmysql²¢¼ç×÷Õ½£¿Í¨¹ýÊý¾Ý¿â·ÖƬÀ´½â¾öÊý¾Ý¿âдÀ©Õ¹µÄÎÊÌâ°ÑÊý¾Ý¿â·ÖƬ£¬²¿Êðµ½²»Í¬µÄ·þÎñÆ÷ÉÏ£¬ÃâµÃÖ»ÓÐÒ»¸öÖ÷·þÎñÆ÷£¬Ð´²Ù×÷³ÉΪƿ¾±ÒÔ¼°¿ÉÄÜÓеġ°µ¥µã¹ÊÕÏ¡±£¬Ò»°ãµÄÊý¾Ý¿â·ÖƬÖ÷ÒªÊÇ°´ÕÕÒµÎñÀ´·Ö£¬¾¡¿ÉÄܵIJð·ÖÒµÎñ£¬²»Ïà¸ÉµÄ¶¼¶ÀÁ¢ÆðÀ´×ö³É·þÎñÒ²ºÃ Ç°¶ËmysqlºÍÒ»¶Ñmemcached·þÎñÆ÷À´Ó¦¸¶¶ÁµÄÎÊÌâÓ¦ÓóÌÐòÊ×ÏÈ´ÓmemcachedÖлñÈ¡Êý¾Ý£¬»ñÈ¡²»µ½ÔÙ´ÓÊý¾Ý¿âÖлñµÃ²¢±£´æÔÚmemcachedÖУ¬ÒÔÇ°¿´¹ýһƪÎÄÕÂ˵ºÃµÄÓ¦ÓÃ95£¥µÄÊý¾Ý´ÓmemcacheµÄÖлñµÃ£¬3£¥µÄÊý¾Ý´ÓmysqlµÄquery cacheÖлñµÃ£¬Ê£ÏÂ2£¥²ÅÈ¥²é±í£¬¶Ô±ÈÒ»ÏÂÄãµÄÓ¦Ó㬲î¾àÓжàÔ¶£¿ ͨ¹ýmysql¸´ÖÆ£¨master-slave£©À´½â¾ö¶ÁµÄÎÊÌâÊ×ÏÈmysqlÊý¾Ý¿âͨ¹ýmaster-slave¶Áд·ÖÀ룬¶à¸öslaveÀ´Ó¦¶ÔÓ¦ÓóÌÐò¶ÁµÄ²Ù×÷¡£ Èý¡¢ÎªÊ²Ã´²»ÓÃmysqlµÄquery cache£¿¡¡¡¡ÎÒÃǶ¼ÖªµÀmysqlÓиöquery cache£¬¿ÉÒÔ»º´æÉϴβéѯµÄ½á¹û£¬¿Éʵ¼ÊÉÏ°ï²»ÉÏÌ«¶àµÄ棬ÏÂÃæÊÇmysql quety cacheµÄ²»×㣺ֻÄÜÓÐÒ»¸öʵÀýÒâζ×ÅÄãÄÜ´æ´¢ÄÚÈݵÄÉÏÏÞ¾ÍÊÇÄã·þÎñÆ÷µÄ¿ÉÓÃÄڴ棬һ̨·þÎñÆ÷ÄÜÓжàÉÙÄڴ棿ÄãÓÖÄÜ´æ¶àÉÙÄØ£¿ Ö»ÒªÓÐд²Ù×÷£¬mysqlµÄquery cache¾ÍʧЧֻҪÊý¾Ý¿âÄÚÈÝÉÔÓиı䣬ÄÇŸıäµÄÊÇÆäËûÐУ¬mysqlµÄquery cacheÒ²»áʧЧ mysqlµÄquery cacheÖ»ÄÜ»º´æÊý¾Ý¿âÊý¾ÝÐÐÒâζ×ÅÆäËûÄÚÈݶ¼²»ÐУ¬±ÈÈçÊý×飬±ÈÈç¶ÔÏ󣬶ømemcachedÀíÂÛÉÏ¿ÉÒÔ»º´æÈκÎÄÚÈÝ£¬ÉõÖÁÎļþ^_^ ËÄ¡¢FotologµÄ»º´æ¼¼Êõ·ÇÈ·¶¨ÐÔ»º´æÄ㲻ȷ¶¨ÄãÒªµÄÊý¾Ý»º´æÖÐÓÐûÓУ¬ÄãÒ²²»ÖªµÀÊDz»ÊǹýÆÚÁË£¬ÓÚÊÇÄã¾ÍÊÔ̽ÐÔµÄÎÊmemcached£¬ÎÒÒªµÄʲôʲôÊý¾ÝÄãÄÇÓÐÂð£¿Îҿɲ»Òª¹ýÆÚµÄÊý¾Ý°¡£¬memcached¸æËßÄã˵Óв¢ÇÒ¸øÄ㣬Äã¾Í¿ªÐÄÁË£¬Èç¹ûûÓÐÄØ£¬Äã¾ÍÒª´ÓÊý¾Ý¿â»òÕß±ðµÄµØ·½È¥»ñÈ¡ÁË£¬ÕâÊÇmemcachedµäÐ͵ÄÓ¦Óá£Ö÷ÒªÓ¦ÓÃÔÚ£º1.¸´ÔÓµÄÊý¾ÝÐèÒª¶à´Î¶ÁÈ¡£¬ÄãµÄÊý¾Ý¿â×öÁË·ÖƬ´¦Àí£¬´Ó¶à¸öÊý¾Ý¿âÖлñÈ¡Êý¾Ý²¢×éºÏÆðÀ´ÊÇÒ»¸ö·Ç³£´óµÄ¿ªÏú£¬Äã´ó¿ÉÒÔ°ÑÕâЩÊý¾ÝÈ¡³öÀ´Ö®ºó´æµ½memcachedÖÐ 2.mysql query cacheµÄÒ»¸öºÃµÄÌæ´ú·½°¸£¬ÕâÑùÊý¾Ý¿âÆäËû²¿ÃŸıäÁË£¬Ö»Òª×Ô¼ºÃ»¸Ä±ä¾ÍûÎÊÌ⣨עÒâÊý¾Ý¿â¸üеÄÎÊÌ⣬ºóÃæ»áÌáµ½£©3.°Ñ¹Øϵ»òÕßÁÐ±í»º´æÆðÀ´£¬±ÈÈçij¸öÀ¸Ä¿ÏµĶàƪÎÄÕÂÁбí4.±»¶à¸öÒ³Ãæµ÷Óò¢ÇÒ»ñÈ¡ÆðÀ´ºÜÂýµÄÊý¾Ý£¬»òÕßÊǸüкÜÂýµÄÊý¾Ý£¬±ÈÈçÎÄÕÂä¯ÀÀÅÅÐаñ5.Èç¹ûcacheµÄ¿ªÏú³¬¹ýÖØлñÈ¡µÄ¿ªÏú£¬ÄÇô²»Òª»º´æËü°É6.±êÇ©ÔƺÍ×Ô¶¯½¨Òé(ÀàËÆgoogle sugest)ÀýÈ磺µ±Ò»¸öÓû§ÉÏ´«Ò»¸öͼƬ£¬Õâ¸öÓû§µÄºÃÓÑÒ³ÃæÉ϶¼ÒªÁгöÕâÕÅͼƬÀ´£¬ÄÇô°ÑËü»º´æÆðÀ´°É¡£Ç±ÔÚÎÊÌ⣺memcachedÏûºÄµÄÖ÷ÒªÊÇ·þÎñÆ÷Äڴ棬¶ÔCPUÏûºÄºÜС£¬ËùÒÔFotolog°Ñmemcached²¿ÊðÔÚËûÃǵÄÓ¦Ó÷þÎñÆ÷ÉÏ£¨Ã²ËÆÎÒÃÇÒ²ÊÇÕâÑù£©£¬ËûÃÇÓöµ½ÁËCPU¸ãµ½90£¥µÄʹÓÃÂÊ£¨Ôõô»áÄÇô¸ß£¿ÄijöÎÊÌâÁË°É£©¡¢ÄÚ´æ»ØÊÕ£¨ÕâÊǸö´óÎÊÌ⣩µÈµÈÎÊÌâ¡£ ״̬»º´æ°ÑÓ¦Ó÷þÎñµÄµ±Ç°×´Ì¬´æÔÚmemcachedÖÐÖ÷ÒªÓ¦ÓÃÔÚ£º1.¡°°º¹ó¡±µÄ²Ù×÷£¬¿ªÏú´óµÄ²Ù×÷