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

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

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

A658ec7f1badf73819dfa501165016c1?s=128

Yuuki Tsubouchi (yuuk1)

August 22, 2015
Tweet

Transcript

  1. 4.
  2. 11.
  3. 12.
  4. 21.
  5. 22.

    ΫϥΠΞϯτ αʔό 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) লུ
  6. 24.

    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ํࣜ
  7. 25.

    thread thread thread thread Client accept loop accept loop accept

    loop accept loop Client Client Client εϨουϓʔϧํࣜ Process
  8. 26.
  9. 27.

    w 1FSM͸1SFGPSL 4DBMB +BWB ͸εϨουϓʔϧ ͕ଟ͍ w Ϛϧνϓϩηε 1SFGPSL ͔ϚϧνεϨου

    εϨο υϓʔϧ ͔Ͱάϩʔόϧม਺ͷѻ͍͕͔ΘΔ w ϚϧνεϨουͰάϩʔόϧม਺ͷϩοΫڝ߹ͯ͠ ٧·ΔͳͲ w ٯʹϚϧνϓϩηεͳΒෳ਺ͷίϯςΩετ͔Βڞ ௨ͷΦϒδΣΫτΛࢀর͢Δ͜ͱ͸͋·Γͳ͍ ʢϑΝΠϧͳͲ04ͷϦιʔε͸ผʣ
  10. 31.

    ઀ଓͷҡ࣋ʁ w σʔλϕʔεͷ઀ଓίετ w 5$1ͷXBZϋϯυγΣʔΫ w %#૚ͷϋϯυγΣʔΫ w %#૚ͷೝূ w

    %#ଆͷ઀ଓ༻ϓϩηεεϨουͷੜ੒ίετ w ઀ଓ਺͕ଟ͍ͱ%#αʔόͷෛՙ͕ߴ͍ w ઀ଓࡁΈͷιέοτΛ࢖͍·Θ͍ͨ͠
  11. 33.

    ઀ଓͷӬଓԽͷϋϚΓϙΠϯτ w ઀ଓ͸͞·͟·ͳཁҼͰ్தͰ੾ΕΔ͜ͱ͕͋Δ w %#͕͓ͪͯϑΣΠϧΦʔόͨ͠ w ωοτϫʔΫো֐ w ECIΦϒδΣΫτ͸উखʹ࠶઀ଓͯ͘͠Εͳ͍ w

    4DPQF$POUBJOFS%#* %#*Y)BOEMFSΛ ࢖͏ w ϩʔυόϥϯα͔ΒॏΈௐ੔Ͱ%#୆αʔϏεΞ΢ τͰ͖ͳ͍ແཧ΍Γ੾Δ
  12. 35.

    Proxy App Database request response request response transaction w ϦόʔεϓϩΩγ/HJOY

    "QBDIF w ΞϓϦέʔγϣϯ1FSM 4DBMB w σʔλϕʔε.Z42- 1PTUHSF42-
  13. 41.

    Proxy App Database request response request response transaction w ϦόʔεϓϩΩγ/HJOY

    "QBDIF w ΞϓϦέʔγϣϯ1FSM 4DBMB w σʔλϕʔε.Z42- 1PTUHSF42-
  14. 43.

    w άϩʔόϧ͔ΒϦΫΤετΛ௚઀ड͚෇͚Δαʔό w ϦΫΤετͷ಺༰ʹ͋Θͤͯ w ޙଓͷαʔόʹϦΫΤετͨ͠Γ w ΞΫηε੍ޚͨ͠Γ w ੩తϑΝΠϧΛฦͨ͠Γ͢Δ

    w ੍ޚՄೳϙΠϯτΛ૿΍ͯ͠ɺύϑΥʔϚϯε޲্ ͤͨ͞ΓɺγεςϜશମͷӡ༻ޮ཰Λ্͛Δ Proxy App Database request response request response transaction
  15. 44.

    Proxy bot༻app request response user༻app UserAgent: ~Googlebot w CPU༻ͱVTFS༻Λ6"Ͱ൑ఆͯ͠ৼΓ෼͚Δ w

    ো֐ͷӨڹൣғΛݶఆ͍ͨ͠ w CPUͱVTFSͰνϡʔχϯά಺༰Λม͑ͨΓ͢Δ w QSFGPSLܕͰ͸ಛʹޮ͖΍͍͢
  16. 46.

    w ͍͍ͩͨطग़ w άϩʔόϧͳϦΫΤετ͸ΞϓϦαʔόͰड͚ͯ͸ ͍͚ͳ͍ͱ͍͏Θ͚Ͱ͸ͳ͍ w 4UBSMFU΍+FUUZΑΓɺ/HJOY"QBDIFͷ΄͏͕ ֎ʹެ։͢Δ8FCαʔόͱͯ͠͸҆৺ w มͳϔομ৯Θ͞ΕΔͱ͔

    w খ͞ͳαʔϏεͩͱΞϓϦαʔόͱϦόʔεϓϩΩ γΛಉډͤ͞Δ͜ͱ΋͋Δ Proxy App Database request response request response transaction
  17. 53.

    w $16ͷΩϟογϡϝϞϦ - -ΩϟογϡͳͲʣ w 04ͷϖʔδΩϟογϡ w .Z42- *OOP%# ͷόοϑΝϓʔϧ

    w ෼ࢄΩϟογϡαʔό NFNDBDIFE  w Ωϟογϡػೳ͖ͭϦόʔεϓϩΩγ 7BSOJTI 4RVJE
  18. 56.

    w 3FEJT NFNDBDIFE .POHP%#ͳͲ w 3%#.4ΑΓ͸΍͍σʔλϕʔε w ετϨʔδͱͯ͠ͷ҆৺ײ͸ྼΔ͔΋͠Εͳ͍ w ো֐࣌ͷσʔλ੔߹ੑ͕ෆ҆

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