cs4344 lecture 8: hybrid architecture

117
Hybrid Architecture for Networked Games 1

Upload: wei-tsang-ooi

Post on 26-Dec-2014

401 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: CS4344 Lecture 8: Hybrid Architecture

Hybrid Architecturefor Networked Games

1

Page 2: CS4344 Lecture 8: Hybrid Architecture

singlecentralized

server

completelydecentralized

2

Page 3: CS4344 Lecture 8: Hybrid Architecture

P2P with Central Arbiter

3

Page 4: CS4344 Lecture 8: Hybrid Architecture

A trusted central arbiter receives all game traffic and resolve conflicts if necessary.

4

Page 5: CS4344 Lecture 8: Hybrid Architecture

Benefits ofP2P + Arbiter

5

Page 6: CS4344 Lecture 8: Hybrid Architecture

low latency among players

6

Page 7: CS4344 Lecture 8: Hybrid Architecture

have trusted authority now

7

Page 8: CS4344 Lecture 8: Hybrid Architecture

Drawbacks ofP2P + Arbiter

8

Page 9: CS4344 Lecture 8: Hybrid Architecture

limited scalability

arbiter becomes bottleneck

9

Page 10: CS4344 Lecture 8: Hybrid Architecture

Mirrored ServersArchitecture

10

Page 11: CS4344 Lecture 8: Hybrid Architecture

Multiple servers, each replicating the complete game states, serve clients from different geographical regions. Each client connects to one server.

11

Page 12: CS4344 Lecture 8: Hybrid Architecture

Servers may be connected with high speed, provisioned networked, reducing synchronization latency among the servers.

12

Page 13: CS4344 Lecture 8: Hybrid Architecture

Updates from a client are sent to its server, which then forwards it to other servers. The servers then forward the updates to all relevant clients.

13

Page 14: CS4344 Lecture 8: Hybrid Architecture

P2P-style state synchronization among servers is easier, since 1. servers can be trusted2. clocks can be synchronized3. IP multicast may be used4. higher availability5. shorter delay

14

Page 15: CS4344 Lecture 8: Hybrid Architecture

Benefits ofMirrored Servers

15

Page 16: CS4344 Lecture 8: Hybrid Architecture

no single point of failures

A client can use another replicated server if their nearest server fails.

16

Page 17: CS4344 Lecture 8: Hybrid Architecture

increase total network capacity

good if networking bandwidth is the bottleneck

17

Page 18: CS4344 Lecture 8: Hybrid Architecture

lower latency between client and server

18

Page 19: CS4344 Lecture 8: Hybrid Architecture

Drawbacks ofMirrored Servers

19

Page 20: CS4344 Lecture 8: Hybrid Architecture

latency between players increases

due to additional forwarding

20

Page 21: CS4344 Lecture 8: Hybrid Architecture

cannot scale to large world

each server still keeps the complete states

21

Page 22: CS4344 Lecture 8: Hybrid Architecture

how to assign players to servers?

22

Page 23: CS4344 Lecture 8: Hybrid Architecture

Assigning players to closest servers may lead to overloaded servers.

23

Page 24: CS4344 Lecture 8: Hybrid Architecture

Assigning players to remote servers may increase end-to-end latency.

24

Page 25: CS4344 Lecture 8: Hybrid Architecture

But we only care about latency between players that are relevant to each other.

25

Page 26: CS4344 Lecture 8: Hybrid Architecture

An Open Problem

26

Page 27: CS4344 Lecture 8: Hybrid Architecture

let

AOI(p) be the set of players relevant to pS(p) be the server of player pd(i,j) be the delay between i and jP(s) be the set of players assigned to server s

27

Page 28: CS4344 Lecture 8: Hybrid Architecture

let

L(p) be the average latency experience by p, considering only relevant players

28

Page 29: CS4344 Lecture 8: Hybrid Architecture

want to find S() such that

maximum L(p) is minimized over all p

subjected to

maximum P(s) is constrained for all s

29

Page 30: CS4344 Lecture 8: Hybrid Architecture

Zoned ServersArchitecture

30

Page 31: CS4344 Lecture 8: Hybrid Architecture

Divide the game world into independent regions. One server is in-charged of one region.

31

Page 32: CS4344 Lecture 8: Hybrid Architecture

A client connects to the server serving its current region, and is handed-off to another server when it moves to another region.

32

Page 33: CS4344 Lecture 8: Hybrid Architecture

Servers seldom communicate with each other.

33

Page 34: CS4344 Lecture 8: Hybrid Architecture

Updates from a client are sent to its server, which then forwards it to all relevant clients in the same region.

34

Page 35: CS4344 Lecture 8: Hybrid Architecture

35

Page 36: CS4344 Lecture 8: Hybrid Architecture

Advantages of Zoned Servers

36

Page 37: CS4344 Lecture 8: Hybrid Architecture

Can scale to large world

Just add more servers

37

Page 38: CS4344 Lecture 8: Hybrid Architecture

