Slide 1

Slide 1 text

ࡾ୐༔հ / Pepabo R&D Institute, GMO Pepabo, Inc. 2017.12.23 Web System Architecture ݚڀձ (WSAݚ) #1 ෼ࢄΞϓϦέʔγϣϯʹ͓͚Δ ෳ਺୺຤ར༻Λߟྀͨ͠ ϓϥΠϕʔτσʔλͷ؅ཧ

Slide 2

Slide 2 text

ϓϦϯγύϧΤϯδχΞ ࡾ୐ ༔հ / @monochromegane 2 http://blog.monochromegane.com Yusuke Miyake ϖύϘݚڀॴ ݚڀһ

Slide 3

Slide 3 text

1. ͸͡Ίʹ 2. ෼ࢄΞϓϦέʔγϣϯʹ͓͚Δ
 ϓϥΠϕʔτσʔλ؅ཧͷ՝୊ 3. ख๏ͷఏҊ 4. ධՁ 5. ·ͱΊ 3 ໨࣍

Slide 4

Slide 4 text

1. ͸͡Ίʹ

Slide 5

Slide 5 text

• ϒϩοΫνΣʔϯٕज़ͷొ৔ʹΑΓɺΠϯλʔωοτΛܦ༝ͨ͠ݸਓؒͰͷ௚ ઀ͷՁ஋ަ׵͕༰қͱͳΓͭͭ͋Δɻ • ͜Ε·ͰͷՁ஋ަ׵ͷ஥հͱͯ͠ΞϓϦέʔγϣϯ͔Βɺ௚઀ͷՁ஋ަ׵ϓϥο τϑΥʔϜͱͯ͠ͷΞϓϦέʔγϣϯ΁ • BitCoin, Ethereum, Stoj, Filecoin, OpenBazzar… 5 ௚઀ͷՁ஋ަ׵ϓϥοτϑΥʔϜͷొ৔

Slide 6

Slide 6 text

• ͜ΕΒͷՁ஋ަ׵ϓϥοτϑΥʔϜ͸ࣗ཯͓ͯ͠Γɺதԝूݖతͳӡ༻΍αʔ όʔ͕ଘࡏ͠ͳ͍ɻ • શһ͕αʔόʔͰ͋ΓɺΫϥΠΞϯτͱͳΔ͜ͱͰՁ஋Λަ׵͠߹͏ • ैདྷܕͷWebαʔϏεʹର͢ΔύϥμΠϜγϑτ 6 ඇதԝूݖతͳΞϓϦέʔγϣϯͷ࣮૷ݕ౼ͷඞཁੑ • ඇதԝूݖతͳΞϓϦέʔγϣϯ࣮૷ͷݕ౼͕ඞཁ • ຊݚڀͰ͸ɺσʔλ؅ཧɺಛʹϓϥΠϕʔτσʔλͷऔΓѻ͍Λݕ౼

Slide 7

Slide 7 text

2. ෼ࢄΞϓϦέʔγϣϯʹ͓͚Δ ϓϥΠϕʔτσʔλ؅ཧͷ՝୊

Slide 8

Slide 8 text

• ຊݚڀใࠂͰ͸ɺ௚઀ͷՁ஋ަ׵ΛՄೳͱ͢ΔɺதԝͷίϯτϩʔϧΛഉ͠ ͨɺࣗ཯෼ࢄܕͷγεςϜΛͻͱͭҎ্૊Έ߹ΘͤͨΞϓϦέʔγϣϯΛ෼ࢄ ΞϓϦέʔγϣϯͱఆٛ͢Δ 8 ෼ࢄΞϓϦέʔγϣϯ Centrized system Distributed system Distributed application

Slide 9

Slide 9 text

• ෼ࢄΞϓϦέʔγϣϯͰ͸ΞϓϦέʔγϣϯ΍σʔλ͸෼ࢄωοτϫʔΫͷϊʔ υʹ෼ࢄ഑ஔ͞ΕΔɻ • σʔλಛੑʹ߹Θͤͨσʔλ؅ཧํࣜΛ૊Έ߹Θͤͯར༻͢Δ 9 ෼ࢄΞϓϦέʔγϣϯͱ༻్ผσʔλ؅ཧ 1. ΞϓϦέʔγϣϯʹͱͬͯॏཁͳऔҾ৘ใ͸ϒϩοΫνΣʔϯ΁ 2. औҾࣗମ͕ൃੜ͠ͳ͍Ϛελ৘ใ͸P2PϑΝΠϧγεςϜ΁ 3. ར༻ऀ͝ͱͷ৘ใ͸୺຤΁ 4. ΞϓϦέʔγϣϯ͸ϩʔΧϧͰ্هΛͭͳ͙ Blockchain P2P file system Local file system

Slide 10

Slide 10 text

