Server Side Swiftを
しばらく運用してみた話

Server Side Swiftを
しばらく運用してみた話

5287c9b9576749092d3170ec738338b8?s=128

Yusuke Ito

June 27, 2017
Tweet

Transcript

  1. S E R V E R S I D E

    S W I F T Λ 
 ͠ ͹ Β ͘ ӡ ༻ ͯ͠ Έ ͨ ࿩ T O K Y O S E R V E R S I D E S W I F T M E E T U P # 8 Yusuke ItoɾനϠΪίʔϙϨʔγϣϯ novi 2017/06/27
  2. χϡʔεΩϡϨʔγϣϯApp اۀ޲͚API

  3. Minutes(λΠϚʔAppͰ͢)

  4. S E R V E R - S I D

    E S W I F T ӡ ༻ ɾ ࢼ ݧ த ͷ α ʔ Ϗ ε • ΫϩʔϦϯάΛߦͳ͏σʔϞϯ(Ϋϩʔϥʔ) • Ұͭ໨: 30kߦ • ೋͭ໨: 2~3000ߦ • gRPCϕʔεͷαʔόʔ • ͲͪΒ΋Swift 3.1.1Λ࢖༻
  5. t r y ! S w i f t ʹ

    ͯ … RDS ECS(EC2 Container Service)
  6. D O C K E R Ͱ C U R

    L ͕ ಈ ͔ ͳ ͍ ໰ ୊ • cURLΛ࢖͏ϥΠϒϥϦ͕Unknown Error·ͨ͸མͪΔ • URLSession • shiroyagicorp/swift-seeurl • Docker on macOS: ⭕, Docker on AWS(ECS): Crash • Docker → • libcurl4-openssl-devͰ͸ͳ͘libcurl4-gnutls-devΛ࢖͏
  7. T I M E Z O N E ܥ A

    P I ͕ ಈ ͔ ͳ ͍ • TimeZone(abbreviation: "JST") => nil ʹͳΔ • λΠϜκʔϯͷϑΝΠϧ͕DockerΠϝʔδʹೖ͍ͬͯ ͳ͍ • apt install tzdata ͢Δ (SR-4921) • SwfitͷDockerΠϝʔδΛެ͔ࣜΒϑΥʔΫͯࣗ͠෼ Ͱ࡞Δ
  8. G R P C α ʔόʔ ͕ མ ͪ Δ

    • AWS(ECS)ʹஔ͍ͯ1࣌ؒ͘Β͍ͯ͠ΞΫηε͢Δͱؾ ·͙ΕʹམͪΔ • XcodeσόοάϏϧυ&RunͰ࠶ݱ • Address Sanitizer, Thread sanitizer Λ࢖͏ • gRPCϥΠϒϥϦपΓʹ໰୊͋Γͦ͏
  9. M Y S Q L ͕ σ ο υ ϩ

    ο Ϋ • (Swift͸௚઀ؔ܎͋Γ·ͤΜ) • SHOW ENGINE INNODB STATUS ; Ͱ࠷ޙʹى͖ͨ σουϩοΫΛදࣔ • BULK INSERT࣌ͷσουϩοΫͬΆ͍ • ݪҼ: autocommit = 1 or 0; ͷ࢖͍ํ͕ؒҧͬͯͨ
  10. ϝϞ Ϧ Ϧ ʔ Ϋ ? • AWS(ECS)্ͰҰ൩ಈ͔͢ 200MB

  11. ௐ ࠪ • InstrumentsΛ࢖͏ • Memory Allocationଌఆπʔϧ • Xcodeͷπʔϧ͕࢖͑ͯศར •

    ϥϯλΠϜ(Linux or Darwin)͕ҧ͏ͷͰͦ͜͸໰୊ • ݪҼ·ͩௐࠪத
  12. ผ ͷ α ʔ Ϗ ε Swift 3.1 (3.0.2ͷͱ͖͸͍ࢗͬͯͨ͞ͷͰ҆ఆͨ͠)

  13. · ͱ Ί • gRPCϥΠϒϥϦ͸·ͩඍົ • Protocol Buffers͸Α͍(Swift͔Βศརʹ࢖͑Δ) • શੈքతʹSwiftͷӡ༻ϊ΢ϋ΢͕গͳ͍

    • Webαʔόʔܥ΋αʔόʔϨεΞʔΩςΫνϟͳΒ͍ ͚Δ͔΋