Building an MMORPG - Here be monsters

124

description

In this session, Yan will share some of his experiences of building a successful MMORPG for a social audience and insights into some of the technical challenges that his team has had to overcome along the way.

Transcript of Building an MMORPG - Here be monsters

Page 1: Building an MMORPG - Here be monsters
Page 2: Building an MMORPG - Here be monsters

Name : Yan CuiOccupation : Server side dev

Company : gamesysIndustry : Social Gaming

about me

Page 3: Building an MMORPG - Here be monsters
Page 4: Building an MMORPG - Here be monsters

The Game

Page 5: Building an MMORPG - Here be monsters

The World

Page 6: Building an MMORPG - Here be monsters

You!!!

Page 7: Building an MMORPG - Here be monsters

Places

Page 8: Building an MMORPG - Here be monsters

Places

Page 9: Building an MMORPG - Here be monsters

Places

Page 10: Building an MMORPG - Here be monsters

Towns

Page 11: Building an MMORPG - Here be monsters

Towns

Page 12: Building an MMORPG - Here be monsters

Homestead

Page 13: Building an MMORPG - Here be monsters

Homestead

Page 14: Building an MMORPG - Here be monsters

Farming

Page 15: Building an MMORPG - Here be monsters

Crafting

Page 16: Building an MMORPG - Here be monsters

Crafting

Page 17: Building an MMORPG - Here be monsters

Almanac

Page 18: Building an MMORPG - Here be monsters

Almanac

Page 19: Building an MMORPG - Here be monsters

Almanac

thousands

of items!

hundreds of recipes!

more coming each week!!!

Page 20: Building an MMORPG - Here be monsters

Almanac

Page 21: Building an MMORPG - Here be monsters

Almanac

Page 22: Building an MMORPG - Here be monsters

Almanac

Page 23: Building an MMORPG - Here be monsters

Monster Trapping

Page 24: Building an MMORPG - Here be monsters

RightTrap

+ RightBait =

CatchingMonsters!

Monster Trapping

Page 25: Building an MMORPG - Here be monsters

Monster Trapping

Page 26: Building an MMORPG - Here be monsters

Quests

Page 27: Building an MMORPG - Here be monsters

Quests

Page 28: Building an MMORPG - Here be monsters

Quests

Page 29: Building an MMORPG - Here be monsters

Achievements

Page 30: Building an MMORPG - Here be monsters

Achievements

Page 31: Building an MMORPG - Here be monsters

Achievements

Page 32: Building an MMORPG - Here be monsters

In-game Buddies

Page 33: Building an MMORPG - Here be monsters

In-game Buddies

Page 34: Building an MMORPG - Here be monsters

The Community

Page 35: Building an MMORPG - Here be monsters

The Community

Page 36: Building an MMORPG - Here be monsters

In April..

Page 37: Building an MMORPG - Here be monsters

• 200,000 unique players

• 300,000 hours of game play

• 100,000,000 server requests

Page 38: Building an MMORPG - Here be monsters

• 45,000,000 items foraged

• 1,000,000 butterflies caught

• 4,000,000 seeds planted

• 4,000,000 monsters caught

Page 39: Building an MMORPG - Here be monsters

• 5,700,000 items bought

• 24,000,000 items sold

• 280,000 hours of time potion used

• 526,000,000+ km travelled • around the earth 13,000 times...

Page 40: Building an MMORPG - Here be monsters

• Bulk of the game developed by• 1 server developer

• 2 flash developers

• 1 producer and 2 game designers

• Several artists

Page 41: Building an MMORPG - Here be monsters

We have had to find ways to solve

problems effectively and efficiently

Page 42: Building an MMORPG - Here be monsters

The Challenges

Page 43: Building an MMORPG - Here be monsters

• States can be BIG

• Grow with content

Efficiency

Page 44: Building an MMORPG - Here be monsters
Page 45: Building an MMORPG - Here be monsters

• 1000s of items on homestead

• Each item has some state

Page 46: Building an MMORPG - Here be monsters
Page 47: Building an MMORPG - Here be monsters

• Storage units add 1000s more items

• Players like to collect things ;-)

Page 48: Building an MMORPG - Here be monsters
Page 49: Building an MMORPG - Here be monsters
Page 50: Building an MMORPG - Here be monsters

• A lot of states to track on character

• 100s of items in backpack

• 100s of quests/achievements

• Players like to collect things ;-)

Page 51: Building an MMORPG - Here be monsters

• Many actions requires both states at once

• Operations are expensive

• Best players get the worst latency

Page 52: Building an MMORPG - Here be monsters

Stateless Server DatabaseClient

Page 53: Building an MMORPG - Here be monsters

• Stateless server approach+ Easy to scale up and down

+ Scaling can be dynamic based on load

+ Every layer can scale independently