• ෼ࢄΞϓϦέʔγϣϯʹ͓͚Δσʔλ؅ཧํࣜͷଟ͘͸ɺඇதԝूݖతͳߏ੒ ͔Βෳ਺ͷ୺຤͔Βൺֱత༰қʹΞΫηεՄೳ • Ұํɺར༻ऀͷ৘ใ͸֤୺຤ʹอଘ͞ΕΔͨΊɺෳ਺୺຤Ͱ؀ڥΛἧ͑ΔͨΊ ʹ͸୺຤ؒͰͷσʔλΛڞ༗͕ඞཁ 10 ෼ࢄΞϓϦέʔγϣϯʹ͓͚ΔϓϥΠϕʔτσʔλڞ༗ͷ՝୊ • ैདྷͷσʔλڞ༗Ϟσϧͷݕ౼Λ௨ͯ͠ɺ෼ࢄΞϓϦέʔγϣϯʹ͓͚Δϓϥ Πϕʔτͳσʔλڞ༗ͷ՝୊Λࣔ͢ɻ

Slide 11

Slide 11 text

ϑΝΠϧڞ༗γεςϜͱ σʔλϕʔε

Slide 12

Slide 12 text

• தԝूݖతͳσʔλڞ༗Ϟσϧ • NFS΍DropboxʹΑΔαʔόʔΛܦ༝ͨ͠ϑΝΠϧڞ༗ • σʔλΛҰݩ؅ཧ͢Δσʔλϕʔεαʔόʔ • αʔόʔ্ͷίϯςϯπΛ૬ޓࢀরͤ͞ΔυΩϡϝϯτϕʔεγεςϜͱ͠ ͯͷWWW 12 ϑΝΠϧڞ༗γεςϜͱσʔλϕʔε

Slide 13

Slide 13 text

P2Pܕσʔλϕʔε

Slide 14

Slide 14 text

• ดͨ͡ωοτϫʔΫΛ༻͍ͨσʔλڞ༗Ϟσϧ • Amazon DynamoDB΍Apache Cassandra • ϊʔυ௥Ճ΍σʔλΞΫηε͸தԝूݖతʹίϯτϩʔϧ • ดͨ͡ઐ༻ͷωοτϫʔΫͱͯ͠ߏஙɺӡ༻ 14 P2Pܕσʔλϕʔε

Slide 15

Slide 15 text

P2Pܕ෼ࢄϑΝΠϧγεςϜ

Slide 16

Slide 16 text

• ։͚ͨωοτϫʔΫΛ༻͍ͨσʔλڞ༗Ϟσϧ • P2PωοτϫʔΫΛ༻͍ͨ෼ࢄϑΝΠϧγεςϜ • ωοτϫʔΫࢀՃऀ͕σʔλΛࢀরՄೳ 16 P2Pܕ෼ࢄϑΝΠϧγεςϜ

Slide 17

Slide 17 text

• IPFS (InterPlanetary File System) • σʔλͷ෼ࢄอଘͱσʔλ಺༰ʹجͮ͘ΞυϨογϯά • σΟϨΫτϦߏ଄Λѻ͑Δ • σʔλมߋ͕ΞυϨεมߋͱಉҙͳͷͰΞυϨεΛ؅ཧ͢Δඞཁ͕͋Δ • IPNS(InterPlanetary Name Service)ʹΑΔ೚ҙΞυϨεΛݻఆతʹࢀর 17 P2Pܕ෼ࢄϑΝΠϧγεςϜ - IPFS -

Slide 18

Slide 18 text

P2Pܕ෼ࢄϑΝΠϧγεςϜ্ͷ σʔλετΞ

Slide 19

Slide 19 text

• P2Pܕ෼ࢄϑΝΠϧγεςϜͷಛੑΛߟྀͨ͠σʔλڞ༗Ϟσϧ • σʔλʹجͮ͘ΞυϨογϯάʹΑΓ෦෼มߋ͕ߦ͑ͳ͍ͨΊɺมߋͷہ ॴԽ͕ඞཁ • ෳ਺୺຤Ͱར༻͢ΔͨΊσʔλڝ߹ͷճආ͕ඞཁ 19 P2Pܕ෼ࢄϑΝΠϧγεςϜ্ͷσʔλετΞ

Slide 20

Slide 20 text

• OrbitDB • ૢ࡞ཤྺΛݸʑʹอଘ͢Δ͜ͱͰมߋΛہॴԽ • Մ׵ͳૢ࡞ͷΈΛೝΊΔ͜ͱͰॱෆಉͳσʔλΛड͚෇͚Δ͜ͱͰσʔλ ڝ߹ΛճආʢCRDTʣ • ཤྺͷ૿Ճʹ൐͍ࢀর࣌ͷΦʔόʔϔου͕ൃੜ͢Δ 20 P2Pܕ෼ࢄϑΝΠϧγεςϜ্ͷσʔλετΞ

