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

Site Reliability Engineering for GMO

Site Reliability Engineering for GMO

GMOインターネットグループの研修でお話しました。

Kazuhiko Yamashita

April 17, 2024
Tweet

More Decks by Kazuhiko Yamashita

Other Decks in Programming

Transcript

  1. Known-Unknowns Known - Knonwns Known - Unknowns Unknown - Unknown

    –O’REILLY ৄղ γεςϜɾύϑΥʔϚϯε 2.3.8 Known - Unknowns ʮΧϨʔ͸ඒຯ͍͠ʯ ʮΧϨʔͬͯ৯͍෺͸ඒຯ͍Β͍͠ͳʁʯ ʮനถ͕Ұ൪ʂʂ͜ΕҎ֎ߟ͑ΒΕͳ͍ʂʂʂʯ ແ֮ࣗʹ஌Βͳ͍··ຊ൪αʔόʹΞϓϩʔν͠ͳ͍
  2. N+1໰୊ ID Name Department ID 1 A 1 2 B

    2 3 C 3 4 D 4 ID Name 1 ૯຿෦ 2 ܦཧ෦ 3 ٕज़෦ 4 ୎ٿ෦ ैۀһςʔϒϧ ෦ॺςʔϒϧ ͢΂ͯͷैۀһͷ෦ॺ໊Λऔಘ͍ͨ͠
  3. N+1໰୊ result = query(“SELECT * FROM ैۀһςʔϒϧ”) result.each do |r|

    dr = query(“SELECT * FROM ෦ॺςʔϒϧ WHERE ID = #{result[‘Department ID’]}”) end O(n²)Ͱޮ཰͕ѱ͍
  4. N+1໰୊ result = query(“SELECT ɹɹɹɹɹɹɹ * ɹɹɹɹɹɹɹFROM ैۀһςʔϒϧ INNER JOIN

    ෦ॺςʔϒϧ ON ैۀһςʔϒϧ.ID = ෦ॺςʔϒϧ.ID”) ݁߹͢Δ͜ͱͰܭࢉྔΛ࡟ݮ
  5. ৄղϨʔτϦϛοτʹΑΔܦࡁଛࣦ 1. େྔΞΫηε͕ൃੜ͢Δ 2. ϨʔτϦϛοτΛ͔͚Δ 3. ঎඼ʹΞΫηε͕Ͱ͖ͳ͍ͷͰചΕͳ͘ͳΔ 4. ঎඼͕ചΕͳ͍ͱ͓٬༷γϣοϓͷച্্͕͕Βͳ͍ 5.

    ͓٬༷ͷച্্͕͕Βͳ͍ͱΧϥʔϛʔͷച্্͕͕Βͳ͍ 6. ձࣾͷച্্͕͕Βͳ͍ 7.Զͷڅྉ্͕͕Βͳ͍!!!ώϧτϯʹߦ͚ͳ͍!!1
  6. Ծ૝଴߹ࣨ֓ཁ proxy role nginx waiting room proxy role nginx waiting

    room proxy role nginx waiting room proxy role nginx waiting room proxy role nginx waiting room proxy role nginx waiting room proxy role nginx waiting room ڐՄϦετ Site A 200 Site B ... Site C ... ΫϥΠΞϯτʹ଴ͪ൪߸Λ࠾൪ͯ͠ɺڐՄϦετͷ൪߸ΑΓ খ͍͞൪߸Λ͍࣋ͬͯΕ͹Ұఆ࣌ؒΞΫηε͕Մೳ Client A ΫϥΠΞϯτ൪߸:100 ΞΫηεڐՄ Client B ΫϥΠΞϯτ൪߸:300 ଴߹ࣨ΁
  7. ϦϦʔεϑϥάͷجຊ ϦϦʔεϑϥά ɹ֎෦ͷαʔόͱ࿈ܞͯ͠ɺιʔεΛมߋ͢Δ ɹ͜ͱͳ͘ɺΞϓϦέʔγϣϯͷڍಈΛ ɹมߋͰ͖Δ <?php /** * ఻આͷϢχίʔϯػೳϦϦʔε؅ཧ *

    NOTE: Ϣχίʔϯػೳ͸·ͩ఻આϨϕϧɻੈք͕४ උͰ͖͍ͯͳ͍Մೳੑ͋Γɻ */ if ($isUnicornReleased) { echo "🦄΢ϗοʂϢχίʔϯΛղ์͠Ζʂ🌈"; } else { echo "🙈·ͩͩɺϢχίʔϯ͸಺ॹͩΑʙ"; } ?>
  8. ϦϦʔεํࣜ ୅දతͳϦϦʔεํࣜ ΧφϦΞϦϦʔε App App App App 25%͚ͩϦϦʔε͢Δ ϩʔϦϯάϦϦʔε App

    App App App ஈ֊తʹ৽͘͠ϦϦʔε͢Δ BlueGreenϦϦʔε App App ৽͍͠ϦϦʔεͷάϧʔϓΛ࡞Δ App App Ұ؏ੑ͕͋Γɺ੾Γ໭͠΋༰қ͕ͩ Ϧιʔε͕ഒඞཁʹͳΔ Өڹൣғ͕ݶఆ͞ΕΔ͕ɺ ΞϓϦέʔγϣϯͷ Ұ؏ੑ͸ଛͳΘΕΔ ΧφϦΞϦϦʔεͱ Ұॹʹར༻͞ΕΔ͜ͱ͕ଟ͍