Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

ウェブアプリケーションフレームワークの向こう側 / The other side of Web...

ウェブアプリケーションフレームワークの向こう側 / The other side of Web Application Frameworks

はてなインターン2015 インフラ講義

Yuuki Tsubouchi (yuuk1)

August 22, 2015
Tweet

More Decks by Yuuki Tsubouchi (yuuk1)

Other Decks in Technology

Transcript

  1. ΫϥΠΞϯτ αʔό socket(2) bind(2) listen(2) accept(2) connect(2) write(2) (ϒϩοΫ͢Δ) socket(2)

    “GET / HTTP1.1\nHost: TCP 3-way handshake “HTTP/1.1 200 OK\n…” read(2) (accept͔Β໭Δ) read(2) (ϒϩοΫ͢Δ) (ϒϩοΫ͢Δ) (ϒϩοΫ͢Δ) (read͔Β໭Δ) ϦΫΤετॲཧ write(2) (read͔Β໭Δ) read(2) (ϒϩοΫ͢Δ) close(2) লུ
  2. worker! process worker! process worker! process worker! process parent! process

    Client accept loop accept loop accept loop accept loop fork fork fork fork Client Client Client 1SFGPSLํࣜ
  3. thread thread thread thread Client accept loop accept loop accept

    loop accept loop Client Client Client εϨουϓʔϧํࣜ Process
  4. w 1FSM͸1SFGPSL 4DBMB +BWB ͸εϨουϓʔϧ ͕ଟ͍ w Ϛϧνϓϩηε 1SFGPSL ͔ϚϧνεϨου

    εϨο υϓʔϧ ͔Ͱάϩʔόϧม਺ͷѻ͍͕͔ΘΔ w ϚϧνεϨουͰάϩʔόϧม਺ͷϩοΫڝ߹ͯ͠ ٧·ΔͳͲ w ٯʹϚϧνϓϩηεͳΒෳ਺ͷίϯςΩετ͔Βڞ ௨ͷΦϒδΣΫτΛࢀর͢Δ͜ͱ͸͋·Γͳ͍ ʢϑΝΠϧͳͲ04ͷϦιʔε͸ผʣ
  5. ઀ଓͷҡ࣋ʁ w σʔλϕʔεͷ઀ଓίετ w 5$1ͷXBZϋϯυγΣʔΫ w %#૚ͷϋϯυγΣʔΫ w %#૚ͷೝূ w

    %#ଆͷ઀ଓ༻ϓϩηεεϨουͷੜ੒ίετ w ઀ଓ਺͕ଟ͍ͱ%#αʔόͷෛՙ͕ߴ͍ w ઀ଓࡁΈͷιέοτΛ࢖͍·Θ͍ͨ͠
  6. ઀ଓͷӬଓԽͷϋϚΓϙΠϯτ w ઀ଓ͸͞·͟·ͳཁҼͰ్தͰ੾ΕΔ͜ͱ͕͋Δ w %#͕͓ͪͯϑΣΠϧΦʔόͨ͠ w ωοτϫʔΫো֐ w ECIΦϒδΣΫτ͸উखʹ࠶઀ଓͯ͘͠Εͳ͍ w

    4DPQF$POUBJOFS%#* %#*Y)BOEMFSΛ ࢖͏ w ϩʔυόϥϯα͔ΒॏΈௐ੔Ͱ%#୆αʔϏεΞ΢ τͰ͖ͳ͍ແཧ΍Γ੾Δ
  7. Proxy App Database request response request response transaction w ϦόʔεϓϩΩγ/HJOY

    "QBDIF w ΞϓϦέʔγϣϯ1FSM 4DBMB w σʔλϕʔε.Z42- 1PTUHSF42-
  8. Proxy App Database request response request response transaction w ϦόʔεϓϩΩγ/HJOY

    "QBDIF w ΞϓϦέʔγϣϯ1FSM 4DBMB w σʔλϕʔε.Z42- 1PTUHSF42-
  9. w άϩʔόϧ͔ΒϦΫΤετΛ௚઀ड͚෇͚Δαʔό w ϦΫΤετͷ಺༰ʹ͋Θͤͯ w ޙଓͷαʔόʹϦΫΤετͨ͠Γ w ΞΫηε੍ޚͨ͠Γ w ੩తϑΝΠϧΛฦͨ͠Γ͢Δ

    w ੍ޚՄೳϙΠϯτΛ૿΍ͯ͠ɺύϑΥʔϚϯε޲্ ͤͨ͞ΓɺγεςϜશମͷӡ༻ޮ཰Λ্͛Δ Proxy App Database request response request response transaction
  10. Proxy bot༻app request response user༻app UserAgent: ~Googlebot w CPU༻ͱVTFS༻Λ6"Ͱ൑ఆͯ͠ৼΓ෼͚Δ w

    ো֐ͷӨڹൣғΛݶఆ͍ͨ͠ w CPUͱVTFSͰνϡʔχϯά಺༰Λม͑ͨΓ͢Δ w QSFGPSLܕͰ͸ಛʹޮ͖΍͍͢
  11. w ͍͍ͩͨطग़ w άϩʔόϧͳϦΫΤετ͸ΞϓϦαʔόͰड͚ͯ͸ ͍͚ͳ͍ͱ͍͏Θ͚Ͱ͸ͳ͍ w 4UBSMFU΍+FUUZΑΓɺ/HJOY"QBDIFͷ΄͏͕ ֎ʹެ։͢Δ8FCαʔόͱͯ͠͸҆৺ w มͳϔομ৯Θ͞ΕΔͱ͔

    w খ͞ͳαʔϏεͩͱΞϓϦαʔόͱϦόʔεϓϩΩ γΛಉډͤ͞Δ͜ͱ΋͋Δ Proxy App Database request response request response transaction
  12. w $16ͷΩϟογϡϝϞϦ - -ΩϟογϡͳͲʣ w 04ͷϖʔδΩϟογϡ w .Z42- *OOP%# ͷόοϑΝϓʔϧ

    w ෼ࢄΩϟογϡαʔό NFNDBDIFE  w Ωϟογϡػೳ͖ͭϦόʔεϓϩΩγ 7BSOJTI 4RVJE
  13. w 3FEJT NFNDBDIFE .POHP%#ͳͲ w 3%#.4ΑΓ͸΍͍σʔλϕʔε w ετϨʔδͱͯ͠ͷ҆৺ײ͸ྼΔ͔΋͠Εͳ͍ w ো֐࣌ͷσʔλ੔߹ੑ͕ෆ҆

    w ϦϨʔγϣφϧϞσϧͷΑ͏ͳཧ࿦తʹཱ֬͞Εͨσʔ λϞσϧͰ͸ͳ͍ w ύϑΥʔϚϯε޲্ͷͨΊʹิॿతʹ࢖༻͢Δ͜ͱ͕ଟ͍ w .BDLFSFMͰ͸࣌ܥྻσʔλϕʔεͱͯ͠(SBQIJUFΛ ࢖͍ͬͯΔ