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

모바일 게임용 PaaS/BaaS 구현사례와 디자인 트레이드오프

모바일 게임용 PaaS/BaaS 구현사례와 디자인 트레이드오프

Gametech 2014 (2014-04-03)에서 발표했던 자료

모바일 게임 서비스, 특히 게임 서버를 만들 때 사용가능한 기술들과, 각각의 기술을 고르는 디자인 선택과 그에 따르는 트레이드 오프를 다룬다.

A417a277d4634ed41678db8fbed7ab3f?s=128

reinkim

April 03, 2014
Tweet

More Decks by reinkim

Other Decks in Programming

Transcript

  1. ݽ߄ੌ ѱ੐ ੹ਊ BaaS/PaaS ҳഅ ࢎ۹৬ ٣੗ੋ ౟ۨ੉٘ য়೐ ӣ૓਌

    (jinuk.kim@ifunfactory.com) iFunFactory Inc.
  2. Who am I • ӣ૓਌ (jinuk.kim@ifunfactory.com) • അ੤: ѱ੐ ࢲ࠺झܳ

    ਤೠ ೞ੉࠳ܻ٘ ௿ۄ਋٘ ࢲ࠺झ ѐߊ ઺ • 2012~2013: ֏ट ௏ܻই नӝࣿѐߊप; ѱ੐ ࢲ࠺झ ਊ ௿ۄ਋٘ ѐߊ • 2007~2012: ূॿࣗ೐౟ ࢲߡ೒ۖಬ ౱; ѱ੐ ࢲߡ ѐߊ
  3. Contents • Design of Game Services • Design of Game

    Server : Tradeoffs • Case Studies
  4. Introduction

  5. What is a BaaS or a PaaS ? • Backend-as-a-Service:

    ѱ੐ ࢲ࠺झܳ ਤೠ ௿ۄ੉঱౟ ੉৻੄ Ѫٜਸ ೙ਃೠ ݅ఀ ઁҕ೧઱ח Ѫ • Platform-as-a-Service: ࣗ೐౟ਝয ࢲ࠺झܳ ٜ݅ӝ ਤೠ بҳ৬ ۄ੉ ࠳۞ܻ, API ١ਸ ೙ਃೠ ݅ఀ ઁҕ೧઱ח Ѫ
  6. Design & Tradeoffs • ٣੗ੋ: ޖ঱оܳ ٜ݅ӝ ਤೠ ઁউ੉ա ҅ദ,

    ӒܻҊ Ӓ प೯ • ౟ۨ੉٘য়೐: ٣੗ੋ ױ҅݃׮ ղܽ Ѿ੿ী ٮۄ ࢤӝח ੢/ױ੼ • ѱ੐ ࢲ࠺झ / ѱ੐ ࢲߡܳ ٜ݅ ٸ ೙ਃೠ Ѿ੿җ Ӓ ࢶఖ੄ ৔ೱਸ ࢓ ಝࠁѷ׮.
  7. Design of Game Services

  8. Game Server Service Infrastructure Billing Authentication Analytics Monitoring Management Push

    Notification C/S Statistics ѱ੐ ࢲ࠺झ ইఃఫ୛ ѱ੐ ࢲߡ ੗୓৬ ੉ܳ ਍ਊೞח ೞ٘ਝয৬ ࢲ࠺झٜ ѱ੐ਸ ࢲ࠺झೞӝ ਤ೧ ೙ਃೠ пઙ ղ/৻ࠗ ࢲ࠺झٜ
  9. ѱ੐ ࢲ࠺झܳ ਤೠ BaaS: ٣੗ੋ ਃࣗ A. যڃ ஹಌք౟ܳ ઁҕ೧઴

    Ѫੋо? B. ݣ౭ ೒ۖಬ૑ਗਸ যڌѱ ب਎ө? C. ѱ੐ ࢲߡח যڃ ੋఠಕ੉झܳ ࠁѱ ؼө?
 (=ѱ੐ ࢲߡח যڃ ઁডਸ ߉ѱ غחо?)
  10. যڃ ஹಌք౟ܳ ઁҕೡө? • BaaSо ݽٚ ࢲ࠺झܳ ઁҕೞח Ѫ਷ ইפ׮

    • ೙ਃೠ ࢲ࠺झܳ ઁҕೞҊ / ੌࠗח ৻ࠗ ࢲ࠺झܳ োزೞѱ ೧ળ׮ • ഑਷, Ѣ੄ ݽٚ ࢲ࠺झܳ ৻ࠗ ࢲ࠺झী ݐӝҊ ੉ܳ োزೞח ৉ೡ݅ ೡ ࣻب ੓׮
  11. যڃ ஹಌք౟ܳ ઁҕೡө? • ৻ࠗ ࢲ࠺झܳ ॳݶ ࢎਊ੗о ঌইঠೞח ࢲ࠺झ

    ղ APIо ઴যٚ׮ • ৻ࠗ ࢲ࠺झо ݆ਸ ࣻ۾ ੹୓ ࢲ࠺झ੄ ాੌࢿ੉ ੷ೞ
  12. ݣ౭೒ۖಬ ૑ਗ • ࢲߡ ࣻળ੄ API۽ ઁҕ? (eg. RESTful API)

    • ೒ۖಬ ߹ ௿ۄ੉঱౟ ೐ۨ੐ਕ௼ / ۄ੉࠳۞ܻ ઁҕ?
  13. ѱ੐ࢲߡ ੋఠಕ੉झ • ࢲߡ ೞ٘ਝযܳ ࠽۰ળ ࣻળ੄ ੗ਬبܳ ઴ Ѫੋо?

    (eg. Amazon EC2) • ౠ੿ ೐۽Ӓې߁ ݽ؛ਸ ъઁೡ Ѫੋо? (eg. Google AppEngine) • ౠ੿ ௿ۄ੉঱౟ API/ݽ؛ਸ ъઁೡ Ѫੋо? (eg. Photon Realtime)
  14. Design Of Game Servers: Tradeoffs

  15. History: ف о૑ ࢶఖ૑ • Web ࢲ࠺झ ܨ੄ ҳഅ •

    ੹ా੸ੋ PC Online ѱ੐ ܨ੄ ҳഅ
  16. Game Server Game Server Game Server Load Balancer Game Server

    Game Server Game Server Game Server Game Server Game Server Data Store Data Store ѱ੐ ࢲߡ ҳࢿ ࢎਊ੗৬ ాनೞҊ / ੉ܳ ୊ܻೞҊ / ੷੢ೞח ੌ۲੄ ӝמٜ
  17. Design: Goals • ѱ੐੉ ਃҳೞח ѱ੐ ೒ۨ੉ ౠࢿ (eg. पदр؀੹

    / ఢ ߑध ࠁ٘ѱ੐) • ഛ੢ࢿ੉ ঴݃ա ೙ਃೠо? • ѐߊ दр (vs. ѱ੐ উ੿ࢿ) • ਍৔ ࠺ਊ
  18. ޖ঺੉ ࢶఖਸ ઝ਋ೡө? • ѱ੐੉ ౠ੿ ࢶఖਸ ъઁ (पदр ؀੹,

    …) • ౱ਸ ٜ݅ ࣻ ੓חо (೧׼ ӝࣿਸ ইח ೐۽Ӓېݠ੄ ࣻ) • ࡈܻ ٜ݅যঠೞա? ࠗೞܳ Ѽ٣חѱ ઺ਃೠо? • ৘ஏೠ ࢲߡ ࣻ, ࢲ࠺झ ழ૕ ٸ ഛ੢ ࠺ਊ
  19. ѱ੐ ࢲߡ ইఃఫ୛: ٣੗ੋ ࢶఖ૑ • Transport Layer: HTTP vs.

    Custom Transport • Server Logic: Stateless vs. Stateful • Data Store: • Write / Cache Policy • Consistency / Isolation for horizontal scaling • Wirte format, …
  20. Transport Layer ѱ੐ ௿ۄ੉঱౟৬ ѱ੐ ࢲߡח যڃ ߑߨਵ۽ ݫद૑ܳ ઱Ҋ

    ߉ਸө?
  21. HTTP vs. Custom Transport • HTTP : ਢ ӒܻҊ ݽ߄ੌ

    द؀੄ ҕਊয (Lingua Franca) • Custom Transport: PC ৡۄੋ द੺җ ਢ द؀੄ ழझథ ೐۽ష௒
  22. HTTP ? • ݆਷ ࣻ੄ ݽ߄ੌ ѱ੐੉ HTTP۽ ాनೠ׮ •

    ѱ੐ ࢲߡח ਢ গ೒ܻா੉࣌ਵ۽ ҳഅ • HTTP ਤী JSON, XML ഑਷ protobuf ١੄ ݫद૑ܳ पয ࠁմ׮
  23. HTTP: Pros • ੜ ੿੄ػ ೐۽ష௒੉ۄ ౟ےझನ౟ ੗୓ܳ न܉ೡ ࣻ

    ੓׮ • ࢲߡ ೐ۨ੐ਖҗ ௿ۄ੉঱౟ ۄ੉࠳۞ܻо ݆׮ • ۽٘ߖ۠ࢲܳ ੉ਊ೧ࢲ ࢲߡ ࣻܳ औѱ ഛ੢(IaaS ࢎਊী ਊ੉) • PC ৡۄੋ ѱ੐ ࢲߡ ૒ҵ ੉৻੄ ѐߊ੗о ݆׮
  24. HTTP: Cons • নߑೱ ాनਸ ೡ ࣻ হ׮ • HTTP

    ೐۽ష௒ ੗୓੄ য়ߡ೻٘ (೻؊, ਃ୒ ঑୷, …) • ೞա੄ োѾী ؀೧ زदী ೞա੄ ਃ୒݅ ࠁյ ࣻ ੓׮ • ܻߡझ ূ૑פয݂ ೞӝ औ׮
  25. Custom Transport? • Ԩ ݆਷ ࣻ੄ ݽ߄ੌ ѱ੐੉ ࢎਊ ઺

    • PC ৡۄੋ ѱ੐ীࢲ ࠗఠ ॳ؍ ߑध: TCP ١ਸ ࢎਊೠ ాनਸ ҳഅ • C++/C# ࡺ݅ ইפۄ node.js ١ਸ ഝਊ • ழझథ ݫद૑ ഑਷ JSON, protobuf, thrift ݫद૑ܳ ੹࣠ೠ׮
  26. Custom Transport: Pros • पदр / নߑೱ ੹࣠੉ औ׮ •

    ౠ੿ ѱ੐ী ౠചदெࢲ ݫद૑ ҳࢿ੉ա ঑୷ਸ ബਯചೞӝ જ׮ • ܻߡझ ূ૑פয݂ೞӝ ખ ؊ ࠂ੟ೞ׮ (৻ࠗী ֢୹ػѱ ੸׮)
  27. Custom Transport: Cons • ؊ ࠂ੟ೞ׮ = ೐۽Ӓېݠ ࢤ࢑ࢿ੉ ڄয૓׮

    • ࢎਊ੗о טযզ ٸ ۽٘ߖ۠य੉ ࠂ੟೧૓׮ • ਬ૑ࠁࣻ ೡ ௏٘੄ ন੉ ݆׮
  28. ѱ੐ ࢲߡ ۽૒ ѱ੐ ࢲߡо ਬ੷ ࢚కܳ ঴݃ա ݆੉ ঴݃ա

    য়ې ਬ૑ೞݶࢲ ѱ੐ ۽૒ਸ ୊ܻೡө?
  29. Stateless vs. Stateful • Stateless: ਢ ࢲߡ୊ۢ ࢲߡী ࢚కܳ ਬ૑ೞ૑

    ঋח ҳઑ • Stateful: PC ৡۄੋѱ੐ ࢲߡ୊ۢ ࢲߡী ਬ੷ ࢚కܳ ਬ૑ೞח ҳઑ
  30. Stateless Game Server • ؀ࠗ࠙੄ ਢ গ೒ܻா੉࣌ ࢲߡо ৈӝী ೧׼

    • ѱ੐ ݫद૑ܳ ୊ܻೞӝ ਤ೧ࢲ ؘ੉ఠ ੷੢ࣗ ҅கী ੽Ӕ೧ঠ ೣ • ਬ੷ р ࢚ഐ੘ਊ ୊ܻب ೦࢚ ؘ੉ఠ ੷੢ࣗ ҅கਸ ੉ਊ
  31. Game Server Game Server Web Server + Memcached Load Balancer

    (haproxy) Game Server Game Server Web Server + Memcached Game Server Game Server Web Server + Memcached Data Store Data Store Configuration Example Web ࢲ࠺झীࢲ ࢎਊೞ؍ ஹಌք౟ٜਸ ഝਊ೧ࢲ ੘ࢿೠ׮
  32. Stateless Game Server: Pros • ѱ੐ ࢲߡ ௼ېदী উ੹ೠ ಞ

    • ѱ੐ ࢲߡܳ ࣻಣ੸ਵ۽ ഛ੢ೞӝ औ׮ • ਢ ࢲ࠺झীࢲ ഝਊೞח пઙ ஹಌք౟ܳ ഝਊೞӝ औ׮:
 (load-balancer, memcached, redis, …)
  33. Stateless Game Server: Cons • ࢲߡ ଃীࢲ ࢤࢿೞח ੉߮౟ ୊ܻо

    ࠂ੟ೞ׮ • ѱ੐ ࢲߡ р زӝചܳ ؘ੉ఠ ੷੢ࣗ ҅கীࢲ ୊ܻೞח য়ߡ೻٘ • ਬ੷ р ࢚ഐ੘ਊਸ ؀ࠗ࠙ ؘ੉ఠ ੷੢ࣗ ࣻળ੄ زӝച۽ ୊ܻ೧ঠ • ؘ੉ఠ ੷੢ࣗ ҅க੉ ࠂ੟ೞ׮
  34. Stateful Game Server • ੹ా੸ੋ PC ৡۄੋ ѱ੐ ࢲߡٜ੉ ৈӝী

    ೧׼ • ѱ੐ ࢚క / ਬ੷ ࢚కܳ ѐ߹ ѱ੐ ࢲߡ੄ ݫݽܻ ࢚ী ਬ૑ • ѱ੐ ࢲߡ = ѱ੐ ۽૒ ୊ܻ + ؘ੉ఠ ੷੢ࣗ ઁয
  35. Game Server Game Server Game Server $VTUPN -PBECBMBODFS Game Server

    Game Server Game Server Game Server Game Server Game Server Data Store Data Store sync sync Configuration Example ѱ੐ ࢲߡ ࢎ੉ী ݺद੸ਵ۽ زӝചೞח ೐۽ష௒੉ ٜযр׮
  36. Stateful Game Server: Pros • ؘ੉ఠ ੷੢ࣗী ੷੢ೡ ߑߨਸ ઁযೞӝ

    औ׮ • पदр ੉߮౟ա ࢲߡ ࢤࢿ ੉߮౟ ୊ܻо औ׮ • ਬ੷р ࢚ഐ ੘ਊ਷ ѐ߹ ѱ੐ ࢲߡ ࣻળীࢲ (؀ࠗ࠙) ୊ܻೠ׮ • ࢲߡ ׼ ز੽ ୊ܻ ࣻо ֫׮
  37. Stateful Game Server: Cons • ѱ੐ ࢲߡܳ ࣻಣ੸ਵ۽ ഛ੢ೞӝ ൨ٜ׮

    • ૒੽ ઁ੘೧ঠೞח ௏٘ ন੉ ݆׮ (زӝച, ۽٘ߖ۠य, …) • ࢲߡ ௼ېद ୊ܻо ࠂ੟ೞ׮
  38. ؘ੉ఠ ੷੢ࣗ ॳӝ ੿଼ நद ҳࢿ ഛ੢ࢿ оਊࢿ …

  39. Facts • ѱ੐ ࢲߡ੄ ؘ੉ఠ ੷੢ࣗח “ॳӝ ਤ઱” (write-intensive) •

    (Ѣ੄ ߸ೞ૑ ঋח) ডр੄ ੍ӝ ਤ઱੄ ؘ੉ఠٜب ੓׮ • ؘ੉ఠ সؘ੉౟о ݽف ٣झ௼۽ о૑ח ঋח׮
  40. Policy • ؘ੉ఠ ॳӝח যڌѱ ୊ܻೡө? (write back vs. write

    through) • ࠙࢑ ࢲߡ ޙઁ: Horizontal Scaling • ؘ੉ఠ ੷੢ ನݘ
  41. ؘ੉ఠ ॳӝ • In-memory write-back cacheח ࢿמਸ ӓ؀ചೡ ࣻ ੓૑݅

    ࢲߡ ௼ې दী ݒ਋ ஂডೞ׮ • ؘ੉ఠ ੷੢ࣗী ૓೯ ઺ੋ ॳӝо ׮ܲ ਬ੷ীѱ ঴݃ա ࡈܻ ࠁৈঠ ೡө? (consistency ޙઁ + isolation ޙઁ) • ࠙࢑ػ ؘ੉ఠ ੷੢ࣗীࢲ ॳӝ ઙܐܳ যڌѱ ࠁ੢ೡө?
  42. ؘ੉ఠ ॳӝ: Cache • நद ۨ੉য ҳࢿ਷ যڌѱ? • ࠙࢑ػ

    நद ࢲߡр੄ coherency ୊ܻח? • நद ࢲߡ - ѱ੐ ࢲߡ р ੋఠಕ੉झ? (transparent cache?)
  43. Datastore Scaling • ѱ੐਷ ॳӝ ਤ઱: masterী ॳӝ + slaveীࢲ

    ੍ӝ۽ח ୭੸ചೞӝ औ ૑ ঋ׮ • ؘ੉ఠ੄ keyী ٮۄ ࢲ۽ ׮ܲ ੷੢ࣗ ࢲߡী ੷੢ೞח ߑߨਸ ॵ׮ • ޙઁ: ࢎਊೞ۰ח بҳо ૑ਗೞח ࣻળ? ੗زച? ೙ਃೠ ӝמ?
  44. Datastore Scaling (2) • DB ࣻળীࢲ auto-sharding? or • ਽ਊ

    ೐۽Ӓ۔ীࢲ Consistent hashing? • ࠙࢑ ౟ے੥࣌਷ যڌѱ? • ೐۽Ӓې߁ ݽ؛ী ઁড?
  45. Auto Sharding: Example • Gizzard from Twitter (https://github.com/twitter/gizzard); retired •

    ೐ۨ੐ਖ ࣻળীࢲ auto-shardingਸ ૑ਗೠ׮ • ֎౟ਕ௼ োѾ ױ੺ ୊ܻ: ੤दب + ୭न ো࢑݅ प೯ • ೐۽Ӓې߁ ݽ؛: ݽٚ ॳӝо idempotent & commutative
  46. Data Format • Storage format vs. wire format ? •

    ೐۽Ӓې߁ ಞ੄ࢿ (ࢤ࢑ࢿ) vs. ٣झ௼ ҕр + ੷੢ࣗ CPU • ࢎਊೡ ࣻ ੓ח ௪ܻ ߑߨ ର੉
  47. Case Studies

  48. Amazon Web Services • Infrastructure-as-a-Service • ੌ߈੸ੋ ਢ ࢲ࠺झ ҳࢿী

    ೙ਃೠ ਃࣗ ٜਸ ݽف о૑Ҋ ੓׮ • ѱ੐੸ੋ ਃࣗח ݽف ѐߊ੗ ࣚী • ԙ ਢ ӝ߈੉ ইפযب ҡଳ׮
 (ઁҕೞח Ѥ о࢚ݠनҗ ݻ о૑ ࢲ࠺झ)
  49. AWS as a Backend Service • ѱ੐ ࢲ࠺झܳ ݅٘חؘ ॶ

    ࣻ ੓ח ৈ۞ ࠽٬ ࠶۟ਸ ઁҕೠ׮ • ࠽٬ ࠶۟ਸ ࢎਊ೧ࢲ пп੄ ѱ੐ ࢲ࠺झܳ ઁ੘೧ঠ ೠ׮ • Write-intensiveೠ ୊ܻܳ dynamo-dbী ځֈӡ ࣻب ੓׮ • Load-balancer ࢲ࠺झ ઁҕ: әѺೠ ۽٘ ࢚थূ ࠗ੸੺ೡ ࣻب ੓׮
  50. AWS: Decisions • Transport Layer: ANY • Server Logic: ANY

    • Data Store: ANY • HTTP + Stateless + Scalable Data Store (DynamoDB) ࢶഐ
  51. Heroku • Platform-as-a-service • ਢ ࢲ࠺झܳ ਤೠ ೒ۖಬ • ਢ

    ࢲߡ + HTTP + RDB ӝ߈੄ ѱ੐ ࢲ ࠺झܳ ٜ݅ӝ જ׮
  52. Heroku as a Backend Service • AWS ਤীࢲ ز੘, ױ

    ਢ ࢲ࠺झ ӝ߈੄ ࢲ࠺झܳ ૑ਗ • ݆਷ ࣻ੄ গ٘ৡ: nosql, notification, monitoring, … • ૑৉ ઁೠ: US + EU
 (see https://devcenter.heroku.com/articles/regions)
  53. Heroku: Decisions • Transport: HTTP • Server Logic: Stateless (web

    application) • Data Store: Relational DB + In memory caches (memcached, redis)
  54. Google AppEngine • Platform-as-a-Service, but … • Managed-VM ਸ ೲਊೣ

    (GCE) • ӝઓ Google Game Platform җ োز • ъ۱ೠ analytics tools
  55. Google AppEngine as a Backend Service • ਢ ࢲ࠺झ ӝ߈੄

    ѱ੐ ࢲߡܳ ૑ਗ • ੢दр ز੘ೞח ࠺زӝ ੘সب оמ • ୶о۽, managed VM ਸ ా೧ࢲ AWS EC2 э਷ ੌب ೡ ࣻ ੓׮ • RDBо ইצ ؘ੉ఠ ੷੢ࣗ ҅க ઁҕ
  56. Google AppEngine as a Backend Service (2) • AppEngine੉ ઁҕೞח

    ঱য ઁೠ: Python, Go, PHP, Java • ೐۽Ӓې߁ ݽ؛੄ ઁೠ: ਽׹ ߑध, ۄ੉࠳۞ܻ, ਽׹ दр ઁড • ؘ੉ఠ ੷੢ࣗ ݽ؛ ઁೠ: • ૑৉ ઁೠ: ઺Ҵীࢲח যڌѱ?
  57. Google AppEngine: Decisions • Transport Layer: HTTP • Server Logic:

    Stateless + Managed VM + Asynchronous Jobs • Data Store: non-relational DB (GQL) + memcached
  58. Google Play Game Services • Room ী ӝ߈ೠ ѱ੐ਸ ૑ਗ

    (realtime) • ഑਷, ఢ ߑध ѱ੐ ૑ਗ • ݫद૑ ӝ߈ (Android, iOS, Web) • Socket interfaceח Android ੹ਊ
  59. Google Play Game Services: Decisions • ӝࠄ੸ਵ۽ AppEngineҗ э૑݅, •

    Transport Layer: Androidח HTTP ੉৻ب ૑ਗ • Server Logic: Google Compute Engine ਤী stateful ࢲߡܳ ૑ਗ
  60. Photon Realtime • Software-as-a-Service • Unity3D ੹ਊ (೒۞Ӓੋ) • ઁড੉

    बೠ ೐۽Ӓې߁ ݽ؛ • ௿ۄ੉঱౟ р ࢚క ࠂઁ ӝ߈ • ઁೠ੸ੋ RPC ૑ਗ
  61. Photon Realtime: Decisions • Transport Layer: Custom Protocol • Server

    Logic: Stateful (௿ۄ੉঱౟ ஏ੄ ࢚క ࠂࢎ) • Data Store: ߹ب ૑ਗ হ਺
  62. ࢶఖ੄ ޙઁ

  63. Summary • ѱ੐ ࢲ࠺झীࢶ (A) ઁҕೡ ஹಌք౟, (B) ݣ౭ ೒ۖಬ

    ૑ਗ ߑध, (C) ѱ੐ ࢲߡ ੋఠಕ੉झܳ Ѿ੿೧ঠ ೠ׮ • ѱ੐ ࢲߡ ࣻળীࢶ, (i) transport, (ii) server logic, (iii) data store ੄ ઙ ܨ/ഋకܳ Ѿ੿೧ঠ ೠ׮ • ੉ܳ ߄ఔਵ۽ AWS, AppEngine, Heroku, Photon ١ਸ ࢓ಝࠌ׮
  64. Questions?