Page 54: Building an MMORPG - Here be monsters

• Stateless server approach– Serialization/deserialization is heavy on CPU

– Heavy load (1:1 read write ratio) on databases

– High bandwidth usage

– High latency

Page 55: Building an MMORPG - Here be monsters

• Stateless server approach– Inefficient

– Expensive

Page 56: Building an MMORPG - Here be monsters

ServerClient

Session 1

Session 2

Page 57: Building an MMORPG - Here be monsters

• Traffic is bursty

• Keep state on server during bursts= Less serialization & deserialization

= Less load on database

= Fewer server and database nodes

=

Page 58: Building an MMORPG - Here be monsters

ServerClient Database

Page 59: Building an MMORPG - Here be monsters

• Stateful server approach

+ 500% improvement on efficiency

+ 60% reduction in average latency

+ Fewer game servers

+ Fewer database nodes

Page 60: Building an MMORPG - Here be monsters

But...

Page 61: Building an MMORPG - Here be monsters

• Server affinity

– Need to ensure server affinity during one burst

– Need to route calls to affined server

Page 62: Building an MMORPG - Here be monsters

• Load balancing

– Some players are more active than others

– Need to avoid hot spots

Page 63: Building an MMORPG - Here be monsters

• Server hogging

– Session lengths vary greatly

– Need to avoid players hogging a server

– Need to be able to scale down!

Page 64: Building an MMORPG - Here be monsters

• Persist state after short inactivity

• Move player to another server after

persistence

Page 65: Building an MMORPG - Here be monsters
Page 66: Building an MMORPG - Here be monsters

• Scaling down

– Need to gracefully drain player states

– Need to be able to stop accepting new players

Page 67: Building an MMORPG - Here be monsters

• Stateful server approach

– Complexity

+ But worthwhile!

+ Others avoid scaling down to reduce complexity

Page 68: Building an MMORPG - Here be monsters

• Progress tied to most actions

• Avoid scripting

• Data driven

Quests & Achievements

Page 69: Building an MMORPG - Here be monsters

Caught a Gnome

Page 70: Building an MMORPG - Here be monsters

EXP Item Gold

Quest Progress

Caught a Gnome

Page 71: Building an MMORPG - Here be monsters

Level Up

Quest Progress

EXP Item Gold

Caught a Gnome

Quest Complete

Page 72: Building an MMORPG - Here be monsters

Level Up

Quest Progress

EXP Item Gold

Caught a Gnome

Quest Complete

New Quest

Page 73: Building an MMORPG - Here be monsters

Level Up

Quest Progress

EXP Item Gold

Caught a Gnome

Quest Complete

New Quest

Page 74: Building an MMORPG - Here be monsters

Level Up

Quest Progress

EXP Item Gold

Caught a Gnome

Quest Complete

New QuestAchievement

Progress

Page 75: Building an MMORPG - Here be monsters

Level Up

Quest Progress

EXP Item Gold

Caught a Gnome

Quest Complete

New QuestAchievement

Progress

Achievement Complete

Page 76: Building an MMORPG - Here be monsters

Level Up

Quest Progress

EXP Item Gold

Caught a Gnome

Quest Complete

New QuestAchievement

Progress

Achievement Complete

Page 77: Building an MMORPG - Here be monsters

Level Up

Quest Progress

EXP Item Gold

Caught a Gnome

Quest Complete

New QuestAchievement

Progress

Achievement Complete

Page 78: Building an MMORPG - Here be monsters

And that’s not all...

Page 79: Building an MMORPG - Here be monsters

• 100+ actions available in the game

• Most can be tied to quests/achievements

• Many yields rewards

Page 80: Building an MMORPG - Here be monsters

• Triggered from different abstraction layers

• Trapping controller

• Level controller

• ...

Page 81: Building an MMORPG - Here be monsters

• Non-functional requirements

• Analytics

• Partner reporting

• ...

Page 82: Building an MMORPG - Here be monsters
Page 83: Building an MMORPG - Here be monsters

• Message broker pattern

• Something happened, it’s a FACT

• Caught a Gnome

• Got some EXP

• ...

Page 84: Building an MMORPG - Here be monsters

Caught Gnome Trapping

Queue

Levelling

Quests

Achievements

Analytics

Partner Reporting

Page 85: Building an MMORPG - Here be monsters

Caught Gnome Trapping

Queue

Levelling

Quests

Achievements

Analytics

Partner Reporting

Ignore

Process

Process

Process

Process

Ignore

Page 86: Building an MMORPG - Here be monsters

Caught Gnome Trapping

Queue

Levelling

Quests

Achievements

Analytics

Partner Reporting

EXPItemGold

Page 87: Building an MMORPG - Here be monsters

Caught Gnome Trapping

Queue

Levelling

Quests

Achievements

