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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
蒼時弦や
August 18, 2019
Programming
820
1
Share
2019 - COSCUP - 復活一個 Browser Game - Unlight 開源事件
蒼時弦や
August 18, 2019
More Decks by 蒼時弦や
See All by 蒼時弦や
2024 - COSCUP - Clean Architecture in Rails
elct9620
2
200
2023 - RubyConfTW - Rethink Rails Architecture
elct9620
0
220
20230916 - DDDTW - 導入 Domain-Driven Design 的最佳時機
elct9620
0
470
2023 - WebConf - 選擇適合你的技能組合
elct9620
0
680
20230322 - Generative AI 小聚 ft. Happy Designer
elct9620
0
440
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
510
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
1
530
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
280
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
320
Other Decks in Programming
See All in Programming
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
130
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
150
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
280
Liberating Ruby's Parser from Lexer Hacks
ydah
2
1.3k
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
220
Making the RBS Parser Faster
soutaro
0
380
Programming with a DJ Controller — not vibe coding
m_seki
3
100
tRPCの概要と少しだけパフォーマンス
misoton665
2
210
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
410
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
270
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
3
310
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
570
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
530
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
69
39k
Ruling the World: When Life Gets Gamed
codingconduct
0
210
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Un-Boring Meetings
codingconduct
0
270
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Facilitating Awesome Meetings
lara
57
6.8k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
350
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Designing for Performance
lara
611
70k
Balancing Empowerment & Direction
lara
6
1.1k
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