Save 37% off PRO during our Black Friday Sale! »

The Architect of Anjuke Inc.

The Architect of Anjuke Inc.

安居客网站架构 - Think in LAMP 2012.6

647939961a7aa188d6008eaa7d573024?s=128

Zhang Erning

June 17, 2012
Tweet

Transcript

  1. 安居客 Think in LAMP - 2012.6 网站架构

  2. ,+^,,|;:':`.: ` ```` .,,|,,|::..;: . :.. . ,,;qgWWggWHWMWWdWWWmdL... ` ,,dBBBBgB$BH&BBBBBBBWB@BWBBW,+=:

    ,dBQQ&@BWWBBBB@0BBBWWW@WW@BBWB@WWBWq. ,dBB@WWBBB0WBWBBWWBWBBWBBBBWQHB@WB@B@WW0m+ ,B@0WB@W@BB$BBBHWBBB@@WB@BBBBBW@WWWWWWWW@WWW ,M@BB@B000@0MBBBBBBBBBWBBBBBWBBW@WBBWWWWWWWWW@ ,d&B0WBB@@#!^|J0BBBBBBB@WWBWBWBW@W@WWBWW@WWWWWWW .+BBBBW@D!^` .199BgBBBBWBBWBW@WWWW@@@BWWWWWWWW JWBBHB@^` 'J39BWBBBWWBBW@WBW@BBWW7WWWWWWW 1MBBW@ +: `^I$BBBBBWWBBBWBWB@9@E$WWWWWW ,W0QW! +a|` .',;=JBWBWBBBBBB0WBWW+@;BWWWWWW ,WWB@ dBE,,ggdY .::+9BB@WBBBB0W0B9E+!dWWWWWWW B&B'+MBiBg^" ,||z40BBB0BBV^4W@T+!qWWWWWWWW '4E .31i$E+` .;JIIII4BQBWMHkJ@\'',dBBWWWWWWW Wg .'`` .,=,^^z=XIM0BBHMuBT:+dBB$@WWWWWWW $@! .;^;|;^IIII4sMWMjHBaQBBBBBWWWWWWWW ^ ..=|^,^;^^zIIUMMHoHW0BA6BHBWWWWWWWW .;,|^||||^^IIXVwHBH4H4BOBBWWWWWWWW@ .,zad: .`|^;|^,=^z+IXHHBMBP44BBBB0WWWWWWWW ,qB0@9\ `;^^|==z^zIUHHH4BBhPBMMBBBWWWWWW@W ?9WWI|`.`|,|.`=|=zzzzIIUHMHHBNBB4WMMBBBBWWWWWWW JC+qdHQe1;==+z==IIVUHHHBUUBBBGoFMMM0BBWWWWWW XBBW@T:.;zzI^IIcUHQWB9UUUUBBIFYYMMBBBWWWWWW ,Q@',vz|,2=!=IIHWqNUBdddUUpBMMsMMMH0BBBWWWW ,IdW#,J|^|dQMHKBBUBBdOdBBDMzLMHoMBBBBBWWB ?9B@" .;zHHBdBBUO666OBBD#XXXLHMHwMBBB0WB ,^.,+dQHW%BdH9AHB0B00#1Iz1XIOMHtMMsY0BI 3IWWgWBBBRBBB0BMO#V^|^|^1XLUMMsYHvMMW .,,+9@@@0@B00B0B8XIII!,,:|^=cUHHMU##XLHM ` 9J2BWOIIII^;;==zIUUvvLXrXcXHH ,dEJBBYHII^,|^IIrOMsCX1IIggdH ,r 0LJ3##IzIaaggggggWWBWWWWWWWW .` .dB@@W@WWWWWWWWWWW@W@W@W@WW@ .s ,,,,,+. WB@BW@@@@@@WW@@W@@@W@W@W@W@ .,,,,. .J! .,+gB&&&B$BW@@WW@B@@@@@W@W@@@W@@W@W@WW@@WWW @erning •ழ΁ʈ೻ࢪ •2008ϋ̋ɝτ֢܄ •eBay CDC •35ʝ䝀
  3. None
  4. •4㽗ၣ१ anjuke.com, aifang.com, haozu.com, jinpu.com •୅ਗᏐ͜ iOS, Android, Windows Phone

    •3ɷຬUV/˜ •2ɷຬPV/˂ •~150̨؂䕂ኜ,3㽗IDC •ڐ200Зʈ೻ࢪ
  5. 㽢ʃՑɽ ɽߧʧୗτ֢܄ݖ࿴੽ʃՑɽٙᜊʷཀ೻

  6. 1 2 3 4 5 6 7 8 9 10

    11 12 0 500000 1000000 1500000 2000000 2500000 10X 200K 2M → DB Replication LIKE% ➡ SOLR V2 Squid Memcached Distributed Images RabbitMQ DB Sharding 1㽗IDC,2̨؂ਕኜ 2㽗IDC,17̨؂ਕኜ Linux Apache MySQL PHP
  7. hᅰኽࢫ hฤ॰ hᇠπ hྡ˪ӻ୕ hऊࢹඟΐ

  8. hᅰኽࢫ hฤ॰ hᇠπ hྡ˪ӻ䕠 hऊࢹඟΐ

  9. ԟჿҢࡁ͜ɪSolrʔఱλə෗?

  10. hɓක֐̥Ϟɓࡈ॰ˏג๕ h॰ˏ஼နεৎԸ຾ߏɛ、ήྡ、ሞእ、ฤ॰౤ͪ h॰ˏٙ˖Ꮶᅰඎᄣɽװʱϓεࡈ hɓࡈၣ१ᜊމεࡈτ֢܄、ฌג、λॡ、ږ⧕、୅ਗ hุਕሜ዆॰ˏ຾੬ࠅࠠܔ h൳Ը൳εSolrٙྼԷცࠅ၍ଣ

  11. ̙˸ІпஷཀWebޢࠦ௴ܔձ၍ଣSolr䕏Է Solr Cloud

  12. ɓ㽗Serviceε㽗Instance

  13. ίᇞݟ޶ձࡌҷschema

  14. h77㽗ʔΝٙ॰ˏ h98㽗༶БʕٙSolr䕏Է h௅໇ί12̨يଣዚኜɪ hӊ˂ߒ8000ຬٙฤ॰ ٤ඝٙSolr䕏Է̙˸ᎇࣛܲცʱৣ,ਗ࿒ሜ዆

  15. hᅰኽࢫ hฤ॰ hᇠπ hྡ˪ӻ䕠 hऊࢹඟΐ

  16. hӊ˂อɪෂ120ຬੵ๫˪ hӊ˂ྡ˪ሗӋߒ1.4䖐ϣ hߒ4䖐ੵྡ˪,44TBπᎷ h௅໇ίዹͭٙIDC,40+PC̨؂䕂ኜ hCDN

  17. hྡ˪ӻ䕠݅ᔊఊɦልᕏ hҢࡁٙҷி຾ዝəɟࡈචݬ htdocs/images ዹͭٙimg1~n ၾᏐ͜༆ᇩ ್Χ݊ͦۃٙӻ䕠 hᅺࡘʷ؂ਕટɹ ዹͭஷٙ͜؂䕂;̙֛Ⴁ,νˉʂձ˥Ι hMogileFSЪމྡ˪πᎷ

  18. hMogileFSԢڭπ˲̥ڭπࡡྡ Ңࡁӊੵྡ˪ڭπ2΅;͜กូٙSATA೷盘,XFS˖΁ӻ୕ h˸ࡡྡٙʫ࢙hash࠽Ъމ˖΁Τ ͟׵ุਕٙᗫڷ,ҢࡁϞ൴ཀ60%ٙอɪෂྡ˪݊ࠠልٙ hᜑͪٙࣛࡉʑஈଣྡ˪ уʲྡ͂˥Ι,ஈଣλٙྡ˪ίۃ၌ᇠπ h˕ܵεࡈၣ१ Էνίτ֢܄ɪෂٙྡ˪,̙˸ίλॡၣ˸λॡٙˉʂձ˥Ι࢝ͪ hဲЧൈ৿ྡ˪ᗆй ί࿁อɪෂٙྡ˪͂ɪTag,̙͜ɲᗆйࠠልٙձ੭˥Ιٙྡ˪

  19. h፯኿ᔊఊྼٙ͜˙ࣩ h஼Ӊҷආ,ʔ͜ɓӉՑЗ hᜫࠠልٙ௶ਗІਗʷ 㽢ʃՑɽٙཀ೻ʕ

  20. ᗫءක೯ձ಻༊ ၣ१ٙݖ࿴ʔස݊வԬ͛ପᐑྤٙଡ଼΁

  21. hක೯࣪ݖ h๕˾ᇁ၍ଣ h಻༊ᐑྤ

  22. hක೯࣪ݖ h๕˾ᇁ၍ଣ h಻༊ᐑྤ

  23. ๕˾ᇁٙو͉၍ଣ masterڭܵᖢ֛ ධͦί΢Іٙfeature branchක೯ ̌ঐ಻༊ஷཀܝmergeΫ˴ʍ 紧ܢٙॹ௘ίrelease branchɪࡌҷ

  24. ᕎ ᇞ ʈ Ъ

  25. GitCorp

  26. ڢ䅎Փ Code Review

  27. hක೯࣪ݖ h๕˾ᇁ၍ଣ h಻༊ᐑྤ

  28. h12-Factor App ѓൡҢࡁ ක䕆、಻༊、͛ପᐑྤ൳ટڐ൳λ hක䕆ᐑྤ.$username.dev.anjuke.com h಻༊ᐑྤ.$fp#.qa.anjuke.com h͛ପᐑྤ.anjuke.com

  29. TiP Test in Production

  30. hεو͉̺໇ ዚኜɪΝࣛϞεࡈو͉ٙ˾ᇁ,͟ৣໄܸ׼Ꮠ༈༶Бࡳࡈو͉ hܸ֛༶Бو͉ ӊࡈɛ̙˸ܸ֛ʔΝٙو͉ hܸ֛༶Бዚኜ ᒔ̙˸ܸ֛ሗӋໝίࡳ̨؂䕂ኜɪ hBetaձGA Ңࡁٙݖ࿴˕ܵί͛ପᐑྤj

  31. m=app10-019, v=20120605_03 hεو͉̺໇ hܸ֛༶Бو͉ hܸ֛༶Бዚኜ hBetaձGA ӊࡈɛ̙˸ܸ֛ʔΝٙو͉

  32. m=app10-019, v=20120605_03 hεو͉̺໇ hܸ֛༶Бو͉ hܸ֛༶Бዚኜ hBetaձGA ᒔ̙˸ܸ֛ሗӋໝίࡳ̨؂䕂ኜɪ

  33. hεو͉̺໇ hܸ֛༶Бو͉ hܸ֛༶Бዚኜ hBetaձGA ί፬ʮ܃ʫ௅ᐼ݊Ꮄ΋ஞਪBetaو͉

  34. ݖ࿴Ꮠ༈ܼ̍ක೯ձ಻༊

  35. л͜ᅰỼձʈՈ ፅඎݖ࿴ٙࣖ؈,ЪމҷආٙԱኽ

  36. hਿᓾ္ٙછ hІ່֛ٙజڌ h༉୚ٙᅰኽʱؓ h˕ุܵਕᅰኽDW/BI

  37. cacti

  38. ᅰኽࢫٙԴ͜฿ر

  39. ᅰኽࢫٙ༉୚္છ

  40. Memcached / Varnish

  41. pyfisheyes֛Ⴁྡڌ

  42. DW/BI 䣽䕂ʱؓʕː

  43. ༉୚ʧୗɓࡈҢᙂ੻ ܘϞจܠٙᅰኽ

  44. PHPሗӋٙஈଣࣛගʱ̺ hεᅰ͜䔚ٙᚤᏐ时䞯݊εˇ? h90%ٙ͜˒ᚤᏐࣛග݊εˇ? hՈ᜗Ցӊ㽗Controller

  45. PHPሗӋٙ༉୚ઋر

  46. None
  47. None
  48. None
  49. None
  50. None
  51. ᅰኽձʈՈܘϞᏍп ݖ࿴ٙணࠇࠅϽᅇᅰኽٙમණ

  52. ܵᚃҷආ ఐϼᒮேStay hungry, Stay foolish

  53. APS P2PٙऊࢹඟΐձମӉჃཀ೻ሜ͜ ØMQ

  54. ᐏ՟ਪᕚ༉୚ڦࢹ ᐏ՟޴ᗫਪᕚΐڌ ᐏ՟Ϋഈΐڌ 10 15 30 ഐҼ ක֐ 10+15+30=55 (ms)

  55. ᐏ՟ਪᕚ༉୚ڦࢹ ᐏ՟޴ᗫਪᕚΐڌ ᐏ՟Ϋഈΐڌ 10 15 30 ഐҼ ක֐ max(10+15, 30)=30

    (ms)
  56. hP2Pٙऊࢹ䕆৔ hPHPٙମӉ˙جሜ͜ hൈᏝٙऊࢹᐼᇞ PHP܄䔚၌ٙ4㽗Ռ数

  57. ᐏ՟ਪᕚ༉୚ڦࢹ ᐏ՟޴ᗫਪᕚΐڌ ᐏ՟Ϋഈΐڌ 10 15 30 ഐҼ ක֐ start_request() wait_for_replies()

  58. ➡ ፯኿ᔊఊྼٙ͜˙ࣩ ➡ Νࣛᗫءක೯ձ಻༊ ➡ л͜ᅰኽձʈՈ ➡ ܵᚃҷආ Ң࿁ၣ१ݖ࿴ٙ᜗ึ݊

  59. Thanks zhang@erning.com