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

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

reinkim
April 03, 2014

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

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

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

reinkim

April 03, 2014
Tweet

More Decks by reinkim

Other Decks in Programming

Transcript

  1. Who am I • ӣ૓਌ ([email protected]) • അ੤: ѱ੐ ࢲ࠺झܳ

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

    Server : Tradeoffs • Case Studies
  3. What is a BaaS or a PaaS ? • Backend-as-a-Service:

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

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

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

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

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

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

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

    (eg. Amazon EC2) • ౠ੿ ೐۽Ӓې߁ ݽ؛ਸ ъઁೡ Ѫੋо? (eg. Google AppEngine) • ౠ੿ ௿ۄ੉঱౟ API/ݽ؛ਸ ъઁೡ Ѫੋо? (eg. Photon Realtime)
  11. History: ف о૑ ࢶఖ૑ • Web ࢲ࠺झ ܨ੄ ҳഅ •

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

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

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

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

    Custom Transport • Server Logic: Stateless vs. Stateful • Data Store: • Write / Cache Policy • Consistency / Isolation for horizontal scaling • Wirte format, …
  16. HTTP vs. Custom Transport • HTTP : ਢ ӒܻҊ ݽ߄ੌ

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

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

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

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

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

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

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

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

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

    • ѱ੐ ݫद૑ܳ ୊ܻೞӝ ਤ೧ࢲ ؘ੉ఠ ੷੢ࣗ ҅கী ੽Ӕ೧ঠ ೣ • ਬ੷ р ࢚ഐ੘ਊ ୊ܻب ೦࢚ ؘ੉ఠ ੷੢ࣗ ҅கਸ ੉ਊ
  26. 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 ࢲ࠺झীࢲ ࢎਊೞ؍ ஹಌք౟ٜਸ ഝਊ೧ࢲ ੘ࢿೠ׮
  27. Stateless Game Server: Pros • ѱ੐ ࢲߡ ௼ېदী উ੹ೠ ಞ

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

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

    ೧׼ • ѱ੐ ࢚క / ਬ੷ ࢚కܳ ѐ߹ ѱ੐ ࢲߡ੄ ݫݽܻ ࢚ী ਬ૑ • ѱ੐ ࢲߡ = ѱ੐ ۽૒ ୊ܻ + ؘ੉ఠ ੷੢ࣗ ઁয
  30. 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 ѱ੐ ࢲߡ ࢎ੉ী ݺद੸ਵ۽ زӝചೞח ೐۽ష௒੉ ٜযр׮
  31. Stateful Game Server: Pros • ؘ੉ఠ ੷੢ࣗী ੷੢ೡ ߑߨਸ ઁযೞӝ

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

    • ૒੽ ઁ੘೧ঠೞח ௏٘ ন੉ ݆׮ (زӝച, ۽٘ߖ۠य, …) • ࢲߡ ௼ېद ୊ܻо ࠂ੟ೞ׮
  33. Facts • ѱ੐ ࢲߡ੄ ؘ੉ఠ ੷੢ࣗח “ॳӝ ਤ઱” (write-intensive) •

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

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

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

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

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

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

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

    ೐۽Ӓې߁ ಞ੄ࢿ (ࢤ࢑ࢿ) vs. ٣झ௼ ҕр + ੷੢ࣗ CPU • ࢎਊೡ ࣻ ੓ח ௪ܻ ߑߨ ର੉
  41. Amazon Web Services • Infrastructure-as-a-Service • ੌ߈੸ੋ ਢ ࢲ࠺झ ҳࢿী

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

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

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

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

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

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

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

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

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

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

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

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

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

    Logic: Stateful (௿ۄ੉঱౟ ஏ੄ ࢚క ࠂࢎ) • Data Store: ߹ب ૑ਗ হ਺
  55. Summary • ѱ੐ ࢲ࠺झীࢶ (A) ઁҕೡ ஹಌք౟, (B) ݣ౭ ೒ۖಬ

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