Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Revive a Browser Game Server The Open Unlight Project Photo by Artem Labunsky on Unsplash
Slide 2
Slide 2 text
WEB DEVELOPER GAME DEVELOPER ࣌ ݭ @elct9620
Slide 3
Slide 3 text
No content
Slide 4
Slide 4 text
No content
Slide 5
Slide 5 text
Ruby + ActionScript 3
Slide 6
Slide 6 text
No content
Slide 7
Slide 7 text
Adobe Flash IDE is unavailable!
Slide 8
Slide 8 text
mxmlc src/Unlight.mxml
Slide 9
Slide 9 text
Unlight can be compiled by Flex SDK 3.x
Slide 10
Slide 10 text
Failed because missing files
Slide 11
Slide 11 text
No content
Slide 12
Slide 12 text
Setup environment takes much time
Slide 13
Slide 13 text
The source code always become dirty
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
•Always reset client compile environment •Patches / Rework •Customizable Server/Client •Adjustable Docker compose configure
Slide 16
Slide 16 text
No content
Slide 17
Slide 17 text
Secure Remote Password not matched!
Slide 18
Slide 18 text
No content
Slide 19
Slide 19 text
http://srp.stanford.edu/design.html
Slide 20
Slide 20 text
http://srp.stanford.edu/design.html Step 1. Client create PublicKey A
Slide 21
Slide 21 text
http://srp.stanford.edu/design.html Step 2. Server create PublicKey B and send it with Salt to user
Slide 22
Slide 22 text
http://srp.stanford.edu/design.html Step 3~. Compute SessionKey and verify other's Matcher
Slide 23
Slide 23 text
No content
Slide 24
Slide 24 text
No content
Slide 25
Slide 25 text
No content
Slide 26
Slide 26 text
No content
Slide 27
Slide 27 text
No content
Slide 28
Slide 28 text
No content
Slide 29
Slide 29 text
No content
Slide 30
Slide 30 text
No content
Slide 31
Slide 31 text
No content
Slide 32
Slide 32 text
No content
Slide 33
Slide 33 text
(/‵Д′)/~ ╧╧
Slide 34
Slide 34 text
No content
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
24 Core CPU 24G RAM 98K IOPS SSD 300M/100M FTTH Sponsor by Poka
Slide 37
Slide 37 text
Feel "LAG" after 500 online players
Slide 38
Slide 38 text
No content
Slide 39
Slide 39 text
No content
Slide 40
Slide 40 text
(0.214518s) SELECT * FROM `card_inventories` WHERE ( `card_inventories`. `chara_card_deck_id` = 2971)
Slide 41
Slide 41 text
src/model/card_inventory.rb
Slide 42
Slide 42 text
No content
Slide 43
Slide 43 text
ALTER TABLE card_inventories ADD INDEX chara_card_deck_id (chara_card_deck_id)
Slide 44
Slide 44 text
No content
Slide 45
Slide 45 text
About 100x faster
Slide 46
Slide 46 text
No content
Slide 47
Slide 47 text
About 1000 online players without "LAG"
Slide 48
Slide 48 text
•Adjust Cpuset to fix database on specify cores •Adjust Swappiness to prevent use disk •Adjust Full Table Index to cache small table
Slide 49
Slide 49 text
•Move Database outside Docker •Enable SR-IOV to use physics network card •Add partition to database
Slide 50
Slide 50 text
Estimate capability > 3000 online players
Slide 51
Slide 51 text
•DAU about 500 online players •Rows grow fast Only two weeks we have 10M ~ 20M rows •1 Developer 1 DevOps 1 Player Support
Slide 52
Slide 52 text
But how to hosting this game?
Slide 53
Slide 53 text
Add CloudWatch to analytic online players
Slide 54
Slide 54 text
Open Unlight's Reword/Customize
Slide 55
Slide 55 text
No content
Slide 56
Slide 56 text
No content
Slide 57
Slide 57 text
Open Unlight's Allow add customize gems
Slide 58
Slide 58 text
Tricks to allow Docker add optional files
Slide 59
Slide 59 text
customize/server/src/authentication.rb
Slide 60
Slide 60 text
customize/server/src/payment.ru
Slide 61
Slide 61 text
No content
Slide 62
Slide 62 text
Use Rack to implement API server
Slide 63
Slide 63 text
No content
Slide 64
Slide 64 text
Extend CLI to serve in docker
Slide 65
Slide 65 text
No content
Slide 66
Slide 66 text
No content
Slide 67
Slide 67 text
Hosting a game have to support players resolve problems
Slide 68
Slide 68 text
SmartLook can replay player session to debug
Slide 69
Slide 69 text
ZenDesk can help players in one central system
Slide 70
Slide 70 text
•ZenDesk - Player support •SmartLook - Client Debug (for HTML5) •Asana - Issue Tracking •AWS - CDN/Monitoring •Discord - Co-working
Slide 71
Slide 71 text
The HTML5 version?
Slide 72
Slide 72 text
Flash will be removed at 2020 in Chrome
Slide 73
Slide 73 text
The Unlight client is Flash
Slide 74
Slide 74 text
But no one knows CPA will maintenance or not
Slide 75
Slide 75 text
From TCPSocket to WebSocket
Slide 76
Slide 76 text
Client Server Packet The TCPSocket send packet directly
Slide 77
Slide 77 text
Client Server Packet The WebSocket send packet with WebSocket wrapper WebSocket
Slide 78
Slide 78 text
Unlight use EventMachine handles connection
Slide 79
Slide 79 text
Comment out all EventMachine connection
Slide 80
Slide 80 text
Implement a Rack middleware with WebSocket gem
Slide 81
Slide 81 text
Add Rack's .ru and it can be served by Puma or Unicorn
Slide 82
Slide 82 text
We already migrated 90% server to WebSocket
Slide 83
Slide 83 text
How the client communicates with the server?
Slide 84
Slide 84 text
It convert data to a command
Slide 85
Slide 85 text
Each packet should have a header to describe command
Slide 86
Slide 86 text
JavaScript can create 2 byte struct?
Slide 87
Slide 87 text
new Int8Array([0x00, 0x03, 0x00, 0x01, 0x00, 0x0a])
Slide 88
Slide 88 text
(/‵Д′)/~ ╧╧
Slide 89
Slide 89 text
You can learn how the C programmer think by Unlight's Ruby source code
Slide 90
Slide 90 text
From Golang to WebAssembly
Slide 91
Slide 91 text
func AuthCmd(name string) []byte { buffer := new(bytes.Buffer) binary.Write(buffer, binary.BigEndian, uint16(1)) binary.Write(buffer, binary.BigEndian, []byte(name)) return buffer.Bytes() }
Slide 92
Slide 92 text
GOOS=js GOARCH=wasm go build -o libul.go
Slide 93
Slide 93 text
Convert Unlight to HTML5 is possible!
Slide 94
Slide 94 text
What the next?
Slide 95
Slide 95 text
Test! Test! Test!
Slide 96
Slide 96 text
We are trying to learn to host a game server as a programmer
Slide 97
Slide 97 text
And last ...
Slide 98
Slide 98 text
New security problem is coming!
Slide 99
Slide 99 text
Thanks