Slide 21

Slide 21 text

3. ෼ࢄΞϓϦέʔγϣϯʹ͓͚Δ ϓϥΠϕʔτσʔλ؅ཧख๏ͷఏҊ

Slide 22

Slide 22 text

1. ඇதԝूݖతͳߏ੒Ͱ͋Δ͜ͱ 2. ෼ࢄอଘ͞ΕΔσʔλʹରͯ͠ࢀর੍ݶΛ͔͚ΕΔ͜ͱ 3. ։͔Εͨීٴ͍ͯ͠ΔP2PܕωοτϫʔΫΛ༻͍Δ͜ͱ 4. ࠷৽ͷΞυϨεΛอ࣋·ͨ͸ղܾͰ͖Δ͜ͱ 5. มߋ͕ہॴԽ͞Ε͍ͯΔ͜ͱ 6. มߋͷڝ߹ʹରԠͰ͖Δ͜ͱ 7. ࢀর࣌ͷΦʔόʔϔου͕গͳ͍͜ͱ 22 ෼ࢄΞϓϦέʔγϣϯʹ͓͚ΔϓϥΠϕʔτσʔλ؅ཧ

Slide 23

Slide 23 text

Kaleidoscope Distributed peer-to-peer personal key-value store. https://github.com/monochromegane/kaleidoscope

Slide 24

Slide 24 text

Kaleidoscopeͷ࢓૊Έ

Slide 25

Slide 25 text

• P2P෼ࢄϑΝΠϧγεςϜ্ͷKey-Value Store • P2PωοτϫʔΫʹIPFSΛ࢖༻ • σʔλετΞ໊ɺΩʔ໊ΛσΟϨΫτϦͱ͠ɺ಺༰ΛϑΝΠϧͱ͢ΔσΟϨΫ τϦߏ଄ΛIPFS্ʹอଘ • σʔλ͸λΠϜελϯϓ౳ͷϝλσʔλͱ಺༰Λ߹Θͤͯ҉߸Խ • IPNSʹΑΔ࠷৽ΞυϨεͷղܾ 25 Kaleidoscopeͷ࢓૊Έ

Slide 26

Slide 26 text

26 Kaleidoscopeͷ࢓૊Έ QmFoo ├── __database_name ├── key1 │ └── value └── key2 └── value IPFS Kaleidoscope Application Encrypt / Decrypt Key <-> Directory IPNS Current address Name Hash Metadata + data Hash

Slide 27

Slide 27 text

• ϑΝΠϧϕʔεࠩ෼ํࣜ • P2P෼ࢄϑΝΠϧγεςϜ্ʹσʔλετΞͷϑΝΠϧΛ௚઀഑ஔ • ΦϖϨʔγϣϯϕʔεࠩ෼ํࣜ (OrbitDB) • P2P෼ࢄϑΝΠϧγεςϜಛੑΛߟྀͨ͠มߋہॴԽΛཤྺ୯ҐอଘͰ࣮ݱ • σΟϨΫτϦϕʔεࠩ෼ํࣜ (Kaleidoscope) • ఏҊํࣜɻσʔλߏ଄ʹΑͬͯมߋہॴԽΛ࣮ݱ 27 ࠩ෼ߋ৽ͷํࣜ෼ྨ

Slide 28

Slide 28 text

• ஋ͷߋ৽͸Ωʔ୯Ґʹ෼཭͞ΕɺσʔλετΞશମͷσʔλ༰ྔʹґଘ͠ͳ͍ • σΟϨΫτϦߏ଄ͷΞυϨεΛࢀর͢ΔͨΊɺཤྺࢀর͕ෆཁ • ஋ʹλΠϜελϯϓΛ࣋ͭ͜ͱͰɺσΟϨΫτϦߏ଄ͷ౷߹͕Մೳ • ॱෆಉͳՄ׵ͳૢ࡞ͱͯ͠දݱͰ͖Δ 28 σΟϨΫτϦϕʔεࠩ෼ํࣜʹΑΔ՝୊ͷղܾ

Slide 29

Slide 29 text

Kaleidoscopeͷجຊతͳར༻ํ๏ 29 # Start IPFS daemon $ ipfs daemon # Start Kaleidoscope CLI $ kes > create my-db # => Create datastore key pair and Register directory on IPFS > > set key1 value1 # => Save encrypted data on IPFS > > get key1 value1 # => Get and decrypt data from directory on IPFS > > save # => Update IPNS by newest hash value

Slide 30

Slide 30 text

KaleidoscopeͰͷ୺຤ؒσʔλڞ༗ (1) 30 $ kes > use my-db # => Get newest hash value from IPNS → ݱঢ়ɺIPNSͷߋ৽ॲཧʹ਺ඵ͔͔ΔͨΊɺϦΞϧλΠϜͷಉظ͕೉͍͠

