Upgrade to Pro — share decks privately, control downloads, hide ads and more …

はてなのサーバ/インフラを支える技術〜2016年新卒編〜 / OSC Tokyo 2016 Fall

Taketo Sasaki
November 05, 2016

はてなのサーバ/インフラを支える技術〜2016年新卒編〜 / OSC Tokyo 2016 Fall

https://speakerdeck.com/masayoshi とOSC Tokyo 2016 Fallにて発表した際の資料です。はてなでどのような仕事をしているのか、どのような技術を用いているかについてお話しました。

Taketo Sasaki

November 05, 2016
Tweet

More Decks by Taketo Sasaki

Other Decks in Technology

Transcript

  1. ͸ͯͳʹ͍ͭͯ • 2001೥૑ۀ • ࣾһ਺110໊ɿژ౎ͱ౦ژͷ2ڌ఺ମ੎ • αʔϏε • Mackerel •

    ͸ͯͳϒοΫϚʔΫ • ͸ͯͳϒϩά • Ոిձٞ • ਓྗݕࡧ͸ͯͳɺΩʔϫʔυɺΞϯςφɺͳͲͳͲ
  2. WebγεςϜͷ3૚ߏ଄ʢཁૉʣ 1SPYZ "QQMJDBUJPO %BUBCBTF 1SPYZαʔόʢϦόʔεϓϩΩγʣ  ֎͔ΒͷϦΫΤετΛ௚઀ड͚औΔ  ੩తϑΝΠϧฦ٫ɺΞΫηε੍ޚͳͲΛߦ͏ "QQMJDBUJPOαʔό

     γεςϜͷத৺ͰΞϓϦέʔγϣϯϩδοΫΛ࣮ߦ  %#ͱͷ઀ଓɺϨεϙϯεͷߏஙͳͲΛߦ͏
 %BUBCBTFαʔό  αʔϏεͷఏڙʹඞཁͳσʔλΛอ࣋͢Δ  *0ॲཧʹΑͬͯҰൠతʹϘτϧωοΫʹͳΓ΍͍͢
  3. WebγεςϜͷ3૚ߏ଄ʢ઀ଓʣ 1SPYZ "QQMJDBUJPO %BUBCBTF 8FCαʔόͷ઀ଓํࣜ  1SFGPSL  5ISFBE1PPM 

    &WFOU%SJWFO %#αʔόͱͷ઀ଓ  ౎౓઀ଓ
 ϦΫΤετͷॲཧதͷΈ઀ଓΛҡ࣋  ৗ࣌઀ଓ
 %#઀ଓΦϒδΣΫτΛΩϟογϡͯ͠͠·͏
  4. ޿ࠂ഑৴γεςϜͷੑ࣭ • ࢀরͷׂ߹͕ଟ͍ • WebαʔϏεͷPV਺ʹൺྫͨ͠ࢀরϦΫΤετʢΊͬͪΌଟ͍ʣ • ΞϓϦέʔγϣϯͷදࣔ଎౓ͳͲʹӨڹΛ༩͑Δ • ߋ৽ͷස౓͕গͳ͍ •

    جຊతʹೖߘऀʹΑͬͯೖߘ͞ΕΔ࣌ • ԿΛͲΕ͘Β͍഑৴͔ͨ͠ͷϩάΛอଘ͢Δඞཁ͕͋Δ • ޿ࠂओ΁޿ࠂޮՌΛใࠂ͠ͳ͍ͱ͍͚ͳ͍ "QQMJDBUJPO "E4FSWFS Ϣʔβ ޿ࠂೖߘऀ
  5. ։ൃͷྲྀΕ • ࢓༷ΛܾΊΔ • ੑ࣭΍ཁٻΛߟྀ • ઃܭ • ੑೳݟੵ΋ΓɺΞʔΩςΫνϟઃܭ •

    ߏங • ઃܭʹج͍࣮ͯࡍʹߏஙΛߦ͏ • ͸ͯͳͰ͸chefΛ࢖͏͜ͱ͕ଟ͍
  6. ΞʔΩςΫνϟ %BUBCBTF 4UPSBHF "QQ $BDIF ޿ࠂೖߘ $BDIF 1SPYZ ޿ࠂ഑৴αʔό "QQ

    ޿ࠂ؅ཧαʔό %BUBCBTF ϦΫΤετ 4FBSDI
 &OHJOF -PH
 'PSXBSEFS ΤϯυϢʔβ ޿ࠂೖߘऀ όον
 ੈ୅؅ཧ͞Εͨ
 Ωϟογϡͷ࡞੒ ϨϓϦέʔγϣϯ ϩά഑ૹ
  7. ޿ࠂ഑৴γεςϜͷཁٻ • ϨΠςϯγཁٻ • 50 msec or dieʢۀքج४ʣ • ߴ͍Մ༻ੑ

    • ഑৴͸Կ͕͋ͬͯ΋ʮઈରʹʯࢭΊͯ͸͍͚ͳ͍ • ϩά഑ૹͷ৴པੑ • ϩάͷॏෳɺܽଛ͸جຊతʹڐ͞ΕΔ΋ͷͰ͸ͳ͍ "QQMJDBUJPO "E4FSWFS Ϣʔβ ޿ࠂೖߘऀ NTFD
  8. ϘτϧωοΫͷಛఆ • γεςϜΛ؍࡯͠ཧղ͢Δͷ͕࠷ॳ • ΞϓϦέʔγϣϯΤϯδχΞʹద੾ͳվળཁٻΛग़͢ • ϘτϧωοΫͷղੳ • ಛఆʹ༻͍Δπʔϧ •

    ίϚϯυ…top, dstat, strace, perfͳͲ • MySQLͷεϩʔΫΤϦ…pt-query-digestͳͲ • ϓϩϑΝΠϥ…NYTProfͳͲͰ࣮ߦ࣌ؒ
  9. ͦͷଞ • PlackʢAppαʔόʣͷύϥϝʔλௐ੔ͳͲ • ϓϩηεΛ௕ੜ͖ͤ͞Δ • worker਺͸ίΞ਺ఔ౓ʹ • ࠷ऴతʹ͸Gazelleʹ •

    MySQL indexվળ • Χʔωϧύϥϝʔλνϡʔχϯά • reuse, recycle port΍tcp_fin_timeoutͳͲ • Մ༻ੑɺϩά഑ૹͷ৴པੑΛߴΊΔ޻෉
  10. લ൒·ͱΊ • ·ͱΊ • WebγεςϜͷجຊతͳ࢓૊Έ • ޿ࠂ഑৴γεςϜͷੑ࣭ͱઃܭ • ߴ଎ԽͷͨΊʹ΍ͬͨ͜ͱ •

    αʔϏεӡ༻ͷָ͠͞ • αʔϏεͷੑ࣭Λߟྀͯ͠࠷దղΛ୳Δͷָ͕͍͠ • ֶΜٕͩज़ͳͲ͕ͦͷ··݁Ռͱͯ͠ݱΕΔ
  11. αʔϏε͕ଟ͍ • 1αʔϏεʹෳ਺ϩʔϧ • Proxy, APP, DB,… • αʔϏε ✕

    ϩʔϧʹΑΔαʔό୆਺ͷ૿Ճ • Ծ૝αʔό͚ͩͰ΋1000୆Ҏ্ (ਓ͸8ਓ) • αʔϏεͷଟ༷ੑ • ϒοΫϚʔΫ, ϒϩά, ޿ࠂ഑৴, Mackerel … • αʔϏε͝ͱʹϩʔϧ͸มԽ͢Δ
  12. ςΩετϕʔεͷWebαʔϏε • 1ճͷΞΫηεͷίωΫγϣϯ਺͕ଟ͍ • ProxyͷίωΫγϣϯॲཧ͸ॏཁ • HTTP2ͳͲͰվળͭͭ͠͸͋Δ • 1ΞΫηεͷ௨৴ྔ͸ଟ͘ͳ͍ •

    ετϦʔϛϯάͳͲͱ͸ҧ͏ • ϦΫΤεταΠζ << ϨεϙϯεαΠζ • େମͷWebαʔϏε͸Ϩεϙϯεͷ΄͏͕େ͖͍
  13. ͸ͯͳͷج൫͍Ζ͍Ζ • ϋ΢δϯά + Ϋϥ΢υ • Debian + Xen ͰͷαʔόԾ૝Խ

    • Chef, CapistranoͰͷϓϩϏδϣχϯά • MackerelͰͷ؂ࢹɺαʔό؅ཧ • Linux LVSͷෛՙ෼ࢄ
  14. /FUXPSL /FUXPSL /FUXPSL 3BDLPS%$ MPDBUJPO 3BDLPS%$ MPDBUJPO 4FSWFS 7. 7.

    7. 7. 7. 7. 7. 7. 7. 7. 4FSWFS 4FSWFS 4FSWFS 4FSWFS 4FSWJDF" 1SPYZ "QQ %# 4FSWJDF# 1SPYZ "QQ %# $BDIF
  15. /FUXPSL /FUXPSL /FUXPSL 3BDLPS%$ MPDBUJPO 3BDLPS%$ MPDBUJPO 4FSWFS 7. 7.

    7. 7. 7. 7. 7. 7. 7. 7. 4FSWFS 4FSWFS 4FSWFS 4FSWFS αʔϏε" 1SPYZ "QQ %# 4FSWJDF# 1SPYZ "QQ %# $BDIF ෺ཧతͳ഑ஔΛҙࣝ ωοτϫʔΫΛҙࣝ ෺ཧαʔόΛҙࣝ
  16. /FUXPSL /FUXPSL /FUXPSL 3BDLPS%$ MPDBUJPO 3BDLPS%$ MPDBUJPO 4FSWFS 7. 7.

    7. 7. 7. 7. 7. 7. 7. 7. 4FSWFS 4FSWFS 4FSWFS 4FSWFS αʔϏε" 1SPYZ "QQ %# αʔϏε# 1SPYZ "QQ %# $BDIF Ϧιʔε͕ڞ༗Ͱ͖ͳ͍
  17. 4FSWJDF" 1SPYZ "QQ %# 4FSWJDF# 1SPYZ "QQ %# $BDIF /FUXPSL

    /FUXPSL /FUXPSL 3BDLPS%$ MPDBUJPO 3BDLPS%$ MPDBUJPO 4FSWFS 7. 7. 7. 7. 7. 7. 7. 7. 7. 7. 4FSWFS 4FSWFS 4FSWFS 4FSWFS
  18. ϩʔϧͱϩʔυόϥϯα • ϩʔϧؒͷ௨৴͸جຊతʹLBΛ௨͢ • ෛՙ෼ࢄɺ৑௕Խ͕ඞཁͳͨΊ • Linux LVS + KeepalivedΛ࢖༻

    (3ํࣜ͋Δ) • LB͕ෳ਺ωοτϫʔΫʹ෼ࢄͰ͖Ε͹Α͍ • LBͷԼ͸جຊతʹಉҰωοτϫʔΫ • L4ɺL7ͷLB͸ऴ୺͢Δ͜ͱͰผωοτϫʔΫՄ • ͨͩ͠ऴ୺͢ΔͷͰ஗͘ͳΓ͕ͪ
  19. LVSΛ࢖ͬͨϩʔυόϥϯα(NAT)   • ໭Γύέοτ͕ूத͢Δ • ࡹ͚ΔίωΫγϣϯ਺͕গͳ͍ • IPϔομΛॻ͖׵͑ΔͷͰ஗͍ =>

    ͸ͯͳͷ༻్ʹ͸߹Θͳ͍     ୯Ұ*1 7*1 ෳ਺*1 3*1 
  20. LVSΛ࢖ͬͨϩʔυόϥϯα(DR) • ໭Γύέοτ͕ूத͠ͳ͍ • ࡹ͚ΔίωΫγϣϯ਺͕ଟ͍ • IPϔομΛॻ͖׵͑ͳ͍ͷͰߴ଎ => Proxy޲͖ 

        "31Ͱղܾͯ͠.BDΞυϨεͷॻ͖׵͑ͷΈ  
  21. 4FSWJDF" 1SPYZ "QQ %# 1SPYZ 1SPYZ "QQ "QQ %# %#

    -PBE#BMBODFSɹ 4FSWJDF# 1SPYZ "QQ %# 1SPYZ 1SPYZ "QQ "QQ %# %# -PBE#BMBODFSɹ -PBE#BMBODFSɹ -PBE#BMBODFSɹ -PBE#BMBODFSɹ -PBE#BMBODFSɹ
  22. 4FSWJDF" 1SPYZ "QQ %# 1SPYZ 1SPYZ "QQ "QQ %# %#

    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FUXPSL /FUXPSL
  28. 4FSWFS 4FSWFS 4FSWFS 4FSWJDF" 1SPYZ "QQ %# 1SPYZ 1SPYZ "QQ

    "QQ %# %# -PBE#BMBODFSɹGPSQSPYZ 4FSWJDF# 1SPYZ "QQ %# 1SPYZ 1SPYZ "QQ "QQ %# %# -PBE#BMBODFSɹGPS"QQ %# ʜ $BDIF $BDIF $BDIF
  29. Linuxϧʔλ • ͸ͯͳͰ͸ήʔτ΢ΣΠͳͲʹVyOSΛ࢖͍ͬͯΔ • సૹ͚ͩͳΒ200Kpps 10Gbps ग़Δ • ςΩετϕʔεͷWebαʔϏεͳΒे෼ •

    OSSͳͲ͕ͦͷ··࢖͑Δ • Chef, GitͳͲͷߏ੒؅ཧπʔϧ • MackerelͰ؂ࢹ͢Ε͹SNMP͍Βͣ
  30. Placing the guest automatically xen 4.5 %PN 1IZTJDBM %PN6 9FO)ZQFSWJTPS

    .FN$POUSPMMFS .FN$POUSPMMFS σʔλ $16 $16 %PN6 %PN6 σʔλ σʔλ
  31. ͦͷଞͷ͸ͯͳͷج൫ͷ͓࿩ • ͸ͯͳͷϩάӡ༻ ͜Ε·Ͱͱ͜Ε͔Β • https://speakerdeck.com/tatsuru/hatena-engineer-seminar-number-6 • ͸ͯͳʹ͓͚ΔLinuxωοτϫʔΫελοΫύϑΥʔϚϯεվળ • https://speakerdeck.com/yuukit/linux-network-performance-improvement-

    at-hatena • Ծ૝Խج൫ͷϦιʔε࠷దԽ • https://speakerdeck.com/taketo957/resource-optimization-on-virtualization-platform • ෛՙ෼ࢄٕज़ΛબͿͱ͖ʹߟ͑Δ͜ͱ • https://speakerdeck.com/masayoshi/fu-he-fen-san-ji-shu-woxuan-butokinikao-erukoto-1