Drawbacks of Zoned Servers

38

Page 39: CS4344 Lecture 8: Hybrid Architecture

Single point of failures

(But can deploy mirrors for each region)

39

Page 40: CS4344 Lecture 8: Hybrid Architecture

Constrained Game Designs

40

Page 41: CS4344 Lecture 8: Hybrid Architecture

Supporting Seamless Game Worlds

41

Page 42: CS4344 Lecture 8: Hybrid Architecture

Divide the game world into regions. One server is in-charged of one region.

42

Page 43: CS4344 Lecture 8: Hybrid Architecture

Player may move around the world seamlessly

43

Page 44: CS4344 Lecture 8: Hybrid Architecture

A client may see events and objects from neighboring regions.

44

Page 45: CS4344 Lecture 8: Hybrid Architecture

Events occurring in one region may affectobjects in another region.

45

Page 46: CS4344 Lecture 8: Hybrid Architecture

Advantage: Partitioning is transparent to the players. No artificial constraints in game design.

46

Page 47: CS4344 Lecture 8: Hybrid Architecture

Advantage: We can now resize the regions to load-balance among the servers, improving server utilization.

47

Page 48: CS4344 Lecture 8: Hybrid Architecture

A client connects to the server serving its current region, and is handed-off to another server when it moves to another region.

48

Page 49: CS4344 Lecture 8: Hybrid Architecture

Server communicates with each other to transfer states, update states etc.

49

Page 50: CS4344 Lecture 8: Hybrid Architecture

Updates from a client are sent to its server, which then forwards it to all relevant clients in the same region or neighboring regions.

50

Page 51: CS4344 Lecture 8: Hybrid Architecture

or

51

Page 52: CS4344 Lecture 8: Hybrid Architecture

A client connects to the servers serving its current region and regions it subscribes to. Updates from neighboring server are sent directly.

52

Page 53: CS4344 Lecture 8: Hybrid Architecture

Q: How to partition the game world?

53

Page 54: CS4344 Lecture 8: Hybrid Architecture

Ideally: each server should handle the same

number of players

54

Page 55: CS4344 Lecture 8: Hybrid Architecture

Ideally: minimize communications between servers

55

Page 56: CS4344 Lecture 8: Hybrid Architecture

Ideally: minimize the number of hand offs

56

Page 57: CS4344 Lecture 8: Hybrid Architecture

Idea: divide the game world into small cells and assign group of

cells to servers.

57

Page 58: CS4344 Lecture 8: Hybrid Architecture

58

Page 59: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

I will simplify the representation to a grid of cells with number indicating the number of players (or loadincurred on server) in this cell.

59

Page 60: CS4344 Lecture 8: Hybrid Architecture

Centralized approach to partitioning

60

Page 61: CS4344 Lecture 8: Hybrid Architecture

Balanced Deployment Algorithm

by Bart De Vleeschauwer et al

61

Page 62: CS4344 Lecture 8: Hybrid Architecture

Idea: sort the cells and assign them one-by-one, highest load first, to the servers to minimize

the maximum server load

62

Page 63: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Suppose we have only two servers (blue and red).

63

Page 64: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Blue’s load = 4 Red’s load = 0

64

Page 65: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Blue’s load = 4 Red’s load = 3

65

Page 66: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Blue’s load = 4 Red’s load = 6

66

Page 67: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Blue’s load = 6 Red’s load = 6

67

Page 68: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Blue’s load = 8 Red’s load = 7

68

Page 69: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Problem: neighboring cells are not adjacent. There are 8 “borders” in this solution. Communication

overhead is not considered.

69

Page 70: CS4344 Lecture 8: Hybrid Architecture

Let’s define a cost function for assigning a cell c to a server S:

cost(c,S) = computation load increase in S + communication load increase in S

70

Page 71: CS4344 Lecture 8: Hybrid Architecture

For simplicity, CPU load = players,

newtork load = borders

71

Page 72: CS4344 Lecture 8: Hybrid Architecture

Clustered Deployment Algorithm

by Bart De Vleeschauwer et al

72

Page 73: CS4344 Lecture 8: Hybrid Architecture

Start with each cell as one cluster

73

Page 74: CS4344 Lecture 8: Hybrid Architecture

Repeatedly merge two adjacent clusters with least overhead until

number of clusters equals to number of servers.

74

Page 75: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

75

Page 76: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Least cost = 1 + 3 = 4

76

Page 77: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Least cost = 2 + 3 = 5

77

Page 78: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Least cost = 1 + 5 = 6

78

Page 79: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

Least cost = 3 + 5 = 8

79

Page 80: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

80

Page 81: CS4344 Lecture 8: Hybrid Architecture

Just a heuristic

the optimization problem is NP-complete

81

Page 82: CS4344 Lecture 8: Hybrid Architecture

Last few steps involve heavily loaded cells and can create

uneven deployment.

82

Page 83: CS4344 Lecture 8: Hybrid Architecture

We can tweak this heuristic in many ways to improve it, but it’s

