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

半年間で60万回叩かれたAPIを公開した話 / rng-api

半年間で60万回叩かれたAPIを公開した話 / rng-api

odanado

July 15, 2017
Tweet

More Decks by odanado

Other Decks in Programming

Transcript

  1. ԿͷAPIΛ࡞ͬͨͷ • ϙέϞϯʁ • ిؾ૏ͷήʔϜ • ڈ೥ൃച͞ΕͨαϯϜʔϯ • ཚ਺ௐ੔ʁ •

    ޙͰ࿩͢ • APIʁ • Application Programming Interface • URLୟ͘ͱඞཁͳ৘ใ͕ฦͬͯ͘Δ ϙέϞϯͷཚ਺ௐ੔ͷͨΊͷ΢ΣϒAPIΛ࡞ͬͨ
  2. ཚ਺ௐ੔ʁ • ٖࣅཚ਺ • seedͷ஋ʹΑͬͯͰͨΒΊʹݟ͑Δ͚Ͳ ࣍ʹԿ͕དྷΔ͔Θ͔͍ͬͯΔཚ਺ • ਅͷཚ਺ • ࣍ʹԿ͕དྷΔ͔༧ଌෆՄೳͳຊ౰ͷཚ਺

    ήʔϜ಺ͷٖࣅཚ਺Λࢥ͍௨Γʹૢ࡞͢Δ͜ͱ seed = 42 ࣍ʹԿ͕དྷΔ͔ ༧ଌՄೳ ࣍ʹԿ͕དྷΔ͔ ༧ଌෆՄೳ
  3. ϙέϞϯͷཚ਺ௐ੔ʁ • ڧ͍ݸମ΍৭ҧ͍ͳͲग़͠์୊ • ιγϟήͰ֬ఆͰSSRΛҾ͘Α͏ͳײ͡ • ྑ͍αΠίϩͷ໨=ڧ͍ݸମ,SSR • Ͳ͏΍Δͷ͔ʁ ٖࣅཚ਺ͷseedʹΑͬͯ

    αΠίϩͷ໨͸ܾ·Δ ٖࣅཚ਺ͷseedͷ஋͸ 0͔Β2"#ͷ஋ΛऔΔ αΠίϩͷ໨͔Βseedͷ஋Λٯࢉ͢Ε͹ ͦͷޙͷαΠίϩͷ໨͸༧ଌՄೳ αΠίϩͷ໨͸ ήʔϜ্Ͱ؍ଌՄೳ
  4. ཚ਺ΞϧΰϦζϜ • ཚ਺ΞϧΰϦζϜ • seed ͔ΒαΠίϩͷ໨Λܭࢉ͢Δํ๏ • ཚ਺ΞϧΰϦζϜͷछྨ • ฏํ࠾த๏

    • ઢܗ߹ಉ๏ • ϝϧηϯψɾπΠελ • xor shift • ͳͲͳͲ ϙέϞϯͰͲͷཚ਺ΞϧΰϦζϜ͕ ࢖ΘΕ͍ͯΔ͔Θ͔Βͳ͍
  5. ࡞ͬͨAPIͷ࢓༷ • લॲཧ • αʔόଆͰ࣍ͷ஋ͷϖΞΛ2"#ݸܭࢉ • (seed, ࠷ॳnݸͷαΠίϩͷ໨) • ࠷ॳnݸͷαΠίϩͷ໨Ͱιʔτ

    • ຊॲཧ • Ϣʔβʔ͔Β࠷ॳnݸͷαΠίϩͷ໨͕དྷΔͱ ೋ෼୳ࡧͰseedΛܭࢉ • ܭࢉ݁ՌΛjsonܗࣜͰฦ٫