49
November 14, 2014 | Las Vegas, NV Nate Wiger, Principal Gaming Solutions Architect, AWS James Gwertzman, CEO, PlayFab

(GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Embed Size (px)

DESCRIPTION

This is a deep-dive straight into the guts of running a low-latency multiplayer game, such as a first-person shooter, on a global scale. We dive into architectures that enable you to split apart your back-end APIs from your game servers, and Auto Scale them independently. See how to run game servers in multiple AWS regions such as China and Frankfurt, and integrate them with your central game stack. We'll even demo this in action, using AWS CloudFormation and Chef to deploy Unreal Engine game servers. In the second half, hear from PlayFab, who built the backend for the Top-10 free-to-play PC shooter Loadout. PlayFab reveals details about their architecture, including AWS Elastic Beanstalk setup, Amazon DynamoDB and Amazon RDS patterns, data sharding, and use of multiple Availability Zones. Finally, PlayFab highlights challenges they faced when deploying to AWS China, and how they solved them.

Citation preview

Page 1: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

November 14, 2014 | Las Vegas, NV

Nate Wiger, Principal Gaming Solutions Architect, AWS

James Gwertzman, CEO, PlayFab

Page 2: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

[Game] Online Problems Continue; Features

Disabled as [Game Studio] Works on Fixes

“We are working hard to get everyone online

as soon as possible,” [Game Studio] says.

Days later, [Game Studio] leaving

disconnected players stranded

[Game] has a great online mode – if you

can get online, that is

“This is total bull**** I paid for a preorder and

I can’t even connect WTF [Game Studio]??”

Page 3: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 4: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

http://bit.ly/verizon-latencyhttp://bit.ly/superdata-latency

Page 5: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 6: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 7: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Tokyo

Oregon

Frankfurt

Virginia

Page 8: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

VPC Subnet

VPC Subnet

Availability Zone

A

Availability Zone B

VPC Subnet

VPC Subnet

Auto Scaling group

WEB

VPC Subnet

WEB

JOBS

Page 9: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Region

① Login via HTTP API

② Download Game Assets

③ Matchmaking to Game Server

EC2

EC2

EC2

Page 10: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Region

① Login via HTTP API

② Download Game Assets

③ Matchmaking to Game Server

④ Connect to Server

⑤ Hack Apart Your Friends

⑥ Game Over EC2

EC2

Page 11: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Region

① Login via HTTP API

② Download Game Assets

③ Matchmaking to Game Server

④ Connect to Server

⑤ Hack Apart Your Friends

⑥ Game Over

⑦ Write via HTTP APIEC2

EC2

Page 12: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

VPC Private Subnet

VPC Public Subnet

Availability Zone A Availability Zone B

VPC Public Subnet

VPC Private Subnet

GAME GAME GAME GAME GAME GAME

Page 13: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

http://bit.ly/ec2-enhanced-net

http://bit.ly/linux-

tuning

Page 14: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

VPC Private Subnet VPC Private Subnet

Availability Zone A Availability Zone B

10.1.0.13 10.2.0.16

TCP 5672

rabbitmq-node1 rabbitmq-node2

TCP 4369

& 25672

Page 15: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

https://www.rabbitmq.com/clustering.html

https://www.rabbitmq.com/ha.html

Page 16: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

5672

rabbitmq-node1

rabbitmq-node2

Page 17: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

VPC Private Subnet

VPC Public Subnet

Availability Zone A Availability Zone B

VPC Public Subnet

VPC Private Subnet

GAME GAME GAME GAME GAME GAME

Auto Scaling group

Page 18: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

VPC Private Subnet

VPC Public Subnet

Availability Zone A

GAME GAME GAME

Auto Scaling group

Page 19: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

UnrealServer

unreal_linux.template.json

true

my-bucket-name

Unreal-123.zip

sshkeyname

1.2.3.4/24

MyPass123

Page 20: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 21: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 22: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 23: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Tokyo

Oregon

Frankfurt

Virginia

?

?

Page 24: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

VPC Subnet

Availability Zone A Availability Zone B

VPC Subnet

Auto Scaling group

WEB WEB

Oregon

Tokyo

VPC SubnetJOBS

Page 25: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 26: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

VPC Private Subnet

VPC Public Subnet

Availability Zone A

S3 Bucket

Amazon CloudWatch Logs

GAME GAME GAME

Page 27: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

VPC Private Subnet

VPC Public Subnet

Availability Zone A

Amazon

Kinesis

S3 Bucket

Amazon Redshift

GAME GAME GAME

Page 28: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 29: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

China

Oregon

Frankfurt

AuthChina

Leaderboard

Page 30: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 31: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

+

Tools for operating &

monetizing live games

Complete set of cloud-based

backend services

Eco-system of pre-integrated

third-party services

.. and

more

+

Page 32: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 33: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 34: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 35: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

AWS cloud: PlayFab Web Services

US EU

Hardware

Game Servers

Hardware

Game ServersGame

Client

Amazon Route 53

(3.playfabapi.com)

Amazon EC2

(API handling)Matchmaker

Instance Instance

Game Server

Monitor

DynamoDB Amazon RDS Amazon S3

Elastic Load Balancing

Amazon RedshiftReports

service

Instance

Logs

Matchmaker

(Secondary)

InstanceUS EU

SA AUS

Amazon EC2

Game Servers

Amazon EC2

Game Servers

Amazon EC2

Game Servers

Amazon EC2

Game Servers

Page 36: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Client ServerAuthentication Title-Wide Data Management Shared Group Data Authentication

AddUsernamePassword GetCatalogItems AddSharedGroupMembers AuthenticateSessionTicket

LoginWithAndroidDeviceID GetStoreItems CreateSharedGroup Account Management

LoginWithFacebook GetTitleData GetSharedGroupData GetUserAccountInfo

LoginWithGameCenter GetTitleNews RemoveSharedGroupMembers SendPushNotification

LoginWithGoogleAccount AddUserVirtualCurrency UpdateSharedGroupData Player Data Management

LoginWithIOSDeviceID Player Item Management Server-Side Game Logic GetLeaderboard

LoginWithPlayFab ConsumeItem GetLogicServerUrl GetLeaderboardAroundUser

LoginWithSteam GetUserInventory GetUserData

RegisterPlayFabUser RedeemCoupon GetUserInternalData

SendAccountRecoveryEmail SubtractUserVirtualCurrency GetUserReadOnlyData

Account Management UnlockContainerItem GetUserStatistics

GetAccountInfo StartPurchase UpdateUserData

GetPlayFabIDsFromFacebookIDs PayForPurchase UpdateUserInternalData

GetUserCombinedInfo ConfirmPurchase UpdateUserReadOnlyData

LinkFacebookAccount PurchaseItem UpdateUserStatistics

LinkGameCenterAccount Friend List Management Title-Wide Data Management

LinkSteamAccount AddFriend GetCatalogItems

UnlinkFacebookAccount GetFriendsList GetTitleData

UnlinkGameCenterAccount RemoveFriend SetTitleData

UnlinkSteamAccount SetFriendTags Player Item Management

UpdateEmailAddress IOS-Specific APIs AddUserVirtualCurrency

UpdatePassword RegisterForIOSPushNotification GetUserInventory

UpdateUserTitleDisplayName ValidateIOSReceipt GrantItemsToUsers

Player Data Management Matchmaking APIs SubtractUserVirtualCurrency

GetFriendLeaderboard GetCurrentGames Matchmaking APIs

GetLeaderboard GetGameServerRegions NotifyMatchmakerPlayerLeft

GetLeaderboardAroundCurrentUser Matchmake RedeemMatchmakerTicket

GetUserData StartGame Steam-Specific APIs

GetUserReadOnlyData Android-Specific APIs AwardSteamAchievement

GetUserStatistics AndroidDevicePushNotificationRegistration

UpdateUserData ValidateGooglePlayPurchase

UpdateUserStatistics Analytics

LogEvent

Page 37: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

API Request: Response from Web Services:

Page 38: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Game ClientAmazon Route 53

(3.playfabapi.com)

API Request:

Elastic Load

Balancing

Logs

Amazon RedshiftAmazon S3

bucket

Reports

service

LogsInstance

Logs include title-specific

endpoint for analytics

AWS wildcard DNS

(*.playfabapi.com)

Log event:

Page 39: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

API NAMETOTAL

CALLS

AVERAGE

BACKEND

TIME (S)

AVERAGE

RESPONSE

TIME (MS)

AVERAGE

REQUEST

TIME (MS)

TOTAL

REQUEST

TIME (M)

AVERAGE

RECIEVED

(BYTES)

AVERAGE

SENT

(BYTES)

TOTAL

ERRORS

adminapi_userinfo 93,081,685 0.03 0.04 0.04 59.83 0 452 1979

gameserver_usercustomdatareadonly 1,582,348 0.06 0.04 0.04 1.06 42 902 290

matchmaker_userinfo 1,138,842 0.20 0.04 0.04 0.81 0 10046 319

matchmaker_playerjoined 1,138,247 0.01 0.04 0.04 0.79 64 2 93

matchmaker_playerleft 1,136,797 0.01 0.04 0.04 0.80 64 2 400

matchmaker_authuser 736,607 0.01 0.03 0.04 0.52 0 48 107

gameserver_usercustomdata 297,735 0.19 0.04 0.04 0.20 0 4080 0

gameserver_usercustomdatainternal 297,469 0.08 0.04 0.04 0.20 0 237 2

Page 40: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

InstanceHealth

Check

Auto Scaling group

Auto Scaling

service

Instance

Matchmaker

(Primary)

Instance

Amazon Route 53

(matchmaker.playfab

api.com)

Elastic Load

Balancing

Matchmaker

(Secondary)

1.Auto Scaling is set to keep

two instances up.

2.Elastic Beanstalk Health

Check terminates bad

instance.

3.Amazon Route 53 fails

over all traffic to secondary

server.

4.Auto Scaling detects

failure and starts new

instance.

Page 41: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Amazon EC2

(API handling)

Elastic Load

Balancing CloudWatch

Health

Check

Email AlertsOn-call Engineer

Mobile Alerts

Page 42: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Amazon EC2 API Server

Server SSD

Amazon Redshift

Local Reports

service Local event

logsInstance

Events:

logins and

purchasesReports

service

Logs

Customer’s game

management dashboard

Analytics

Server

Logs

RabbitMQ

message

queue

LogsInstance

Logstash

service

Logstash

Instance

ElasticSearch

Instance

Instance

Page 43: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

DynamoDB Amazon RDS Amazon S3

Player data:

• Accounts

• Profile

• Inventory

• Save data

• Player stats

• Player currency

values

• Auditing

• Log files

• Game replays

Amazon Redshift

• Analytics data

Page 44: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Amazon

DynamoDB

• Player data: accounts, profile, inventory, save data

User:

UserID: Hash

TitleID: range key

- DisplayName

- Linked accounts

- …

Custom user data:

UserID: Hash

TitleID: range key

- Key/value 1

- Key/value 2

- …

Inventory:

UserID: Hash

ItemID: range key

- titleID

- Catalog Item

- …

Page 45: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

AZ 1

AZ 2

PlayFab Web

Services

PlayFab Web

Services

N. California

AZ 1

AZ 2

PlayFab Web

Services

PlayFab Web

Services

Oregon

AZ 1

PlayFab Web

Services

Beijing

• Original deployment: us-west-1

• Expanded to us-west-2 in July

• Coming soon: cn-north-1

Amazon EC2

Game Server

Singapore

Game Client

Instance

Page 46: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

Player accounts are shared

across all regions:• Cross-regional wrapper for

user.get sets order of

databases and regions to

check

• user.get then checks for

player account data

• High availability, transparent

to customers and players

// Returns the first matching player record, searching DynamoDB and SimpleDB

// in both regions in the specified order.

// Updates the player record in the store and region from which it was loaded.

// Creates a player record in the default store and region.

Page 47: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014
Page 48: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

AWS cloud: PlayFab Web Services

US EU

Hardware

Game Servers

Hardware

Game ServersGame

Client

Amazon Route 53

(3.playfabapi.com)

Amazon EC2

(API handling)Matchmaker

Instance Instance

Game Server

Monitor

DynamoDB Amazon RDS Amazon S3

Elastic Load Balancing

Amazon RedshiftReports

service

Instance

Logs

Matchmaker

(Secondary)

InstanceUS EU

SA AUS

Amazon EC2

Game Servers

Amazon EC2

Game Servers

Amazon EC2

Game Servers

Amazon EC2

Game Servers

Page 49: (GAM402) Deploying a Low-Latency Multiplayer Game Globally: Loadout | AWS re:Invent 2014

http://bit.ly/awsevals

http://playfab.com