Analytics

Partner Reporting

EXPItemGold

Page 88: Building an MMORPG - Here be monsters

Caught Gnome Trapping

Queue

Levelling

Quests

Achievements

Analytics

Partner Reporting

EXPItemGold

Process

Ignore

Ignore

Ignore

Process

Ignore

Page 89: Building an MMORPG - Here be monsters

Caught Gnome Trapping

Queue

Levelling

Quests

Achievements

Analytics

Partner Reporting

EXPItemGold

Level Up

Page 90: Building an MMORPG - Here be monsters

Caught Gnome Trapping

Queue

Levelling

Quests

Achievements

Analytics

Partner Reporting

EXPItemGold

Level Up

Page 91: Building an MMORPG - Here be monsters

• Message broker approach

+ Simple

+ Flexible

+ Extensible

Page 92: Building an MMORPG - Here be monsters

• Message broker approach

– Requires large number of different facts

+ F# to the rescue!

Page 93: Building an MMORPG - Here be monsters
Page 94: Building an MMORPG - Here be monsters

• OK for small number of DU cases

• 100+ actions available in the game

Page 95: Building an MMORPG - Here be monsters
Page 96: Building an MMORPG - Here be monsters

• Players love quests

Agility

Page 97: Building an MMORPG - Here be monsters

• Need regular content releases

• Game is heavily data driven

+ No developer involvement for content changes

• Tech team needs to be enablers

Page 98: Building an MMORPG - Here be monsters

• Producers need ability to

• Plan changes weeks in advance

• Quickly see and validate changes before release

Page 99: Building an MMORPG - Here be monsters

• Game designers need ability to

• Work on changes in isolation

• Quickly iterate and test changes in isolation

Page 100: Building an MMORPG - Here be monsters

• QA need ability to

• Quickly switch between different changes to test

• Smoke-test changes in live environment without

affecting real players

Page 101: Building an MMORPG - Here be monsters

• Server team needs ability to

• Version data changes

• Rollback/hotfix data changes with no downtime

Page 102: Building an MMORPG - Here be monsters

We version control our code,

why not our data?

Page 103: Building an MMORPG - Here be monsters

• Git + Git flow

• Servers allow multiple data branches and

switching between them

Page 104: Building an MMORPG - Here be monsters

• What do our players like to do?

• Every action in the game is recorded

Analytics

Page 105: Building an MMORPG - Here be monsters

Feature Analyze

Page 106: Building an MMORPG - Here be monsters

• Analytics is a key decision-making tool

• A/B testing

Page 107: Building an MMORPG - Here be monsters

• 150,000,000+ events recorded in April

• Several GBs of analytics data a day

• Fast growing!

Page 108: Building an MMORPG - Here be monsters

• Google BigQuery

+ Cheap

+ Fast

+ Scalable

+ SQL-like query syntax

Page 109: Building an MMORPG - Here be monsters

• Google BigQuery

– OLAP

– Append-only

Page 110: Building an MMORPG - Here be monsters

• What is our code doing?

Monitoring

Page 111: Building an MMORPG - Here be monsters

• Monitoring

• Not the same as profiling

• Should be always ON

• Difficult to set up in large distributed environment

Page 112: Building an MMORPG - Here be monsters

What to monitor?

Page 113: Building an MMORPG - Here be monsters

• Method execution time

• e.g. IO, CPU intensive

• Method execution count

• e.g. service entry points

• Error count

• ...

Page 114: Building an MMORPG - Here be monsters

• Amazon CloudWatch

+ Cheap

+ Supports alarms and notifications

+ Visualization tool

Page 115: Building an MMORPG - Here be monsters

PostSharp

Page 116: Building an MMORPG - Here be monsters
Page 117: Building an MMORPG - Here be monsters

PostSharp

AmazonCloudWatch

+

=

Page 118: Building an MMORPG - Here be monsters
Page 119: Building an MMORPG - Here be monsters
Page 120: Building an MMORPG - Here be monsters
Page 121: Building an MMORPG - Here be monsters
Page 122: Building an MMORPG - Here be monsters

• Metrics are aggregated at instance level

• Metrics gatherer has high concurrency

requirement

• F# agents to the rescue!

Page 123: Building an MMORPG - Here be monsters

Thank You!

@theburningmonk

Page 124: Building an MMORPG - Here be monsters

Here Be Monstershttp://apps.facebook.com/herebemonsters

AOP and pseudo real-time monitoring with CloudWatchhttp://bit.ly/11GL3SQhttp://bit.ly/10fe98N

Building social games with a .Net stackhttp://bit.ly/ZKtHWb http://bit.ly/10CtyY9

F# Agentshttp://bit.ly/ZmXuEPhttp://bit.ly/17kjbam

F# Deep Diveshttp://bit.ly/XZe10E