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

Practical Hexaville(ja)

Practical Hexaville(ja)

Tokyo Server Side Swift Meetup #8

Yuki Takei

July 05, 2017
Tweet

More Decks by Yuki Takei

Other Decks in Technology

Transcript

  1. ࣮ફHexaville Yuki Takei@Tokyo Server Side Swift Meetup #8 27 Jun,

    2017 ʙ 5෼Ͱ࡞ΔαʔόʔϨεͳSwift੡SNSೝূαʔόʔ ʙ
  2. Hexavilleͱ͸ • Swift੡ͷαʔόʔϨε؀ڥΛߏங͢ΔϑϨʔϜϫʔΫͱͦͷ πʔϧ܈ (ݱࡏ͸AWS Lambda + API GatewayͷΈ) •

    ίʔυϕʔε͕SwiftͷͨΊɺiOSΞϓϦέʔγϣϯΛॻ͘Ԇ௕ ͰαʔόʔϓϩάϥϜΛهड़Ͱ͖Δɻ • ී௨ͷwebΞϓϦέʔγϣϯΛ࡞ͬͯσϓϩΠ͢Δ͚ͩ • ίϚϯυҰͭͰΫϥ΢υ্ʹσϓϩΠ͞Εɺαʔόʔӡ༻ͳ ͠ͰαʔϏεΛ։࢝Ͱ͖Δ • XcodeͰͷ։ൃ؀ڥΛఏڙɺInstrumentsɺLLDBΛ࢖ͬͨσ όοά΋Մೳ
  3. $ hexaville deploy Hello Start to build swift... Building application....

    Generating Routing Manifest file.... Sending build context to Docker daemon 176 MB Step 1/11 : FROM ubuntu:14.04 ---> 132b7427a3b4 Step 2/11 : RUN apt-get update -y ---> Using cache ---> fd9a040329d6 Step 3/11 : RUN apt-get install -y clang libicu-dev libbsd-dev uuid-dev git libxml2-dev libxslt1-dev python-dev libcurl4-openssl-dev wget ---> Using cache ---> c4890f13de61 Step 4/11 : ENV SWIFT_DOWNLOAD_URL https://swift.org/builds/swift-3.1-release/ ubuntu1404/swift-3.1-RELEASE/swift-3.1-RELEASE-ubuntu14.04.tar.gz ---> Using cache ---> a5ac353284e3 Step 5/11 : ENV SWIFTFILE swift-3.1-RELEASE-ubuntu14.04 ---> Using cache Ϗϧυ։࢝ σϓϩΠ
  4. • Hexavilleʹ༷ʑͳೝূػೳΛఏڙ͢ΔϓϥάΠϯ • OAuth1, OAuth2ΫϥΠΞϯτΛఏڙ • FacebookɺGithubɺGoogle, TwitterͷOAuthΛσϑΥϧτͰ ఏڙ •

    HexavilleͷRouterͱͯ͠ಈ࡞͢Δ • ηογϣϯΛར༻Մೳ(Memory, Redis, Dynamodb(࣮૷த)) • ಠࣗͷOAuthΫϥΠΞϯτΛϓϩτίϧʹԊͬͯ؆୯ʹ࡞੒ Մೳ HexavilleAuth
  5. DB Lambda Function Lambda Function Lambda Function Lambda Function Lambda

    Function αʔόʔϨε ίϯϐϡʔςΟϯάͷ࣮ߦϞσϧ(DB઀ଓ༗Γ)
  6. αʔόʔϨε ίϯϐϡʔςΟϯάͷ࣮ߦϞσϧ(DB઀ଓ༗Γ) DB Lambda Function Lambda Function Lambda Function Lambda

    Function Lambda Function ΫϥΠΞϯτͷίωΫγϣϯ਺ || DBͷίωΫγϣϯ઀ଓ਺
  7. αʔόʔϨε ίϯϐϡʔςΟϯάͷ࣮ߦϞσϧ(DB઀ଓ༗Γ) DB Lambda Function Lambda Function Lambda Function Lambda

    Function Lambda Function DB͸1connection = 1threadͰ ड͚෇͚Δ࣮૷͕ଟ͍
  8. αʔόʔϨε ίϯϐϡʔςΟϯάͷ࣮ߦϞσϧ(DB઀ଓ༗Γ) DB Lambda Function Lambda Function Lambda Function Lambda

    Function Lambda Function ॏ͍ΫΤϦΛ౤͍͛ͯͳͯ͘΋ɺ େͨ͠਺ͷΫΤϦΛ౤͍͛ͯͳͯ͘΋ɺ ͋ͳͨͷDB͸൵໐Λ্͛Δ͜ͱʹͳΓ·͢ɻ
  9. αʔόʔϨε ίϯϐϡʔςΟϯάͷ࣮ߦϞσϧ(DB઀ଓ༗Γ) DB Lambda Function Lambda Function Lambda Function Lambda

    Function Lambda Function RedisͳͲͷϊϯϒϩοΩϯάͳNoSQLσʔλ ϕʔε΋ྫ֎ʹ΋ΕͣɺίωΫγϣϯ਺΍ಉ࣮࣌ ߦ਺͕૿͑Ε͹ͦͷ෼DB΁ͷෛՙ΋্͕Δɻ ·ͨɺ઀ଓՄೳͳΫϥΠΞϯτ਺͸Ϛγϯεϖο Ϋʹґଘ͢ΔͨΊɺແବʹNode͕૿͑ΔՄೳੑ ΋ɻ