still a heuristic.

83

Page 84: CS4344 Lecture 8: Hybrid Architecture

Simulated Annealing by Bart De Vleeschauwer et al

84

Page 85: CS4344 Lecture 8: Hybrid Architecture

A general method for finding good solution in an optimization

problem (meta-heuristic)

85

Page 86: CS4344 Lecture 8: Hybrid Architecture

At every step, move towards a nearby, better configuration probabilistically (allowing a move towards worse solution, prevent stuck at local minimum)

86

Page 87: CS4344 Lecture 8: Hybrid Architecture

cost

config

87

Page 88: CS4344 Lecture 8: Hybrid Architecture

Start with a solution from a heuristic.

88

Page 89: CS4344 Lecture 8: Hybrid Architecture

Move to a nearby config:swap cells with an adjacent

server, or move cell from one server to another

89

Page 90: CS4344 Lecture 8: Hybrid Architecture

Is it a better solution?If so, keep it as current solution

with some probability.

90

Page 91: CS4344 Lecture 8: Hybrid Architecture

2 0 3

3 1 4

011

91

Page 92: CS4344 Lecture 8: Hybrid Architecture

Experimental results show that Simulated Annealing works best

among the methods.

92

Page 93: CS4344 Lecture 8: Hybrid Architecture

Disadvantages of centralized approach

93

Page 94: CS4344 Lecture 8: Hybrid Architecture

Expensive to compute a good solution

94

Page 95: CS4344 Lecture 8: Hybrid Architecture

How frequent should the world be repartitioned?

95

Page 96: CS4344 Lecture 8: Hybrid Architecture

Localized World Partitioning

96

Page 97: CS4344 Lecture 8: Hybrid Architecture

Idea: Only repartition locally if a server is overloaded. Look for a

lightly loaded server to shed some load to.

97

Page 98: CS4344 Lecture 8: Hybrid Architecture

overload

safe

light

98

Page 99: CS4344 Lecture 8: Hybrid Architecture

overload

safe

light

Overloaded server sheds load until it’s load is below a safe level. The new load of a previously lightly loaded should remain below safe level.

99

Page 100: CS4344 Lecture 8: Hybrid Architecture

l + o - s < sl < 2s - o

100

Page 101: CS4344 Lecture 8: Hybrid Architecture

Who to shed to?

101

Page 102: CS4344 Lecture 8: Hybrid Architecture

Minimize overhead: try to shed to as few neighboring server as

possible

102

Page 103: CS4344 Lecture 8: Hybrid Architecture

Migrate cells to neighboring servers that are not overloaded

103

Page 104: CS4344 Lecture 8: Hybrid Architecture

Overload = 10, Safe = 7, Light = 4

2 0 3

1 1 4

035

0 1 1

104

Page 105: CS4344 Lecture 8: Hybrid Architecture

Green server is overloaded. Shed some load to neighbors.

2 0 3

1 1 4

035

0 1 1

105

Page 106: CS4344 Lecture 8: Hybrid Architecture

If still not enough, look at the list of lightly loaded servers maintained. Pick the least load and shed to it.

106

Page 107: CS4344 Lecture 8: Hybrid Architecture

Green server is still overloaded. Neighbor (purple) server has hit the safe threshold.

2 0 3

1 1 4

035

0 1 1

107

Page 108: CS4344 Lecture 8: Hybrid Architecture

Shed load to remote server. But this could lead to high communication cost.

2 0 3

1 1 4

035

0 1 1

108

Page 109: CS4344 Lecture 8: Hybrid Architecture

When communication overhead is too high, isolated cells can be migrated to a nearby server, “merging” with neighboring regions to form contiguous regions, as long as the load remains below the safe threshold.

2 0 3

1 1 0

031

0 1 1

109

Page 110: CS4344 Lecture 8: Hybrid Architecture

Another Open Problem

110

Page 111: CS4344 Lecture 8: Hybrid Architecture

No consideration on hand offs

111

Page 112: CS4344 Lecture 8: Hybrid Architecture

Idea: If traffic is high between point A and point B, then A and B should be managed by the same

server.

112

Page 113: CS4344 Lecture 8: Hybrid Architecture

3 2

10

0 2

42

1 1

1

2

2

4

2

2

1

113

Page 114: CS4344 Lecture 8: Hybrid Architecture

3 2

10

0 2

42

1 1

1

2

2

4

2

2

1

Minimizing hand-off means finding minimum cuts.

114

Page 115: CS4344 Lecture 8: Hybrid Architecture

3 2

1

2

421

2

2

4

2

2

Minimizing hand-off means finding minimum cuts.

115

Page 116: CS4344 Lecture 8: Hybrid Architecture

3 2

1

2

42

24

2

2

Minimizing hand-off means finding minimum cuts.

116

Page 117: CS4344 Lecture 8: Hybrid Architecture

Question: how to combine the three objectives:

1. limiting number of players2. reduce communication cost3. reduce number of hand offs

117