$30 off During Our Annual Pro Sale. View Details »

Introduction of Slimane And Server Side Swift (...

Yuki Takei
March 08, 2016

Introduction of Slimane And Server Side Swift (Japanese)

Yuki Takei

March 08, 2016
Tweet

More Decks by Yuki Takei

Other Decks in Technology

Transcript

  1. TABLE OF CONTENTS ▸ ࣗݾ঺հ ▸ Swift ͰServer Side? ▸

    Slimaneʹ͍ͭͯ ▸ σϞ ▸ ϕϯνϚʔΫ ▸ ։ൃܦݧஊ(ςετ΍ɺLinuxͰࠔͬͨ͜ͱͳͲ) ▸ ՝୊ɺ·ͱΊ
  2. ࣗݾ঺հ ෢Ҫ ༏ݾ ϑϦʔϥϯε ιϑτ΢ΣΞΤϯδχΞ / ϥδΦύʔιφϦςΟ ௨শ noppoman ݱࡏͷओͳ࢓ࣄ

    ɾגࣜձࣾiDEAKITT Ϧʔυσϕϩούʔ ʢ૑ۀظ͔Β) ɾגࣜձࣾSmartDrive όοΫΤϯυ/σʔλղੳʢ૑ۀظ͔Β) ݴޠͩͱɺNode.js, Ruby, Python, GO, SwiftΛ࠷ۙͩͱΑ͘࢖͍·͢ɻ MikeTOKYOͱ͍͏ϥδΦΛ΍͍ͬͯ·͢ɻস
  3. SWIFTͰSERVER SIDE? ▸ core-foundation (Swift࣮૷ͷFoundation) ▸ Swift Package Manager (go

    getతͳ΍ͭ) ▸ XCTest ▸ gcd ▸ swift-llvm/lldb ύʔβʔ΍ϥϯλΠϜͳͲͷجຊతͳswiftݴޠػೳͷଞɺ ͳͲ΋ҰॹʹOSSԽ
  4. SLIMANEʹ͍ͭͯ ▸ ExpressɺSinatraͷྲྀΕΛ૊ΉܰྔϑϨʔϜϫʔΫ ▸ ඇಉظI/OʢΠϕϯτϧʔϓʣ ▸ C10K໰୊ ▸ ؆୯ɺγϯϓϧͳrouting ▸

    middlewareʹΑΔ֦ு ▸ Cluster mode(Ϛϧνϓϩηε؀ڥ) ▸ ໊લͷ༝དྷ͸ϑΝογϣϯσβΠφͷΤσΟεϦϚϯ Slimane͸ݱࡏචऀ͕։ൃதͷܰྔwebϑϨʔϜϫʔΫ
  5. SLIMANEʹ͍ͭͯ Slimane͸Web Server/Web Application FrameWork ҎԼͷ̏૚͔Βߏ੒͞ΕΔ Slimane SlimaneHTTP Suv *

    ɾURL Routing * ɾMiddleware * ɾBody Parser * ɾCookie And Session * ɾStatic Assets Serving ɾHTTP Server ɾHTTP Client Not implemented yet ɾHTTP Upgrade ɾHTTPS ɾNetworking ɾFileSystem ɾProcess ɾCluster and Worker ɾTimer, DNS, Signal ɾEncryption etc… High Low
  6. SLIMANEʹ͍ͭͯ / SLIMANEHTTP SlimaneHTTP ɾHTTP Server ɾHTTP Client Not implemented

    yet ɾHTTP Upgrade ɾHTTPS SuvϕʔεͷඇಉظHTTP Server/Client ɾSlimaneͷHTTPϨΠϠʔ ɾryan࡞ͷhttp-parser͕ϕʔε ɾHTTP/1.1ͷServerͱClient࣮૷ ɾHTTPS͸·ͩʢۙ೔ணखʣ ɾUpgrade(Websocket/HTTP2.0ͳͲ)͸·ͩ
  7. SLIMANEʹ͍ͭͯ / SLIMANE Slimane ɾURL RoutingɺMiddlewareΛఏڙ ɾCookie ParserɺSessionɺBodyParserɺFile Serving ɾ֦ு͕ඞཁ͕ͩɺViewςϯϓϨʔτ΋࢖͑Δ

    ɾModelͳ͠ʢඇಉظDBDriver͸طଘͷ΋ͷΛfolkͳͲ͠ ͯผ్։ൃ༧ఆʣ ɾઐ༻ίϚϯυϥΠϯΠϯλʔϑΣʔεʢۙ೔ެ։ʣ * ɾURL Routing * ɾMiddleware * ɾBody Parser * ɾCookie And Session * ɾStatic Assets Serving
  8. ϕϯνϚʔΫͷલʹ…. SWIFTͰ࢖͑ΔϑϨʔϜϫʔΫͷ঺հ ▸ Zewo (CSPɺGCDɺServerɺRoutingɺSSLͳͲ) ▸ Vapor (Laravel Inspired MVC)

    ▸ Swifton (Rails Inspired MVC) ▸ Kitura (From IBM. Express Like) ▸ Nest (Common Swift Server Side Interface PJ) େখͷServerɺWAF΍CSP࣮૷ͳͲ͕ɺ͜ͷ3ϲ݄ؒͰଓʑొ৔
  9. BENCHMARK݁Ռ Time 0 1.75 3.5 5.25 7 SLIMANE SLIMANE HTTP

    NGINX EXPRESS REVEL SWIFTON VAPOR KITURA ɾܭଌ͸apache benchͰߦͬͨ (ab -n 10000 -c 100) ɾ؀ڥ͸ɺAWS EC2ͷt2.medium(vCPU: 2, Mem: 4) ɾDBΞΫηεແ͠ɺͦΕͧΕͷindex htmlΛฦ͢୯७ͳςετ ɾKituraҎ֎͸Έͳrelease build
  10. SLIMANEͷࠓޙͷ՝୊ ▸ libuvʢඇಉظʣͷͨΊɺྑ͘΋ѱ͘΋ͦ͜ʹͱΒΘΕΔ ▸ ಛʹωοτϫʔΫ΍ϑΝΠϧI/Oޙͷcallback hell ▸ PromiseͳͲͰcallback hellΛආ͚Δ(nodeͷyieldཉ͍͠…) ▸

    αʔυύʔςΟ੡ͷϥΠϒϥϦͱͷ਌࿨ੑ(ಛʹಉظI/Oܥ) ▸ ·ͩ·ͩmemory leak͕͋ΔʢZewoͷϥΠϒϥϦͰ͢Β͍ͯ͠Δ..ʣ ▸ ϓϩμΫγϣϯ؀ڥͰͷӡ༻ɺϑΟʔυόοΫ͕ඞਢ ▸ ։ൃ଎౓ͷ໰୊ɻ஥ؒΛूΊͯεϐʔυΞοϓ͍ͨ͠