Slide 31

Slide 31 text

KaleidoscopeͰͷ୺຤ؒσʔλڞ༗ (2) 31 # Start IPFS daemon with pubsub option $ ipfs daemon --enable-pubsub-experiment $ kes > sync # => Thereafter, operation history from other own terminal online is shared • ૢ࡞छผͱର৅ͱͳͬͨϑΝΠϧͷϋογϡ஋ΛPubSubܦ༝Ͱૹ৴ • ड৴ଆ͸ɺࣗ਎ͷૢ࡞ʹͦΕΒͷૢ࡞Λࠩ͠ࠐΈͳ͕Βॱ൪ʹॲཧ → ࣮ࡍͷӡ༻Ͱ͸λΠϜελϯϓ·Ͱߟྀͨ͠౷߹͕ඞཁ

Slide 32

Slide 32 text

KaleidoscopeͰͷ୺຤ؒσʔλϚʔδ 32 ݱ࣌఺Ͱ͸ະ࣮૷ σΟϨΫτϦΛλΠϜελϯϓΛߟྀͯ͠Ϛʔδ ࡟আ࣌΋λΠϜελϯϓΛอ͓࣋ͯ͘͠ඞཁ͕͋Γͦ͏

Slide 33

Slide 33 text

4. ධՁ

Slide 34

Slide 34 text

ࠩ෼ํࣜʹΑΔߋ৽࣌ؒͷൺֱ 34 .# .# .# .# .# .# .# .# .# .# pMFCBTFE PQFCBTFE EJSCBTFE • σʔλετΞͷ༰ྔ͝ͱͷ IPFS΁ͷొ࿥࣌ؒΛൺֱ • ϑΝΠϧϕʔεࠩ෼͸༰ྔʹൺ ྫͯ͠ొ࿥͕࣌ؒ૿Ճ • มߋΛہॴԽ͢ΔํࣜͰ͸༰ ྔʹґଘͤͣҰఆ • σΟϨΫτϦϕʔεࠩ෼ํࣜͰ ͸σΟϨΫτϦߋ৽෼ͷΦʔόʔ ϔου͕ݟΒΕΔ

Slide 35

Slide 35 text

ࠩ෼ํࣜʹΑΔॳظىಈ࣌ؒͷൺֱ 35 .# .# .# .# .# .# .# .# .# .# pMFCBTFE PQFCBTFE EJSCBTFE • σʔλετΞͷ༰ྔ͝ͱͷॳ ظىಈ࣌ؒΛൺֱ • ϑΝΠϧϕʔεࠩ෼ɺΦϖϨʔ γϣϯϕʔεࠩ෼Ͱ͸༰ྔ·ͨ ͸ཤྺͷ૿Ճʹൺྫ͢Δ • σΟϨΫτϦϕʔεࠩ෼͸ৗʹ ࠷৽Λอ࣋͢ΔͨΊॳظىಈ ࣌ؒ͸ൃੜ͠ͳ͍

Slide 36

Slide 36 text

• ະ࣮૷ • ΦϖϨʔγϣϯϕʔεࠩ෼ํࣜ͸શཤྺΛ࢖͏ͷʹର͠ɺσΟϨΫτϦϕʔε ࠩ෼ํࣜ͸࠷৽ͷ஋ಉ࢜ͷΈͰϚʔδΛߦ͏ͨΊɺ༏ҐͰ͋Δͱ૝ఆ 36 ࠩ෼ํࣜʹΑΔϚʔδ࣌ؒͷൺֱ

Slide 37

Slide 37 text

5. ·ͱΊ

Slide 38

Slide 38 text

• ෼ࢄΞϓϦέʔγϣϯ࣮૷ʹ͓͚ΔϓϥΠϕʔτσʔλڞ༗ͷ՝୊Λݕ౼ͨ͠ • ैདྷํࣜͰ࠷΋ద͍ͯ͠ΔP2P෼ࢄϑΝΠϧγεςϜ্ͷσʔλετΞͷ՝୊ ΛσΟϨΫτϦϕʔεࠩ෼ํࣜͰղܾΛਤͬͨ • σʔλ༰ྔ΍ཤྺʹґଘ͠ͳ͍͜ͱΛݕূͨ͠ • σΟϨΫτϦϕʔεͷσʔλߏ଄͸֦ு΋ݟࠐΊΔ • ࠓޙ͸ಉظͱ·ʔ͡ͷ࣮૷ʹ͍ͭͯӡ༻ଇ͔Β஌ݟΛ൓өͯ͠ਐΊ͍ͨ 38 ·ͱΊ

Slide 39

Slide 39 text

No content