Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
2019 - COSCUP - 復活一個 Browser Game - Unlight 開源事件
Search
蒼時弦や
August 18, 2019
Programming
1
690
2019 - COSCUP - 復活一個 Browser Game - Unlight 開源事件
蒼時弦や
August 18, 2019
Tweet
Share
More Decks by 蒼時弦や
See All by 蒼時弦や
2024 - COSCUP - Clean Architecture in Rails
elct9620
2
120
2023 - RubyConfTW - Rethink Rails Architecture
elct9620
0
93
20230916 - DDDTW - 導入 Domain-Driven Design 的最佳時機
elct9620
0
360
2023 - WebConf - 選擇適合你的技能組合
elct9620
0
570
20230322 - Generative AI 小聚 ft. Happy Designer
elct9620
0
290
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
400
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
1
430
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
220
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
240
Other Decks in Programming
See All in Programming
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
330
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
Better Code Design in PHP
afilina
PRO
0
130
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Six Lessons from altMBA
skipperchong
27
3.5k
Being A Developer After 40
akosma
87
590k
Visualization
eitanlees
145
15k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Building Your Own Lightsaber
phodgson
103
6.1k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Unsuck your backbone
ammeep
668
57k
For a Future-Friendly Web
brad_frost
175
9.4k
Producing Creativity
orderedlist
PRO
341
39k
Scaling GitHub
holman
458
140k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Transcript
Revive a Browser Game Server The Open Unlight Project Photo
by Artem Labunsky on Unsplash
WEB DEVELOPER GAME DEVELOPER ࣌ ݭ @elct9620
None
None
Ruby + ActionScript 3
None
Adobe Flash IDE is unavailable!
mxmlc src/Unlight.mxml
Unlight can be compiled by Flex SDK 3.x
Failed because missing files
None
Setup environment takes much time
The source code always become dirty
None
•Always reset client compile environment •Patches / Rework •Customizable Server/Client
•Adjustable Docker compose configure
None
Secure Remote Password not matched!
None
http://srp.stanford.edu/design.html
http://srp.stanford.edu/design.html Step 1. Client create PublicKey A
http://srp.stanford.edu/design.html Step 2. Server create PublicKey B and send it
with Salt to user
http://srp.stanford.edu/design.html Step 3~. Compute SessionKey and verify other's Matcher
None
None
None
None
None
None
None
None
None
None
(/‵Д′)/~ ╧╧
None
None
24 Core CPU 24G RAM 98K IOPS SSD 300M/100M FTTH
Sponsor by Poka
Feel "LAG" after 500 online players
None
None
(0.214518s) SELECT * FROM `card_inventories` WHERE ( `card_inventories`. `chara_card_deck_id` =
2971)
src/model/card_inventory.rb
None
ALTER TABLE card_inventories ADD INDEX chara_card_deck_id (chara_card_deck_id)
None
About 100x faster
None
About 1000 online players without "LAG"
•Adjust Cpuset to fix database on specify cores •Adjust Swappiness
to prevent use disk •Adjust Full Table Index to cache small table
•Move Database outside Docker •Enable SR-IOV to use physics network
card •Add partition to database
Estimate capability > 3000 online players
•DAU about 500 online players •Rows grow fast Only two
weeks we have 10M ~ 20M rows •1 Developer 1 DevOps 1 Player Support
But how to hosting this game?
Add CloudWatch to analytic online players
Open Unlight's Reword/Customize
None
None
Open Unlight's Allow add customize gems
Tricks to allow Docker add optional files
customize/server/src/authentication.rb
customize/server/src/payment.ru
None
Use Rack to implement API server
None
Extend CLI to serve in docker
None
None
Hosting a game have to support players resolve problems
SmartLook can replay player session to debug
ZenDesk can help players in one central system
•ZenDesk - Player support •SmartLook - Client Debug (for HTML5)
•Asana - Issue Tracking •AWS - CDN/Monitoring •Discord - Co-working
The HTML5 version?
Flash will be removed at 2020 in Chrome
The Unlight client is Flash
But no one knows CPA will maintenance or not
From TCPSocket to WebSocket
Client Server Packet The TCPSocket send packet directly
Client Server Packet The WebSocket send packet with WebSocket wrapper
WebSocket
Unlight use EventMachine handles connection
Comment out all EventMachine connection
Implement a Rack middleware with WebSocket gem
Add Rack's .ru and it can be served by Puma
or Unicorn
We already migrated 90% server to WebSocket
How the client communicates with the server?
It convert data to a command
Each packet should have a header to describe command
JavaScript can create 2 byte struct?
new Int8Array([0x00, 0x03, 0x00, 0x01, 0x00, 0x0a])
(/‵Д′)/~ ╧╧
You can learn how the C programmer think by Unlight's
Ruby source code
From Golang to WebAssembly
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() }
GOOS=js GOARCH=wasm go build -o libul.go
Convert Unlight to HTML5 is possible!
What the next?
Test! Test! Test!
We are trying to learn to host a game server
as a programmer
And last ...
New security problem is coming!
Thanks